|
|
|
@ -4,6 +4,7 @@ import com.engine.jucailinkq.attendance.component.persongroup.service.Scheduling
|
|
|
|
|
import com.engine.jucailinkq.attendance.component.persongroup.service.impl.SchedulingResultsServiceImpl;
|
|
|
|
|
import com.engine.jucailinkq.attendance.enums.AccountingUnitEnum;
|
|
|
|
|
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.GetAskForLeaveRecordListCmd;
|
|
|
|
|
import com.engine.jucailinkq.attendance.workflow.cmd.GetRestDayIntervalCmd;
|
|
|
|
@ -185,13 +186,29 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
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 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 id=?";
|
|
|
|
|
Map<String,Object> holidayItem = DbTools.getSqlToMap(sql,leaveType);
|
|
|
|
|
//勾选假期类型名称
|
|
|
|
|
String checkItemName = Util.null2String(holidayItem.get("mc"));
|
|
|
|
|
//判断是否需要自动移除时间区间内的非工作时长、自动移除日期区间内的休息日
|
|
|
|
|
boolean removeNonWorkTimeRange = "1".equals(Util.null2String(holidayItem.get("zdycbcndfgzsd")));
|
|
|
|
|
boolean removeNonWorkDayRange = "1".equals(Util.null2String(holidayItem.get("zdycrqqjndxxb")));
|
|
|
|
|
//获取作用时段
|
|
|
|
|
String zysd = Util.null2String(holidayItem.get("zysd"));
|
|
|
|
|
//获取需要统计时长的班段类型集合(仅作用在“指定时间区间”请假方式)
|
|
|
|
|
List<String> countBdlxList = new ArrayList<>();
|
|
|
|
|
List<String> zysdList = new ArrayList<>();
|
|
|
|
|
if (!"".equals(zysd)) {
|
|
|
|
|
zysdList = Arrays.asList(zysd.split(","));
|
|
|
|
|
for(String zysdKey : zysdList) {
|
|
|
|
|
countBdlxList.add(Utils.getClassSegmenByWorkFor(zysdKey));
|
|
|
|
|
}
|
|
|
|
|
if (!removeNonWorkTimeRange) {
|
|
|
|
|
countBdlxList.add(ClassSegmentTypeEnum.REST_AND_DINE.getKey());
|
|
|
|
|
countBdlxList.add(ClassSegmentTypeEnum.REST_PERIOD.getKey());
|
|
|
|
|
countBdlxList.add(ClassSegmentTypeEnum.DINING_PERIOD.getKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//判断考勤项目是否需要强制使用“优先使用项目”
|
|
|
|
|
boolean useFirstItemSign = CheckBoxEnum.CHECKED.getKey().equals(holidayItem.get("qzsyyxjb")) && CheckBoxEnum.CHECKED.getKey().equals(holidayItem.get("jcbyxsyqjb"));
|
|
|
|
|
Map<String,Object> holidayPriorityItem = useFirstItemSign ? DbTools.getSqlToMap(sql,holidayItem.get("yxsydjb")) : null;
|
|
|
|
@ -202,8 +219,8 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
Map<String, List<Map<String, Object>>> scheduleInfoMap = (removeNonWorkDayRange || removeNonWorkTimeRange) ? getScheduleInfoWithEmpId(leaveEmpIdList, startDate, endDate) : null;
|
|
|
|
|
|
|
|
|
|
//收集未关联假期余额的请假明细数据
|
|
|
|
|
List<Map<String, String>> simpleLeaveDetailList = createSimpleLeaveDetailList(leaveEmpIdList, leaveDateList, removeNonWorkDayRange, removeNonWorkTimeRange, scheduleInfoMap,
|
|
|
|
|
restDayInfo, leaveMode, startTime, endTime, leaveDuration);
|
|
|
|
|
List<Map<String, String>> simpleLeaveDetailList = createSimpleLeaveDetailList(leaveEmpIdList, leaveDateList, removeNonWorkDayRange, scheduleInfoMap,
|
|
|
|
|
restDayInfo, leaveMode, startTime, endTime, leaveDuration, countBdlxList);
|
|
|
|
|
//收集已关联假期余额的请假明细数据
|
|
|
|
|
List<Map<String, String>> completeLeaveDetailList = new ArrayList<>();
|
|
|
|
|
//按照人员id分组处理请假明细信息,关联假期余额数据
|
|
|
|
@ -306,30 +323,28 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
* @param leaveEmpIdList 请假人员id集合
|
|
|
|
|
* @param leaveDateList 请假日期集合
|
|
|
|
|
* @param removeNonWorkDayRange 是否移除非工作日时长
|
|
|
|
|
* @param removeNonWorkTimeRange 是否移除非工作时间时长
|
|
|
|
|
* @param scheduleInfoMap 排班信息
|
|
|
|
|
* @param restDayInfo 休息日信息
|
|
|
|
|
* @param leaveMode 请假方式
|
|
|
|
|
* @param startTime 开始时间
|
|
|
|
|
* @param endTime 结束时间
|
|
|
|
|
* @param leaveDuration 请假时长
|
|
|
|
|
* @param countBdlxList 收集需要统计时长的班段类型
|
|
|
|
|
* @return 组装初步的请假明细
|
|
|
|
|
*/
|
|
|
|
|
private List<Map<String, String>> createSimpleLeaveDetailList(List<String> leaveEmpIdList, List<String> leaveDateList, boolean removeNonWorkDayRange, boolean removeNonWorkTimeRange,
|
|
|
|
|
private List<Map<String, String>> createSimpleLeaveDetailList(List<String> leaveEmpIdList, List<String> leaveDateList, boolean removeNonWorkDayRange,
|
|
|
|
|
Map<String, List<Map<String, Object>>> scheduleInfoMap, Map<String, List<String>> restDayInfo, String leaveMode,
|
|
|
|
|
String startTime, String endTime, String leaveDuration) {
|
|
|
|
|
String startTime, String endTime, String leaveDuration, List<String> countBdlxList) {
|
|
|
|
|
List<Map<String, String>> simpleLeaveDetailList = new ArrayList<>();
|
|
|
|
|
Map<String, String> simpleLeaveDetailItem;
|
|
|
|
|
//实际需要请假的日期集合
|
|
|
|
|
List<String> realLeaveDateList;
|
|
|
|
|
for (String leaveEmpId : leaveEmpIdList) {
|
|
|
|
|
//需要自动移除日期区间内的休息日时,去除请假日期区间中的休息日
|
|
|
|
|
List<Map<String, Object>> scheduleInfoList = new ArrayList<>();
|
|
|
|
|
Map<String, String> dateToBcxxMap = new HashMap<>();
|
|
|
|
|
if (removeNonWorkDayRange || removeNonWorkTimeRange) {
|
|
|
|
|
scheduleInfoList = scheduleInfoMap.get(leaveEmpId);
|
|
|
|
|
dateToBcxxMap = scheduleInfoList.stream().collect(Collectors.toMap(e->Util.null2String(e.get("bcrq")),e->Util.null2String(e.get("bcxx"))));
|
|
|
|
|
}
|
|
|
|
|
List<Map<String, Object>> scheduleInfoList = scheduleInfoMap.get(leaveEmpId);
|
|
|
|
|
Map<String, String> dateToBcxxMap = scheduleInfoList == null ? new HashMap<>()
|
|
|
|
|
: scheduleInfoList.stream().collect(Collectors.toMap(e->Util.null2String(e.get("bcrq")),e->Util.null2String(e.get("bcxx"))));
|
|
|
|
|
|
|
|
|
|
if (removeNonWorkDayRange) {
|
|
|
|
|
//排班结果中休息的日期
|
|
|
|
|
List<String> restDateListFromSchedule = scheduleInfoList.stream()
|
|
|
|
@ -361,17 +376,18 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
//获取班次id
|
|
|
|
|
String bcId = Util.null2String(dateToBcxxMap.get(leaveDate)).split("-")[0];
|
|
|
|
|
//需要自动移除时间区间内的非工作时长,且请假方式为“指定时间区间”时,去除当前明细中开始时间、结束时间之间的非工作时长
|
|
|
|
|
if (removeNonWorkTimeRange && !"".equals(bcId)) {
|
|
|
|
|
if ("".equals(bcId)) {
|
|
|
|
|
//组装初步的请假时长
|
|
|
|
|
simpleLeaveDetailItem.put("qjsc", String.format("%.2f", DateUtil.getBetWeenMinutes(leaveDate + " " + startTime, leaveDate + " " + endTime) / 60.0));
|
|
|
|
|
} else {
|
|
|
|
|
//查询班次明细
|
|
|
|
|
String sql = "select id, bdlx, gsrq, kssj as dtkssj, jssj as dtjssj from uf_jcl_kq_bcxx_dt1 where mainid = " + bcId;
|
|
|
|
|
List<Map<String, Object>> bcDetailData = DbTools.getSqlToList(sql);
|
|
|
|
|
//获取移除后的分钟数
|
|
|
|
|
int scMinutes = Utils.removeRestTime(leaveDate + " " + startTime, leaveDate + " " + endTime, bcDetailData, leaveDate);
|
|
|
|
|
bcDetailData = bcDetailData.stream().filter(e -> countBdlxList.contains(Util.null2String(e.get("bdlx")))).collect(Collectors.toList());
|
|
|
|
|
//获取需要累计的班段时长区间和请假区间存在交集的分钟数
|
|
|
|
|
int scMinutes = Utils.removeTime(leaveDate + " " + startTime, leaveDate + " " + endTime, bcDetailData, leaveDate);
|
|
|
|
|
//组装初步的请假时长
|
|
|
|
|
simpleLeaveDetailItem.put("qjsc", String.format("%.2f", scMinutes / 60.0));
|
|
|
|
|
} else {
|
|
|
|
|
//组装初步的请假时长
|
|
|
|
|
simpleLeaveDetailItem.put("qjsc", String.format("%.2f", DateUtil.getBetWeenMinutes(leaveDate + " " + startTime, leaveDate + " " + endTime) / 60.0));
|
|
|
|
|
}
|
|
|
|
|
simpleLeaveDetailList.add(simpleLeaveDetailItem);
|
|
|
|
|
} else if (leaveMode.equals(AskAndEvctionWayEnum.HOUR.getKey())) {
|
|
|
|
@ -587,15 +603,16 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//勾选的假期类型需要进行额度校验
|
|
|
|
|
boolean checkItemDealSign = true;
|
|
|
|
|
if (!checkItemEditedDetail) {
|
|
|
|
|
dealLeaveDetailWithJqyeInfo(detailData, canUseCheckJqyeInfo, editedUseJqed, leaveDurationMap, ksrq, checkItemId, checkItemName, result);
|
|
|
|
|
checkItemDealSign = dealLeaveDetailWithJqyeInfo(detailData, canUseCheckJqyeInfo, editedUseJqed, leaveDurationMap, ksrq, checkItemId, checkItemName, result);
|
|
|
|
|
}
|
|
|
|
|
if (leaveDurationMap.get("leaveDuration") > 0) {
|
|
|
|
|
String message = empName;
|
|
|
|
|
if (checkItemEditedDetail) {
|
|
|
|
|
//人员id+日期+假期类型三种条件约束唯一性
|
|
|
|
|
message = message + "_" + ksrq + "已存在一笔该请假类型的请假明细!";
|
|
|
|
|
} else if(!checkItemNonCheck && canUseCheckJqyeInfo.size() == 0) {
|
|
|
|
|
} else if(!checkItemDealSign) {
|
|
|
|
|
message = message + "_" + ksrq + "不存在可使用的假期余额,请检查假期余额使用次数和最小使用时长设置!";
|
|
|
|
|
} else {
|
|
|
|
|
//假期余额不足
|
|
|
|
@ -608,7 +625,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
return matchResultSign ? result : new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dealLeaveDetailWithJqyeInfo(Map<String, String> detailData, List<Map<String, Object>> canUseJqyeInfo,
|
|
|
|
|
private boolean dealLeaveDetailWithJqyeInfo(Map<String, String> detailData, List<Map<String, Object>> canUseJqyeInfo,
|
|
|
|
|
Map<String, Double> editedUseJqed, Map<String, Double> leaveDurationMap,
|
|
|
|
|
String ksrq, String itemId, String itemName, List<Map<String, String>> result) {
|
|
|
|
|
double totalLeaveDuration = leaveDurationMap.get("totalLeaveDuration");
|
|
|
|
@ -621,7 +638,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (holidayBalancefilterList.size() == 0) {
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//使用的假期类型的额度单位
|
|
|
|
|
String eddw = Util.null2String(holidayBalancefilterList.get(0).get("eddw"));
|
|
|
|
@ -632,11 +649,11 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
//2-如果编辑记录中不存在,则需要判断是否满足最小使用时长
|
|
|
|
|
if (!minLeaveDurationSign) {
|
|
|
|
|
String minLeaveDuration = Util.null2String(holidayBalance.get("minLeaveDuration"));
|
|
|
|
|
minLeaveDurationSign = "".equals(minLeaveDuration) || totalLeaveDuration > Double.parseDouble(minLeaveDuration) * multipleNum;
|
|
|
|
|
minLeaveDurationSign = "".equals(minLeaveDuration) || totalLeaveDuration >= Double.parseDouble(minLeaveDuration) * multipleNum;
|
|
|
|
|
}
|
|
|
|
|
//不满足最小使用时长,直接执行下一条
|
|
|
|
|
if (!minLeaveDurationSign) {
|
|
|
|
|
continue;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//额定未休时长
|
|
|
|
|
double wxsc = "".equals(Util.null2String(holidayBalance.get("wxsc"))) ? 0 : Double.parseDouble(holidayBalance.get("wxsc").toString());
|
|
|
|
@ -677,6 +694,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
}
|
|
|
|
|
leaveDurationMap.put("totalLeaveDuration", totalLeaveDuration);
|
|
|
|
|
leaveDurationMap.put("leaveDuration", leaveDuration);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|