zm_dev
liuliang 1 year ago
parent b56b72e12b
commit 00747aed0c

@ -754,3 +754,11 @@
>> targetcom.engine.workflowDesign.cmd.DoSaveLayout
>> proxy->com.engine.plugin.odoc.command.rightMenuSetting.OdocDoSaveLayoutCmd
2023-11-17 13:45:18,436 [main] [com.engine.core.cfg.DynamicProxyConfiguration] [INFO] - The business class dynamic proxy is loaded.
2023-11-19 23:26:59,000 [Timer-0] [A2] [INFO] - rootPath == null
2023-11-19 23:26:59,003 [Timer-0] [A2] [INFO] - filePath == nullWEB-INF\prop\isSyncLog4j.properties
2023-11-20 12:06:52,129 [Timer-0] [A2] [INFO] - rootPath == null
2023-11-20 12:06:52,132 [Timer-0] [A2] [INFO] - filePath == nullWEB-INF\prop\isSyncLog4j.properties
2023-11-20 14:02:52,158 [Timer-0] [A2] [INFO] - rootPath == null
2023-11-20 14:02:52,160 [Timer-0] [A2] [INFO] - filePath == nullWEB-INF\prop\isSyncLog4j.properties
2023-11-20 14:35:59,979 [Timer-0] [A2] [INFO] - rootPath == null
2023-11-20 14:35:59,982 [Timer-0] [A2] [INFO] - filePath == nullWEB-INF\prop\isSyncLog4j.properties

@ -0,0 +1,281 @@
package com.engine.attendance.attendanceanalysis.cmd;
import com.engine.attendance.enums.AccountingUnitEnum;
import com.engine.attendance.enums.CheckBoxEnum;
import com.engine.attendance.enums.ClassSegmentTypeEnum;
import com.engine.attendance.enums.ClockPointEnum;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.common.util.DateUtil;
import com.engine.common.util.Utils;
import com.engine.core.interceptor.CommandContext;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import weaver.general.Util;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*
*/
@Slf4j
public class GetClockInPointCmd extends AbstractCommonCommand<Map<String,Object>> {
public GetClockInPointCmd(Map<String,Object> params){
this.params=params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = Maps.newHashMap();
String analysisDate = Util.null2String(params.get("analysisDate"));
List<Map<String, Object>> needClockInSchedule = (List<Map<String, Object>>)params.get("needClockInSchedule");
List<Map<String, Object>> clockInTimeList = (List<Map<String, Object>>)params.get("clockInTimeList");
List<Map<String, Map<String,Object>>> clcokInTimeData = getClockInPoint(analysisDate,needClockInSchedule,clockInTimeList);
resultMap.put("clcokInTimeData",clcokInTimeData);
return resultMap;
}
/**
*
* @param analysisDate
* @param needClockInSchedule
* @param clockInTimeList
* @return
*/
public static List<Map<String, Map<String,Object>>> getClockInPoint(String analysisDate, List<Map<String, Object>> needClockInSchedule, List<Map<String, Object>> clockInTimeList){
List<Map<String,Map<String,Object>>> clcokInTimeData = Lists.newArrayList();
for (Map<String, Object> needClockIn :needClockInSchedule){
if (CheckBoxEnum.CHECKED.getKey().equals(needClockIn.get("ksdk"))){
String dtkssj = analysisDate+" "+needClockIn.get("dtkssj");
String dtjssj = analysisDate+" "+needClockIn.get("dtjssj");
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0){
dtjssj = DateUtil.AfterDay(analysisDate,1) +" "+needClockIn.get("dtjssj");
}
int tqdkfzs = Integer.valueOf(Util.null2String(needClockIn.get("tqdkfzs")));
Map<String,Map<String,Object>> ksdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(dtkssj,clockInTimeList);
String timeType = ClockPointEnum.EMPTY.getKey();
Map<String,Map<String,Object>> clcokInTimeMap = Maps.newHashMap();
if (ksdkNearestClcokInTime.get(ClockPointEnum.EQUAL.getKey()) != null){
timeType=ClockPointEnum.EQUAL.getKey();
}
if (ClockPointEnum.EMPTY.getKey().equals(timeType) && ksdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()) != null){
String clockInTime = ksdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signdate") +" "+ksdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(DateUtil.beforeMinutes(dtkssj,tqdkfzs))) >=0){
//打卡时间大于等于最早打卡时间
timeType=ClockPointEnum.BEFORE.getKey();
}
}
if (ClockPointEnum.EMPTY.getKey().equals(timeType) && ksdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()) != null){
String clockInTime = ksdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signdate") +" "+ksdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(dtjssj)) < 0){
//打卡时间小于结束时间
timeType=ClockPointEnum.AFTER.getKey();
}
}
clcokInTimeMap.put(dtkssj+"|"+ClockPointEnum.START.getKey()+"|"+timeType,ksdkNearestClcokInTime.get(timeType));
clcokInTimeData.add(clcokInTimeMap);
}
if (CheckBoxEnum.CHECKED.getKey().equals(needClockIn.get("jsdk"))){
String dtkssj = analysisDate+" "+needClockIn.get("dtkssj");
String dtjssj = analysisDate+" "+needClockIn.get("dtjssj");
int thdkfzs = Integer.valueOf(Util.null2String(needClockIn.get("thdkfzs")));
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0){
dtjssj = DateUtil.AfterDay(analysisDate,1) +" "+needClockIn.get("dtjssj");
}
Map<String,Map<String,Object>> jsdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(dtjssj,clockInTimeList);
String timeType = ClockPointEnum.EMPTY.getKey();
Map<String,Map<String,Object>> clcokInTimeMap = Maps.newHashMap();
if (jsdkNearestClcokInTime.get(ClockPointEnum.EQUAL.getKey()) != null){
timeType=ClockPointEnum.EQUAL.getKey();
}
if (ClockPointEnum.EMPTY.getKey().equals(timeType) && jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()) != null){
String clockInTime = jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signdate") +" "+jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(DateUtil.AfterMinutes(dtjssj,thdkfzs))) <=0){
timeType=ClockPointEnum.AFTER.getKey();
}
}
if (ClockPointEnum.EMPTY.getKey().equals(timeType) && jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()) != null){
String clockInTime = jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signdate") +" "+jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(dtkssj)) >0){
timeType=ClockPointEnum.BEFORE.getKey();
}
}
clcokInTimeMap.put(dtjssj+"|"+ClockPointEnum.END.getKey()+"|"+timeType,jsdkNearestClcokInTime.get(timeType));
clcokInTimeData.add(clcokInTimeMap);
}
}
//当弹性上下班时
if (needClockInSchedule.size() > 0){
//是否弹性
String sfdx = Util.null2String(needClockInSchedule.get(0).get("sfdx"));
//最大弹性分钟
int zddxfz = Integer.valueOf(Util.null2String(needClockInSchedule.get(0).get("zddxfz")));
//弹性核算
int dxhs = Integer.valueOf(Util.null2String(needClockInSchedule.get(0).get("dxhs")));
if (CheckBoxEnum.CHECKED.getKey().equals(sfdx)){
//上下班弹性
List<Map<String, Object>> needClockInStartList = needClockInSchedule.stream().filter(e -> ClassSegmentTypeEnum.WORK_TIME.getKey().equals(e.get("bdlx")) && CheckBoxEnum.CHECKED.getKey().equals(e.get("ksdk"))).collect(Collectors.toList());
List<Map<String, Object>> needClockInEndList = needClockInSchedule.stream().filter(e -> ClassSegmentTypeEnum.WORK_TIME.getKey().equals(e.get("bdlx")) && CheckBoxEnum.CHECKED.getKey().equals(e.get("jsdk"))).collect(Collectors.toList());
if (needClockInStartList.size()>0 && needClockInEndList.size()>0){
Map<String, Object> ksdkMap = needClockInStartList.get(0);
String kssjStart = analysisDate + " " +Util.null2String(ksdkMap.get("dtkssj"));
String jssjStart = analysisDate +" "+Util.null2String(ksdkMap.get("dtjssj"));
Map<String, Object> jsdkMap = needClockInEndList.get(needClockInEndList.size()-1);
int thdkfzs = Integer.valueOf(Util.null2String(jsdkMap.get("thdkfzs")));
String kssjEnd = analysisDate + " " +Util.null2String(jsdkMap.get("dtkssj"));
String jssjEnd = analysisDate +" "+Util.null2String(jsdkMap.get("dtjssj"));
if (ksdkMap != jsdkMap){
if (DateUtil.getTime(kssjStart).compareTo(DateUtil.getTime(jssjStart)) > 0){
kssjStart = DateUtil.beforeDay(analysisDate,1)+" "+Util.null2String(ksdkMap.get("dtkssj"));
}
if (DateUtil.getTime(kssjEnd).compareTo(DateUtil.getTime(jssjEnd)) > 0){
jssjEnd = DateUtil.AfterDay(analysisDate,1)+" "+Util.null2String(jsdkMap.get("dtjssj"));
}
}else {
jssjEnd = DateUtil.AfterDay(analysisDate,1)+" "+Util.null2String(jsdkMap.get("dtjssj"));
}
//弹性上班卡
String flexibleWork = "";
for (int i=0;i<clcokInTimeData.size();i++){
Map<String,Map<String,Object>> clcokInTimeMap = clcokInTimeData.get(i);
//卡点
String point = "";
//当天打卡数据
Map<String,Object> clcokInTime = null;
for (Map.Entry<String,Map<String,Object>> entry :clcokInTimeMap.entrySet()){
point = entry.getKey();
clcokInTime = entry.getValue();
}
//需要计算的班次打卡时间点
String pointTime = point.split("\\|")[0];
//start开始打卡时间点end结束打卡时间点
String pointType = point.split("\\|")[1];
//empty:漏卡equal:打卡时间和班次时间相等before打卡时间在班次时间之前after打卡时间在班次时间之后
String timeType = point.split("\\|")[2];
if (pointTime.equals(kssjStart) && ClockPointEnum.START.getKey().equals(pointType) && clcokInTime != null){
String signTime = clcokInTime.get("signdate")+" "+clcokInTime.get("signtime");
//该卡点是弹性开始时间
if (ClockPointEnum.BEFORE.getKey().equals(timeType)){
int betWeenTime = DateUtil.getBetWeenMinutes(signTime,kssjStart);
String newPonit = point;
if (betWeenTime <= zddxfz){
betWeenTime = Double.valueOf(Utils.getItemdurationDown(5.0, AccountingUnitEnum.MINUTES.getKey(),betWeenTime,AccountingUnitEnum.MINUTES)).intValue();
flexibleWork = DateUtil.beforeMinutes(kssjStart,betWeenTime);
newPonit = pointTime+"|"+pointType+"|"+ClockPointEnum.EQUAL.getKey()+"|"+flexibleWork;
}else if (betWeenTime > zddxfz){
newPonit = point +"|"+DateUtil.beforeMinutes(kssjStart,zddxfz);
flexibleWork = DateUtil.beforeMinutes(kssjStart,zddxfz);
}
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit,clcokInTime);
}else if (ClockPointEnum.AFTER.getKey().equals(timeType)){
//迟到
String newPonit = point;
int betWeenTime = DateUtil.getBetWeenMinutes(kssjStart,signTime);
if (betWeenTime <= zddxfz){
betWeenTime = Double.valueOf(Utils.getItemduration(5.0, AccountingUnitEnum.MINUTES.getKey(),betWeenTime,AccountingUnitEnum.MINUTES)).intValue();
flexibleWork = DateUtil.AfterMinutes(kssjStart,betWeenTime);
newPonit = pointTime+"|"+pointType+"|"+ClockPointEnum.EQUAL.getKey()+"|"+flexibleWork;
}else if (betWeenTime > zddxfz){
newPonit = point +"|"+DateUtil.AfterMinutes(kssjStart,zddxfz);
flexibleWork = DateUtil.AfterMinutes(kssjStart,zddxfz);
}
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit,clcokInTime);
}
}else if (pointTime.equals(jssjEnd) && ClockPointEnum.END.getKey().equals(pointType) && clcokInTime != null){
//该卡点是弹性下班点
int betweenToWorkTime = DateUtil.getBetWeenMinutes(flexibleWork,kssjStart);
//弹性下班时间点
String flexibleOffWork = jssjEnd;
if (betweenToWorkTime >=0){
flexibleOffWork = DateUtil.beforeMinutes(flexibleOffWork,Math.abs(betweenToWorkTime));
}else if (betweenToWorkTime < 0){
flexibleOffWork = DateUtil.AfterMinutes(flexibleOffWork,Math.abs(betweenToWorkTime));
}
//根据弹性下班时间点重新计算
Map<String,Map<String,Object>> jsdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(flexibleOffWork,clockInTimeList);
String newtimeType = ClockPointEnum.EMPTY.getKey();
if (jsdkNearestClcokInTime.get(ClockPointEnum.EQUAL.getKey()) != null){
newtimeType=ClockPointEnum.EQUAL.getKey();
}
if (ClockPointEnum.EMPTY.getKey().equals(newtimeType) && jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()) != null){
String clockInTime = jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signdate") +" "+jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(DateUtil.AfterMinutes(flexibleOffWork,thdkfzs))) <=0){
newtimeType=ClockPointEnum.AFTER.getKey();
}
}
if (ClockPointEnum.EMPTY.getKey().equals(newtimeType) && jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()) != null){
String clockInTime = jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signdate") +" "+jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(kssjEnd)) >0){
newtimeType=ClockPointEnum.BEFORE.getKey();
}
}
String newPonit = jssjEnd+"|"+ClockPointEnum.END.getKey()+"|"+newtimeType+"|"+flexibleOffWork;
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit,jsdkNearestClcokInTime.get(newtimeType));
}
}
}
}
}
//当有2笔需要打卡时可能会有打卡歧义的情况歧义情况取2个时间点的中间值当打卡时间小于中间值归属前一个打卡大于则相反
if (clcokInTimeData.size() >1){
for (int i=0;i<clcokInTimeData.size()-1;i++){
Map<String,Map<String,Object>> beforeClcokInTimeData = clcokInTimeData.get(i);
Map<String,Map<String,Object>> afterClcokInTimeData = clcokInTimeData.get(i+1);
Map<String,Object> beforeClcokInTimeMap = null;
String beforeClcokInTime = "";
String afterClcokInTime = "";
Map<String,Object> afterClcokInTimeMap = null;
for (Map.Entry<String,Map<String,Object>> beforeEntry :beforeClcokInTimeData.entrySet()){
beforeClcokInTimeMap = beforeEntry.getValue();
beforeClcokInTime = beforeEntry.getKey();
}
for (Map.Entry<String,Map<String,Object>> afterEntry :afterClcokInTimeData.entrySet()){
afterClcokInTimeMap = afterEntry.getValue();
afterClcokInTime = afterEntry.getKey();
}
//重复
if (beforeClcokInTimeMap != null && beforeClcokInTimeMap == afterClcokInTimeMap ){
String beforeTime = beforeClcokInTime.split("\\|")[0];
String afterTime = afterClcokInTime.split("\\|")[0];
long betWeenMinutes = DateUtil.getBetWeenMinutes(beforeTime,afterTime);
String middileTime = DateUtil.AfterMinutes(beforeTime,betWeenMinutes/2);
String signdateTime = beforeClcokInTimeMap.get("signdate") +" "+beforeClcokInTimeMap.get("signtime");
if (DateUtil.getTime(signdateTime).compareTo(DateUtil.getTime(middileTime)) <=0){
//该打卡归属前一个打卡点
afterClcokInTimeData.put(afterClcokInTime,null);
}else if (DateUtil.getTime(signdateTime).compareTo(DateUtil.getTime(middileTime)) >0){
//该打卡归属后一个打卡点
beforeClcokInTimeData.put(beforeClcokInTime,null);
}
}
}
}
return clcokInTimeData;
}
}

@ -28,6 +28,15 @@ public interface UtilService {
*/
void recordItem(Map<String,Object> params);
/**
*
* @param clcokInTimeData
* @return
*/
Map<String,Object> getNeedRecordClockInTime(List<Map<String,Map<String,Object>>> clcokInTimeData);
/**
*
*/
List<Map<String,Map<String,Object>>> getClockInPointCmd(Map<String,Object> params);
}

@ -0,0 +1,8 @@
package com.engine.attendance.attendanceanalysis.service;
import java.util.List;
import java.util.Map;
public interface WorkOverTimeService {
List<Map<String, Object>> recordWorkOverTime(Map<String,Object> params);
}

@ -33,6 +33,8 @@ public class AbnormalAttendanceServiceImpl extends Service implements AbnormalAt
List<Map<String,Object>> attendanceItems = (List<Map<String,Object>>)params.get("attendanceItems");
//班段类型
String bdlx = Util.null2String(classInfo.get("bdlx"));
//卡点
String point = Util.null2String(params.get("point"));
//分析日期
String analysisDate = Util.null2String(params.get("analysisDate"));
//人员
@ -40,7 +42,14 @@ public class AbnormalAttendanceServiceImpl extends Service implements AbnormalAt
List<Map<String,Object>> resultList = Lists.newArrayList();
String clockInTime = clcokInTimeData.get("signdate")+" "+clcokInTimeData.get("signtime");
String classStartTime = analysisDate +" "+Util.null2String(classInfo.get("dtkssj"));
String classStartTime = "";
if (point.split("\\|").length > 3){
//弹性上班
classStartTime=point.split("\\|")[3];
}else {
classStartTime=point.split("\\|")[0];
}
int between = DateUtil.getBetWeenMinutes(classStartTime,clockInTime);
Map<String,Object> lateParams = Maps.newHashMap();
@ -159,15 +168,18 @@ public class AbnormalAttendanceServiceImpl extends Service implements AbnormalAt
String analysisDate = Util.null2String(params.get("analysisDate"));
//人员
String userId = Util.null2String(params.get("userId"));
//卡点
String point = Util.null2String(params.get("point"));
List<Map<String,Object>> resultList = Lists.newArrayList();
String clockInTime = clcokInTimeData.get("signdate")+" "+clcokInTimeData.get("signtime");
String dtkssj = analysisDate+" "+classInfo.get("dtkssj");
String dtjssj = analysisDate+" "+classInfo.get("dtjssj");
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0){
dtjssj = DateUtil.AfterDay(analysisDate,1) +" "+classInfo.get("dtjssj");
String classEndTime = "";
if (point.split("\\|").length > 3){
//弹性下班
classEndTime=point.split("\\|")[3];
}else {
classEndTime=point.split("\\|")[0];
}
String classEndTime = dtjssj;
int between = DateUtil.getBetWeenMinutes(clockInTime,classEndTime);
Map<String,Object> earlyParams = Maps.newHashMap();

@ -1,5 +1,6 @@
package com.engine.attendance.attendanceanalysis.service.impl;
import com.engine.attendance.attendanceanalysis.cmd.GetClockInPointCmd;
import com.engine.attendance.attendanceanalysis.cmd.GetClockInTimeItemCmd;
import com.engine.attendance.attendanceanalysis.cmd.recordDataCmd;
import com.engine.attendance.attendanceanalysis.service.UtilService;
@ -42,7 +43,7 @@ public class UtilServiceImpl extends Service implements UtilService {
// Map<String,String> schedulingMap = schedulingResultsList.stream().collect(Collectors.toMap(e-> Util.null2String(e.get("bcxx")).split("-")[0], e->Util.null2String(e.get("bcrq"))+"&"+Util.null2String(e.get("rqlx"))));
Map<String,List<Map<String,Object>>> schedulingMap = schedulingResultsList.stream().collect(Collectors.groupingBy(e-> Util.null2String(e.get("bcxx")).split("-")[0]));
Map<String,List<Map<String,Object>>> resultMap = Maps.newHashMap();
String sql = "select a.id bcxx,a.edsc,a.bcsdxx,a.sfdx,a.sfkt,b.bdlx,b.zddxfz,b.dxhs,b.kssj dtkssj,b.jssj dtjssj,b.ksdk,b.jsdk,b.tqdkfzs,b.thdkfzs from uf_jcl_kq_bcxx a left join uf_jcl_kq_bcxx_dt1 b on a.id=b.mainid where a.id in (";
String sql = "select a.id bcxx,a.edsc,a.bcsdxx,a.sfdx,a.sfkt,b.bdlx,a.zddxfz,a.dxhs,b.kssj dtkssj,b.jssj dtjssj,b.ksdk,b.jsdk,b.tqdkfzs,b.thdkfzs from uf_jcl_kq_bcxx a left join uf_jcl_kq_bcxx_dt1 b on a.id=b.mainid where a.id in (";
String bcxxIds = "";
for (Map.Entry<String,List<Map<String,Object>>> entry :schedulingMap.entrySet()){
bcxxIds +=entry.getKey() +",";
@ -134,6 +135,7 @@ public class UtilServiceImpl extends Service implements UtilService {
map.put("sfdx","0");
map.put("zddxfz","0");
map.put("dxhs","0");
map.put("rqlx",dateMap.get(e.getKey()));
if (attendanceItems.size() >0){
map.put("ksdk",attendanceItems.get(0).get("ksjbbxydk"));
map.put("jsdk",attendanceItems.get(0).get("jsjbbxydk"));
@ -228,4 +230,11 @@ public class UtilServiceImpl extends Service implements UtilService {
}
return resultMap;
}
@Override
public List<Map<String, Map<String, Object>>> getClockInPointCmd(Map<String,Object> params) {
Map<String,Object> resultMap = commandExecutor.execute(new GetClockInPointCmd(params));
return (List<Map<String,Map<String,Object>>>)resultMap.get("clcokInTimeData");
}
}

@ -0,0 +1,222 @@
package com.engine.attendance.attendanceanalysis.service.impl;
import com.engine.attendance.attendanceanalysis.cmd.item.WorkOvertimeItemCmd;
import com.engine.attendance.attendanceanalysis.service.WorkOverTimeService;
import com.engine.attendance.enums.CheckBoxEnum;
import com.engine.attendance.enums.ClassSegmentTypeEnum;
import com.engine.attendance.enums.DateTypeEnum;
import com.engine.attendance.enums.WorkForTimeEnum;
import com.engine.common.util.DateUtil;
import com.engine.common.util.DbTools;
import com.engine.common.util.Utils;
import com.engine.core.impl.Service;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import weaver.general.TimeUtil;
import weaver.general.Util;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class WorkOverTimeServiceImpl extends Service implements WorkOverTimeService {
@Override
public List<Map<String, Object>> recordWorkOverTime(Map<String, Object> params) {
//考勤项目
List<Map<String,Object>> attendanceItems = (List<Map<String,Object>>)params.get("attendanceItems");
//排班
List<Map<String, Object>> scheduleResult = (List<Map<String,Object>>)params.get("scheduleResult");
//分析日期
String analysisDate = Util.null2String(params.get("analysisDate"));
//请假记录
List<Map<String,Object>> askForLeaveList = (List<Map<String,Object>>)params.get("askForLeaveList");
//外出记录
List<Map<String,Object>> evectionList = (List<Map<String,Object>>)params.get("evectionList");
//打卡卡点
List<Map<String,Map<String,Object>>> clcokInTimeList = (List<Map<String,Map<String,Object>>>)params.get("clcokInTimeList");
Map<String,Map<String,Object>> clcokInTimeMap = Maps.newHashMap();
List<Map<String, Object>> workOverTimeResults = null;
Calendar calendar = Calendar.getInstance();
calendar.set(Integer.valueOf(analysisDate.split("-")[0]), Integer.valueOf(analysisDate.split("-")[1]) - 1, 1);
long diffdays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
for (Map<String,Map<String,Object>> map :clcokInTimeList){
String point = "";
//当天打卡数据
Map<String,Object> clcokInTimeData = null;
for (Map.Entry<String,Map<String,Object>> entry :map.entrySet()){
point = entry.getKey();
clcokInTimeData = entry.getValue();
}
//需要计算的班次打卡时间点
String pointTime = point.split("\\|")[0];
clcokInTimeMap.put(pointTime,clcokInTimeData);
}
//人员
String userId = Util.null2String(params.get("userId"));
List<Map<String, Object>> resultLists = Lists.newArrayList();
int maxDayTime = 0;
int maxWeekTime = 0;
int maxMonthTime = 0;
for (Map<String, Object> scheduleMap :scheduleResult){
String bdlx = Util.null2String(scheduleMap.get("bdlx"));
String rqlx = Util.null2String(scheduleMap.get("rqlx"));
Map<String,Object> getWorkOverTimeParam = Maps.newHashMap();
Map<String,Object> workOverTimeItems = Maps.newHashMap();
//加班开始时间
String dtkssj = Util.null2String(scheduleMap.get("dtkssj"));
//加班结束时间
String dtjssj = Util.null2String(scheduleMap.get("dtjssj"));
String kssj = analysisDate +" "+Util.null2String(scheduleMap.get("dtkssj"));
String jssj = analysisDate +" "+Util.null2String(scheduleMap.get("dtjssj"));
if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(jssj)) >0){
jssj = DateUtil.AfterDay(analysisDate,1)+" "+Util.null2String(scheduleMap.get("dtjssj"));
}
//申请时间
int applicationTime = DateUtil.getBetWeenMinutes(kssj,jssj);
//扣除休息时间后的剩余
int applicationRestTime = applicationTime;
resultLists.add(workOverTimeItems);
getWorkOverTimeParam.put("attendanceItems",attendanceItems);
getWorkOverTimeParam.put("rqlx",scheduleMap.get("rqlx"));
if (ClassSegmentTypeEnum.EXTENDED_OVERTIME.getKey().equals(bdlx)){
getWorkOverTimeParam.put("workfor", WorkForTimeEnum.DELAY_TO_WORK_OVERTIME.getKey());
}else if (ClassSegmentTypeEnum.EARLY_OVERTIME.getKey().equals(bdlx)){
getWorkOverTimeParam.put("workfor",WorkForTimeEnum.EARLY_TO_WORK_OVERTIME.getKey());
}else if (ClassSegmentTypeEnum.OVERTIME_PLAN.getKey().equals(bdlx)){
applicationRestTime = Utils.removeRestTime(kssj,jssj,scheduleResult,analysisDate);
getWorkOverTimeParam.put("workfor",WorkForTimeEnum.PLAN_WORK_OVERTIME.getKey());
}
Map<String,Object> result = commandExecutor.execute(new WorkOvertimeItemCmd(getWorkOverTimeParam));
//加班项目
List<Map<String,Object>> workTimeBeLateItems = (List<Map<String,Object>>)result.get("attendanceItems");
if (workTimeBeLateItems.size() == 0){
continue;
}
workOverTimeItems.put("item",workTimeBeLateItems.get(0).get("key"));
//提前打卡开始的时长计入加班
String tqdkjrjb = Util.null2String(workTimeBeLateItems.get(0).get("tqdkjrjb"));
//推后打卡结束的时长计入加班
String thdkjrjb = Util.null2String(workTimeBeLateItems.get(0).get("thdkjrjb"));
//结算加班时长不得超过申请的时长
String jbscbdccsqsc = Util.null2String(workTimeBeLateItems.get(0).get("jbscbdccsqsc"));
//结算加班时长不得超过申请的时长
String zdkcjcxxsc = Util.null2String(workTimeBeLateItems.get(0).get("zdkcjcxxsc"));
//超出限制时长的处理方式
String ccclfs = Util.null2String(workTimeBeLateItems.get(0).get("ccclfs"));
//工作日加班最大小时数
String rzdjbxss = Util.null2String(workTimeBeLateItems.get(0).get("rzdjbxss"));
//每周最大加班小时数
String yzdjbxss = Util.null2String(workTimeBeLateItems.get(0).get("yzdjbxss"));
//每月最大加班小时数
String zzdjbxss = Util.null2String(workTimeBeLateItems.get(0).get("zzdjbxss"));
//加班时长自动转入假期余额
String jbzdzjqye= Util.null2String(workTimeBeLateItems.get(0).get("jbzdzjqye"));
if (CheckBoxEnum.CHECKED.getKey().equals(tqdkjrjb)){
Map<String,Object> clcokInTimeData = clcokInTimeMap.get(dtkssj);
String signTime = clcokInTimeData.get("signdate")+" "+clcokInTimeData.get("signtime");
if (DateUtil.getTime(signTime).compareTo(DateUtil.getTime(dtkssj)) < 0){
dtkssj = signTime;
}
}
if (CheckBoxEnum.CHECKED.getKey().equals(thdkjrjb)){
Map<String,Object> clcokInTimeData = clcokInTimeMap.get(dtjssj);
String signTime = clcokInTimeData.get("signdate")+" "+clcokInTimeData.get("signtime");
if (DateUtil.getTime(signTime).compareTo(DateUtil.getTime(dtjssj)) > 0){
dtjssj = signTime;
}
}
//自动扣除
if ("2".equals(ccclfs) && workOverTimeResults == null){
String startDate = analysisDate.split("-")[0]+"-"+ analysisDate.split("-")[1]+"-01";
String endDate = analysisDate.split("-")[0]+"-"+ analysisDate.split("-")[1]+"-"+diffdays;
workOverTimeResults =getWorkOverTimeResults(startDate,endDate,userId);
}
if ("2".equals(ccclfs) && !"".equals(rzdjbxss) && DateTypeEnum.WORK_DAY.getKey().equals(rqlx)){
//工作日加班最大数
maxDayTime = getWorkDayTime(workOverTimeResults,analysisDate);
}else if ("2".equals(ccclfs) && !"".equals(yzdjbxss)){
//每月最大加班数
maxWeekTime = getMonthTime(workOverTimeResults);
}else if ("2".equals(ccclfs) && !"".equals(zzdjbxss)){
//每周最大加班小时数
maxMonthTime = getWeekTime(workOverTimeResults,analysisDate);
}
//加班时长自动转入假期余额
if (CheckBoxEnum.CHECKED.getKey().equals(jbzdzjqye)){
}
}
return resultLists;
}
public List<Map<String, Object>> getWorkOverTimeResults(String startDate,String endDate,String userId){
String sql = "select sjjbsc,sjksrq,sjjsrq from uf_jcl_kq_jbjg where jbry=? and sjksrq>? and sjjsrq<?";
List<Map<String, Object>> dataList = DbTools.getSqlToList(sql,userId,startDate,endDate);
return dataList;
}
/**
*
* @param dataList
* @return
*/
public int getWorkDayTime(List<Map<String, Object>> dataList,String date){
List<Map<String, Object>> list = dataList.stream().filter(e->date.equals(e.get("sjksrq"))).collect(Collectors.toList());
int totalHour = list.stream().mapToInt(e->Integer.valueOf(e.get("sjjbsc").toString())).sum();
return totalHour;
}
/**
*
* @param dataList
* @return
*/
public int getWeekTime(List<Map<String, Object>> dataList,String date){
int day = TimeUtil.getDayOfWeek(date);
if (day ==0){
day = 7;
}
String startDate = DateUtil.beforeDay(date,day-1);
String endDate = DateUtil.AfterDay(date,7-day);
List<Map<String, Object>> list = dataList.stream().filter(e->{
String sjksrq = Util.null2String(e.get("sjksrq"));
if (DateUtil.getTime(sjksrq).compareTo(DateUtil.getTime(startDate)) >=0 &&
DateUtil.getTime(sjksrq).compareTo(DateUtil.getTime(endDate)) >=0){
return true;
}else {
return false;
}
}).collect(Collectors.toList());
int totalHour = list.stream().mapToInt(e->Integer.valueOf(e.get("sjjbsc").toString())).sum();
return totalHour;
}
/**
*
* @param dataList
* @return
*/
public int getMonthTime(List<Map<String, Object>> dataList){
int totalHour = dataList.stream().mapToInt(e->Integer.valueOf(e.get("sjjbsc").toString())).sum();
return totalHour;
}
}

@ -1,9 +1,11 @@
package com.engine.attendance.attendanceanalysis.wrapper;
import com.engine.attendance.attendanceanalysis.cmd.GetClockInPointCmd;
import com.engine.attendance.attendanceanalysis.service.ForgetClockInService;
import com.engine.attendance.attendanceanalysis.service.UtilService;
import com.engine.attendance.attendanceanalysis.service.impl.ForgetClockInServiceImpl;
import com.engine.attendance.attendanceanalysis.service.impl.UtilServiceImpl;
import com.engine.attendance.enums.AccountingUnitEnum;
import com.engine.attendance.enums.CheckBoxEnum;
import com.engine.attendance.enums.ClassSegmentTypeEnum;
import com.engine.attendance.enums.ClockPointEnum;
@ -242,7 +244,11 @@ public class AttendanceAnalysisWrapper extends Service {
needClockInSchedule = needClockInSchedule.stream().sorted(Comparator.comparing(e->DateUtil.getTime(analysisDate+" "+e.get("dtkssj")).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());
List<Map<String,Map<String,Object>>> clcokInTimeData = getClockInPoint(analysisDate,needClockInSchedule,clockInTimeList);
Map<String,Object> clcokInTimeDataParam = Maps.newHashMap();
clcokInTimeDataParam.put("analysisDate",analysisDate);
clcokInTimeDataParam.put("needClockInSchedule",needClockInSchedule);
clcokInTimeDataParam.put("clockInTimeList",clockInTimeList);
List<Map<String,Map<String,Object>>> clcokInTimeData = utilService.getClockInPointCmd(clcokInTimeDataParam);
Map<String,Object> recordAbnormalParam = Maps.newHashMap();
recordAbnormalParam.put("clcokInTimeList",clcokInTimeData);
@ -268,10 +274,6 @@ public class AttendanceAnalysisWrapper extends Service {
List<Map<String,Object>> abnormalClockInList = updateAttendanceResultWrapper.recordAbnormalClockIn(recordAbnormalParam);
/**
*
*/
boolean recordWorkOverTime= updateAttendanceResultWrapper.recordWorkOverTime(recordAbnormalParam);
/**
*
@ -293,6 +295,12 @@ public class AttendanceAnalysisWrapper extends Service {
abnormalClockInList = (List<Map<String,Object>>)recordEvection.get("abnormalClockInList");
List<Map<String,Object>> evectionResultList = (List<Map<String,Object>>)recordEvection.get("resultList");
/**
*
*/
List<Map<String,Object>> recordWorkOverTime= updateAttendanceResultWrapper.recordWorkOverTime(recordAbnormalParam);
/**
*
*/
@ -312,125 +320,4 @@ public class AttendanceAnalysisWrapper extends Service {
}
/**
*
* @param analysisDate
* @param needClockInSchedule
* @param clockInTimeList
* @return
*/
public List<Map<String,Map<String,Object>>> getClockInPoint(String analysisDate,List<Map<String, Object>> needClockInSchedule,List<Map<String, Object>> clockInTimeList){
List<Map<String,Map<String,Object>>> clcokInTimeData = Lists.newArrayList();
if (needClockInSchedule.size() > 0){
String sfdx = Util.null2String(needClockInSchedule.get(0).get("sfdx"));
String zddxfz = Util.null2String(needClockInSchedule.get(0).get("zddxfz"));
String dxhs = Util.null2String(needClockInSchedule.get(0).get("dxhs"));
if (CheckBoxEnum.CHECKED.getKey().equals(sfdx)){
//上下班弹性
List<Map<String, Object>> needClockInStart = needClockInSchedule.stream().filter(e -> ClassSegmentTypeEnum.WORK_TIME.getKey().equals(e.get("bdlx")) && CheckBoxEnum.CHECKED.getKey().equals(e.get("ksdk"))).collect(Collectors.toList());
List<Map<String, Object>> needClockInEnd = needClockInSchedule.stream().filter(e -> ClassSegmentTypeEnum.WORK_TIME.getKey().equals(e.get("bdlx")) && CheckBoxEnum.CHECKED.getKey().equals(e.get("jsdk"))).collect(Collectors.toList());
}
}
for (Map<String, Object> needClockIn :needClockInSchedule){
if (CheckBoxEnum.CHECKED.getKey().equals(needClockIn.get("ksdk"))){
String dtkssj = analysisDate+" "+needClockIn.get("dtkssj");
String dtjssj = analysisDate+" "+needClockIn.get("dtjssj");
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0){
dtjssj = DateUtil.AfterDay(analysisDate,1) +" "+needClockIn.get("dtjssj");
}
int tqdkfzs = Integer.valueOf(Util.null2String(needClockIn.get("tqdkfzs")));
Map<String,Map<String,Object>> ksdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(dtkssj,clockInTimeList);
String timeType = ClockPointEnum.EMPTY.getKey();
Map<String,Map<String,Object>> clcokInTimeMap = Maps.newHashMap();
if (ksdkNearestClcokInTime.get(ClockPointEnum.EQUAL.getKey()) != null){
timeType=ClockPointEnum.EQUAL.getKey();
}
if (ClockPointEnum.EMPTY.getKey().equals(timeType) && ksdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()) != null){
String clockInTime = ksdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signdate") +" "+ksdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(DateUtil.beforeMinutes(dtkssj,tqdkfzs))) >=0){
//打卡时间大于等于最早打卡时间
timeType=ClockPointEnum.BEFORE.getKey();
}
}
if (ClockPointEnum.EMPTY.getKey().equals(timeType) && ksdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()) != null){
String clockInTime = ksdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signdate") +" "+ksdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(dtjssj)) < 0){
//打卡时间小于结束时间
timeType=ClockPointEnum.AFTER.getKey();
}
}
clcokInTimeMap.put(dtkssj+"|"+ClockPointEnum.START.getKey()+"|"+timeType,ksdkNearestClcokInTime.get(timeType));
clcokInTimeData.add(clcokInTimeMap);
}
if (CheckBoxEnum.CHECKED.getKey().equals(needClockIn.get("jsdk"))){
String dtkssj = analysisDate+" "+needClockIn.get("dtkssj");
String dtjssj = analysisDate+" "+needClockIn.get("dtjssj");
int thdkfzs = Integer.valueOf(Util.null2String(needClockIn.get("thdkfzs")));
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0){
dtjssj = DateUtil.AfterDay(analysisDate,1) +" "+needClockIn.get("dtjssj");
}
Map<String,Map<String,Object>> jsdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(dtjssj,clockInTimeList);
String timeType = ClockPointEnum.EMPTY.getKey();
Map<String,Map<String,Object>> clcokInTimeMap = Maps.newHashMap();
if (jsdkNearestClcokInTime.get(ClockPointEnum.EQUAL.getKey()) != null){
timeType=ClockPointEnum.EQUAL.getKey();
}
if (ClockPointEnum.EMPTY.getKey().equals(timeType) && jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()) != null){
String clockInTime = jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signdate") +" "+jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(DateUtil.AfterMinutes(dtjssj,thdkfzs))) <=0){
timeType=ClockPointEnum.AFTER.getKey();
}
}
if (ClockPointEnum.EMPTY.getKey().equals(timeType) && jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()) != null){
String clockInTime = jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signdate") +" "+jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(dtkssj)) >0){
timeType=ClockPointEnum.BEFORE.getKey();
}
}
clcokInTimeMap.put(dtjssj+"|"+ClockPointEnum.END.getKey()+"|"+timeType,jsdkNearestClcokInTime.get(timeType));
clcokInTimeData.add(clcokInTimeMap);
}
}
//当有2笔需要打卡时可能会有打卡歧义的情况歧义情况取2个时间点的中间值当打卡时间小于中间值归属前一个打卡大于则相反
if (clcokInTimeData.size() >1){
for (int i=0;i<clcokInTimeData.size()-1;i++){
Map<String,Map<String,Object>> beforeClcokInTimeData = clcokInTimeData.get(i);
Map<String,Map<String,Object>> afterClcokInTimeData = clcokInTimeData.get(i+1);
Map<String,Object> beforeClcokInTimeMap = null;
String beforeClcokInTime = "";
String afterClcokInTime = "";
Map<String,Object> afterClcokInTimeMap = null;
for (Map.Entry<String,Map<String,Object>> beforeEntry :beforeClcokInTimeData.entrySet()){
beforeClcokInTimeMap = beforeEntry.getValue();
beforeClcokInTime = beforeEntry.getKey();
}
for (Map.Entry<String,Map<String,Object>> afterEntry :afterClcokInTimeData.entrySet()){
afterClcokInTimeMap = afterEntry.getValue();
afterClcokInTime = afterEntry.getKey();
}
//重复
if (beforeClcokInTimeMap != null && beforeClcokInTimeMap == afterClcokInTimeMap ){
String beforeTime = beforeClcokInTime.split("\\|")[0];
String afterTime = afterClcokInTime.split("\\|")[0];
long betWeenMinutes = DateUtil.getBetWeenMinutes(beforeTime,afterTime);
String middileTime = DateUtil.AfterMinutes(beforeTime,betWeenMinutes/2);
String signdateTime = beforeClcokInTimeMap.get("signdate") +" "+beforeClcokInTimeMap.get("signtime");
if (DateUtil.getTime(signdateTime).compareTo(DateUtil.getTime(middileTime)) <=0){
//该打卡归属前一个打卡点
afterClcokInTimeData.put(afterClcokInTime,null);
}else if (DateUtil.getTime(signdateTime).compareTo(DateUtil.getTime(middileTime)) >0){
//该打卡归属后一个打卡点
beforeClcokInTimeData.put(beforeClcokInTime,null);
}
}
}
}
return clcokInTimeData;
}
}

@ -2,14 +2,9 @@ package com.engine.attendance.attendanceanalysis.wrapper;
import com.engine.attendance.attendanceanalysis.cmd.UpdateAttendanceResultsCmd;
import com.engine.attendance.attendanceanalysis.service.AbnormalAttendanceService;
import com.engine.attendance.attendanceanalysis.service.AskForLeaveService;
import com.engine.attendance.attendanceanalysis.service.EvectionService;
import com.engine.attendance.attendanceanalysis.service.ForgetClockInService;
import com.engine.attendance.attendanceanalysis.service.impl.AbnormalAttendanceServiceImpl;
import com.engine.attendance.attendanceanalysis.service.impl.AskForLeaveServiceImpl;
import com.engine.attendance.attendanceanalysis.service.impl.EvectionServiceImpl;
import com.engine.attendance.attendanceanalysis.service.impl.ForgetClockInServiceImpl;
import com.engine.attendance.attendanceanalysis.cmd.item.WorkOvertimeItemCmd;
import com.engine.attendance.attendanceanalysis.service.*;
import com.engine.attendance.attendanceanalysis.service.impl.*;
import com.engine.attendance.enums.*;
import com.engine.common.util.DateUtil;
import com.engine.common.util.ServiceUtil;
@ -30,6 +25,7 @@ public class UpdateAttendanceResultWrapper extends Service {
private ForgetClockInService forgetClockInService = ServiceUtil.getService(ForgetClockInServiceImpl.class);
private AskForLeaveService askForLeaveService= ServiceUtil.getService(AskForLeaveServiceImpl.class);
private EvectionService evectionService= ServiceUtil.getService(EvectionServiceImpl.class);
private WorkOverTimeService workOverTimeService = ServiceUtil.getService(WorkOverTimeServiceImpl.class);
/**
*
@ -82,6 +78,7 @@ public class UpdateAttendanceResultWrapper extends Service {
missCardParams.put("attendanceItems",attendanceItems);
missCardParams.put("analysisDate",analysisDate);
missCardParams.put("userId",userId);
missCardParams.put("point",point);
log.info("missCardParams classInfo: [{}],clcokInTimeData:[{}]",classInfo,clcokInTimeData);
List<Map<String,Object>> iforgetClockIn = forgetClockInService.forgetClockIn(missCardParams);
if (iforgetClockIn.size() >0){
@ -97,6 +94,7 @@ public class UpdateAttendanceResultWrapper extends Service {
beLateParams.put("attendanceItems",attendanceItems);
beLateParams.put("analysisDate",analysisDate);
beLateParams.put("userId",userId);
beLateParams.put("point",point);
log.info("beLateParams classInfo: [{}],clcokInTimeData:[{}]",classInfo,clcokInTimeData);
List<Map<String,Object>> ifBeLate = beLateService.beLate(beLateParams);
if (ifBeLate.size() > 0){
@ -111,6 +109,7 @@ public class UpdateAttendanceResultWrapper extends Service {
leaveEarlyParams.put("attendanceItems",attendanceItems);
leaveEarlyParams.put("analysisDate",analysisDate);
leaveEarlyParams.put("userId",userId);
leaveEarlyParams.put("point",point);
log.info("leaveEarlyParams classInfo: [{}],clcokInTimeData:[{}]",classInfo,clcokInTimeData);
List<Map<String,Object>> ifLeaveEarly = beLateService.leaveEarly(leaveEarlyParams);
if (ifLeaveEarly.size() > 0){
@ -132,29 +131,8 @@ public class UpdateAttendanceResultWrapper extends Service {
* @param params
* @return
*/
public boolean recordWorkOverTime(Map<String,Object> params){
//考勤项目
List<Map<String,Object>> attendanceItems = (List<Map<String,Object>>)params.get("attendanceItems");
//排班
List<Map<String, Object>> scheduleResult = (List<Map<String,Object>>)params.get("scheduleResult");
//分析日期
String analysisDate = Util.null2String(params.get("analysisDate"));
//人员
String userId = Util.null2String(params.get("userId"));
scheduleResult = scheduleResult.stream().filter(e -> {
String bdlx = Util.null2String(e.get("bdlx"));
if (ClassSegmentTypeEnum.EXTENDED_OVERTIME.getKey().equals(bdlx) || ClassSegmentTypeEnum.EARLY_OVERTIME.getKey().equals(bdlx)
|| ClassSegmentTypeEnum.OVERTIME_PLAN.getKey().equals(bdlx)){
return true;
}else {
return false;
}
}).collect(Collectors.toList());
return false;
public List<Map<String, Object>> recordWorkOverTime(Map<String,Object> params){
return workOverTimeService.recordWorkOverTime(params);
}
@ -175,6 +153,7 @@ public class UpdateAttendanceResultWrapper extends Service {
//异常记录
List<Map<String,Object>> abnormalClockInList = (List<Map<String,Object>>)params.get("abnormalClockInList");
Map<String, Object> map = Maps.newHashMap();
List<Map<String, Object>> resultList = Lists.newArrayList();
@ -223,7 +202,7 @@ public class UpdateAttendanceResultWrapper extends Service {
//按照开始时间,结束时间请假
int timeMinutes = DateUtil.getBetWeenMinutes(kssj,jssj);
if (CheckBoxEnum.CHECKED.getKey().equals(zdycbcndfgzsd)){
timeMinutes = removeRestTime(kssj,jssj,scheduleResult,analysisDate);
timeMinutes = Utils.removeRestTime(kssj,jssj,scheduleResult,analysisDate);
}
log.info("recordAskForLeave timeMinutes [{}] ,hsl:{},hsdw",timeMinutes,hsl,hsdw);
itemduration = Utils.getItemduration(hsl,hsdw,timeMinutes,AccountingUnitEnum.MINUTES);
@ -307,7 +286,7 @@ public class UpdateAttendanceResultWrapper extends Service {
//按照开始时间,结束时间出差
int timeMinutes = DateUtil.getBetWeenMinutes(kssj,jssj);
if (CheckBoxEnum.CHECKED.getKey().equals(zdycbcndfgzsd)){
timeMinutes = removeRestTime(kssj,jssj,scheduleResult,analysisDate);
timeMinutes = Utils.removeRestTime(kssj,jssj,scheduleResult,analysisDate);
}
log.info("recordEvection timeMinutes [{}] ,hsl:{},hsdw",timeMinutes,hsl,hsdw);
itemduration = Utils.getItemduration(hsl,hsdw,timeMinutes,AccountingUnitEnum.MINUTES);
@ -385,45 +364,5 @@ public class UpdateAttendanceResultWrapper extends Service {
return false;
}
/**
*
* @param kssj
* @param jssj
* @param scheduleResult
* @return
*/
public int removeRestTime(String kssj,String jssj,List<Map<String, Object>> scheduleResult,String analysisDate){
scheduleResult = scheduleResult.stream().filter(e -> ClassSegmentTypeEnum.REST_AND_DINE.getKey().equals(e.get("bdlx")) ||
ClassSegmentTypeEnum.REST_PERIOD.getKey().equals(e.get("bdlx")) || ClassSegmentTypeEnum.DINING_PERIOD.getKey().equals(e.get("bdlx"))).collect(Collectors.toList());
int betweenMinutes = DateUtil.getBetWeenMinutes(kssj,jssj);
log.info("removeRestTime scheduleResult : {}",scheduleResult);
for (Map<String, Object> restSchedule :scheduleResult){
String dtkssj = analysisDate+" "+restSchedule.get("dtkssj");
String dtjssj = analysisDate+" "+restSchedule.get("dtjssj");
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0){
dtjssj = DateUtil.AfterDay(analysisDate,1) +" "+restSchedule.get("dtjssj");
}
if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtkssj)) <=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtjssj)) >=0){
//休息时间在请假时间中间
betweenMinutes = betweenMinutes - DateUtil.getBetWeenMinutes(dtkssj,dtjssj);
log.info("休息时间在请假时间中间");
}else if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtkssj)) <=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtjssj)) <=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtkssj)) >=0){
//休息时间在请假时间 左边
betweenMinutes = betweenMinutes - DateUtil.getBetWeenMinutes(dtkssj,jssj);
log.info("休息时间在请假时间 左边");
}else if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtkssj)) >=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtjssj)) >=0 && DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtjssj)) <=0){
//休息时间在请假时间 右边
betweenMinutes = betweenMinutes - DateUtil.getBetWeenMinutes(kssj,dtjssj);
log.info("休息时间在请假时间 右边");
}else if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtkssj)) >=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtjssj)) <=0){
//请假时间在休息时间中间
betweenMinutes = 0;
log.info("请假时间在休息时间中间");
}
}
return betweenMinutes;
}
}

@ -36,7 +36,7 @@ public class DateUtil {
public static String beforeMinutes(String time,long minutes){
LocalDateTime localDateTime = DateUtil.getTime(time);
return localDateTime.minusDays(minutes).format(yyyyMMddHHmm);
return localDateTime.minusMinutes(minutes).format(yyyyMMddHHmm);
}
public static String AfterMinutes(String time,long minutes){

@ -1,10 +1,12 @@
package com.engine.common.util;
import com.engine.attendance.enums.AccountingUnitEnum;
import com.engine.attendance.enums.ClassSegmentTypeEnum;
import com.engine.attendance.enums.ClockPointEnum;
import com.google.common.collect.Maps;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import weaver.general.BaseBean;
@ -23,7 +25,9 @@ import java.util.List;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
@Slf4j
public class Utils<T> {
public static Gson gson = new Gson();
public static Type list_map_type = new TypeToken<List<Map<String,String>>>(){}.getType();
@ -302,4 +306,109 @@ public class Utils<T> {
return itemDuration;
}
/**
*
* @param hsl
* @param hsdw
* @param duration
* @param unit
* @return
*/
public static double getItemdurationDown(double hsl, String hsdw,int duration, AccountingUnitEnum unit){
double itemDuration = 0.0;
BigDecimal durationBig = new BigDecimal(duration);
BigDecimal hslBig = new BigDecimal(hsl);
if (AccountingUnitEnum.DAY.getKey().equals(hsdw) || AccountingUnitEnum.ONCE.getKey().equals(hsdw)){
itemDuration = hsl;
}else if (AccountingUnitEnum.HOUR.getKey().equals(hsdw)){
if (unit.equals(AccountingUnitEnum.MINUTES)){
double durationHour = duration/60.0;
// if (duration%60 > 0){
// durationHour = durationHour +1;
// }
durationBig = new BigDecimal(durationHour);
if ((durationHour/hsl) > Math.floor(durationHour/hsl)){
// (durationHour/hsl)*hsl+hsl
durationBig = new BigDecimal(Math.floor(durationHour/hsl));
itemDuration = durationBig.multiply(hslBig).doubleValue();
}else {
itemDuration = durationBig.divide(hslBig,BigDecimal.ROUND_DOWN).multiply(hslBig).doubleValue();
}
}else if (unit.equals(AccountingUnitEnum.HOUR)){
if ((duration/hsl) > Math.floor(duration/hsl)){
durationBig = new BigDecimal(Math.floor(duration/hsl));
itemDuration=durationBig.multiply(hslBig).doubleValue();
}else {
itemDuration = durationBig.divide(hslBig,BigDecimal.ROUND_DOWN).multiply(hslBig).doubleValue();
}
}
}else if (AccountingUnitEnum.MINUTES.getKey().equals(hsdw)){
if (unit.equals(AccountingUnitEnum.MINUTES)){
if ((duration/hsl) > Math.floor(duration/hsl)){
durationBig = new BigDecimal(Math.floor(duration/hsl));
itemDuration=durationBig.multiply(hslBig).doubleValue();
}else {
itemDuration = durationBig.divide(hslBig,BigDecimal.ROUND_DOWN).multiply(hslBig).doubleValue();
}
}else if (unit.equals(AccountingUnitEnum.HOUR)){
int durationMinute = duration*60;
durationBig = new BigDecimal(durationMinute);
if ((durationMinute/hsl) > Math.floor(durationMinute/hsl)){
durationBig = new BigDecimal(Math.floor(durationMinute/hsl));
itemDuration=durationBig.multiply(hslBig).doubleValue();
}else {
itemDuration = durationBig.divide(hslBig,BigDecimal.ROUND_DOWN).multiply(hslBig).doubleValue();
}
}
}
return itemDuration;
}
/**
*
* @param kssj
* @param jssj
* @param scheduleResult
* @return
*/
public static int removeRestTime(String kssj,String jssj,List<Map<String, Object>> scheduleResult,String analysisDate){
scheduleResult = scheduleResult.stream().filter(e -> ClassSegmentTypeEnum.REST_AND_DINE.getKey().equals(e.get("bdlx")) ||
ClassSegmentTypeEnum.REST_PERIOD.getKey().equals(e.get("bdlx")) || ClassSegmentTypeEnum.DINING_PERIOD.getKey().equals(e.get("bdlx"))).collect(Collectors.toList());
int betweenMinutes = DateUtil.getBetWeenMinutes(kssj,jssj);
log.info("removeRestTime scheduleResult : {}",scheduleResult);
for (Map<String, Object> restSchedule :scheduleResult){
String dtkssj = analysisDate+" "+restSchedule.get("dtkssj");
String dtjssj = analysisDate+" "+restSchedule.get("dtjssj");
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0){
dtjssj = DateUtil.AfterDay(analysisDate,1) +" "+restSchedule.get("dtjssj");
}
if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtkssj)) <=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtjssj)) >=0){
//休息时间在请假时间中间
betweenMinutes = betweenMinutes - DateUtil.getBetWeenMinutes(dtkssj,dtjssj);
log.info("休息时间在请假时间中间");
}else if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtkssj)) <=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtjssj)) <=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtkssj)) >=0){
//休息时间在请假时间 左边
betweenMinutes = betweenMinutes - DateUtil.getBetWeenMinutes(dtkssj,jssj);
log.info("休息时间在请假时间 左边");
}else if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtkssj)) >=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtjssj)) >=0 && DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtjssj)) <=0){
//休息时间在请假时间 右边
betweenMinutes = betweenMinutes - DateUtil.getBetWeenMinutes(kssj,dtjssj);
log.info("休息时间在请假时间 右边");
}else if (DateUtil.getTime(kssj).compareTo(DateUtil.getTime(dtkssj)) >=0 && DateUtil.getTime(jssj).compareTo(DateUtil.getTime(dtjssj)) <=0){
//请假时间在休息时间中间
betweenMinutes = 0;
log.info("请假时间在休息时间中间");
}
}
return betweenMinutes;
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -11,6 +11,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import io.swagger.models.auth.In;
import weaver.general.TimeUtil;
import weaver.general.Util;
import java.math.BigDecimal;
@ -18,10 +19,7 @@ import java.math.MathContext;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@ -118,9 +116,26 @@ public class Test {
// map3.put("value","222");
// System.out.println(DateUtil.getBetWeenMinutes("2023-11-16 08:00","2023-11-16 09:10"));
// BigDecimal durationBig = new BigDecimal(1.5);
List<Map<String,String>> list = Lists.newArrayList();
// list.add(new HashMap(){{
// put("aa","bb");
// }});
// list.add(new HashMap(){{
// put("bb","cc");
// }});
// Map<String,String> map1 = list.get(0);
//
// map1.remove("aa");
// map1.put("dd","aa");
// // System.out.println(list);
// System.out.println(DateUtil.getBetWeenMinutes("2023-11-20 10:39","2023-11-20 11:39"));
// System.out.println(DateUtil.getBetWeenMinutes("2023-11-20 12:39","2023-11-20 11:39"));
// System.out.println("11,12,33".split(",").length);
// System.out.println(Utils.getItemdurationDown(5.0,AccountingUnitEnum.MINUTES.getKey(),36,AccountingUnitEnum.MINUTES));
//System.out.println( durationBig.divide(hslBig,BigDecimal.ROUND_DOWN).multiply(hslBig).add(hslBig,new MathContext(BigDecimal.ROUND_HALF_DOWN)).doubleValue());
System.out.println(Utils.getItemduration(1,"1",DateUtil.getBetWeenMinutes("2023-11-16 08:00","2023-11-16 09:10"),AccountingUnitEnum.MINUTES));
// System.out.println(Utils.getItemduration(1,"1",DateUtil.getBetWeenMinutes("2023-11-16 08:00","2023-11-16 09:10"),AccountingUnitEnum.MINUTES));
// lists2.add(lists.get(1));
// lists3.add(lists.get(1));
@ -165,7 +180,24 @@ public class Test {
// System.out.println(lists2);
//
// System.out.println(Double.valueOf("1.00").intValue()*60);
// System.out.println(DateUtil.getTime("2023-11-15 10:00:00").compareTo(DateUtil.getTime("2023-11-15 09:00:00")));
String analysisDate = "2023-11-22";
// Calendar calendar = Calendar.getInstance();
// calendar.set(Integer.valueOf(analysisDate.split("-")[0]), Integer.valueOf(analysisDate.split("-")[1]) - 1, 1);
int day = TimeUtil.getDayOfWeek(analysisDate);
System.out.println(DateUtil.AfterDay(analysisDate,0));
// System.out.println(calendar.getActualMaximum(Calendar.DAY_OF_WEEK));
// List<Map<String, Object>> lists = Lists.newArrayList();
// lists.add(new HashMap(){{
// put("sjjbsc","5");
// }});
// lists.add(new HashMap(){{
// put("sjjbsc","5");
// }});
//
//
// System.out.println(lists.stream().mapToInt(e->Integer.valueOf(e.get("sjjbsc").toString())).sum());
// System.out.println(DateUtil.getTime("2023-11-15 10:00:00").compareTo(DateUtil.getTime("2023-11-15 09:00:00")));
//long numDays = DateUtil.getBetWeenMinutes("2023-11-08 17:40","2023-11-08 16:30");
// BigDecimal duration = new BigDecimal(5);
// BigDecimal hsl = new BigDecimal(0.6);

@ -1,7 +1,9 @@
import com.engine.attendance.attendanceanalysis.service.UtilService;
import com.engine.attendance.attendanceanalysis.service.impl.UtilServiceImpl;
import com.engine.attendance.attendanceanalysis.wrapper.AttendanceAnalysisWrapper;
import com.engine.attendance.enums.AccountingUnitEnum;
import com.engine.attendance.enums.CheckBoxEnum;
import com.engine.attendance.enums.ClassSegmentTypeEnum;
import com.engine.attendance.enums.ClockPointEnum;
import com.engine.common.util.DateUtil;
import com.engine.common.util.ServiceUtil;
@ -13,6 +15,7 @@ import weaver.general.Util;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class TestGetClockInPoint {
@ -29,7 +32,7 @@ public class TestGetClockInPoint {
put("bcxx","25");
put("dxhs","5");
put("bcsdxx","09:00-13:00|13:00-18:30");
put("sfdx","0");
put("sfdx","1");
put("dtkssj","09:00");
put("thdkfzs","60");
put("ksdk","1");
@ -46,8 +49,8 @@ public class TestGetClockInPoint {
put("bcxx","25");
put("dxhs","5");
put("bcsdxx","09:00-13:00|13:00-18:30");
put("sfdx","0");
put("dtkssj","03:00");
put("sfdx","1");
put("dtkssj","13:00");
put("thdkfzs","60");
put("ksdk","0");
put("rqlx","11");
@ -55,7 +58,7 @@ public class TestGetClockInPoint {
List<Map<String,Object>> dataList = Lists.newArrayList();
dataList.add(new HashMap(){{
put("signtime","08:45:00");
put("signtime","09:11:00");
put("id","48");
put("userid","53");
put("signdate","2023-11-12");
@ -84,21 +87,20 @@ public class TestGetClockInPoint {
put("userid","53");
put("signdate","2023-11-12");
}});
// dataList.add(new HashMap(){{
// put("signtime","18:15:00");
// put("id","48");
// put("userid","53");
// put("signdate","2023-11-12");
// }});
dataList.add(new HashMap(){{
put("signtime","18:35:00");
put("id","48");
put("userid","53");
put("signdate","2023-11-12");
}});
List<Map<String, Map<String,Object>>> collect = getClockInPoint("2023-11-12",schedulingList,dataList);
System.out.println(collect);
Map<String,Object> clock = getNeedRecordClockInTime(collect);
System.out.println(clock);
// Map<String,Object> clock = getNeedRecordClockInTime(collect);
// System.out.println(clock);
}
public static List<Map<String, Map<String,Object>>> getClockInPoint(String analysisDate, List<Map<String, Object>> needClockInSchedule, List<Map<String, Object>> clockInTimeList){
List<Map<String,Map<String,Object>>> clcokInTimeData = Lists.newArrayList();
for (Map<String, Object> needClockIn :needClockInSchedule){
if (CheckBoxEnum.CHECKED.getKey().equals(needClockIn.get("ksdk"))){
String dtkssj = analysisDate+" "+needClockIn.get("dtkssj");
@ -160,6 +162,132 @@ public class TestGetClockInPoint {
clcokInTimeData.add(clcokInTimeMap);
}
}
//当弹性上下班时
if (needClockInSchedule.size() > 0){
//是否弹性
String sfdx = Util.null2String(needClockInSchedule.get(0).get("sfdx"));
//最大弹性分钟
int zddxfz = Integer.valueOf(Util.null2String(needClockInSchedule.get(0).get("zddxfz")));
//弹性核算
int dxhs = Integer.valueOf(Util.null2String(needClockInSchedule.get(0).get("dxhs")));
if (CheckBoxEnum.CHECKED.getKey().equals(sfdx)){
//上下班弹性
List<Map<String, Object>> needClockInStartList = needClockInSchedule.stream().filter(e -> ClassSegmentTypeEnum.WORK_TIME.getKey().equals(e.get("bdlx")) && CheckBoxEnum.CHECKED.getKey().equals(e.get("ksdk"))).collect(Collectors.toList());
List<Map<String, Object>> needClockInEndList = needClockInSchedule.stream().filter(e -> ClassSegmentTypeEnum.WORK_TIME.getKey().equals(e.get("bdlx")) && CheckBoxEnum.CHECKED.getKey().equals(e.get("jsdk"))).collect(Collectors.toList());
if (needClockInStartList.size()>0 && needClockInEndList.size()>0){
Map<String, Object> ksdkMap = needClockInStartList.get(0);
String kssjStart = analysisDate + " " +Util.null2String(ksdkMap.get("dtkssj"));
String jssjStart = analysisDate +" "+Util.null2String(ksdkMap.get("dtjssj"));
Map<String, Object> jsdkMap = needClockInEndList.get(needClockInEndList.size()-1);
int thdkfzs = Integer.valueOf(Util.null2String(jsdkMap.get("thdkfzs")));
String kssjEnd = analysisDate + " " +Util.null2String(jsdkMap.get("dtkssj"));
String jssjEnd = analysisDate +" "+Util.null2String(jsdkMap.get("dtjssj"));
if (ksdkMap != jsdkMap){
if (DateUtil.getTime(kssjStart).compareTo(DateUtil.getTime(jssjStart)) > 0){
kssjStart = DateUtil.beforeDay(analysisDate,1)+" "+Util.null2String(ksdkMap.get("dtkssj"));
}
if (DateUtil.getTime(kssjEnd).compareTo(DateUtil.getTime(jssjEnd)) > 0){
jssjEnd = DateUtil.AfterDay(analysisDate,1)+" "+Util.null2String(jsdkMap.get("dtjssj"));
}
}else {
jssjEnd = DateUtil.AfterDay(analysisDate,1)+" "+Util.null2String(jsdkMap.get("dtjssj"));
}
//弹性上班卡
String flexibleWork = "";
for (int i=0;i<clcokInTimeData.size();i++){
Map<String,Map<String,Object>> clcokInTimeMap = clcokInTimeData.get(i);
//卡点
String point = "";
//当天打卡数据
Map<String,Object> clcokInTime = null;
for (Map.Entry<String,Map<String,Object>> entry :clcokInTimeMap.entrySet()){
point = entry.getKey();
clcokInTime = entry.getValue();
}
//需要计算的班次打卡时间点
String pointTime = point.split("\\|")[0];
//start开始打卡时间点end结束打卡时间点
String pointType = point.split("\\|")[1];
//empty:漏卡equal:打卡时间和班次时间相等before打卡时间在班次时间之前after打卡时间在班次时间之后
String timeType = point.split("\\|")[2];
if (pointTime.equals(kssjStart) && ClockPointEnum.START.getKey().equals(pointType) && clcokInTime != null){
String signTime = clcokInTime.get("signdate")+" "+clcokInTime.get("signtime");
//该卡点是弹性开始时间
if (ClockPointEnum.BEFORE.getKey().equals(timeType)){
int betWeenTime = DateUtil.getBetWeenMinutes(signTime,kssjStart);
String newPonit = point;
if (betWeenTime <= zddxfz){
betWeenTime = Double.valueOf(Utils.getItemdurationDown(5.0, AccountingUnitEnum.MINUTES.getKey(),betWeenTime,AccountingUnitEnum.MINUTES)).intValue();
flexibleWork = DateUtil.beforeMinutes(kssjStart,betWeenTime);
newPonit = pointTime+"|"+pointType+"|"+ClockPointEnum.EQUAL.getKey()+"|"+flexibleWork;
}else if (betWeenTime > zddxfz){
newPonit = point +"|"+DateUtil.beforeMinutes(kssjStart,zddxfz);
flexibleWork = DateUtil.beforeMinutes(kssjStart,zddxfz);
}
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit,clcokInTime);
}else if (ClockPointEnum.AFTER.getKey().equals(timeType)){
//迟到
String newPonit = point;
int betWeenTime = DateUtil.getBetWeenMinutes(kssjStart,signTime);
if (betWeenTime <= zddxfz){
betWeenTime = Double.valueOf(Utils.getItemduration(5.0, AccountingUnitEnum.MINUTES.getKey(),betWeenTime,AccountingUnitEnum.MINUTES)).intValue();
flexibleWork = DateUtil.AfterMinutes(kssjStart,betWeenTime);
newPonit = pointTime+"|"+pointType+"|"+ClockPointEnum.EQUAL.getKey()+"|"+flexibleWork;
}else if (betWeenTime > zddxfz){
newPonit = point +"|"+DateUtil.AfterMinutes(kssjStart,zddxfz);
flexibleWork = DateUtil.AfterMinutes(kssjStart,zddxfz);
}
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit,clcokInTime);
}
}else if (pointTime.equals(jssjEnd) && ClockPointEnum.END.getKey().equals(pointType) && clcokInTime != null){
//该卡点是弹性下班点
int betweenToWorkTime = DateUtil.getBetWeenMinutes(flexibleWork,kssjStart);
//弹性下班时间点
String flexibleOffWork = jssjEnd;
if (betweenToWorkTime >=0){
flexibleOffWork = DateUtil.beforeMinutes(flexibleOffWork,Math.abs(betweenToWorkTime));
}else if (betweenToWorkTime < 0){
flexibleOffWork = DateUtil.AfterMinutes(flexibleOffWork,Math.abs(betweenToWorkTime));
}
//根据弹性下班时间点重新计算
Map<String,Map<String,Object>> jsdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(flexibleOffWork,clockInTimeList);
String newtimeType = ClockPointEnum.EMPTY.getKey();
if (jsdkNearestClcokInTime.get(ClockPointEnum.EQUAL.getKey()) != null){
newtimeType=ClockPointEnum.EQUAL.getKey();
}
if (ClockPointEnum.EMPTY.getKey().equals(newtimeType) && jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()) != null){
String clockInTime = jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signdate") +" "+jsdkNearestClcokInTime.get(ClockPointEnum.AFTER.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(DateUtil.AfterMinutes(flexibleOffWork,thdkfzs))) <=0){
newtimeType=ClockPointEnum.AFTER.getKey();
}
}
if (ClockPointEnum.EMPTY.getKey().equals(newtimeType) && jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()) != null){
String clockInTime = jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signdate") +" "+jsdkNearestClcokInTime.get(ClockPointEnum.BEFORE.getKey()).get("signtime");
if (DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(kssjEnd)) >0){
newtimeType=ClockPointEnum.BEFORE.getKey();
}
}
String newPonit = jssjEnd+"|"+ClockPointEnum.END.getKey()+"|"+newtimeType+"|"+flexibleOffWork;
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit,jsdkNearestClcokInTime.get(newtimeType));
}
}
}
}
}
//当有2笔需要打卡时可能会有打卡歧义的情况歧义情况取2个时间点的中间值当打卡时间小于中间值归属前一个打卡大于则相反
if (clcokInTimeData.size() >1){
for (int i=0;i<clcokInTimeData.size()-1;i++){

Loading…
Cancel
Save