|
@@ -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
|
|
|
|
|
|
//同一天,同一个人有相同排班,则先删除,后插入
|