From d325c96872594bfd7ab28e3970ff98e58157e9f5 Mon Sep 17 00:00:00 2001 From: sy Date: Thu, 18 Apr 2024 10:27:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=EF=BC=8C=E5=87=BA=E5=8B=A4?= =?UTF-8?q?=E6=B4=A5=E8=B4=B4=E6=95=B0=E6=8D=AE=E7=94=9F=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AllowanceServiceImpl.java | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/src/com/engine/attendance/workflow/service/impl/AllowanceServiceImpl.java b/src/com/engine/attendance/workflow/service/impl/AllowanceServiceImpl.java index 2aa0da1..f77cbd4 100644 --- a/src/com/engine/attendance/workflow/service/impl/AllowanceServiceImpl.java +++ b/src/com/engine/attendance/workflow/service/impl/AllowanceServiceImpl.java @@ -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 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> allowanceIdWithKqxmInfo = new HashMap<>(); Map> 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> bcData = DbTools.getSqlToList(bcSql); for (Map 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> 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 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 map : allowanceInfoList) { List 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 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 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 cqMap, Map 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> collectJcInfoByCq(Map cqMap) {