考勤-请假、出差明细生成,全局唯一性规则校验增加请假与出差之间的冲突情况

main
sy 5 months ago
parent 489bacad72
commit de33cf1fac

@ -226,8 +226,8 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
List<Map<String, Object>> holidayPriorityItemList = new ArrayList<>(); List<Map<String, Object>> holidayPriorityItemList = new ArrayList<>();
holidayPriorityItemList.add(holidayItem); holidayPriorityItemList.add(holidayItem);
//获取假期类型的考勤项目 //获取假期类型的考勤项目
sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb,zdycbcndfgzsd,zdycrqqjndxxb,yxyz,zdyzsl,zysd from uf_jcl_kq_kqxm where xmlx=?"; sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb,zdycbcndfgzsd,zdycrqqjndxxb,yxyz,zdyzsl,zysd from uf_jcl_kq_kqxm where xmlx=? or xmlx=?";
List<Map<String,Object>> holidayItemList = DbTools.getSqlToList(sql, AttendanceItemTypeEnum.HOLIDAY.getKey()); List<Map<String,Object>> holidayItemList = DbTools.getSqlToList(sql, AttendanceItemTypeEnum.HOLIDAY.getKey(), AttendanceItemTypeEnum.EVECTION.getKey());
Map<String, Map<String,Object>> holidayItemInfos = holidayItemList.stream().collect(Collectors.toMap(e->e.get("id").toString(), e->e)); Map<String, Map<String,Object>> holidayItemInfos = holidayItemList.stream().collect(Collectors.toMap(e->e.get("id").toString(), e->e));
Map<String, String> jbIdToHsdw = holidayItemList.stream().collect(Collectors.toMap(e->e.get("id").toString(), e->e.get("hsdw").toString())); Map<String, String> jbIdToHsdw = holidayItemList.stream().collect(Collectors.toMap(e->e.get("id").toString(), e->e.get("hsdw").toString()));
//逐级获取优先使用项目 //逐级获取优先使用项目
@ -558,8 +558,6 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
} }
} else if (leaveMode.equals(AskAndEvctionWayEnum.ALLDAY.getKey()) && !restDateList.contains(leaveDate)) { } else if (leaveMode.equals(AskAndEvctionWayEnum.ALLDAY.getKey()) && !restDateList.contains(leaveDate)) {
simpleLeaveDetailItem = new HashMap<>(); simpleLeaveDetailItem = new HashMap<>();
//获取当天班次id
// String currentDayBcId = restDateList.contains(leaveDate) ? "" : Util.null2String(dateToBcxxMap.get(leaveDate)).split("-")[0];
Map<String, Object> shiftInfo = shiftInfoMap.get(currentDayBcId); Map<String, Object> shiftInfo = shiftInfoMap.get(currentDayBcId);
qjscHours = shiftInfo == null ? "8" : shiftInfo.get("edsc").toString(); qjscHours = shiftInfo == null ? "8" : shiftInfo.get("edsc").toString();
//组装初步的请假明细数据 //组装初步的请假明细数据
@ -571,8 +569,6 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
simpleLeaveDetailList.add(simpleLeaveDetailItem); simpleLeaveDetailList.add(simpleLeaveDetailItem);
} else if (leaveMode.equals(AskAndEvctionWayEnum.HALFDAY.getKey()) && !restDateList.contains(leaveDate)) { } else if (leaveMode.equals(AskAndEvctionWayEnum.HALFDAY.getKey()) && !restDateList.contains(leaveDate)) {
simpleLeaveDetailItem = new HashMap<>(); simpleLeaveDetailItem = new HashMap<>();
//获取当天班次id
// String currentDayBcId = restDateList.contains(leaveDate) ? "" : Util.null2String(dateToBcxxMap.get(leaveDate)).split("-")[0];
Map<String, Object> shiftInfo = shiftInfoMap.get(currentDayBcId); Map<String, Object> shiftInfo = shiftInfoMap.get(currentDayBcId);
qjscHours = shiftInfo == null ? "4" : String.valueOf(Double.parseDouble(shiftInfo.get("edsc").toString()) / 2); qjscHours = shiftInfo == null ? "4" : String.valueOf(Double.parseDouble(shiftInfo.get("edsc").toString()) / 2);
//组装初步的请假明细数据 //组装初步的请假明细数据
@ -1494,7 +1490,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
//然后判断其他请假方式是由已经存在记录,结合该类请假记录的已有请假时长之和判断 //然后判断其他请假方式是由已经存在记录,结合该类请假记录的已有请假时长之和判断
if (otherLeaveList.size() > 0) { if (otherLeaveList.size() > 0) {
// existLeaveSc = existLeaveSc + otherLeaveList.stream().mapToDouble(e->Double.parseDouble(e.getOrDefault("qjsc", "0").toString())).sum(); // existLeaveSc = existLeaveSc + otherLeaveList.stream().mapToDouble(e->Double.parseDouble(e.getOrDefault("qjsc", "0").toString())).sum();
existLeaveSc = otherLeaveList.stream().mapToDouble(e-> { existLeaveSc = existLeaveSc + otherLeaveList.stream().mapToDouble(e-> {
if (jbIdToHsdw.get(e.get("qjlx").toString()).equals(AccountingUnitEnum.DAY.getKey())) { if (jbIdToHsdw.get(e.get("qjlx").toString()).equals(AccountingUnitEnum.DAY.getKey())) {
return Double.parseDouble(e.getOrDefault("qjsc", "0").toString()) * dateToRatedHours.getOrDefault(ksrq, 8.0); return Double.parseDouble(e.getOrDefault("qjsc", "0").toString()) * dateToRatedHours.getOrDefault(ksrq, 8.0);
} }
@ -1510,6 +1506,90 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
} }
} }
//判断已存在出差记录和待生成请假信息是否存在冲突
//查询数据库中当天存在的出差记录
List<Map<String, Object>> existCcInfo;
sql = "select b.* from uf_jcl_kq_ccjl a left join uf_jcl_kq_ccjl_dt1 b on b.mainid = a.id where a.jlzt != 2 and b.cxcc= 0 and b.ccr = " + empId;
if (leaveMode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey())) {
sql = sql + " and ((b.ksrq >= ? and b.ksrq <= ?) or (b.jsrq >= ? and b.jsrq <= ?) or (b.ksrq <= ? and b.jsrq >= ?))";
existCcInfo = DbTools.getSqlToList(sql, ksrq, jsrq, ksrq, jsrq, ksrq, jsrq);
} else {
sql = sql + " and b.ksrq <= ? and b.jsrq >= ?";
existCcInfo = DbTools.getSqlToList(sql, ksrq, ksrq);
}
//分析数据库中已存在出差数据
double existCcSc = 0;
if (existCcInfo.size() > 0) {
List<Map<String, Object>> timeIntervalCcList = new ArrayList<>();
List<Map<String, Object>> allDayCcList = new ArrayList<>();
List<Map<String, Object>> otherCcList = new ArrayList<>();
for (Map<String, Object> leaveItem : existCcInfo) {
if (!"".equals(Util.null2String(leaveItem.get("kssj")))) {
timeIntervalCcList.add(leaveItem);
} else if ("1".equals(Util.null2String(leaveItem.get("qtcc")))) {
allDayCcList.add(leaveItem);
} else {
otherCcList.add(leaveItem);
}
}
if (allDayCcList.size() > 0) {
//该日期已存在全天出差时
message = message + "_" + ksrq + "已存在全天出差, 不允许再进行任何请假申请!";
errorMessage.add(message);
return false;
} else if (leaveMode.equals(AskAndEvctionWayEnum.ALLDAY.getKey())) {
//该日期即将生成全天出差
//首先判断,是否已存在区间出差信息,且区间出差区间与目标日期有重叠时间段,然后判断其他出差方式是由已经存在记录
List<Map<String, Object>> overlappingList = timeIntervalCcList.stream().filter(f ->
DateUtil.isOverlapping(ksrq + " 00:00", ksrq + " 23:59", f.get("ksrq") + " " + f.get("kssj"), f.get("jsrq") + " " + f.get("jssj")))
.collect(Collectors.toList());
if (overlappingList.size() > 0 || otherCcList.size() > 0) {
message = message + "_" + ksrq + "已存在出差记录, 不允许再进行全天请假方式的请假申请!";
errorMessage.add(message);
return false;
}
} else if (leaveMode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey())) {
//该日期即将生成指定时间区间出差
//首先判断,是否已存在区间出差之外的信息,然后判断是否存在区间出差且存在交集
List<Map<String, Object>> overlappingList = timeIntervalCcList.stream().filter(f ->
DateUtil.isOverlapping(ksrq + " " + kssj, jsrq + " " + jssj, f.get("ksrq") + " " + f.get("kssj"), f.get("jsrq") + " " + f.get("jssj")))
.collect(Collectors.toList());
if (overlappingList.size() > 0 || otherCcList.size() > 0) {
message = message + "在" + ksrq + "到" + jsrq + "的出差区间内已存在出差记录, 不允许再进行请假申请!";
errorMessage.add(message);
return false;
}
} else if (leaveMode.equals(AskAndEvctionWayEnum.HALFDAY.getKey()) || leaveMode.equals(AskAndEvctionWayEnum.HOUR.getKey())) {
//该日期即将生成指定时间长度出差或者半天出差
//首先判断,是否已存在区间出差信息,且区间出差区间与目标日期有重叠时间段
List<Map<String, Object>> overlappingList = timeIntervalCcList.stream().filter(f ->
DateUtil.isOverlapping(ksrq + " 00:00", ksrq + " 23:59", f.get("ksrq") + " " + f.get("kssj"), f.get("jsrq") + " " + f.get("jssj")))
.collect(Collectors.toList());
if (overlappingList.size() > 0) {
message = message + "_" + ksrq + "已存在指定时间区间出差记录, 不允许再其他方式的请假申请!";
errorMessage.add(message);
return false;
}
//然后判断其他出差方式是由已经存在记录,结合该类出差记录的已有出差时长之和判断
if (otherCcList.size() > 0) {
existCcSc = otherCcList.stream().mapToDouble(e-> {
if (jbIdToHsdw.get(e.get("cclx").toString()).equals(AccountingUnitEnum.DAY.getKey())) {
return Double.parseDouble(e.getOrDefault("ccsc", "0").toString()) * dateToRatedHours.getOrDefault(ksrq, 8.0);
}
return Double.parseDouble(e.getOrDefault("ccsc", "0").toString());
}).sum();
if (existLeaveSc + existCcSc + leaveHours > dateToRatedHours.getOrDefault(ksrq, 8.0)) {
message = message + "_" + ksrq + "已存在共计" + existCcSc
+ "小时的出差记录、" + existLeaveSc
+ "小时的请假记录,新申请假期累计后已超过当天上班额定时长" + dateToRatedHours.getOrDefault(ksrq, 8.0) + "小时!";
errorMessage.add(message);
return false;
}
}
}
}
return true; return true;
} }

@ -4,10 +4,7 @@ import com.engine.common.util.ServiceUtil;
import com.engine.jucailinkq.attendance.component.persongroup.commonutil.PersongroupCommonUtil; import com.engine.jucailinkq.attendance.component.persongroup.commonutil.PersongroupCommonUtil;
import com.engine.jucailinkq.attendance.component.persongroup.service.SchedulingResultsService; import com.engine.jucailinkq.attendance.component.persongroup.service.SchedulingResultsService;
import com.engine.jucailinkq.attendance.component.persongroup.service.impl.SchedulingResultsServiceImpl; import com.engine.jucailinkq.attendance.component.persongroup.service.impl.SchedulingResultsServiceImpl;
import com.engine.jucailinkq.attendance.enums.AccountingUnitEnum; import com.engine.jucailinkq.attendance.enums.*;
import com.engine.jucailinkq.attendance.enums.CheckBoxEnum;
import com.engine.jucailinkq.attendance.enums.ClassSegmentTypeEnum;
import com.engine.jucailinkq.attendance.enums.DateTypeEnum;
import com.engine.jucailinkq.attendance.workflow.cmd.GetRestDayIntervalCmd; import com.engine.jucailinkq.attendance.workflow.cmd.GetRestDayIntervalCmd;
import com.engine.jucailinkq.attendance.workflow.enums.AskAndEvctionWayEnum; import com.engine.jucailinkq.attendance.workflow.enums.AskAndEvctionWayEnum;
import com.engine.jucailinkq.attendance.workflow.service.BusinessTripsApplyService; import com.engine.jucailinkq.attendance.workflow.service.BusinessTripsApplyService;
@ -98,8 +95,10 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
empIdToName = data.stream().collect(Collectors.toMap(e->Util.null2String(e.get("id")), e->Util.null2String(e.get("lastname")))); empIdToName = data.stream().collect(Collectors.toMap(e->Util.null2String(e.get("id")), e->Util.null2String(e.get("lastname"))));
} }
//获取填写的出差类型关联的考勤项目 //获取填写的出差类型关联的考勤项目
String sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb,zdycbcndfgzsd,zdycrqqjndxxb,yxyz,zdyzsl,zysd from uf_jcl_kq_kqxm where id=?"; String sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb,zdycbcndfgzsd,zdycrqqjndxxb,yxyz,zdyzsl,zysd from uf_jcl_kq_kqxm where xmlx=? or xmlx=?";
Map<String,Object> holidayItem = DbTools.getSqlToMap(sql,ccType); List<Map<String,Object>> cclxItemList = DbTools.getSqlToList(sql, AttendanceItemTypeEnum.EVECTION.getKey(), AttendanceItemTypeEnum.HOLIDAY.getKey());
Map<String, String> cclxIdToHsdw = cclxItemList.stream().collect(Collectors.toMap(e->e.get("id").toString(), e->e.get("hsdw").toString()));
Map<String,Object> holidayItem = cclxItemList.stream().filter(m -> ccType.equals(m.get("id"))).findFirst().orElse(new HashMap<>());
//出差类型名称 //出差类型名称
String checkItemName = Util.null2String(holidayItem.get("mc")); String checkItemName = Util.null2String(holidayItem.get("mc"));
//核算单位 //核算单位
@ -137,15 +136,18 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
Map<String, List<String>> restDayInfo = removeNonWorkDayRange ? getRestDayWithEmpId(ccEmpIdList, startDate, endDate) : new HashMap<>(); Map<String, List<String>> restDayInfo = removeNonWorkDayRange ? getRestDayWithEmpId(ccEmpIdList, startDate, endDate) : new HashMap<>();
//出差人的出差区间内的排班结果 //出差人的出差区间内的排班结果
Map<String, List<Map<String, Object>>> scheduleInfoMap = getScheduleInfoWithEmpId(ccEmpIdList, DateUtil.beforeDay(startDate,1), DateUtil.AfterDay(endDate,1)); Map<String, List<Map<String, Object>>> scheduleInfoMap = getScheduleInfoWithEmpId(ccEmpIdList, DateUtil.beforeDay(startDate,1), DateUtil.AfterDay(endDate,1));
//班次信息与班次id的映射
Map<String, Map<String, Object>> shiftInfoMap = getShiftInfoWithShiftId();
//收集请假人有班次时的日期对应的额定时长信息
Map<String, Map<String, Double>> empIdToDateRatedHours = new HashMap<>();
//生成出差明细数据 //生成出差明细数据
List<Map<String, String>> simpleDetailList; List<Map<String, String>> simpleDetailList;
if (ccMode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey()) && !"1".equals(dailyRepeat)) { if (ccMode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey()) && !"1".equals(dailyRepeat)) {
simpleDetailList = createDetailListWithNoDaily(ccEmpIdList, ccDateList, removeNonWorkDayRange, scheduleInfoMap, simpleDetailList = createDetailListWithNoDaily(ccEmpIdList, ccDateList, removeNonWorkDayRange, scheduleInfoMap,
restDayInfo, startDate, endDate, startTime, endTime, countBdlxList, hsdw, hsl, ccType, empIdToName, checkItemName); restDayInfo, startDate, endDate, startTime, endTime, countBdlxList, hsdw, hsl, ccType, empIdToName, checkItemName, shiftInfoMap, empIdToDateRatedHours);
} else { } else {
simpleDetailList = createDetailList(ccEmpIdList, ccDateList, removeNonWorkDayRange, scheduleInfoMap, simpleDetailList = createDetailList(ccEmpIdList, ccDateList, removeNonWorkDayRange, scheduleInfoMap,
restDayInfo, ccMode, startTime, endTime, ccDuration, countBdlxList, hsdw, hsl, ccType, empIdToName, checkItemName); restDayInfo, ccMode, startTime, endTime, ccDuration, countBdlxList, hsdw, hsl, ccType, empIdToName, checkItemName, shiftInfoMap, empIdToDateRatedHours, cclxIdToHsdw);
} }
//按照人员id分组处理请假明细信息关联假期余额数据 //按照人员id分组处理请假明细信息关联假期余额数据
@ -162,7 +164,7 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
// //
for (Map<String,String> detailItem : entry.getValue()) { for (Map<String,String> detailItem : entry.getValue()) {
//单日出差“全局唯一性”约束校验 //单日出差“全局唯一性”约束校验
boolean dailyCheckSign = checkDailyBusinessTripsLicense(entry.getKey(), detailItem, editedEmpCcInfo.get(entry.getKey()), errorMessage); boolean dailyCheckSign = checkDailyBusinessTripsLicense(entry.getKey(), detailItem, editedEmpCcInfo.get(entry.getKey()), errorMessage, cclxIdToHsdw, empIdToDateRatedHours.get(entry.getKey()));
if (dailyCheckSign) { if (dailyCheckSign) {
completeLeaveDetailList.add(detailItem); completeLeaveDetailList.add(detailItem);
} }
@ -194,46 +196,56 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
return resultMap; return resultMap;
} }
private boolean checkDailyBusinessTripsLicense(String empId, Map<String, String> detailData, List<Map<String, String>> editedBusinessTripsList, List<String> errorMessage) { private Map<String, Map<String, Object>> getShiftInfoWithShiftId() {
//出差时间 Map<String, Map<String, Object>> result = new HashMap<>();
double ccDuration; String sql = "select id, mc ,edsc, fgsjd, zgzsc, btgz from uf_jcl_kq_bcxx";
List<Map<String, Object>> shiftInfoList = DbTools.getSqlToList(sql);
if (shiftInfoList.size() > 0) {
result = shiftInfoList.stream().collect(Collectors.toMap(e -> e.get("id").toString(), e -> e));
}
return result;
}
private boolean checkDailyBusinessTripsLicense(String empId, Map<String, String> detailData, List<Map<String, String>> editedBusinessTripsList, List<String> errorMessage, Map<String, String> cclxIdToHsdw, Map<String, Double> dateToRatedHours) {
//出差时间小时数
double ccscHours;
//判断当前请假信息属于哪一种出差方式(全天、半天、指定时长、指定区间) //判断当前请假信息属于哪一种出差方式(全天、半天、指定时长、指定区间)
String leaveMode = ""; String leaveMode = "";
if (!"".equals(Util.null2String(detailData.get("kssj")))) { if (!"".equals(Util.null2String(detailData.get("kssj")))) {
leaveMode = AskAndEvctionWayEnum.TIME_INTERVAL.getKey(); leaveMode = AskAndEvctionWayEnum.TIME_INTERVAL.getKey();
ccDuration = Double.parseDouble(Util.null2String(detailData.get("ccsc"))); ccscHours = Double.parseDouble(Util.null2String(detailData.get("ccsc")));
} else if ("1".equals(Util.null2String(detailData.get("qtcc")))) { } else if ("1".equals(Util.null2String(detailData.get("qtcc")))) {
leaveMode = AskAndEvctionWayEnum.ALLDAY.getKey(); leaveMode = AskAndEvctionWayEnum.ALLDAY.getKey();
ccDuration = 8; ccscHours = Double.parseDouble(detailData.getOrDefault("ccscHours", "8"));
} else if ("1".equals(Util.null2String(detailData.get("btcc")))) { } else if ("1".equals(Util.null2String(detailData.get("btcc")))) {
leaveMode = AskAndEvctionWayEnum.HALFDAY.getKey(); leaveMode = AskAndEvctionWayEnum.HALFDAY.getKey();
ccDuration = 4; ccscHours = Double.parseDouble(detailData.getOrDefault("ccscHours", "4"));
} else { } else {
leaveMode = AskAndEvctionWayEnum.HOUR.getKey(); leaveMode = AskAndEvctionWayEnum.HOUR.getKey();
ccDuration = Double.parseDouble(Util.null2String(detailData.get("ccsc"))); ccscHours = Double.parseDouble(Util.null2String(detailData.get("ccsc")));
} }
String ksrq = Util.null2String(detailData.get("ksrq")); String ksrq = Util.null2String(detailData.get("ksrq"));
String jsrq = Util.null2String(detailData.get("jsrq")); String jsrq = Util.null2String(detailData.get("jsrq"));
String kssj = Util.null2String(detailData.get("kssj")); String kssj = Util.null2String(detailData.get("kssj"));
String jssj = Util.null2String(detailData.get("jssj")); String jssj = Util.null2String(detailData.get("jssj"));
//查询数据库中当天存在的出差记录 //查询数据库中当天存在的出差记录
List<Map<String, Object>> existLeaveInfo; List<Map<String, Object>> existCcInfo;
String sql = "select b.* from uf_jcl_kq_ccjl a left join uf_jcl_kq_ccjl_dt1 b on b.mainid = a.id where a.jlzt != 2 and b.cxcc= 0 and b.ccr = " + empId; String sql = "select b.* from uf_jcl_kq_ccjl a left join uf_jcl_kq_ccjl_dt1 b on b.mainid = a.id where a.jlzt != 2 and b.cxcc= 0 and b.ccr = " + empId;
if (leaveMode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey())) { if (leaveMode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey())) {
sql = sql + " and ((b.ksrq >= ? and b.ksrq <= ?) or (b.jsrq >= ? and b.jsrq <= ?) or (b.ksrq <= ? and b.jsrq >= ?))"; sql = sql + " and ((b.ksrq >= ? and b.ksrq <= ?) or (b.jsrq >= ? and b.jsrq <= ?) or (b.ksrq <= ? and b.jsrq >= ?))";
existLeaveInfo = DbTools.getSqlToList(sql, ksrq, jsrq, ksrq, jsrq, ksrq, jsrq); existCcInfo = DbTools.getSqlToList(sql, ksrq, jsrq, ksrq, jsrq, ksrq, jsrq);
} else { } else {
sql = sql + " and b.ksrq <= ? and b.jsrq >= ?"; sql = sql + " and b.ksrq <= ? and b.jsrq >= ?";
existLeaveInfo = DbTools.getSqlToList(sql, ksrq, ksrq); existCcInfo = DbTools.getSqlToList(sql, ksrq, ksrq);
} }
//分析数据库中已存在出差数据 //分析数据库中已存在出差数据
String message = Util.null2String(detailData.get("ccrName")); String message = Util.null2String(detailData.get("ccrName"));
double existCcSc = 0; double existCcSc = 0;
if (existLeaveInfo.size() > 0) { if (existCcInfo.size() > 0) {
List<Map<String, Object>> timeIntervalCcList = new ArrayList<>(); List<Map<String, Object>> timeIntervalCcList = new ArrayList<>();
List<Map<String, Object>> allDayCcList = new ArrayList<>(); List<Map<String, Object>> allDayCcList = new ArrayList<>();
List<Map<String, Object>> otherCcList = new ArrayList<>(); List<Map<String, Object>> otherCcList = new ArrayList<>();
for (Map<String, Object> leaveItem : existLeaveInfo) { for (Map<String, Object> leaveItem : existCcInfo) {
if (!"".equals(Util.null2String(leaveItem.get("kssj")))) { if (!"".equals(Util.null2String(leaveItem.get("kssj")))) {
timeIntervalCcList.add(leaveItem); timeIntervalCcList.add(leaveItem);
} else if ("1".equals(Util.null2String(leaveItem.get("qtcc")))) { } else if ("1".equals(Util.null2String(leaveItem.get("qtcc")))) {
@ -282,17 +294,16 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
} }
//然后判断其他出差方式是由已经存在记录,结合该类出差记录的已有出差时长之和判断 //然后判断其他出差方式是由已经存在记录,结合该类出差记录的已有出差时长之和判断
if (otherCcList.size() > 0) { if (otherCcList.size() > 0) {
existCcSc = otherCcList.stream().mapToDouble(e -> {
if ("1".equals(Util.null2String(e.get("btcc")))) { existCcSc = otherCcList.stream().mapToDouble(e-> {
return Double.parseDouble("4"); if (cclxIdToHsdw.get(e.get("cclx").toString()).equals(AccountingUnitEnum.DAY.getKey())) {
} else if (!"".equals(Util.null2String(e.get("ccsc")))) { return Double.parseDouble(e.getOrDefault("ccsc", "0").toString()) * dateToRatedHours.getOrDefault(ksrq, 8.0);
return Double.parseDouble(e.get("ccsc").toString());
} else {
return Double.parseDouble("0");
} }
return Double.parseDouble(e.getOrDefault("ccsc", "0").toString());
}).sum(); }).sum();
if (existCcSc + ccDuration > 8) { if (existCcSc + ccscHours > dateToRatedHours.getOrDefault(ksrq, 8.0)) {
message = message + "_" + ksrq + "已存在共计" + existCcSc + "小时的出差记录, 新申请出差累计后已超过8小时"; message = message + "_" + ksrq + "已存在共计" + existCcSc +
"小时的出差记录, 新申请出差累计后已超过当天上班额定时长" + dateToRatedHours.getOrDefault(ksrq, 8.0) + "小时!";
errorMessage.add(message); errorMessage.add(message);
return false; return false;
} }
@ -365,9 +376,100 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
} }
//然后判断其他出差方式是由已经存在记录,结合该类出差记录的已有出差时长之和判断 //然后判断其他出差方式是由已经存在记录,结合该类出差记录的已有出差时长之和判断
if (otherCcList.size() > 0) { if (otherCcList.size() > 0) {
existCcSc = existCcSc + otherCcList.stream().mapToDouble(e->Double.parseDouble(e.getOrDefault("ccsc", "0").toString())).sum();
if (existCcSc + ccDuration > 8) { existCcSc = existCcSc + otherCcList.stream().mapToDouble(e-> {
message = message + "_" + ksrq + "已存在当天出差记录和当前流程已编辑出差明细共计" + existCcSc + "小时的出差记录, 新申请出差累计后已超过8小时"; if (cclxIdToHsdw.get(e.get("cclx").toString()).equals(AccountingUnitEnum.DAY.getKey())) {
return Double.parseDouble(e.getOrDefault("ccsc", "0").toString()) * dateToRatedHours.getOrDefault(ksrq, 8.0);
}
return Double.parseDouble(e.getOrDefault("ccsc", "0").toString());
}).sum();
if (existCcSc + ccscHours > dateToRatedHours.getOrDefault(ksrq, 8.0)) {
message = message + "_" + ksrq + "已存在当天出差记录和当前流程已编辑出差明细共计" + existCcSc +
"小时的出差记录, 新申请出差累计后已超过当天上班额定时长" + dateToRatedHours.getOrDefault(ksrq, 8.0) + "小时!";
errorMessage.add(message);
return false;
}
}
}
}
//判断已存在请假记录和待生成出差信息是否存在冲突
//查询数据库中当天存在的请假记录
List<Map<String, Object>> existLeaveInfo;
sql = "select b.* from uf_jcl_kq_qjjl a left join uf_jcl_kq_qjjl_dt1 b on b.mainid = a.id where a.jlzt != 2 and b.cxqj = 0 and b.qjry = " + empId;
if (leaveMode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey())) {
sql = sql + " and ((b.ksrq >= ? and b.ksrq <= ?) or (b.jsrq >= ? and b.jsrq <= ?) or (b.ksrq <= ? and b.jsrq >= ?))";
existLeaveInfo = DbTools.getSqlToList(sql, ksrq, jsrq, ksrq, jsrq, ksrq, jsrq);
} else {
sql = sql + " and b.ksrq <= ? and b.jsrq >= ?";
existLeaveInfo = DbTools.getSqlToList(sql, ksrq, ksrq);
}
//分析数据库中已存在请假数据
double existLeaveSc = 0;
if (existLeaveInfo.size() > 0) {
List<Map<String, Object>> timeIntervalLeaveList = new ArrayList<>();
List<Map<String, Object>> allDayLeaveList = new ArrayList<>();
List<Map<String, Object>> otherLeaveList = new ArrayList<>();
for (Map<String, Object> leaveItem : existLeaveInfo) {
if (!"".equals(Util.null2String(leaveItem.get("kssj")))) {
timeIntervalLeaveList.add(leaveItem);
} else if ("1".equals(Util.null2String(leaveItem.get("qtj")))) {
allDayLeaveList.add(leaveItem);
} else {
otherLeaveList.add(leaveItem);
}
}
if (allDayLeaveList.size() > 0) {
//该日期已存在全天假时
message = message + "_" + ksrq + "已存在全天假, 不允许再进行任何出差申请!";
errorMessage.add(message);
return false;
} else if (leaveMode.equals(AskAndEvctionWayEnum.ALLDAY.getKey())) {
//该日期即将生成全天假
//首先判断,是否已存在区间假信息,且区间假区间与目标日期有重叠时间段,然后判断其他请假方式是由已经存在记录
List<Map<String, Object>> overlappingList = timeIntervalLeaveList.stream().filter(f ->
DateUtil.isOverlapping(ksrq + " 00:00", ksrq + " 23:59", f.get("ksrq") + " " + f.get("kssj"), f.get("jsrq") + " " + f.get("jssj")))
.collect(Collectors.toList());
if (overlappingList.size() > 0 || otherLeaveList.size() > 0) {
message = message + "_" + ksrq + "已存在请假记录, 不允许再进行全天假方式的出差申请!";
errorMessage.add(message);
return false;
}
} else if (leaveMode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey())) {
//该日期即将生成指定时间区间假
//首先判断,是否已存在区间假之外的信息,然后判断是否存在区间假且存在交集
List<Map<String, Object>> overlappingList = timeIntervalLeaveList.stream().filter(f ->
DateUtil.isOverlapping(ksrq + " " + kssj, jsrq + " " + jssj, f.get("ksrq") + " " + f.get("kssj"), f.get("jsrq") + " " + f.get("jssj")))
.collect(Collectors.toList());
if (overlappingList.size() > 0 || otherLeaveList.size() > 0) {
message = message + "在" + ksrq + "开始的出差区间内已存在请假记录的区间重叠, 不允许再进行出差申请!";
errorMessage.add(message);
return false;
}
} else if (leaveMode.equals(AskAndEvctionWayEnum.HALFDAY.getKey()) || leaveMode.equals(AskAndEvctionWayEnum.HOUR.getKey())) {
//该日期即将生成指定时间长度假或者半天假
//首先判断,是否已存在区间假信息,且区间假区间与目标日期有重叠时间段
List<Map<String, Object>> overlappingList = timeIntervalLeaveList.stream().filter(f ->
DateUtil.isOverlapping(ksrq + " 00:00", ksrq + " 23:59", f.get("ksrq") + " " + f.get("kssj"), f.get("jsrq") + " " + f.get("jssj")))
.collect(Collectors.toList());
if (overlappingList.size() > 0) {
message = message + "_" + ksrq + "已存在指定时间区间请假记录, 不允许再其他方式的出差申请!";
errorMessage.add(message);
return false;
}
//然后判断其他请假方式是由已经存在记录,结合该类请假记录的已有请假时长之和判断
if (otherLeaveList.size() > 0) {
existLeaveSc = otherLeaveList.stream().mapToDouble(e-> {
if (cclxIdToHsdw.get(e.get("jqlx").toString()).equals(AccountingUnitEnum.DAY.getKey())) {
return Double.parseDouble(e.getOrDefault("qjsc", "0").toString()) * dateToRatedHours.getOrDefault(ksrq, 8.0);
}
return Double.parseDouble(e.getOrDefault("qjsc", "0").toString());
}).sum();
if (existLeaveSc + existCcSc + ccscHours > dateToRatedHours.getOrDefault(ksrq, 8.0)) {
message = message + "_" + ksrq + "已存在共计" + existCcSc
+ "小时的出差记录、" + existLeaveSc
+ "小时的请假记录,新申请出差累计后已超过当天上班额定时长" + dateToRatedHours.getOrDefault(ksrq, 8.0) + "小时!";
errorMessage.add(message); errorMessage.add(message);
return false; return false;
} }
@ -508,13 +610,16 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
* @param countBdlxList * @param countBdlxList
* @return * @return
*/ */
private List<Map<String, String>> createDetailList(List<String> empIdList, List<String> dateList, boolean removeNonWorkDayRange, private List<Map<String, String>> createDetailList(List<String> empIdList, List<String> dateList, boolean removeNonWorkDayRange, Map<String, List<Map<String, Object>>> scheduleInfoMap,
Map<String, List<Map<String, Object>>> scheduleInfoMap, Map<String, List<String>> restDayInfo, Map<String, List<String>> restDayInfo, String mode, String startTime, String endTime, String ccDuration, List<String> countBdlxList,
String mode, String startTime, String endTime, String ccDuration, List<String> countBdlxList, String hsdw, double hsl, String ccType, Map<String, String> empIdToName, String checkItemName, Map<String, Map<String, Object>> shiftInfoMap,
String hsdw, double hsl, String ccType, Map<String, String> empIdToName, String checkItemName) { Map<String, Map<String, Double>> empIdToDateRatedHours, Map<String, String> cclxIdToHsdw) {
List<Map<String, String>> simpleDetailList = new ArrayList<>(); List<Map<String, String>> simpleDetailList = new ArrayList<>();
Map<String, String> simpleDetailItem; Map<String, String> simpleDetailItem;
Map<String, Double> dateToRatedHours;
String ccScHours = "";
for (String ccEmpId : empIdList) { for (String ccEmpId : empIdList) {
dateToRatedHours = new HashMap<>();
//需要自动移除日期区间内的休息日时,去除出差日期区间中的休息日 //需要自动移除日期区间内的休息日时,去除出差日期区间中的休息日
List<Map<String, Object>> scheduleInfoList = scheduleInfoMap.getOrDefault(ccEmpId, new ArrayList<>()); List<Map<String, Object>> scheduleInfoList = scheduleInfoMap.getOrDefault(ccEmpId, new ArrayList<>());
Map<String, String> dateToBcxxMap = scheduleInfoList.stream().collect(Collectors.toMap(e->Util.null2String(e.get("bcrq")),e->Util.null2String(e.get("bcxx")))); Map<String, String> dateToBcxxMap = scheduleInfoList.stream().collect(Collectors.toMap(e->Util.null2String(e.get("bcrq")),e->Util.null2String(e.get("bcxx"))));
@ -536,6 +641,13 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
} }
String ccEmpName = empIdToName.get(ccEmpId); String ccEmpName = empIdToName.get(ccEmpId);
for (String ccDate : dateList) { for (String ccDate : dateList) {
//获取当天班次id
String currentDayBcId = restDateList.contains(ccDate) ? "" : Util.null2String(dateToBcxxMap.get(ccDate)).split("-")[0];
if (!"".equals(currentDayBcId)) {
Map<String, Object> shiftInfo = shiftInfoMap.get(currentDayBcId);
ccScHours = shiftInfo == null ? "8" : shiftInfo.get("edsc").toString();
dateToRatedHours.put(ccDate, Double.parseDouble(ccScHours));
}
//出差方式为“指定时间区间”时 //出差方式为“指定时间区间”时
if (mode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey())) { if (mode.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey())) {
simpleDetailItem = new HashMap<>(); simpleDetailItem = new HashMap<>();
@ -549,7 +661,7 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
simpleDetailItem.put("kssj", startTime); simpleDetailItem.put("kssj", startTime);
simpleDetailItem.put("jssj", endTime); simpleDetailItem.put("jssj", endTime);
//获取当天班次id //获取当天班次id
String currentDayBcId = restDateList.contains(ccDate) ? "" : Util.null2String(dateToBcxxMap.get(ccDate)).split("-")[0]; // String currentDayBcId = restDateList.contains(ccDate) ? "" : Util.null2String(dateToBcxxMap.get(ccDate)).split("-")[0];
//获取前一天班次id //获取前一天班次id
String yesterday = DateUtil.beforeDay(ccDate,1); String yesterday = DateUtil.beforeDay(ccDate,1);
String yesterdayBcId = restDateList.contains(yesterday) ? "" : Util.null2String(dateToBcxxMap.get(yesterday)).split("-")[0]; String yesterdayBcId = restDateList.contains(yesterday) ? "" : Util.null2String(dateToBcxxMap.get(yesterday)).split("-")[0];
@ -621,6 +733,8 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
} }
} else if (mode.equals(AskAndEvctionWayEnum.ALLDAY.getKey()) && !restDateList.contains(ccDate)) { } else if (mode.equals(AskAndEvctionWayEnum.ALLDAY.getKey()) && !restDateList.contains(ccDate)) {
simpleDetailItem = new HashMap<>(); simpleDetailItem = new HashMap<>();
Map<String, Object> shiftInfo = shiftInfoMap.get(currentDayBcId);
ccScHours = shiftInfo == null ? "8" : shiftInfo.get("edsc").toString();
//组装初步的明细数据 //组装初步的明细数据
simpleDetailItem.put("ccr", ccEmpId); simpleDetailItem.put("ccr", ccEmpId);
simpleDetailItem.put("cclx", ccType); simpleDetailItem.put("cclx", ccType);
@ -629,9 +743,17 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
simpleDetailItem.put("ksrq", ccDate); simpleDetailItem.put("ksrq", ccDate);
simpleDetailItem.put("jsrq", ccDate); simpleDetailItem.put("jsrq", ccDate);
simpleDetailItem.put("qtcc", "1"); simpleDetailItem.put("qtcc", "1");
simpleDetailItem.put("ccscHours", ccScHours);
if (cclxIdToHsdw.get(ccType).equals(AccountingUnitEnum.DAY.getKey())) {
simpleDetailItem.put("ccsc", "1");
} else {
simpleDetailItem.put("ccsc", ccScHours);
}
simpleDetailList.add(simpleDetailItem); simpleDetailList.add(simpleDetailItem);
} else if (mode.equals(AskAndEvctionWayEnum.HALFDAY.getKey()) && !restDateList.contains(ccDate)) { } else if (mode.equals(AskAndEvctionWayEnum.HALFDAY.getKey()) && !restDateList.contains(ccDate)) {
simpleDetailItem = new HashMap<>(); simpleDetailItem = new HashMap<>();
Map<String, Object> shiftInfo = shiftInfoMap.get(currentDayBcId);
ccScHours = shiftInfo == null ? "4" : String.valueOf(Double.parseDouble(shiftInfo.get("edsc").toString()) / 2);
//组装初步的明细数据 //组装初步的明细数据
simpleDetailItem.put("ccr", ccEmpId); simpleDetailItem.put("ccr", ccEmpId);
simpleDetailItem.put("cclx", ccType); simpleDetailItem.put("cclx", ccType);
@ -640,9 +762,16 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
simpleDetailItem.put("ksrq", ccDate); simpleDetailItem.put("ksrq", ccDate);
simpleDetailItem.put("jsrq", ccDate); simpleDetailItem.put("jsrq", ccDate);
simpleDetailItem.put("btcc", "1"); simpleDetailItem.put("btcc", "1");
simpleDetailItem.put("ccscHours", ccScHours);
if (cclxIdToHsdw.get(ccType).equals(AccountingUnitEnum.DAY.getKey())) {
simpleDetailItem.put("ccsc", "0.5");
} else {
simpleDetailItem.put("ccsc", ccScHours);
}
simpleDetailList.add(simpleDetailItem); simpleDetailList.add(simpleDetailItem);
} }
} }
empIdToDateRatedHours.put(ccEmpId, dateToRatedHours);
} }
return simpleDetailList; return simpleDetailList;
} }
@ -660,10 +789,10 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
* @param countBdlxList * @param countBdlxList
* @return * @return
*/ */
private List<Map<String, String>> createDetailListWithNoDaily(List<String> empIdList, List<String> dateList, boolean removeNonWorkDayRange, private List<Map<String, String>> createDetailListWithNoDaily(List<String> empIdList, List<String> dateList, boolean removeNonWorkDayRange, Map<String, List<Map<String, Object>>> scheduleInfoMap,
Map<String, List<Map<String, Object>>> scheduleInfoMap, Map<String, List<String>> restDayInfo, Map<String, List<String>> restDayInfo, String startDate, String endDate, String startTime, String endTime, List<String> countBdlxList,
String startDate, String endDate, String startTime, String endTime, List<String> countBdlxList, String hsdw, double hsl, String ccType, Map<String, String> empIdToName, String checkItemName, Map<String, Map<String, Object>> shiftInfoMap,
String hsdw, double hsl, String ccType, Map<String, String> empIdToName, String checkItemName) { Map<String, Map<String, Double>> empIdToDateRatedHours) {
List<Map<String, String>> simpleDetailList = new ArrayList<>(); List<Map<String, String>> simpleDetailList = new ArrayList<>();
Map<String, String> simpleDetailItem; Map<String, String> simpleDetailItem;
String sql = ""; String sql = "";
@ -671,7 +800,9 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
String targetDateBcId = ""; String targetDateBcId = "";
dateList.add(0, DateUtil.beforeDay(startDate,1)); dateList.add(0, DateUtil.beforeDay(startDate,1));
dateList.add(DateUtil.AfterDay(endDate,1)); dateList.add(DateUtil.AfterDay(endDate,1));
Map<String, Double> dateToRatedHours;
for (String ccEmpId : empIdList) { for (String ccEmpId : empIdList) {
dateToRatedHours = new HashMap<>();
int scMinutes = 0; int scMinutes = 0;
//需要自动移除日期区间内的休息日时,去除出差日期区间中的休息日 //需要自动移除日期区间内的休息日时,去除出差日期区间中的休息日
List<Map<String, Object>> scheduleInfoList = scheduleInfoMap.getOrDefault(ccEmpId, new ArrayList<>()); List<Map<String, Object>> scheduleInfoList = scheduleInfoMap.getOrDefault(ccEmpId, new ArrayList<>());
@ -707,6 +838,9 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
for (String date : dateList) { for (String date : dateList) {
targetDateBcId = restDateList.contains(date) ? "" : Util.null2String(dateToBcxxMap.get(date)).split("-")[0]; targetDateBcId = restDateList.contains(date) ? "" : Util.null2String(dateToBcxxMap.get(date)).split("-")[0];
if (!"".equals(targetDateBcId)) { if (!"".equals(targetDateBcId)) {
Map<String, Object> shiftInfo = shiftInfoMap.get(targetDateBcId);
dateToRatedHours.put(date, Double.parseDouble(shiftInfo == null ? "8" : shiftInfo.get("edsc").toString()));
sql = "select id, bdlx, gsrq, kssj as dtkssj, jssj as dtjssj from uf_jcl_kq_bcxx_dt1 where mainid = " + targetDateBcId; sql = "select id, bdlx, gsrq, kssj as dtkssj, jssj as dtjssj from uf_jcl_kq_bcxx_dt1 where mainid = " + targetDateBcId;
bcDetailData = DbTools.getSqlToList(sql); bcDetailData = DbTools.getSqlToList(sql);
bcDetailData = bcDetailData.stream().filter(e -> countBdlxList.contains(Util.null2String(e.get("bdlx")))).collect(Collectors.toList()); bcDetailData = bcDetailData.stream().filter(e -> countBdlxList.contains(Util.null2String(e.get("bdlx")))).collect(Collectors.toList());
@ -714,6 +848,7 @@ public class BusinessTripsApplyServiceImpl extends Service implements BusinessTr
scMinutes = scMinutes + Utils.removeTime(startDate + " " + startTime, endDate + " " + endTime, bcDetailData, date); scMinutes = scMinutes + Utils.removeTime(startDate + " " + startTime, endDate + " " + endTime, bcDetailData, date);
} }
} }
empIdToDateRatedHours.put(ccEmpId, dateToRatedHours);
//增加加班计划中的数据,加班计划明细中的数据作为“加班计划”班段类型数据的补充 //增加加班计划中的数据,加班计划明细中的数据作为“加班计划”班段类型数据的补充
if (countBdlxList.contains(ClassSegmentTypeEnum.OVERTIME_PLAN.getKey())) { if (countBdlxList.contains(ClassSegmentTypeEnum.OVERTIME_PLAN.getKey())) {
sql = "select b.jbry,b.ksrq,b.kssj,b.jblx,b.jsrq,b.jssj,b.jbsc,b.gsrq from uf_jcl_kq_jbjh a left join uf_jcl_kq_jbjh_dt1 b on a.id=b.mainid where b.jbry =? and b.ksrq>=? and b.jsrq<=? and (b.jbcx=0 or b.jbcx is null) and a.jlzt=1"; sql = "select b.jbry,b.ksrq,b.kssj,b.jblx,b.jsrq,b.jssj,b.jbsc,b.gsrq from uf_jcl_kq_jbjh a left join uf_jcl_kq_jbjh_dt1 b on a.id=b.mainid where b.jbry =? and b.ksrq>=? and b.jsrq<=? and (b.jbcx=0 or b.jbcx is null) and a.jlzt=1";

Loading…
Cancel
Save