|
|
|
@ -18,7 +18,6 @@ import com.google.common.collect.Maps;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.time.ZoneOffset;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -136,35 +135,131 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量请假-生成请假信息明细表数据
|
|
|
|
|
* @param params
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> generateLeaveInfoList(Map<String, Object> params) throws ParseException {
|
|
|
|
|
Map<String,Object> resultMap = Maps.newHashMap();
|
|
|
|
|
List<String> errorMessage = new ArrayList<>();
|
|
|
|
|
// 流程表单主表数据
|
|
|
|
|
Map<String,String> mainTableData = (Map<String,String>)params.get("mainTableData");
|
|
|
|
|
// 流程表单明细表1数据
|
|
|
|
|
List<Map<String, String>> detailTableData = (List<Map<String, String>>)params.get("detailTableData");
|
|
|
|
|
//需要校验假期额度的假期类型
|
|
|
|
|
List<String> checkAmountJqIdList = CommonUtil.getJqInfoWithAmount();
|
|
|
|
|
//已编辑内容中的假期额度使用信息
|
|
|
|
|
Map<String, Double> editedUseJqed = new HashMap<>();
|
|
|
|
|
//已编辑内容中的假期类型使用时长_人员信息
|
|
|
|
|
Map<String, Double> editedUseJqlxWithEmp = new HashMap<>();
|
|
|
|
|
//假期余额时长已用完的假期余额id
|
|
|
|
|
List<String> unableUseJqyeIdList = new ArrayList<>();
|
|
|
|
|
//记录已编辑的请假记录,<人员id-请假类型-日期, 请假时长>
|
|
|
|
|
Map<String, String> editedLeaveInfo = new HashMap<>();
|
|
|
|
|
//处理明细表1数据,生成之前编辑内容中已使用的假期额度信息
|
|
|
|
|
public Map<String, Object> generateLeaveInfoList(Map<String, Object> params){
|
|
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
|
|
try {
|
|
|
|
|
List<String> errorMessage = new ArrayList<>();
|
|
|
|
|
// 流程表单主表数据
|
|
|
|
|
Map<String,String> mainTableData = (Map<String,String>)params.get("mainTableData");
|
|
|
|
|
// 流程表单明细表1数据
|
|
|
|
|
List<Map<String, String>> detailTableData = (List<Map<String, String>>)params.get("detailTableData");
|
|
|
|
|
//需要校验假期额度的假期类型
|
|
|
|
|
List<String> checkAmountJqIdList = CommonUtil.getJqInfoWithAmount();
|
|
|
|
|
//开始日期、结束日期、请假方式、开始时间、结束时间、假期类型、请假时长
|
|
|
|
|
String startDate = Util.null2String(mainTableData.get("ksrq"));
|
|
|
|
|
String endDate = Util.null2String(mainTableData.get("jsrq"));
|
|
|
|
|
String startTime = Util.null2String(mainTableData.get("kssj"));
|
|
|
|
|
String endTime = Util.null2String(mainTableData.get("jssj"));
|
|
|
|
|
String leaveMode = Util.null2String(mainTableData.get("cxjqj"));
|
|
|
|
|
String leaveType = Util.null2String(mainTableData.get("jqlx"));
|
|
|
|
|
String leaveDuration = Util.null2String(mainTableData.get("qjsc"));
|
|
|
|
|
//获取请假日期集合
|
|
|
|
|
List<String> leaveDateList = DateUtil.getDatesBetween(startDate, endDate);
|
|
|
|
|
//已编辑内容中的假期额度使用信息
|
|
|
|
|
Map<String, Double> editedUseJqed = new HashMap<>();
|
|
|
|
|
//记录本次触发按钮时,目标日期区间内已编辑内容中的<假期类型_人员,使用时长>信息
|
|
|
|
|
Map<String, Double> editedUseJqlxWithEmp = new HashMap<>();
|
|
|
|
|
//假期余额时长已用完的假期余额id
|
|
|
|
|
List<String> unableUseJqyeIdList = new ArrayList<>();
|
|
|
|
|
//记录已编辑的请假记录,<人员id-请假类型-日期, 请假时长>
|
|
|
|
|
Map<String, String> editedLeaveInfo = new HashMap<>();
|
|
|
|
|
//处理明细表1数据,生成触发接口之前编辑内容中已使用的假期额度信息
|
|
|
|
|
editedLeaveInfo = dealDetailTableData(detailTableData, leaveDateList, editedUseJqlxWithEmp, editedUseJqed, unableUseJqyeIdList, editedLeaveInfo);
|
|
|
|
|
//处理主表数据
|
|
|
|
|
String qjr = Util.null2String(mainTableData.get("qjr"));
|
|
|
|
|
//请假人姓名映射
|
|
|
|
|
Map<String, String> empIdToName = new HashMap<>();
|
|
|
|
|
//请假人员列表
|
|
|
|
|
List<String> leaveEmpIdList = new ArrayList<>();
|
|
|
|
|
if (!"".equals(qjr)) {
|
|
|
|
|
leaveEmpIdList = Arrays.asList(qjr.split(","));
|
|
|
|
|
String sql = "select id, lastname from hrmresource where id in (" + qjr + ")";
|
|
|
|
|
List<Map<String, Object>> data = DbTools.getSqlToList(sql);
|
|
|
|
|
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 from uf_jcl_kq_kqxm where id=?";
|
|
|
|
|
Map<String,Object> holidayItem = DbTools.getSqlToMap(sql,leaveType);
|
|
|
|
|
//判断是否需要自动移除时间区间内的非工作时长、自动移除日期区间内的休息日
|
|
|
|
|
boolean removeNonWorkTimeRange = "1".equals(Util.null2String(holidayItem.get("zdycbcndfgzsd")));
|
|
|
|
|
boolean removeNonWorkDayRange = "1".equals(Util.null2String(holidayItem.get("zdycrqqjndxxb")));
|
|
|
|
|
//判断考勤项目是否需要强制使用“优先使用项目”
|
|
|
|
|
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;
|
|
|
|
|
//遍历人员、日期,生成人员+日期+请假时长的请假信息
|
|
|
|
|
//请假人的请假区间内每一天的日期类型信息
|
|
|
|
|
Map<String, List<String>> restDayInfo = removeNonWorkDayRange ? getRestDayWithEmpId(leaveEmpIdList, leaveType, startDate, endDate) : null;
|
|
|
|
|
//请假人的请假区间内的排班结果
|
|
|
|
|
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>> completeLeaveDetailList = new ArrayList<>();
|
|
|
|
|
//按照人员id分组处理请假明细信息,关联假期余额数据
|
|
|
|
|
Map<String, List<Map<String, String>>> leaveDetailGroupByEmp = simpleLeaveDetailList.stream().collect(Collectors.groupingBy(e -> Util.null2String(e.get("qjr"))));
|
|
|
|
|
|
|
|
|
|
for(Map.Entry<String,List<Map<String,String>>> entry : leaveDetailGroupByEmp.entrySet()) {
|
|
|
|
|
//校验该人员的考勤周期是否正常
|
|
|
|
|
boolean kqCycleAllow = kqCycleCheck(entry.getKey(), entry.getValue(), errorMessage, empIdToName.get(entry.getKey()));
|
|
|
|
|
if (!kqCycleAllow) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//1-收集使用勾选的关联的可使用的余额,才能够生成请假明细,可使用的条件为,a-满足最小使用时长,b-满足使用次数上限,c-存在未休时长
|
|
|
|
|
List<Map<String, Object>> canUseCheckJqyeInfo = collectUsableHolidayBalance(unableUseJqyeIdList, editedUseJqed, leaveType, startDate, entry.getKey());
|
|
|
|
|
List<Map<String,String>> detailListItem;
|
|
|
|
|
//判断考勤项目是否需要强制使用“优先使用项目”
|
|
|
|
|
if (useFirstItemSign) {
|
|
|
|
|
//2-收集优先使用的项目关联的可使用的余额,才能够生成请假明细,可使用的条件为,a-满足最小使用时长,b-满足使用次数上限,c-存在未休时长
|
|
|
|
|
List<Map<String, Object>> canUseFirstJqyeInfo = collectUsableHolidayBalance(unableUseJqyeIdList, editedUseJqed, holidayPriorityItem.get("id").toString(), startDate, entry.getKey());
|
|
|
|
|
detailListItem = matchHolidayBalance(editedLeaveInfo, checkAmountJqIdList, errorMessage, entry.getKey(), empIdToName.get(entry.getKey()), canUseCheckJqyeInfo, canUseFirstJqyeInfo, editedUseJqed, editedUseJqlxWithEmp, entry.getValue(), leaveType, holidayPriorityItem.get("id").toString());
|
|
|
|
|
} else {
|
|
|
|
|
detailListItem = matchHolidayBalance(editedLeaveInfo, checkAmountJqIdList, errorMessage, entry.getKey(), empIdToName.get(entry.getKey()), canUseCheckJqyeInfo, null, editedUseJqed, editedUseJqlxWithEmp, entry.getValue(), leaveType, null);
|
|
|
|
|
}
|
|
|
|
|
if (detailListItem.size() > 0) {
|
|
|
|
|
completeLeaveDetailList.addAll(detailListItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (errorMessage.size() == 0) {
|
|
|
|
|
resultMap.put("status", true);
|
|
|
|
|
resultMap.put("data", completeLeaveDetailList);
|
|
|
|
|
} else {
|
|
|
|
|
resultMap.put("status", false);
|
|
|
|
|
resultMap.put("errorInfo", errorMessage);
|
|
|
|
|
resultMap.put("data", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.info(e.getMessage());
|
|
|
|
|
resultMap.put("status", false);
|
|
|
|
|
resultMap.put("errorInfo", e.getMessage());
|
|
|
|
|
resultMap.put("data", null);
|
|
|
|
|
}
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param detailTableData 明细表1数据
|
|
|
|
|
* @param leaveDateList 请假日期集合
|
|
|
|
|
* @param editedUseJqlxWithEmp 记录本次触发按钮时,目标日期区间内已编辑内容中的<假期类型_人员,使用时长>信息
|
|
|
|
|
* @param editedUseJqed 记录已编辑内容中的假期额度使用信息
|
|
|
|
|
* @param unableUseJqyeIdList 记录假期余额时长已用完的假期余额id
|
|
|
|
|
* @param editedLeaveInfo 记录记录已编辑的请假记录,<人员id-请假类型-日期, 请假时长>
|
|
|
|
|
* @return 处理明细表1数据,生成触发接口之前编辑内容中已使用的假期额度信息
|
|
|
|
|
*/
|
|
|
|
|
private Map<String, String> dealDetailTableData(List<Map<String, String>> detailTableData, List<String> leaveDateList, Map<String, Double> editedUseJqlxWithEmp, Map<String, Double> editedUseJqed, List<String> unableUseJqyeIdList, Map<String, String> editedLeaveInfo) {
|
|
|
|
|
if (detailTableData != null && detailTableData.size() > 0){
|
|
|
|
|
for (Map<String, String> detailItem : detailTableData) {
|
|
|
|
|
double detailSc = "".equals(Util.null2String(detailItem.get("qjsc"))) ? 0 : Double.parseDouble(Util.null2String(detailItem.get("qjsc")));
|
|
|
|
|
String leaveType = Util.null2String(detailItem.get("qjlx"));
|
|
|
|
|
String empId = Util.null2String(detailItem.get("qjr"));
|
|
|
|
|
editedUseJqlxWithEmp.merge(leaveType + "_" + empId, detailSc, Double::sum);
|
|
|
|
|
|
|
|
|
|
if (leaveDateList.contains(Util.null2String(detailItem.get("ksrq")))) {
|
|
|
|
|
double detailSc = "".equals(Util.null2String(detailItem.get("qjsc"))) ? 0 : Double.parseDouble(Util.null2String(detailItem.get("qjsc")));
|
|
|
|
|
String qjlx = Util.null2String(detailItem.get("qjlx"));
|
|
|
|
|
String empId = Util.null2String(detailItem.get("qjr"));
|
|
|
|
|
editedUseJqlxWithEmp.merge(qjlx + "_" + empId, detailSc, Double::sum);
|
|
|
|
|
}
|
|
|
|
|
String jqye = Util.null2String(detailItem.get("jqye"));
|
|
|
|
|
if ("".equals(jqye)) {
|
|
|
|
|
continue;
|
|
|
|
@ -188,55 +283,34 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
double qjsc = Double.parseDouble(jqyeInfo[1]);
|
|
|
|
|
editedUseJqed.merge(jqyeId, qjsc, Double::sum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
editedLeaveInfo = detailTableData.stream()
|
|
|
|
|
.collect(Collectors.toMap(e-> Util.null2String(e.get("qjr")) + "_" + Util.null2String(e.get("qjlx")) + "_" + Util.null2String(e.get("ksrq")),
|
|
|
|
|
e->Util.null2String(e.get("qjsc"))));
|
|
|
|
|
}
|
|
|
|
|
//处理主表数据
|
|
|
|
|
String qjr = Util.null2String(mainTableData.get("qjr"));
|
|
|
|
|
//请假人姓名映射
|
|
|
|
|
Map<String, String> empIdToName = new HashMap<>();
|
|
|
|
|
//请假人员列表
|
|
|
|
|
List<String> leaveEmpIdList = new ArrayList<>();
|
|
|
|
|
if (!"".equals(qjr)) {
|
|
|
|
|
leaveEmpIdList = Arrays.asList(qjr.split(","));
|
|
|
|
|
String sql = "select id, lastname from hrmresource where id in (" + qjr + ")";
|
|
|
|
|
List<Map<String, Object>> data = DbTools.getSqlToList(sql);
|
|
|
|
|
empIdToName = data.stream().collect(Collectors.toMap(e->Util.null2String(e.get("id")),e->Util.null2String(e.get("lastname"))));
|
|
|
|
|
}
|
|
|
|
|
//开始日期、结束日期、请假方式、开始时间、结束时间、假期类型、请假时长
|
|
|
|
|
String startDate = Util.null2String(mainTableData.get("ksrq"));
|
|
|
|
|
String endDate = Util.null2String(mainTableData.get("jsrq"));
|
|
|
|
|
String startTime = Util.null2String(mainTableData.get("kssj"));
|
|
|
|
|
String endTime = Util.null2String(mainTableData.get("jssj"));
|
|
|
|
|
String leaveMode = Util.null2String(mainTableData.get("cxjqj"));
|
|
|
|
|
String leaveType = Util.null2String(mainTableData.get("jqlx"));
|
|
|
|
|
String leaveDuration = Util.null2String(mainTableData.get("qjsc"));
|
|
|
|
|
//获取填写的请假类型关联的考勤项目
|
|
|
|
|
String sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb,zdycbcndfgzsd,zdycrqqjndxxb from uf_jcl_kq_kqxm where id=?";
|
|
|
|
|
Map<String,Object> holidayItem = DbTools.getSqlToMap(sql,leaveType);
|
|
|
|
|
//判断是否需要自动移除时间区间内的非工作时长、自动移除日期区间内的休息日
|
|
|
|
|
boolean removeNonWorkTimeRange = "1".equals(Util.null2String(holidayItem.get("zdycbcndfgzsd")));
|
|
|
|
|
boolean removeNonWorkDayRange = "1".equals(Util.null2String(holidayItem.get("zdycrqqjndxxb")));
|
|
|
|
|
//判断考勤项目是否需要强制使用“优先使用项目”
|
|
|
|
|
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;
|
|
|
|
|
//遍历人员、日期,生成人员+日期+请假时长的请假信息
|
|
|
|
|
//获取请假日期集合
|
|
|
|
|
List<String> leaveDateList = DateUtil.getDatesBetween(startDate, endDate);
|
|
|
|
|
//请假人的请假区间内每一天的日期类型信息
|
|
|
|
|
Map<String, List<String>> restDayInfo = removeNonWorkDayRange ? getRestDayWithEmpId(leaveEmpIdList, leaveType, startDate, endDate) : null;
|
|
|
|
|
//请假人的请假区间内的排班结果
|
|
|
|
|
Map<String, List<Map<String, Object>>> scheduleInfoMap = (removeNonWorkDayRange || removeNonWorkTimeRange) ? getScheduleInfoWithEmpId(leaveEmpIdList, startDate, endDate) : null;
|
|
|
|
|
//实际需要请假的日期集合
|
|
|
|
|
List<String> realLeaveDateList;
|
|
|
|
|
//收集未关联假期余额的请假明细数据
|
|
|
|
|
return editedLeaveInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param leaveEmpIdList 请假人员id集合
|
|
|
|
|
* @param leaveDateList 请假日期集合
|
|
|
|
|
* @param removeNonWorkDayRange 是否移除非工作日时长
|
|
|
|
|
* @param removeNonWorkTimeRange 是否移除非工作时间时长
|
|
|
|
|
* @param scheduleInfoMap 排班信息
|
|
|
|
|
* @param restDayInfo 休息日信息
|
|
|
|
|
* @param leaveMode 请假方式
|
|
|
|
|
* @param startTime 开始时间
|
|
|
|
|
* @param endTime 结束时间
|
|
|
|
|
* @param leaveDuration 请假时长
|
|
|
|
|
* @return 组装初步的请假明细
|
|
|
|
|
*/
|
|
|
|
|
private List<Map<String, String>> createSimpleLeaveDetailList(List<String> leaveEmpIdList, List<String> leaveDateList, boolean removeNonWorkDayRange, boolean removeNonWorkTimeRange,
|
|
|
|
|
Map<String, List<Map<String, Object>>> scheduleInfoMap, Map<String, List<String>> restDayInfo, String leaveMode,
|
|
|
|
|
String startTime, String endTime, String leaveDuration) {
|
|
|
|
|
List<Map<String, String>> simpleLeaveDetailList = new ArrayList<>();
|
|
|
|
|
//收集已关联假期余额的请假明细数据
|
|
|
|
|
List<Map<String, String>> completeLeaveDetailList = new ArrayList<>();
|
|
|
|
|
Map<String, String> simpleLeaveDetailItem;
|
|
|
|
|
//实际需要请假的日期集合
|
|
|
|
|
List<String> realLeaveDateList;
|
|
|
|
|
for (String leaveEmpId : leaveEmpIdList) {
|
|
|
|
|
//需要自动移除日期区间内的休息日时,去除请假日期区间中的休息日
|
|
|
|
|
List<Map<String, Object>> scheduleInfoList = new ArrayList<>();
|
|
|
|
@ -251,7 +325,6 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
.filter(f -> Util.null2String(f.get("sfxx")).equals(CheckBoxEnum.CHECKED.getKey()))
|
|
|
|
|
.map(e -> Util.null2String(e.get("bcrq")))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<String> allDateListFromSchedule = scheduleInfoList.stream().map(e -> Util.null2String(e.get("bcrq"))).collect(Collectors.toList());
|
|
|
|
|
//排班结果中未出现的日期
|
|
|
|
|
List<String> nonSetDateListFromSchedule = leaveDateList.stream().filter(f -> !allDateListFromSchedule.contains(f)).collect(Collectors.toList());
|
|
|
|
@ -279,7 +352,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
//需要自动移除时间区间内的非工作时长,且请假方式为“指定时间区间”时,去除当前明细中开始时间、结束时间之间的非工作时长
|
|
|
|
|
if (removeNonWorkTimeRange && !"".equals(bcId)) {
|
|
|
|
|
//查询班次明细
|
|
|
|
|
sql = "select id, bdlx, gsrq, kssj as dtkssj, jssj as dtjssj from uf_jcl_kq_bcxx_dt1 where mainid = " + bcId;
|
|
|
|
|
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);
|
|
|
|
@ -317,48 +390,19 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//按照人员id分组处理请假明细信息,关联假期余额数据
|
|
|
|
|
Map<String, List<Map<String, String>>> leaveDetailGroupByEmp = simpleLeaveDetailList.stream().collect(Collectors.groupingBy(e -> Util.null2String(e.get("qjr"))));
|
|
|
|
|
|
|
|
|
|
for(Map.Entry<String,List<Map<String,String>>> entry : leaveDetailGroupByEmp.entrySet()) {
|
|
|
|
|
//校验该人员的考勤周期是否正常
|
|
|
|
|
boolean kqCycleAllow = kqCycleCheck(entry.getKey(), entry.getValue(), errorMessage, empIdToName.get(entry.getKey()));
|
|
|
|
|
if (!kqCycleAllow) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//1-收集使用勾选的关联的可使用的余额,才能够生成请假明细,可使用的条件为,a-满足最小使用时长,b-满足使用次数上限,c-存在未休时长
|
|
|
|
|
List<Map<String, Object>> canUseCheckJqyeInfo = collectUsableHolidayBalance(unableUseJqyeIdList, editedUseJqed, leaveType, startDate, entry.getKey());
|
|
|
|
|
List<Map<String,String>> detailListItem = new ArrayList<>();
|
|
|
|
|
//判断考勤项目是否需要强制使用“优先使用项目”
|
|
|
|
|
if (useFirstItemSign) {
|
|
|
|
|
//2-收集优先使用的项目关联的可使用的余额,才能够生成请假明细,可使用的条件为,a-满足最小使用时长,b-满足使用次数上限,c-存在未休时长
|
|
|
|
|
List<Map<String, Object>> canUseFirstJqyeInfo = collectUsableHolidayBalance(unableUseJqyeIdList, editedUseJqed, holidayPriorityItem.get("id").toString(), startDate, entry.getKey());
|
|
|
|
|
detailListItem = matchHolidayBalance(editedLeaveInfo, checkAmountJqIdList, errorMessage, entry.getKey(), empIdToName.get(entry.getKey()), canUseCheckJqyeInfo, canUseFirstJqyeInfo, editedUseJqed, editedUseJqlxWithEmp, entry.getValue(), leaveType, holidayPriorityItem.get("id").toString());
|
|
|
|
|
} else {
|
|
|
|
|
detailListItem = matchHolidayBalance(editedLeaveInfo, checkAmountJqIdList, errorMessage, entry.getKey(), empIdToName.get(entry.getKey()), canUseCheckJqyeInfo, null, editedUseJqed, editedUseJqlxWithEmp, entry.getValue(), leaveType, null);
|
|
|
|
|
}
|
|
|
|
|
if (detailListItem.size() > 0) {
|
|
|
|
|
completeLeaveDetailList.addAll(detailListItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (errorMessage.size() == 0) {
|
|
|
|
|
resultMap.put("status", true);
|
|
|
|
|
resultMap.put("data", completeLeaveDetailList);
|
|
|
|
|
} else {
|
|
|
|
|
resultMap.put("status", false);
|
|
|
|
|
resultMap.put("errorInfo", errorMessage);
|
|
|
|
|
resultMap.put("data", null);
|
|
|
|
|
}
|
|
|
|
|
return resultMap;
|
|
|
|
|
return simpleLeaveDetailList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param qjry 请假人员id
|
|
|
|
|
* @param detailTableData 请假明细
|
|
|
|
|
* @param errorMessage 错误信息
|
|
|
|
|
* @param empName 请假人姓名
|
|
|
|
|
* @return 校验该人员的考勤周期是否正常
|
|
|
|
|
*/
|
|
|
|
|
private boolean kqCycleCheck(String qjry, List<Map<String, String>> detailTableData, List<String> errorMessage, String empName) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 补打卡日期是否关账
|
|
|
|
|
*/
|
|
|
|
|
Map<String, Object> params = Maps.newHashMap();
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("userId",qjry);
|
|
|
|
|
params.put("submitDate",DateUtil.getCurrentDate());
|
|
|
|
|
params.put("submitStr","ksrq");
|
|
|
|
@ -370,7 +414,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
Map<String,Object> dataMap = makeUpClockInService.getKqCycleTimeIntervalCmd(params);
|
|
|
|
|
List<Map<String,Object>> closeList = (List<Map<String,Object>>)dataMap.get("closeList");
|
|
|
|
|
List<String> nocycleList = (List<String>)dataMap.get("nocycleList");
|
|
|
|
|
List<Map<String,Object>> dateList = (List<Map<String,Object>>)dataMap.get("dataList");
|
|
|
|
|
// List<Map<String,Object>> dateList = (List<Map<String,Object>>)dataMap.get("dataList");
|
|
|
|
|
|
|
|
|
|
boolean status = (boolean)dataMap.get("status");
|
|
|
|
|
if (!status){
|
|
|
|
@ -392,6 +436,21 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param editedLeaveInfo 触发接口前已编辑的请假明细信息
|
|
|
|
|
* @param checkAmountJqIdList 需要校验假期额度的假期类型id集合
|
|
|
|
|
* @param errorMessage 错误信息记录集合
|
|
|
|
|
* @param empId 请假人员id
|
|
|
|
|
* @param empName 请假人员姓名
|
|
|
|
|
* @param canUseCheckJqyeInfo 勾选的假期类型可使用的假期余额信息
|
|
|
|
|
* @param canUseFirstJqyeInfo 优先使用的假期类型可使用的假期余额信息
|
|
|
|
|
* @param editedUseJqed 触发接口前已编辑的假期额度使用信息
|
|
|
|
|
* @param editedUseJqlxWithEmp 触发接口前已编辑的假期类型id_人员id条件下已使用的时长
|
|
|
|
|
* @param leaveDetailList 请假明细集合
|
|
|
|
|
* @param checkItemId 勾选的假期类型id
|
|
|
|
|
* @param firstItemId 优先使用的假期类型id
|
|
|
|
|
* @return 给请假明细中请假时长分配应扣的假期余额id及时长
|
|
|
|
|
*/
|
|
|
|
|
private List<Map<String, String>> matchHolidayBalance(Map<String, String> editedLeaveInfo, List<String> checkAmountJqIdList, List<String> errorMessage, String empId, String empName,
|
|
|
|
|
List<Map<String, Object>> canUseCheckJqyeInfo, List<Map<String, Object>> canUseFirstJqyeInfo, Map<String, Double> editedUseJqed,
|
|
|
|
|
Map<String, Double> editedUseJqlxWithEmp,List<Map<String, String>> leaveDetailList, String checkItemId, String firstItemId) {
|
|
|
|
@ -404,7 +463,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
String qtj = Util.null2String(detailData.get("qtj"));
|
|
|
|
|
String btj = Util.null2String(detailData.get("btj"));
|
|
|
|
|
//请假时间
|
|
|
|
|
double leaveDuration = 0;
|
|
|
|
|
double leaveDuration;
|
|
|
|
|
if (qtj.equals(CheckBoxEnum.CHECKED.getKey())) {
|
|
|
|
|
//全天默认8小时
|
|
|
|
|
leaveDuration = 8;
|
|
|
|
@ -439,7 +498,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
String qtj = Util.null2String(detailData.get("qtj"));
|
|
|
|
|
String btj = Util.null2String(detailData.get("btj"));
|
|
|
|
|
//请假时间
|
|
|
|
|
double leaveDuration = 0;
|
|
|
|
|
double leaveDuration;
|
|
|
|
|
if (qtj.equals(CheckBoxEnum.CHECKED.getKey())) {
|
|
|
|
|
//全天默认8小时
|
|
|
|
|
leaveDuration = 8;
|
|
|
|
@ -456,12 +515,11 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
//勾选的请假项目是否已被编辑
|
|
|
|
|
double checkItemEditedDetailSc = editedLeaveInfo.get(empId + "_" + checkItemId + "_" + ksrq) == null ? 0 : Double.parseDouble(editedLeaveInfo.get(empId + "_" + checkItemId + "_" + ksrq));
|
|
|
|
|
boolean checkItemEditedDetail = editedLeaveInfo.get(empId + "_" + checkItemId + "_" + ksrq) != null || (firstItemEditedDetail && firstItemEditedDetailSc - leaveDuration >= 0);
|
|
|
|
|
if (checkItemEditedDetail) {
|
|
|
|
|
leaveDuration = Utils.subtract(leaveDuration, firstItemEditedDetailSc);
|
|
|
|
|
leaveDuration = Utils.subtract(leaveDuration, checkItemEditedDetailSc);
|
|
|
|
|
if (leaveDuration <= 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leaveDuration = Utils.subtract(leaveDuration, firstItemEditedDetailSc);
|
|
|
|
|
leaveDuration = Utils.subtract(leaveDuration, checkItemEditedDetailSc);
|
|
|
|
|
if (leaveDuration <= 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//存在优先使用假期类型时,且该假期类型不需要进行额度校验
|
|
|
|
|
if (firstItemNonCheck && !firstItemEditedDetail) {
|
|
|
|
@ -507,6 +565,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
if (checkItemNonCheck && !checkItemEditedDetail) {
|
|
|
|
|
detailData.put("qjlx", checkItemId);
|
|
|
|
|
detailData.put("qjsc", String.valueOf(leaveDurationMap.get("leaveDuration")));
|
|
|
|
|
leaveDurationMap.put("totalLeaveDuration", Utils.subtract(leaveDurationMap.get("totalLeaveDuration"), leaveDurationMap.get("leaveDuration")));
|
|
|
|
|
result.add(detailData);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -515,11 +574,16 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
dealLeaveDetailWithJqyeInfo(detailData, canUseCheckJqyeInfo, editedUseJqed, leaveDurationMap, ksrq, checkItemId, result);
|
|
|
|
|
}
|
|
|
|
|
if (leaveDurationMap.get("leaveDuration") > 0) {
|
|
|
|
|
//假期余额不足
|
|
|
|
|
String message = empName + "假期余额不足!";
|
|
|
|
|
String message = empName;
|
|
|
|
|
if (checkItemEditedDetail) {
|
|
|
|
|
//人员id+日期+假期类型三种条件约束唯一性
|
|
|
|
|
message = message + "_" + ksrq + "在明细表1中已存在一笔该请假类型的请假明细!";
|
|
|
|
|
} else {
|
|
|
|
|
//假期余额不足
|
|
|
|
|
message = message + "_" + ksrq + "假期余额不足!";
|
|
|
|
|
}
|
|
|
|
|
errorMessage.add(message);
|
|
|
|
|
matchResultSign = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return matchResultSign ? result : new ArrayList<>();
|
|
|
|
@ -531,7 +595,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
double totalLeaveDuration = leaveDurationMap.get("totalLeaveDuration");
|
|
|
|
|
double leaveDuration = leaveDurationMap.get("leaveDuration");
|
|
|
|
|
//假期类型相关的假期余额记录
|
|
|
|
|
List<Map<String, Object>> holidayBalancefilterList = Lists.newArrayList();
|
|
|
|
|
List<Map<String, Object>> holidayBalancefilterList = new ArrayList<>();
|
|
|
|
|
for (Map<String, Object> map : canUseJqyeInfo){
|
|
|
|
|
if (DateUtil.getTime(map.get("yqsxrq").toString()).compareTo(DateUtil.getTime(ksrq)) >= 0){
|
|
|
|
|
holidayBalancefilterList.add(map);
|
|
|
|
@ -553,7 +617,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//额定未休时长
|
|
|
|
|
double wxsc = Util.null2String(holidayBalance.get("wxsc")).equals("") ? 0 : Double.valueOf(holidayBalance.get("wxsc").toString());
|
|
|
|
|
double wxsc = "".equals(Util.null2String(holidayBalance.get("wxsc"))) ? 0 : Double.parseDouble(holidayBalance.get("wxsc").toString());
|
|
|
|
|
wxsc = multipleNum * wxsc;
|
|
|
|
|
if (leaveDuration > 0 && wxsc > 0) {
|
|
|
|
|
detailData.put("qjlx", itemId);
|
|
|
|
@ -598,9 +662,8 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
* @param unableUseJqyeIdList 不可使用的假期余额id集合
|
|
|
|
|
* @param editedUseJqed 已编辑过的假期余额id和具体使用的时长映射
|
|
|
|
|
* @param itemId 假期类型对应的考勤项目id
|
|
|
|
|
* @param startDate
|
|
|
|
|
* @param leaveEmpId
|
|
|
|
|
* @return
|
|
|
|
|
* @param startDate 开始日期
|
|
|
|
|
* @param leaveEmpId 请假人id
|
|
|
|
|
*/
|
|
|
|
|
private List<Map<String, Object>> collectUsableHolidayBalance(List<String> unableUseJqyeIdList, Map<String, Double> editedUseJqed, String itemId, String startDate, String leaveEmpId) {
|
|
|
|
|
String sql = "select id,jqid,sxrq,ktsc,yxsc,wxsc,yqsxrq,ztsc from uf_jcl_kq_jqye where ygid=? and jqid=? and sxrq<=? and yqsxrq>=? order by sxrq";
|
|
|
|
@ -628,7 +691,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
List<Map<String, Object>> leaveList = DbTools.getSqlToList(sql);
|
|
|
|
|
Map<String, Integer> jqyeUseNumInfo = new HashMap<>();
|
|
|
|
|
List<String> leaveUseList = new ArrayList<>();
|
|
|
|
|
Integer useNum = 0;
|
|
|
|
|
Integer useNum;
|
|
|
|
|
for (Map<String, Object> leaveItem : leaveList) {
|
|
|
|
|
String jqyeId = Util.null2String(leaveItem.get("jqye"));
|
|
|
|
|
if (!"".equals(jqyeId)) {
|
|
|
|
@ -671,10 +734,9 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 请假人的请假区间内的排班结果
|
|
|
|
|
* @param leaveEmpIdList
|
|
|
|
|
* @param startDate
|
|
|
|
|
* @param endDate
|
|
|
|
|
* @return
|
|
|
|
|
* @param leaveEmpIdList 请假人id集合
|
|
|
|
|
* @param startDate 开始日期
|
|
|
|
|
* @param endDate 结束日期
|
|
|
|
|
*/
|
|
|
|
|
private Map<String, List<Map<String, Object>>> getScheduleInfoWithEmpId(List<String> leaveEmpIdList, String startDate, String endDate) {
|
|
|
|
|
Map<String, List<Map<String, Object>>> scheduleInfo = new HashMap<>();
|
|
|
|
@ -696,11 +758,10 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 请假人的请假区间内属于休息日的日期集合
|
|
|
|
|
* @param leaveEmpIdList
|
|
|
|
|
* @param leaveType
|
|
|
|
|
* @param startDate
|
|
|
|
|
* @param endDate
|
|
|
|
|
* @return
|
|
|
|
|
* @param leaveEmpIdList 请假人id集合
|
|
|
|
|
* @param leaveType 假期类型id,即考勤项目id
|
|
|
|
|
* @param startDate 开始日期
|
|
|
|
|
* @param endDate 结束日期
|
|
|
|
|
*/
|
|
|
|
|
private Map<String, List<String>> getRestDayWithEmpId(List<String> leaveEmpIdList, String leaveType, String startDate, String endDate) {
|
|
|
|
|
Map<String, List<String>> restDayInfoWithEmpId = new HashMap<>();
|
|
|
|
@ -714,8 +775,8 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
|
|
|
|
|
dateTypeList.add(DateTypeEnum.HOLIDAY.getKey());
|
|
|
|
|
dateTypeList.add(DateTypeEnum.PUBLIC_RESTDAY.getKey());
|
|
|
|
|
dateTypeList.add(DateTypeEnum.EXCHANGE_LEAVEDAY.getKey());
|
|
|
|
|
Map<String, Object> restDayInfo = new HashMap<>();
|
|
|
|
|
List<Map<String,Object>> dataList = new ArrayList<>();
|
|
|
|
|
Map<String, Object> restDayInfo;
|
|
|
|
|
List<Map<String,Object>> dataList;
|
|
|
|
|
List<String> restDateList = new ArrayList<>();
|
|
|
|
|
for (String empId : leaveEmpIdList) {
|
|
|
|
|
restDayParam.put("userId", empId);
|
|
|
|
|