Преглед на файлове

Merge remote-tracking branch 'origin/master'

wang.sq@aliyun.com преди 1 месец
родител
ревизия
e0c0ac99c0
променени са 10 файла, в които са добавени 164 реда и са изтрити 50 реда
  1. 6 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/dao/ScheduleUserDateMapper.java
  2. 3 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/ScheduleUserDateService.java
  3. 64 47
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/impl/ScheduleUserDateServiceImpl.java
  4. 3 1
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/classSchedule/ScheduleMonthMapper.xml
  5. 14 2
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/classSchedule/ScheduleUserDateMapper.xml
  6. 22 0
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/classSchedule/ScheduleUserDateController.java
  7. 12 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/dto/ScheduleUserDatePageDTO.java
  8. 2 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/dto/ScheduleUserDateSaveDTO.java
  9. 5 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/dto/ScheduleUserDateUpdateDTO.java
  10. 33 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/entity/ScheduleUserDate.java

+ 6 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/dao/ScheduleUserDateMapper.java

@@ -1,8 +1,13 @@
 package com.github.zuihou.business.classSchedule.dao;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.github.zuihou.authority.entity.auth.User;
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.business.classSchedule.entity.ScheduleUserDate;
 
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -24,4 +29,5 @@ public interface ScheduleUserDateMapper extends SuperMapper<ScheduleUserDate> {
 
     void updateUserChange(Map params);
 
+    List<ScheduleUserDate> getPageList(@Param(Constants.WRAPPER) Wrapper<ScheduleUserDate> wrapper);
 }

+ 3 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/ScheduleUserDateService.java

@@ -1,8 +1,10 @@
 package com.github.zuihou.business.classSchedule.service;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.github.zuihou.base.service.SuperService;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserDateSaveDTO;
 import com.github.zuihou.business.classSchedule.entity.ScheduleUserDate;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 
 import java.util.List;
 import java.util.Map;
@@ -36,4 +38,5 @@ public interface ScheduleUserDateService extends SuperService<ScheduleUserDate>
 
     void updateUserChange(Map params);
 
+    List<ScheduleUserDate> getPageList(LbqWrapper<ScheduleUserDate> lbqWrapper);
 }

+ 64 - 47
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/impl/ScheduleUserDateServiceImpl.java

@@ -2,6 +2,7 @@ package com.github.zuihou.business.classSchedule.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.github.zuihou.authority.service.auth.UserService;
 import com.github.zuihou.business.classSchedule.dao.ScheduleUserDateMapper;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserDateSaveDTO;
@@ -14,12 +15,15 @@ import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.google.common.collect.Maps;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDate;
+import java.time.format.TextStyle;
 import java.util.*;
 
 import static com.github.zuihou.utils.BizAssert.isFalse;
@@ -45,11 +49,19 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
         int count = 0;
         List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
         //获取动态头
-        String year = StrUtil.isEmpty(map.get("year"))?"1":map.get("year").toString();
-        String month = StrUtil.isEmpty(map.get("month"))?"1":map.get("month").toString();
-        String queryDate = year+"-"+month;
-        String dateSql = "select * from c_common_date_info where date  like '"+queryDate+"%' ";
-        List<Map<String,Object>> dateList = baseMapper.selectSql(dateSql);
+        int year = StrUtil.isEmpty(map.get("year"))? LocalDate.now().getYear():Integer.parseInt(map.get("year"));
+        int month = StrUtil.isEmpty(map.get("month"))? LocalDate.now().getMonthValue():Integer.parseInt(map.get("month"));
+        List<Map<String, Object>> dateList = Lists.newArrayList();
+        LocalDate date = LocalDate.of(year, month, 1);
+        int dayLen = date.lengthOfMonth();
+        for(int i = 1; i <= dayLen; i++){
+            Map<String, Object> dateMap = Maps.newHashMap();
+            LocalDate currentDate = LocalDate.of(year, month, i);
+            dateMap.put("date", currentDate.toString());
+            String week = currentDate.getDayOfWeek().getDisplayName(TextStyle.FULL,Locale.getDefault()).replace("星期", "周");
+            dateMap.put("week", week);
+            dateList.add(dateMap);
+        }
         List titleList = getTtileList(dateList);
         //只有配置了年月,才需要动态查询
         if(titleList!=null&&titleList.size()>0){
@@ -101,7 +113,7 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
         int size = Integer.parseInt(StrUtil.isEmpty(map.get("size"))?"10":map.get("size").toString());
         current = (current-1)*size;
         String hangzhuanlieSql = gethangzhuanlieSQL(map,dateList);
-        String sql = " select u.id userId,u.name userName,o.label orgName ,z.* from (" + hangzhuanlieSql +" ) z,   c_auth_user u , c_core_org o where 1=1 and u.org_id = o.id AND z.user_id = u.id";
+        String sql = " select u.id userId, u.account model, u.name userName,o.label orgName ,z.* from (" + hangzhuanlieSql +" ) z,   c_auth_user u , c_core_org o where 1=1 and u.org_id = o.id AND z.user_id = u.id";
         sql+=genCustSearchParam(map);
         sql += " order by u.name desc limit  "+current+","+size+"";
 
@@ -115,8 +127,8 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
      */
     private String getCount(Map<String, String> map){
         //年月条件
-        String year = StrUtil.isEmpty(map.get("year"))?"1":map.get("year").toString();
-        String month = StrUtil.isEmpty(map.get("month"))?"1":map.get("month").toString();
+        String year = StrUtil.isEmpty(map.get("year"))? String.valueOf(LocalDate.now().getYear()):map.get("year");
+        String month = StrUtil.isEmpty(map.get("month"))?String.valueOf(LocalDate.now().getMonthValue()):map.get("month");
         //年月条件
         String date = year+"-"+month;
         String sql = " select count(distinct user_id) count from imcs_s_schedule_user_date issud  where 1=1";
@@ -152,18 +164,17 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
      */
     private String getDynQuerySQL(Map<String, String> map){
         //年月条件
-        String year = StrUtil.isEmpty(map.get("year"))?"1":map.get("year").toString();
-        String month = StrUtil.isEmpty(map.get("month"))?"1":map.get("month").toString();
+        String year = StrUtil.isEmpty(map.get("year"))?String.valueOf(LocalDate.now().getYear()):map.get("year");
+        String month = StrUtil.isEmpty(map.get("month"))?String.valueOf(LocalDate.now().getMonthValue()):map.get("month");
         /*String deptId = StrUtil.isEmpty(map.get("deptId"))?"1":map.get("deptId").toString();
         String name = StrUtil.isEmpty(map.get("name"))?"1":map.get("name").toString();*/
         String date = year+"-"+month;
-        String sql = "select i.date,a.user_id,a.scheduleInfo from c_common_date_info i LEFT JOIN " +
-                "(select ud.date,ud.user_id, GROUP_CONCAT(CONCAT(di.name,';',color))scheduleInfo from imcs_s_schedule_user_date ud LEFT JOIN imcs_s_schedule_frequency f on ud.frequency_id = f.id " +
+        String sql = "select ud.date,ud.user_id, GROUP_CONCAT(CONCAT(di.name,';',color))scheduleInfo from imcs_s_schedule_user_date ud LEFT JOIN imcs_s_schedule_frequency f on ud.frequency_id = f.id " +
                 "left join c_common_dictionary_item di on f.name = di.code and di.dictionary_type = 'FREQUENCY' " +
-                "GROUP BY ud.date,ud.user_id) a on i.date = a.date  where 1=1 ";
+                " where 1=1 ";
 
         if(StrUtil.isNotEmpty(year)&&StrUtil.isNotEmpty(month)){
-            sql+="  and i.date like '"+date+"%' ";
+            sql+="  and ud.date like '"+date+"%' " + " GROUP BY ud.date, ud.user_id";
         }
         return sql;
     }
@@ -211,39 +222,39 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
         isFalse(userList==null||userList.size()==0, "请选择排班部门人员");
         isFalse(dateList==null||dateList.size()==0, "请选择设置日期");
 
-        // 判断基础表c_common_date_info是否存在设定日期的值,如果没有,先插入90天
-        List<Map<String,Object>> maxCommonDates = baseMapper.selectSql("select max(ifnull(date,'')) AS maxCommonDate from c_common_date_info");
-        String maxDate = "";
-        for (String selectDate : data.getDateList()){
-            if(StringUtils.isBlank(maxDate)){
-                maxDate = selectDate;
-            }
-            if(maxDate.compareTo(selectDate) < 0){
-                maxDate = selectDate;
-            }
-        }
-
-        if(CollectionUtil.isEmpty(maxCommonDates)
-                || (!CollectionUtil.isEmpty(maxCommonDates) && maxDate.compareTo(null == maxCommonDates.get(0) ? "":maxCommonDates.get(0).get("maxCommonDate").toString() ) > 0)){
-            int i = 0;
-            Calendar calendar = Calendar.getInstance();
-            Date date = null;
-            if(null == maxCommonDates.get(0)){
-                date=calendar.getTime();
-                calendar.setTime(date);
-                calendar.add(Calendar.DATE , -1);
-            }else{
-                date=  DateUtil.stringToDate3(maxCommonDates.get(0).get("maxCommonDate").toString());
-                calendar.setTime(date);
-            }
-
-            while( i <= 90){
-                calendar.add(Calendar.DATE , 1);
-                String sql = "insert into c_common_date_info values (" + "'" + DateUtil.dateToString(calendar.getTime()) + "','" + dayofWeek(calendar) + "')";
-                baseMapper.selectSql(sql);
-                i++;
-            }
-        }
+//        // 判断基础表c_common_date_info是否存在设定日期的值,如果没有,先插入90天
+//        List<Map<String,Object>> maxCommonDates = baseMapper.selectSql("select max(ifnull(date,'')) AS maxCommonDate from c_common_date_info");
+//        String maxDate = "";
+//        for (String selectDate : data.getDateList()){
+//            if(StringUtils.isBlank(maxDate)){
+//                maxDate = selectDate;
+//            }
+//            if(maxDate.compareTo(selectDate) < 0){
+//                maxDate = selectDate;
+//            }
+//        }
+//
+//        if(CollectionUtil.isEmpty(maxCommonDates)
+//                || (!CollectionUtil.isEmpty(maxCommonDates) && maxDate.compareTo(null == maxCommonDates.get(0) ? "":maxCommonDates.get(0).get("maxCommonDate").toString() ) > 0)){
+//            int i = 0;
+//            Calendar calendar = Calendar.getInstance();
+//            Date date = null;
+//            if(null == maxCommonDates.get(0)){
+//                date=calendar.getTime();
+//                calendar.setTime(date);
+//                calendar.add(Calendar.DATE , -1);
+//            }else{
+//                date=  DateUtil.stringToDate3(maxCommonDates.get(0).get("maxCommonDate").toString());
+//                calendar.setTime(date);
+//            }
+//
+//            while( i <= 90){
+//                calendar.add(Calendar.DATE , 1);
+//                String sql = "insert into c_common_date_info values (" + "'" + DateUtil.dateToString(calendar.getTime()) + "','" + dayofWeek(calendar) + "')";
+//                baseMapper.selectSql(sql);
+//                i++;
+//            }
+//        }
 
         //主要验证不能同一人,同一天,不能有休班和排班TODO
 
@@ -259,6 +270,7 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
                 scheduleUserDate.setUserId(userId);
                 scheduleUserDate.setDate(date);
                 scheduleUserDate.setFrequencyId(data.getFrequencyId());
+                scheduleUserDate.setMonthId(data.getMonthId());
                 list.add(scheduleUserDate);
             }
         }
@@ -284,4 +296,9 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
         baseMapper.updateUserChange(params);
     }
 
+    @Override
+    public List<ScheduleUserDate> getPageList(LbqWrapper<ScheduleUserDate> lbqWrapper) {
+        return baseMapper.getPageList(lbqWrapper);
+    }
+
 }

+ 3 - 1
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/classSchedule/ScheduleMonthMapper.xml

@@ -27,7 +27,9 @@
         <include refid="Base_Column_List"/>
         from (
         select a.*,u.name as applyDesc, u.org_id from imcs_s_schedule_month a
-         left join c_auth_user u on u.id = a.create_user
+         left join imcs_s_schedule_user_date d on a.id = d.month_id
+         left join c_auth_user u on u.id = d.user_id
+         group by a.id
         ) s ${ew.customSqlSegment}
     </select>
 

+ 14 - 2
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/classSchedule/ScheduleUserDateMapper.xml

@@ -10,14 +10,17 @@
         <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
         <result column="update_user" jdbcType="BIGINT" property="updateUser"/>
         <result column="user_id" jdbcType="BIGINT" property="userId"/>
+        <result column="month_id" jdbcType="BIGINT" property="monthId"/>
         <result column="frequency_id" jdbcType="BIGINT" property="frequencyId"/>
+        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
+        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
         <result column="date" jdbcType="VARCHAR" property="date"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id,create_time,create_user,update_time,update_user,
-        user_id, frequency_id, date
+        id,create_time,create_user,update_time,update_user,month_id,
+        user_id, frequency_id, date,start_time,end_time,planStartTime,planEndTime
     </sql>
 
     <select id="selectSql" parameterType="String" resultType="map">
@@ -28,4 +31,13 @@
         update imcs_s_schedule_user_date set user_id = #{changeUserId} where user_id = #{userId} and frequency_id =  #{frequencyId} and date = #{applyTime}
     </update>
 
+    <select id="getPageList" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from (
+           select d.*, f.start_time as planStartTime, f.end_time as planEndTime from imcs_s_schedule_user_date d
+           left join imcs_s_schedule_frequency f on f.id = d.frequency_id
+        ) s ${ew.customSqlSegment}
+    </select>
+
 </mapper>

+ 22 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/classSchedule/ScheduleUserDateController.java

@@ -5,11 +5,15 @@ import com.github.zuihou.business.classSchedule.dto.ScheduleUserDateSaveDTO;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserDateUpdateDTO;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserDatePageDTO;
 import com.github.zuihou.business.classSchedule.service.ScheduleUserDateService;
+
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.R;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.google.common.collect.Maps;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -83,4 +87,22 @@ public class ScheduleUserDateController extends SuperController<ScheduleUserDate
 
         return R.success(baseService.saveBatch(scheduleUserDateList));
     }
+
+
+    @ApiOperation(value = "获取班次", notes = "获取班次")
+    @PostMapping("/getCurrentSchedule")
+    public R<ScheduleUserDate> getCurrentSchedule(@RequestBody ScheduleUserDatePageDTO scheduleUserDatePageDTO) {
+        ScheduleUserDate scheduleUserDate = baseService.getOne(new LbqWrapper<ScheduleUserDate>().eq(ScheduleUserDate::getUserId, scheduleUserDatePageDTO.getUserId()).eq(ScheduleUserDate::getDate, scheduleUserDatePageDTO.getDate()).last("limit 1"));
+        return scheduleUserDate!=null ? success(scheduleUserDate) : fail("数据不存在");
+    }
+
+    @ApiOperation(value = "排班--分页列表", notes = "排班--分页列表")
+    @PostMapping("/getPageList")
+    public R<Map<String,Object>> getPageList(@RequestBody Map<String,String> map) {
+        List<ScheduleUserDate> dataList = baseService.getPageList(new LbqWrapper<ScheduleUserDate>().eq(ScheduleUserDate::getUserId, map.get("userId")).lt(ScheduleUserDate::getCreateTime, new Date()).orderByDesc(ScheduleUserDate::getCreateTime).last("limit 50"));
+        Map returnMap = Maps.newHashMap();
+        returnMap.put("data", dataList);
+        returnMap.put("count", dataList.size());
+        return success(returnMap);
+    }
 }

+ 12 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/dto/ScheduleUserDatePageDTO.java

@@ -21,6 +21,7 @@ import lombok.ToString;
 import lombok.experimental.Accessors;
 import com.github.zuihou.common.constant.DictionaryType;
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * <p>
@@ -53,6 +54,13 @@ public class ScheduleUserDatePageDTO implements Serializable {
      */
     @ApiModelProperty(value = "班次id")
     private Long frequencyId;
+
+    @ApiModelProperty(value = "班表id")
+    private Long monthId;
+
+    private Date startTime;
+
+    private Date endTime;
     /**
      * 日期(yyyy-mm-dd格式)
      */
@@ -62,4 +70,8 @@ public class ScheduleUserDatePageDTO implements Serializable {
 
     private boolean searchSelfFlag;
 
+    private String planStartTime;
+
+    private String planEndTime;
+
 }

+ 2 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/dto/ScheduleUserDateSaveDTO.java

@@ -70,4 +70,6 @@ public class ScheduleUserDateSaveDTO implements Serializable {
     @ApiModelProperty(value = "日期list")
     private List<String>dateList;
 
+    private Long monthId;
+
 }

+ 5 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/dto/ScheduleUserDateUpdateDTO.java

@@ -21,6 +21,7 @@ import lombok.ToString;
 import lombok.experimental.Accessors;
 import com.github.zuihou.common.constant.DictionaryType;
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * <p>
@@ -63,4 +64,8 @@ public class ScheduleUserDateUpdateDTO implements Serializable {
     @ApiModelProperty(value = "日期(yyyy-mm-dd格式)")
     @Length(max = 10, message = "日期(yyyy-mm-dd格式)长度不能超过10")
     private String date;
+
+    private Date startTime;
+
+    private Date endTime;
 }

+ 33 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/entity/ScheduleUserDate.java

@@ -14,6 +14,8 @@ import javax.validation.constraints.NotNull;
 import org.hibernate.validator.constraints.Length;
 import org.hibernate.validator.constraints.Range;
 import java.time.LocalDateTime;
+import java.util.Date;
+
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -65,6 +67,14 @@ public class ScheduleUserDate extends Entity<Long> {
     @Excel(name = "班次id")
     private Long frequencyId;
 
+    /**
+     * 班次id
+     */
+    @ApiModelProperty(value = "班表id")
+    @TableField("month_id")
+    @Excel(name = "班次id")
+    private Long monthId;
+
     /**
      * 日期(yyyy-mm-dd格式)
      */
@@ -74,6 +84,29 @@ public class ScheduleUserDate extends Entity<Long> {
     @Excel(name = "日期(yyyy-mm-dd格式)")
     private String date;
 
+    /**
+     * 开始时间
+     */
+    @ApiModelProperty(value = "上班开始时间")
+    @TableField("start_time")
+    @Excel(name = "上班开始时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
+    private Date startTime;
+
+
+    /**
+     * 开始时间
+     */
+    @ApiModelProperty(value = "上班结束时间")
+    @TableField("end_time")
+    @Excel(name = "上班结束时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
+    private Date endTime;
+
+    @TableField(exist = false)
+    private String planStartTime;
+
+    @TableField(exist = false)
+    private String planEndTime;
+
 
     @Builder
     public ScheduleUserDate(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,