Browse Source

628 班表管理——设置班表成功不展示在列表问题修改

yejian 3 years ago
parent
commit
25593f3711

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

@@ -1,6 +1,5 @@
 package com.github.zuihou.business.classSchedule.service.impl;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import com.github.zuihou.authority.service.auth.UserService;
@@ -10,18 +9,18 @@ import com.github.zuihou.business.classSchedule.entity.ScheduleUserDate;
 import com.github.zuihou.business.classSchedule.service.ScheduleUserDateService;
 import com.github.zuihou.base.service.SuperServiceImpl;
 
-import com.github.zuihou.common.constant.BizConstant;
+import com.github.zuihou.common.util.DateUtil;
+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 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.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static com.github.zuihou.utils.BizAssert.isFalse;
 
@@ -194,6 +193,15 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
         return sql;
     }
 
+    private static String dayofWeek(Calendar date) {
+        String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六" };
+        int w = date.get(Calendar.DAY_OF_WEEK) -1;
+        if(w < 0){
+            w = 0;
+        }
+        return weekDays[w];
+    }
+
     @Override
     public ScheduleUserDate save(ScheduleUserDateSaveDTO data) {
         List<Long>userList = data.getUserList();
@@ -203,6 +211,40 @@ 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++;
+            }
+        }
+
         //主要验证不能同一人,同一天,不能有休班和排班TODO
 
         //同一天,同一个人有相同排班,则先删除,后插入

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

@@ -67,17 +67,6 @@ public class ScheduleFrequencyController extends SuperController<ScheduleFrequen
 
     @Override
     public void query(PageParams<ScheduleFrequencyPageDTO> params, IPage<ScheduleFrequency> page, Long defSize) {
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
-        String jsonParam = "";
-        Object obj = redisTemplate.opsForValue().get("testParam");
-        if(obj != null){
-            jsonParam = redisTemplate.opsForValue().get("testParam").toString();
-        }
-
-        HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam,headers);
-        //调用接口
-        String returnData = restTemplate.postForObject(url, formEntity, String.class);
 
         ScheduleFrequencyPageDTO data = params.getModel();
         QueryWrap<ScheduleFrequency> wrap = handlerWrapper(null, params);