Merge remote-tracking branch 'origin/main'
commit
7ffed5f24e
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -1,74 +0,0 @@
|
||||
package com.engine.attendance.attendanceanalysis.cmd.getclockInpoint;
|
||||
|
||||
import com.engine.attendance.attendanceanalysis.dto.clockpoint.ClockPointDTO;
|
||||
import com.engine.attendance.attendanceanalysis.dto.clockpoint.ClockPointInfo;
|
||||
import com.engine.attendance.enums.ClockPointEnum;
|
||||
import com.engine.common.util.DateUtil;
|
||||
import com.engine.common.util.Utils;
|
||||
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 当卡点成对出现时合并对应的班段
|
||||
*/
|
||||
public class AdjustWhenHaveTwoClockPoint implements AdjustClockPointAction{
|
||||
@Override
|
||||
public List<ClockPointDTO> execute(ClockPointInfo clockPointInfo) {
|
||||
List<ClockPointDTO> clcokInPointList = clockPointInfo.getClcokInPointList();
|
||||
List<Map<String, Object>> scheduleResult = clockPointInfo.getScheduleResult();
|
||||
String analysisDate = clockPointInfo.getAnalysisDate();
|
||||
|
||||
clcokInPointList = clcokInPointList.stream().sorted(Comparator.comparing(e-> DateUtil.getTime(e.getClassTime()).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());
|
||||
|
||||
if (clcokInPointList.size() ==2 && clcokInPointList.get(0).getPointType() == ClockPointEnum.START
|
||||
&& clcokInPointList.get(1).getPointType() == ClockPointEnum.END){
|
||||
if (clcokInPointList.get(0).getTimeType() == ClockPointEnum.EMPTY){
|
||||
//当上班存在漏卡时则全天漏卡
|
||||
for (Map<String, Object> map :scheduleResult){
|
||||
if (!Utils.getkssjTime(map,analysisDate).equals(clcokInPointList.get(0).getClassTime())){
|
||||
clcokInPointList.add(ClockPointDTO.builder().classTime(Utils.getkssjTime(map,analysisDate)).pointType(ClockPointEnum.START).timeType(ClockPointEnum.EMPTY).classSegmentType(map.get("bdlx").toString())
|
||||
.record(false).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (clcokInPointList.get(1).getTimeType() == ClockPointEnum.EMPTY){
|
||||
//当上班存在漏卡时则全天漏卡
|
||||
for (Map<String, Object> map :scheduleResult){
|
||||
if (!Utils.getjssjTime(map,analysisDate).equals(clcokInPointList.get(1).getClassTime())){
|
||||
clcokInPointList.add(ClockPointDTO.builder().classTime(Utils.getjssjTime(map,analysisDate)).pointType(ClockPointEnum.END).timeType(ClockPointEnum.EMPTY).classSegmentType(map.get("bdlx").toString())
|
||||
.record(false).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (clcokInPointList.get(1).getTimeType() != ClockPointEnum.EMPTY && clcokInPointList.get(0).getTimeType() != ClockPointEnum.EMPTY){
|
||||
//上班时间
|
||||
String toWorkTime = clcokInPointList.get(0).getClockTime().get("signdate")+" "+clcokInPointList.get(0).getClockTime().get("signtime");
|
||||
//下班时间
|
||||
String afterWorkTime = clcokInPointList.get(1).getClockTime().get("signdate")+" "+clcokInPointList.get(1).getClockTime().get("signtime");
|
||||
|
||||
|
||||
if (clcokInPointList.get(0).getTimeType() == ClockPointEnum.AFTER){
|
||||
//上班迟到
|
||||
for (Map<String, Object> map :scheduleResult){
|
||||
String kssj = Utils.getkssjTime(map,analysisDate);
|
||||
String jssj = Utils.getjssjTime(map,analysisDate);
|
||||
if (kssj.equals(clcokInPointList.get(0).getClassTime())){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (clcokInPointList.get(1).getTimeType() == ClockPointEnum.BEFORE){
|
||||
//下班早退
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
package com.engine.attendance.attendanceanalysis.cmd.getclockInpoint;
|
||||
|
||||
import com.engine.attendance.attendanceanalysis.dto.clockpoint.ClockPointDTO;
|
||||
import com.engine.attendance.attendanceanalysis.dto.clockpoint.ClockPointInfo;
|
||||
import com.engine.attendance.enums.ClockPointEnum;
|
||||
import com.engine.common.util.DateUtil;
|
||||
import com.engine.common.util.Utils;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 当卡点成对出现时合并对应的班段
|
||||
*/
|
||||
@Slf4j
|
||||
public class MergeApairClockPoint implements AdjustClockPointAction{
|
||||
private String analysisDate;
|
||||
@Override
|
||||
public List<ClockPointDTO> execute(ClockPointInfo clockPointInfo) {
|
||||
List<ClockPointDTO> clcokInPointList = clockPointInfo.getClcokInPointList();
|
||||
List<Map<String, Object>> scheduleResult = clockPointInfo.getScheduleResult();
|
||||
analysisDate = clockPointInfo.getAnalysisDate();
|
||||
clcokInPointList = clcokInPointList.stream().sorted(Comparator.comparing(e-> DateUtil.getTime(e.getClassTime()).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());
|
||||
if (clcokInPointList.size() <= 1){
|
||||
return clcokInPointList;
|
||||
}
|
||||
List<ClockPointDTO> adjustClcokInPointList = Lists.newArrayList();
|
||||
for (int i=0;i<clcokInPointList.size()-1;i++){
|
||||
ClockPointDTO startPointDTO = clcokInPointList.get(i);
|
||||
ClockPointDTO endPointDTO = clcokInPointList.get(i+1);
|
||||
|
||||
if (startPointDTO.getPointType() == ClockPointEnum.START && endPointDTO.getPointType() == ClockPointEnum.END){
|
||||
int startScheduleIndex = getStartScheduleIndex(startPointDTO.getClassTime(),scheduleResult);
|
||||
int endScheduleIndex = getEndScheduleIndex(endPointDTO.getClassTime(),scheduleResult);
|
||||
if (startScheduleIndex == endScheduleIndex){
|
||||
//同属一个班段不用合并
|
||||
i = i+1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (startPointDTO.getTimeType() == ClockPointEnum.EMPTY){
|
||||
//开始漏卡
|
||||
for (int j=startScheduleIndex+1;j<=endScheduleIndex;j++){
|
||||
Map<String, Object> scheduleMap = scheduleResult.get(j);
|
||||
if (!Utils.ifRestClassSegment(scheduleMap.get("bdlx").toString())){
|
||||
ClockPointDTO clockPointDTO = ClockPointDTO.builder().classTime(Utils.getkssjTime(scheduleMap,analysisDate)).pointType(ClockPointEnum.START).timeType(ClockPointEnum.EMPTY)
|
||||
.classSegmentType(scheduleMap.get("bdlx").toString()).record(false).build();
|
||||
adjustClcokInPointList.add(clockPointDTO);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (startPointDTO.getTimeType() == ClockPointEnum.AFTER){
|
||||
//迟到
|
||||
//打卡时间
|
||||
String startClockTime = startPointDTO.getClockTime().get("signdate")+" "+startPointDTO.getClockTime().get("signtime");
|
||||
if (DateUtil.getTime(startClockTime).compareTo(DateUtil.getTime(Utils.getjssjTime(scheduleResult.get(startScheduleIndex),analysisDate))) > 0){
|
||||
int index = getAfterAccordWithScheduleIndex(startClockTime,scheduleResult,startScheduleIndex);
|
||||
for (int j=startScheduleIndex+1;j<=index;j++){
|
||||
Map<String, Object> scheduleMap = scheduleResult.get(j);
|
||||
if (!Utils.ifRestClassSegment(scheduleMap.get("bdlx").toString())){
|
||||
ClockPointDTO clockPointDTO = ClockPointDTO.builder().classTime(Utils.getkssjTime(scheduleMap,analysisDate)).pointType(ClockPointEnum.START).timeType(ClockPointEnum.AFTER)
|
||||
.classSegmentType(scheduleMap.get("bdlx").toString()).record(false).clockTime(startPointDTO.getClockTime()).build();
|
||||
// if (j<index){
|
||||
// clockPointDTO.getClockTime().put("signdate",Utils.getjssjTime(scheduleMap,analysisDate).split(" ")[0]);
|
||||
// clockPointDTO.getClockTime().put("signtime",Utils.getjssjTime(scheduleMap,analysisDate).split(" ")[1]);
|
||||
// }
|
||||
adjustClcokInPointList.add(clockPointDTO);
|
||||
}
|
||||
}
|
||||
// startPointDTO.getClockTime().put("signdate",Utils.getjssjTime(scheduleResult.get(startScheduleIndex),analysisDate).split(" ")[0]);
|
||||
// startPointDTO.getClockTime().put("signtime",Utils.getjssjTime(scheduleResult.get(startScheduleIndex),analysisDate).split(" ")[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (endPointDTO.getTimeType() == ClockPointEnum.EMPTY){
|
||||
//结束漏卡
|
||||
for (int j=startScheduleIndex;j<endScheduleIndex;j++){
|
||||
Map<String, Object> scheduleMap = scheduleResult.get(j);
|
||||
if (!Utils.ifRestClassSegment(scheduleMap.get("bdlx").toString())){
|
||||
ClockPointDTO clockPointDTO = ClockPointDTO.builder().classTime(Utils.getjssjTime(scheduleMap,analysisDate)).pointType(ClockPointEnum.END).timeType(ClockPointEnum.EMPTY)
|
||||
.classSegmentType(scheduleMap.get("bdlx").toString()).record(false).build();
|
||||
adjustClcokInPointList.add(clockPointDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (endPointDTO.getTimeType() == ClockPointEnum.BEFORE){
|
||||
//早退
|
||||
//打卡时间
|
||||
String endClockTime = endPointDTO.getClockTime().get("signdate")+" "+endPointDTO.getClockTime().get("signtime");
|
||||
if (DateUtil.getTime(endClockTime).compareTo(DateUtil.getTime(Utils.getkssjTime(scheduleResult.get(endScheduleIndex),analysisDate))) < 0){
|
||||
int index = getBeforeAccordWithScheduleIndex(endClockTime,scheduleResult,endScheduleIndex);
|
||||
for (int j=index;j<endScheduleIndex;j++){
|
||||
Map<String, Object> scheduleMap = scheduleResult.get(j);
|
||||
if (!Utils.ifRestClassSegment(scheduleMap.get("bdlx").toString())){
|
||||
ClockPointDTO clockPointDTO = ClockPointDTO.builder().classTime(Utils.getjssjTime(scheduleMap,analysisDate)).pointType(ClockPointEnum.END).timeType(ClockPointEnum.BEFORE)
|
||||
.classSegmentType(scheduleMap.get("bdlx").toString()).record(false).clockTime(endPointDTO.getClockTime()).build();
|
||||
// if (j>index){
|
||||
// clockPointDTO.getClockTime().put("signdate",Utils.getkssjTime(scheduleMap,analysisDate).split(" ")[0]);
|
||||
// clockPointDTO.getClockTime().put("signtime",Utils.getkssjTime(scheduleMap,analysisDate).split(" ")[1]);
|
||||
// }
|
||||
adjustClcokInPointList.add(clockPointDTO);
|
||||
}
|
||||
}
|
||||
// endPointDTO.getClockTime().put("signdate",Utils.getkssjTime(scheduleResult.get(endScheduleIndex),analysisDate).split(" ")[0]);
|
||||
// endPointDTO.getClockTime().put("signtime",Utils.getkssjTime(scheduleResult.get(endScheduleIndex),analysisDate).split(" ")[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
i = i+1;
|
||||
}
|
||||
|
||||
}
|
||||
adjustClcokInPointList.addAll(clcokInPointList);
|
||||
log.debug("AdjustByWorkOverTimeCmd : [{}]",adjustClcokInPointList);
|
||||
return adjustClcokInPointList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 往后递归排班
|
||||
* @return
|
||||
*/
|
||||
public int getAfterAccordWithScheduleIndex(String startClockTime,List<Map<String, Object>> scheduleResult,int startScheduleIndex){
|
||||
for (int i=startScheduleIndex+1;i<scheduleResult.size();i++){
|
||||
String kssj = Utils.getkssjTime(scheduleResult.get(i),analysisDate);
|
||||
String jssj = Utils.getjssjTime(scheduleResult.get(i),analysisDate);
|
||||
if (DateUtil.getTime(startClockTime).compareTo(DateUtil.getTime(kssj))>=0 &&
|
||||
DateUtil.getTime(startClockTime).compareTo(DateUtil.getTime(jssj)) <=0){
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
return scheduleResult.size()-1;
|
||||
}
|
||||
/**
|
||||
* 往前递归排班
|
||||
* @return
|
||||
*/
|
||||
public int getBeforeAccordWithScheduleIndex(String endClockTime,List<Map<String, Object>> scheduleResult,int endScheduleIndex){
|
||||
for (int i=endScheduleIndex-1;i>=0;i--){
|
||||
String kssj = Utils.getkssjTime(scheduleResult.get(i),analysisDate);
|
||||
String jssj = Utils.getjssjTime(scheduleResult.get(i),analysisDate);
|
||||
if (DateUtil.getTime(endClockTime).compareTo(DateUtil.getTime(kssj))>=0 &&
|
||||
DateUtil.getTime(endClockTime).compareTo(DateUtil.getTime(jssj)) <=0){
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getStartScheduleIndex(String time,List<Map<String, Object>> scheduleResult){
|
||||
for (int i =0;i<scheduleResult.size();i++){
|
||||
String dtkssj = Utils.getkssjTime(scheduleResult.get(i),analysisDate);
|
||||
if (dtkssj.equals(time)){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public int getEndScheduleIndex(String time,List<Map<String, Object>> scheduleResult){
|
||||
for (int i =0;i<scheduleResult.size();i++){
|
||||
String dtjssj = Utils.getjssjTime(scheduleResult.get(i),analysisDate);
|
||||
if (dtjssj.equals(time)){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.engine.common.util;
|
||||
|
||||
import com.engine.attendance.attendanceanalysis.cmd.getclockInpoint.AdjustClockPointAction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 扩展类
|
||||
*/
|
||||
public class ExtensionClassHolder {
|
||||
/**
|
||||
* 打卡卡点扩展类
|
||||
*/
|
||||
private static ThreadLocal<List<AdjustClockPointAction>> adjustClockPointActionThreadLocal = new ThreadLocal<>();
|
||||
|
||||
public static void setAdjustClockPointAction(List<AdjustClockPointAction> adjustClockPointActionList) {
|
||||
adjustClockPointActionThreadLocal.set(adjustClockPointActionList);
|
||||
}
|
||||
|
||||
public static List<AdjustClockPointAction> getAdjustClockPointAction() {
|
||||
return adjustClockPointActionThreadLocal.get();
|
||||
}
|
||||
}
|
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.
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.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue