|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|