考勤,出勤津贴数据生成功能优化

zm_dev
sy 1 year ago
parent 46a4de5964
commit d325c96872

@ -4,6 +4,7 @@ import com.engine.attendance.enums.AccountingUnitEnum;
import com.engine.attendance.enums.AttendanceItemTypeEnum;
import com.engine.attendance.workflow.service.AllowanceService;
import com.engine.common.util.CommonUtil;
import com.engine.common.util.DateUtil;
import com.engine.common.util.DbTools;
import com.engine.common.util.Utils;
import com.engine.core.impl.Service;
@ -14,6 +15,7 @@ import weaver.general.Util;
import java.time.Duration;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: sy
@ -67,13 +69,18 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
targetAllowanceIdList.addAll(allowanceIdList);
//构建映射
empIdList.forEach(f -> {
List<String> valueIdList = new ArrayList<>();
if (empIdWithAllowanceInfo.get(f) == null) {
empIdWithAllowanceInfo.put(f, allowanceIdList);
if (tyAllowanceIds.size() > 0) {
empIdWithAllowanceInfo.get(f).addAll(tyAllowanceIds);
valueIdList.addAll(allowanceIdList);
valueIdList.addAll(tyAllowanceIds);
empIdWithAllowanceInfo.put(f, valueIdList);
}
} else {
empIdWithAllowanceInfo.get(f).addAll(allowanceIdList);
valueIdList = empIdWithAllowanceInfo.get(f);
valueIdList.addAll(allowanceIdList);
empIdWithAllowanceInfo.put(f, valueIdList);
}
});
}
@ -82,6 +89,9 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
Map<String, Map<String, Object>> allowanceIdWithKqxmInfo = new HashMap<>();
Map<String, List<String>> bcWithAllowanceInfo = new HashMap<>();
if (targetAllowanceIdList.size() > 0) {
//去重
targetAllowanceIdList = targetAllowanceIdList.stream().distinct().collect(Collectors.toList());
//构建映射
String bcSql = "select * from uf_jcl_kq_kqxm where id in ("+String.join(",",targetAllowanceIdList) + ") and sydbc is not null ";
List<Map<String, Object>> bcData = DbTools.getSqlToList(bcSql);
for (Map<String, Object> map : bcData) {
@ -96,7 +106,9 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
values.add(allowanceId);
bcWithAllowanceInfo.put(f, values);
} else {
bcWithAllowanceInfo.get(f).add(allowanceId);
values = bcWithAllowanceInfo.get(f);
values.add(allowanceId);
bcWithAllowanceInfo.put(f, values);
}
});
}
@ -111,6 +123,9 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
String endDate = Util.null2String(params.get("endDate"));
List<Map<String, Object>> cqData = new ArrayList<>();
if (targetEmpIdList.size() > 0 && targetBcIdList.size() > 0) {
//去重
targetBcIdList = targetBcIdList.stream().distinct().collect(Collectors.toList());
//查询
String cqSql = "select * from uf_jcl_kq_cqjg where ygid in ("+String.join(",",targetEmpIdList) + ") and rq >= '" + startDate +"'" + " and rq <= '" + endDate +"'"
+ " and bc in ("+String.join(",",targetBcIdList) + ")";
cqData = DbTools.getSqlToList(cqSql);
@ -130,9 +145,18 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
bs.writeLog("delSign : " + delSign + ", delSql : " + delSql);
//插入津贴数据
List<List> dataList = new ArrayList<>();
String insertSql = " insert into uf_jcl_kq_cqjt(szjg,yg,rq,bc,jtlx,sc) values(?,?,?,?,?,?)";
String insertSql = " insert into uf_jcl_kq_cqjt(formmodeid,modeuuid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
"szjg,yg,rq,bc,jtlx,sc) values(?,?,?,?,?,?,?,?,?,?,?,?)";
String formmodeId = formmodeIdMap.get("uf_jcl_kq_cqjt");
for (Map<String, String> map : allowanceInfoList) {
List<String> list = new ArrayList<>();
list.add(formmodeId);
list.add(UUID.randomUUID().toString());
list.add("1");
list.add("0");
list.add(DateUtil.getCurrentTime().split(" ")[0]);
list.add(DateUtil.getCurrentTime().split(" ")[1]);
list.add(map.get("szjg"));
list.add(map.get("yg"));
list.add(map.get("rq"));
@ -180,7 +204,14 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
//判断该人员是否有相关的津贴
List<String> allowanceIdsByEmp = empIdWithAllowanceInfo.get(empId);
//处理该人员在该班次可生效的津贴
if(allowanceIdsByBc != null && allowanceIdsByEmp != null && allowanceIdsByBc.retainAll(allowanceIdsByEmp)) {
if(allowanceIdsByBc != null && allowanceIdsByEmp != null) {
//取交集
allowanceIdsByBc = allowanceIdsByBc.stream()
.filter(allowanceIdsByEmp::contains)
.collect(Collectors.toList());
if (allowanceIdsByBc.size() == 0) {
continue;
}
//收集下出勤结果中项目1-8存在的项目id
List<String> kqxmIdsWithCq = collectKqxmIdsByCq(map);
bs.writeLog("kqxmIdsWithCq : " + kqxmIdsWithCq);
@ -226,7 +257,11 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
+ ",startMinutes : " + startMinutes,"maxMinutes : " + maxMinutes + ",oneTimeAddMinutes : " + oneTimeAddMinutes);
//逐一判断是否满足津贴时长计入规则
//1-此为考勤项目的多选如果员工当天出勤中的项目1~项目8存在不核算此津贴的项目则员工不能获得此津贴
if (kqxmIdsWithCq.size() > 0 && banKqxmList.size() > 0 && banKqxmList.retainAll(kqxmIdsWithCq)) {
//取交集
banKqxmList = banKqxmList.stream()
.filter(kqxmIdsWithCq::contains)
.collect(Collectors.toList());
if (banKqxmList.size() > 0) {
continue;
}
//2-如果勾选“检查特定时间点是否在岗”,则需要判断员工当天“须要在岗的时间点”所设置的时间员工是否在岗
@ -432,7 +467,7 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
}
private Integer collectOvertimeMinutes(Map<String, Object> cqMap, Map<String, String> jbKqxmUnitInfo) {
Integer minutes = 0;
double minutes = 0;
String xm = "";
String sc = "";
String unit = "";
@ -446,10 +481,10 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
sc = Util.null2String(cqMap.get("sc" + i));
unit = Util.null2String(jbKqxmUnitInfo.get(xm));
if (!xm.equals("") && !sc.equals("") && !unit.equals("")) {
minutes = minutes + Integer.parseInt(sc) * unitToMinutes.get(unit);
minutes = minutes + Double.parseDouble(sc) * unitToMinutes.get(unit);
}
}
return minutes;
return (int) Math.round(minutes);
}
private List<Map<String, String>> collectJcInfoByCq(Map<String, Object> cqMap) {

Loading…
Cancel
Save