You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

874 lines
54 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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.time.ZoneOffset;
import java.util.Comparator;
import java.util.HashMap;
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>> scheduleResult = (List<Map<String, Object>>) params.get("scheduleResult");
List<Map<String, Object>> clockInTimeList = (List<Map<String, Object>>) params.get("clockInTimeList");
List<Map<String, Object>> askForLeaveAndEvctionScheduleList = (List<Map<String, Object>>) params.get("askForLeaveAndEvctionSchedule");
List<Map<String, Object>> needClockInList = 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());
/**
* 当请假或外出开始时间和外出时间在上班之外时,不需要打卡
*/
log.info("未重新计算卡点时 老的scheduleResult : [{}],askForLeaveAndEvctionScheduleList:[{}]",scheduleResult,askForLeaveAndEvctionScheduleList);
boolean ifStartNeedClock=false;
boolean ifEndNeedClock=false;
if (needClockInList.size() > 0 && askForLeaveAndEvctionScheduleList.size() > 0) {
String startTime = Utils.getkssjTime(needClockInList.get(0),analysisDate);
String endStartTime = Utils.getkssjTime(needClockInList.get(needClockInList.size()-1),analysisDate);
String endTime = Utils.getjssjTime(needClockInList.get(needClockInList.size()-1),analysisDate);
for (Map<String, Object> askForLeaveAndEvctionSchedule :askForLeaveAndEvctionScheduleList){
String dtkssj = Utils.getkssjTime(askForLeaveAndEvctionSchedule,analysisDate);
String dtjssj = Utils.getjssjTime(askForLeaveAndEvctionSchedule,analysisDate);
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(startTime))<=0 || DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(endTime)) >= 0){
askForLeaveAndEvctionSchedule.put("ksdk",CheckBoxEnum.UNCHECKED.getKey());
}
if (DateUtil.getTime(dtjssj).compareTo(DateUtil.getTime(endTime))>=0 || DateUtil.getTime(dtjssj).compareTo(DateUtil.getTime(startTime))<=0){
askForLeaveAndEvctionSchedule.put("jsdk",CheckBoxEnum.UNCHECKED.getKey());
}
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(startTime))<=0 && DateUtil.getTime(dtjssj).compareTo(DateUtil.getTime(endTime))<0 && DateUtil.getTime(dtjssj).compareTo(DateUtil.getTime(startTime)) >0){
//骑在开始上班时间
for (Map<String,Object> needClockMap:needClockInList){
String kssj = Utils.getkssjTime(needClockMap,analysisDate);
String jssj = Utils.getjssjTime(needClockMap,analysisDate);
if (CheckBoxEnum.CHECKED.getKey().equals(needClockMap.get("ksdk")) && DateUtil.getTime(dtjssj).compareTo(DateUtil.getTime(jssj)) >=0){
ifStartNeedClock=true;
}
}
}
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(startTime)) > 0 && DateUtil.getTime(dtjssj).compareTo(DateUtil.getTime(endTime))>=0 && DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(endTime)) < 0){
//骑在下班时间
for (Map<String,Object> needClockMap:needClockInList){
String kssj = Utils.getkssjTime(needClockMap,analysisDate);
if (CheckBoxEnum.CHECKED.getKey().equals(needClockMap.get("jsdk")) && DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(kssj)) <=0){
ifEndNeedClock=true;
}
}
}
}
}
/**
* 当请假或外出包含打卡卡点时,判断该卡点是否需要打卡
*/
for (Map<String, Object> askForLeaveAndEvctionMap :askForLeaveAndEvctionScheduleList){
String evctiondtkssj = Utils.getkssjTime(askForLeaveAndEvctionMap,analysisDate);
String evctionksdk = Util.null2String(askForLeaveAndEvctionMap.get("ksdk"));
String evctiondtjssj = Utils.getjssjTime(askForLeaveAndEvctionMap,analysisDate);
String evctionjsdk = Util.null2String(askForLeaveAndEvctionMap.get("jsdk"));
List<String> lists = Lists.newArrayList();
for (int i=0;i<scheduleResult.size();i++){
String dtkssj = Utils.getkssjTime(scheduleResult.get(i),analysisDate);
String dtjssj = Utils.getjssjTime(scheduleResult.get(i),analysisDate);
String bdlx = Util.null2String(scheduleResult.get(i).get("bdlx"));
if (DateUtil.getTime(evctiondtkssj).compareTo(DateUtil.getTime(dtkssj)) <= 0 && DateUtil.getTime(evctiondtjssj).compareTo(DateUtil.getTime(dtkssj)) >=0
&& !ClassSegmentTypeEnum.REST_AND_DINE.getKey().equals(bdlx) && !ClassSegmentTypeEnum.REST_PERIOD.getKey().equals(bdlx) && !ClassSegmentTypeEnum.DINING_PERIOD.getKey().equals(bdlx)){
lists.add(dtkssj+"&"+ClockPointEnum.START.getKey()+"&"+Util.null2String(scheduleResult.get(i).get("ksdk")));
}
if (DateUtil.getTime(evctiondtkssj).compareTo(DateUtil.getTime(dtjssj)) <= 0 && DateUtil.getTime(evctiondtjssj).compareTo(DateUtil.getTime(dtjssj)) >=0
&& !ClassSegmentTypeEnum.REST_AND_DINE.getKey().equals(bdlx) && !ClassSegmentTypeEnum.REST_PERIOD.getKey().equals(bdlx) && !ClassSegmentTypeEnum.DINING_PERIOD.getKey().equals(bdlx)){
lists.add(dtjssj+"&"+ClockPointEnum.END.getKey()+"&"+Util.null2String(scheduleResult.get(i).get("jsdk")));
}
}
//新打卡
List<String> newNeedClockLists = Lists.newArrayList();
//时间-结束卡\开始卡-是否打卡
if (lists.size() == 1){
String str = lists.get(0);
if (ClockPointEnum.START.getKey().equals(str.split("&")[1]) && CheckBoxEnum.CHECKED.getKey().equals(evctionjsdk)){
newNeedClockLists.add(str.split("&")[0]+"&"+str.split("&")[1]+"&0");
}else if (ClockPointEnum.END.getKey().equals(str.split("-")[1]) && CheckBoxEnum.CHECKED.getKey().equals(evctionksdk)){
newNeedClockLists.add(str.split("&")[0]+"&"+str.split("&")[1]+"&0");
}
}else if (lists.size() > 1){
for(int i=0;i<lists.size();i++){
String str = lists.get(i);
if (i ==0){
if (CheckBoxEnum.CHECKED.getKey().equals(evctionksdk) || ClockPointEnum.START.getKey().equals(str.split("&")[1])){
newNeedClockLists.add(str.split("&")[0]+"&"+str.split("&")[1]+"&0");
}
}else if (i == lists.size()-1){
if (CheckBoxEnum.CHECKED.getKey().equals(evctionjsdk) || ClockPointEnum.END.getKey().equals(str.split("&")[1])){
newNeedClockLists.add(str.split("&")[0]+"&"+str.split("&")[1]+"&0");
}
}else {
newNeedClockLists.add(str.split("&")[0]+"&"+str.split("&")[1]+"&0");
}
}
}
for (int i=0;i<scheduleResult.size();i++){
String dtkssj = Utils.getkssjTime(scheduleResult.get(i),analysisDate);
String dtjssj = Utils.getjssjTime(scheduleResult.get(i),analysisDate);
for (String newNeedClock : newNeedClockLists){
if (ClockPointEnum.START.getKey().equals(newNeedClock.split("&")[1])){
if (newNeedClock.split("&")[0].equals(dtkssj)){
scheduleResult.get(i).put("ksdk",newNeedClock.split("&")[2]);
}
}else if (ClockPointEnum.END.getKey().equals(newNeedClock.split("&")[1])){
if (newNeedClock.split("&")[0].equals(dtjssj)){
scheduleResult.get(i).put("jsdk",newNeedClock.split("&")[2]);
}
}
}
}
}
if (askForLeaveAndEvctionScheduleList.size() > 0){
scheduleResult.addAll(askForLeaveAndEvctionScheduleList);
scheduleResult = scheduleResult.stream().sorted(Comparator.comparing(e->DateUtil.getTime(Utils.getkssjTime(e,analysisDate)).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());
}
List<String> needClockDateList = Lists.newArrayList();
for (int i=0;i<scheduleResult.size();i++){
String dtkssj = Utils.getkssjTime(scheduleResult.get(i),analysisDate);
String dtjssj = Utils.getjssjTime(scheduleResult.get(i),analysisDate);
if (CheckBoxEnum.CHECKED.getKey().equals(scheduleResult.get(i).get("ksdk"))) {
needClockDateList.add(dtkssj);
}
if (CheckBoxEnum.CHECKED.getKey().equals(scheduleResult.get(i).get("jsdk"))){
needClockDateList.add(dtjssj);
}
}
/**
* 当请假时间或出差时间包含最早上班时间和最晚下班时间时,补偿机制
*/
if (needClockDateList.size() == 1){
for (int i=0;i<scheduleResult.size();i++){
String dtkssj = Util.null2String(scheduleResult.get(i).get("dtkssj"));
String dtjssj = Util.null2String(scheduleResult.get(i).get("dtjssj"));
String bdlx = Util.null2String(scheduleResult.get(i).get("bdlx"));
if (ifStartNeedClock && needClockInList.get(0).get("dtkssj").equals(dtkssj) &&
!ClassSegmentTypeEnum.EVECTION.getKey().equals(bdlx) &&
!ClassSegmentTypeEnum.ASK_FOR_LEAVE.getKey().equals(bdlx)){
scheduleResult.get(i).put("ksdk",CheckBoxEnum.CHECKED.getKey());
needClockDateList.add(0,Utils.getkssjTime(scheduleResult.get(i),analysisDate));
break;
}
if (ifEndNeedClock && needClockInList.get(needClockInList.size()-1).get("dtjssj").equals(dtjssj) &&
!ClassSegmentTypeEnum.EVECTION.getKey().equals(bdlx) &&
!ClassSegmentTypeEnum.ASK_FOR_LEAVE.getKey().equals(bdlx)){
scheduleResult.get(i).put("jsdk",CheckBoxEnum.CHECKED.getKey());
dtkssj = Utils.getkssjTime(scheduleResult.get(i),analysisDate);
dtjssj = Utils.getjssjTime(scheduleResult.get(i),analysisDate);
needClockDateList.add(dtjssj);
break;
}
}
}
log.info("经过重新计算卡点时 新的scheduleResult : [{}]",scheduleResult);
List<Map<String, Map<String, Object>>> clcokInTimeData = getClockInPoint(analysisDate, scheduleResult, clockInTimeList,needClockDateList);
log.info("clcokInTimeData :[{}]",clcokInTimeData);
resultMap.put("clcokInTimeData", clcokInTimeData);
return resultMap;
}
/**
* 获取打卡卡点
*
* @param analysisDate 分析日期
* @param scheduleResult 需要打卡的班次
* @param clockInTimeList 打卡集合
* @param needClockDateList 需要打卡的时间点
* @return {2023-11-12 09:00|0|3|2023-11-12 09:15 ={signtime=09:11:00, id=48, userid=53, signdate=2023-11-12}}
* 班次时间|打卡类型(上班卡或下班卡)|打卡时间处所在位置|timeType|弹性时间 = 打卡时间map集合
*/
public List<Map<String, Map<String, Object>>> getClockInPoint(String analysisDate, List<Map<String, Object>> scheduleResult, List<Map<String, Object>> clockInTimeList, List<String> needClockDateList) {
List<Map<String, Map<String, Object>>> clcokInTimeData = Lists.newArrayList();
for (Map<String, Object> needClockIn : scheduleResult) {
/**非请假外出开始打卡逻辑处理*/
if (CheckBoxEnum.CHECKED.getKey().equals(needClockIn.get("ksdk")) && !ClassSegmentTypeEnum.EVECTION.getKey().equals(needClockIn.get("bdlx")) &&
!ClassSegmentTypeEnum.ASK_FOR_LEAVE.getKey().equals(needClockIn.get("bdlx"))) {
String dtkssj = Utils.getkssjTime(needClockIn,analysisDate);
String dtjssj = Utils.getjssjTime(needClockIn,analysisDate);
//计算最大提前打卡分钟数
int tqdkfzs = 60;
if (Util.null2String(needClockIn.get("tqdkfzs")).equals("") && !"".equals(getBeforeClockTime(needClockDateList,dtkssj))){
tqdkfzs = DateUtil.getBetWeenMinutes(getBeforeClockTime(needClockDateList,dtkssj),dtkssj);
}else {
tqdkfzs = Util.null2String(needClockIn.get("tqdkfzs")).equals("")?60:Integer.valueOf(needClockIn.get("tqdkfzs").toString());
}
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 &&
(getBeforeClockTime(needClockDateList,dtkssj).equals("") || DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,dtkssj))) > 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 (getNextClockTime(needClockDateList,dtkssj).equals("") || DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,dtkssj))) < 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")) && !ClassSegmentTypeEnum.EVECTION.getKey().equals(needClockIn.get("bdlx")) &&
!ClassSegmentTypeEnum.ASK_FOR_LEAVE.getKey().equals(needClockIn.get("bdlx"))) {
String dtkssj = Utils.getkssjTime(needClockIn,analysisDate);
String dtjssj = Utils.getjssjTime(needClockIn,analysisDate);
//计算最大退后打卡分钟数
int thdkfzs = 60;
if (Util.null2String(needClockIn.get("thdkfzs")).equals("") && !"".equals(getNextClockTime(needClockDateList,dtjssj))){
thdkfzs = DateUtil.getBetWeenMinutes(dtjssj,getNextClockTime(needClockDateList,dtjssj));
}else {
thdkfzs = Util.null2String(needClockIn.get("thdkfzs")).equals("")?60:Integer.valueOf(needClockIn.get("thdkfzs").toString());
}
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 &&
(getNextClockTime(needClockDateList,dtjssj).equals("") || DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,dtjssj))) < 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 (getBeforeClockTime(needClockDateList,dtjssj).equals("") || DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,dtjssj))) > 0) {
timeType = ClockPointEnum.BEFORE.getKey();
}
}
clcokInTimeMap.put(dtjssj + "|" + ClockPointEnum.END.getKey() + "|" + timeType, jsdkNearestClcokInTime.get(timeType));
clcokInTimeData.add(clcokInTimeMap);
}
/**
* 请假外出的开始打卡处理
*/
if (CheckBoxEnum.CHECKED.getKey().equals(needClockIn.get("ksdk")) && (ClassSegmentTypeEnum.EVECTION.getKey().equals(needClockIn.get("bdlx")) ||
ClassSegmentTypeEnum.ASK_FOR_LEAVE.getKey().equals(needClockIn.get("bdlx")))){
String dtkssj = Utils.getkssjTime(needClockIn,analysisDate);
int thdkfzs = Integer.valueOf(Util.null2String(needClockIn.get("thdkfzs")));
if (!"".equals(getNextClockTime(needClockDateList,dtkssj))){
DateUtil.getBetWeenMinutes(dtkssj,getNextClockTime(needClockDateList,dtkssj));
}
Map<String, Map<String, Object>> jsdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(dtkssj, 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(dtkssj, thdkfzs))) <= 0 &&
(getNextClockTime(needClockDateList,dtkssj).equals("") || DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,dtkssj))) < 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 (getBeforeClockTime(needClockDateList,dtkssj).equals("") || DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,dtkssj))) > 0) {
timeType = ClockPointEnum.BEFORE.getKey();
}
}
clcokInTimeMap.put(dtkssj + "|" + ClockPointEnum.END.getKey() + "|" + timeType+"|0", jsdkNearestClcokInTime.get(timeType));
clcokInTimeData.add(clcokInTimeMap);
}
/**
* 请假外出的结束打卡处理
*/
if (CheckBoxEnum.CHECKED.getKey().equals(needClockIn.get("jsdk")) && (ClassSegmentTypeEnum.EVECTION.getKey().equals(needClockIn.get("bdlx")) ||
ClassSegmentTypeEnum.ASK_FOR_LEAVE.getKey().equals(needClockIn.get("bdlx")))){
String dtkssj = Utils.getkssjTime(needClockIn,analysisDate);
String dtjssj = Utils.getjssjTime(needClockIn,analysisDate);
int tqdkfzs = Integer.valueOf(Util.null2String(needClockIn.get("tqdkfzs")));
if (!"".equals(getBeforeClockTime(needClockDateList,dtjssj))){
tqdkfzs = DateUtil.getBetWeenMinutes(getBeforeClockTime(needClockDateList,dtjssj),dtjssj);
}
Map<String, Map<String, Object>> ksdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(dtjssj, 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(dtjssj, tqdkfzs))) >= 0 &&
(getBeforeClockTime(needClockDateList,dtjssj).equals("") || DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,dtjssj))) > 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 (getNextClockTime(needClockDateList,dtjssj).equals("") || DateUtil.getTime(clockInTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,dtjssj))) < 0) {
//打卡时间小于结束时间
timeType = ClockPointEnum.AFTER.getKey();
}
}
clcokInTimeMap.put(dtjssj + "|" + ClockPointEnum.START.getKey() + "|" + timeType+"|0", ksdkNearestClcokInTime.get(timeType));
clcokInTimeData.add(clcokInTimeMap);
}
}
clcokInTimeData = clcokInTimeData.stream().sorted(Comparator.comparing(e->{
//卡点
String point = "";
//当天打卡数据
for (Map.Entry<String,Map<String,Object>> entry :e.entrySet()){
point = entry.getKey();
}
return DateUtil.getTime(point.split("\\|")[0]).toInstant(ZoneOffset.of("+8")).toEpochMilli();
})).collect(Collectors.toList());
/**
* 计算弹性上下班
*/ //上下班弹性,
List<Map<String, Object>> workScheduleList = scheduleResult.stream().filter(e -> ClassSegmentTypeEnum.WORK_TIME.getKey().equals(e.get("bdlx")) || ClassSegmentTypeEnum.EARLY_OVERTIME.getKey().equals(e.get("bdlx"))).collect(Collectors.toList());
if (scheduleResult.size() > 0 && workScheduleList.size()>0) {
//请假和外出集合
List<Map<String, Object>> leaveAndEvctionList = scheduleResult.stream().filter(e -> ClassSegmentTypeEnum.ASK_FOR_LEAVE.getKey().equals(e.get("bdlx")) ||
ClassSegmentTypeEnum.EVECTION.getKey().equals(e.get("bdlx"))).collect(Collectors.toList());
//是否弹性
String sfdx = Util.null2String(workScheduleList.get(0).get("sfdx"));
//上班是否需要打卡
String ifToWorkClock = Util.null2String(workScheduleList.get(0).get("ksdk"));
//下班是否需要打卡
String ifToCloseClock = Util.null2String(workScheduleList.get(workScheduleList.size()-1).get("jsdk"));
//第一条工作时段、早上加班
if (workScheduleList.size() > 0 && CheckBoxEnum.CHECKED.getKey().equals(sfdx)) {
//最大弹性分钟
int zddxfz = Integer.valueOf(Util.null2String(workScheduleList.get(0).get("zddxfz")));
//弹性核算
int dxhs = Integer.valueOf(Util.null2String(workScheduleList.get(0).get("dxhs")));
Map<String, Object> ksdkMap = workScheduleList.get(0);
//最早上班时间
String kssjStart = Utils.getkssjTime(ksdkMap,analysisDate);
Map<String, Object> jsdkMap = workScheduleList.get(workScheduleList.size() - 1);
//最晚下班时间
int thdkfzs = Integer.valueOf(Util.null2String(jsdkMap.get("thdkfzs")).equals("")?"60":Util.null2String(jsdkMap.get("thdkfzs")));
String jssjEnd = Utils.getjssjTime(jsdkMap,analysisDate);
//弹性上班时间
String flexibleWorkTime = "";
//弹性下班时间
String flexibleOffWorkTime="";
if (leaveAndEvctionList.size() >0){
//第一笔请假、外出时间
Map<String, Object> leaveAndEvctionMap = leaveAndEvctionList.get(0);
String leaveAndEvctionkssj = Utils.getkssjTime(leaveAndEvctionMap,analysisDate);
//最大开始弹性时间
String minkssjStart = DateUtil.beforeMinutes(kssjStart,zddxfz);
String maxkssjStart = DateUtil.AfterMinutes(kssjStart,zddxfz);
//请假开始时间在最大开始弹性时间之内
if (DateUtil.getTime(leaveAndEvctionkssj).compareTo(DateUtil.getTime(maxkssjStart))<=0){
//弹性上班卡
flexibleWorkTime = leaveAndEvctionkssj;
if (DateUtil.getTime(leaveAndEvctionkssj).compareTo(DateUtil.getTime(minkssjStart)) <0){
flexibleWorkTime=minkssjStart;
}
//弹性下班时间点
int betweenToWorkTime = DateUtil.getBetWeenMinutes(flexibleWorkTime, kssjStart);
//弹性下班时间点
flexibleOffWorkTime = jssjEnd;
if (betweenToWorkTime >= 0) {
flexibleOffWorkTime = DateUtil.beforeMinutes(flexibleOffWorkTime, Math.abs(betweenToWorkTime));
} else if (betweenToWorkTime < 0) {
flexibleOffWorkTime = DateUtil.AfterMinutes(flexibleOffWorkTime, Math.abs(betweenToWorkTime));
}
}
}
//弹性上班卡
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
&& CheckBoxEnum.CHECKED.getKey().equals(ifToWorkClock)) {
String signTime = clcokInTime.get("signdate") + " " + clcokInTime.get("signtime");
//该卡点是弹性开始时间
if ("".equals(flexibleWorkTime) ){
//弹性上班期间未被请假开始时间占据
if (ClockPointEnum.BEFORE.getKey().equals(timeType)) {
int betWeenTime = DateUtil.getBetWeenMinutes(signTime, kssjStart);
String newPonit = point;
if (betWeenTime <= zddxfz) {
betWeenTime = Double.valueOf(Utils.getItemdurationDown(dxhs, AccountingUnitEnum.MINUTES.getKey(), betWeenTime, AccountingUnitEnum.MINUTES)).intValue();
flexibleWorkTime = DateUtil.beforeMinutes(kssjStart, betWeenTime);
newPonit = pointTime + "|" + pointType + "|" + ClockPointEnum.EQUAL.getKey() + "|" + flexibleWorkTime;
} else if (betWeenTime > zddxfz) {
flexibleWorkTime = DateUtil.beforeMinutes(kssjStart, zddxfz);
newPonit = point + "|" + flexibleWorkTime;
}
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(dxhs, AccountingUnitEnum.MINUTES.getKey(), betWeenTime, AccountingUnitEnum.MINUTES)).intValue();
flexibleWorkTime = DateUtil.AfterMinutes(kssjStart, betWeenTime);
newPonit = pointTime + "|" + pointType + "|" + ClockPointEnum.EQUAL.getKey() + "|" + flexibleWorkTime;
} else if (betWeenTime > zddxfz) {
flexibleWorkTime = DateUtil.AfterMinutes(kssjStart, zddxfz);
newPonit = point + "|" + flexibleWorkTime;
}
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit, clcokInTime);
}
}else {
//弹性上班期间被请假开始时间占据
String newPonit = point +"|"+flexibleWorkTime;
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit, clcokInTime);
}
} else if (pointTime.equals(jssjEnd) && ClockPointEnum.END.getKey().equals(pointType) && CheckBoxEnum.CHECKED.getKey().equals(ifToCloseClock)) {
//该卡点是弹性下班点
if ("".equals(flexibleOffWorkTime) && !"".equals(flexibleWorkTime)){
int betweenToWorkTime = DateUtil.getBetWeenMinutes(flexibleWorkTime, kssjStart);
//弹性下班时间点
flexibleOffWorkTime = jssjEnd;
if (betweenToWorkTime >= 0) {
flexibleOffWorkTime = DateUtil.beforeMinutes(flexibleOffWorkTime, Math.abs(betweenToWorkTime));
} else if (betweenToWorkTime < 0) {
flexibleOffWorkTime = DateUtil.AfterMinutes(flexibleOffWorkTime, Math.abs(betweenToWorkTime));
}
}
if (!"".equals(flexibleOffWorkTime)){
//根据弹性下班时间点重新计算
Map<String, Map<String, Object>> jsdkNearestClcokInTime = Utils.getNearestClcokInTimeCmd(flexibleOffWorkTime, 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(flexibleOffWorkTime, 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(getBeforeClockTime(needClockDateList,jssjEnd))) > 0) {
newtimeType = ClockPointEnum.BEFORE.getKey();
}
}
String newPonit = jssjEnd + "|" + ClockPointEnum.END.getKey() + "|" + newtimeType + "|" + flexibleOffWorkTime;
clcokInTimeMap.remove(point);
clcokInTimeMap.put(newPonit, jsdkNearestClcokInTime.get(newtimeType));
}
}
}
}
}
/**
* 计算休息时间段的弹性上下班
*/
if (scheduleResult.size() > 0) {
List<Map<String, Object>> restScheduleList = 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());
for (int i=0;i<restScheduleList.size();i++){
Map<String, Object> restSchedule = restScheduleList.get(i);
String dtsfdx = Util.null2String(restSchedule.get("dtsfdx"));
String dtzddxfz = Util.null2String(restSchedule.get("dtzddxfz"));
String dtdxhs = Util.null2String(restSchedule.get("dtdxhs"));
if (CheckBoxEnum.CHECKED.getKey().equals(dtsfdx)){
}
}
}
/**
* 当有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];
if (beforeClcokInTime.split("\\|").length ==4 && !"0".equals(beforeClcokInTime.split("\\|")[3])){
beforeTime = beforeClcokInTime.split("\\|")[3];
}
String afterTime = afterClcokInTime.split("\\|")[0];
if (afterClcokInTime.split("\\|").length ==4 && !"0".equals(afterClcokInTime.split("\\|")[3])){
afterTime = afterClcokInTime.split("\\|")[3];
}
long betWeenMinutes = DateUtil.getBetWeenMinutes(beforeTime, afterTime);
String middileTime = DateUtil.AfterMinutes(beforeTime, betWeenMinutes / 2);
String signdateTime = beforeClcokInTimeMap.get("signdate") + " " + beforeClcokInTimeMap.get("signtime");
String resetClcokInTime ="";
Map<String, Map<String, Object>> resetClcokInTimeData = null;
if (DateUtil.getTime(signdateTime).compareTo(DateUtil.getTime(middileTime)) <= 0) {
//该打卡归属前一个打卡点,后一个打卡点需要重新设置
resetClcokInTime = afterClcokInTime;
resetClcokInTimeData = afterClcokInTimeData;
} else if (DateUtil.getTime(signdateTime).compareTo(DateUtil.getTime(middileTime)) > 0) {
//该打卡归属后一个打卡点,前一个打卡点需要重新设置
resetClcokInTime=beforeClcokInTime;
resetClcokInTimeData = beforeClcokInTimeData;
}
//需要重新赋值的打卡时间
String restTime = resetClcokInTime.split("\\|")[0];
if (resetClcokInTime.split("\\|").length ==4 && !"0".equals(resetClcokInTime.split("\\|")[3])){
restTime = resetClcokInTime.split("\\|")[3];
}
Map<String, Map<String, Object>> nearestClcokInTime = Utils.getNearestClcokInTimeCmd(restTime, clockInTimeList);
//start开始打卡时间点end结束打卡时间点
String pointType = resetClcokInTime.split("\\|")[1];
//empty:漏卡equal:打卡时间和班次时间相等before打卡时间在班次时间之前after打卡时间在班次时间之后
String timeType = resetClcokInTime.split("\\|")[2];
String time = resetClcokInTime.split("\\|")[0];
String newPonit = time+"|"+pointType;
String newtimeType = "";
if (timeType.equals(ClockPointEnum.BEFORE.getKey())){
newtimeType = ClockPointEnum.AFTER.getKey();
}else if (timeType.equals(ClockPointEnum.AFTER.getKey())){
newtimeType = ClockPointEnum.BEFORE.getKey();
}
if (nearestClcokInTime.get(newtimeType) != null){
newPonit = newPonit +"|"+newtimeType;
if (resetClcokInTime.split("\\|").length ==4){
newPonit = newPonit +"|"+resetClcokInTime.split("\\|")[3];
}
Map<String, Object> newClockTimeMap = nearestClcokInTime.get(newtimeType);
String newClockTime = newClockTimeMap.get("signdate")+ " "+newClockTimeMap.get("signtime");
int index = clcokInTimeData.indexOf(resetClcokInTimeData);
if (newtimeType.equals(ClockPointEnum.BEFORE.getKey())){
if (!getBeforeClockTime(needClockDateList,time).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,time))) <= 0){
newClockTimeMap = null;
}
if ((index-1) >= 0){
//当重新需要打卡的时间戳与打卡时间之前的打卡集合时,进行比对
Map<String, Map<String, Object>> resetBeforeData = clcokInTimeData.get(index-1);
Map<String, Object> resetBeforeClcokInTimeMap = null;
for (Map.Entry<String, Map<String, Object>> resetBeforeEntry : resetBeforeData.entrySet()) {
resetBeforeClcokInTimeMap = resetBeforeEntry.getValue();
}
if (newClockTimeMap == resetBeforeClcokInTimeMap){
newClockTimeMap = null;
}
}
}else if (newtimeType.equals(ClockPointEnum.AFTER.getKey())){
if (!getNextClockTime(needClockDateList,time).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,time))) >= 0){
newClockTimeMap = null;
}
}
if (newClockTimeMap == null){
//当需要调整的卡点为漏卡时将打卡进行退回,若另一个卡点调整后为不漏卡情况,则调整该节点
if (resetClcokInTimeData == beforeClcokInTimeData){
resetClcokInTime = afterClcokInTime;
resetClcokInTimeData = afterClcokInTimeData;
}else if (resetClcokInTimeData == afterClcokInTimeData){
resetClcokInTime=beforeClcokInTime;
resetClcokInTimeData = beforeClcokInTimeData;
}
if (!resetClcokInTimeData(analysisDate,resetClcokInTime,resetClcokInTimeData,clockInTimeList,needClockDateList,clcokInTimeData,scheduleResult)){
if (resetClcokInTimeData == beforeClcokInTimeData){
resetClcokInTimeData = afterClcokInTimeData;
}else if (resetClcokInTimeData == afterClcokInTimeData){
resetClcokInTimeData = beforeClcokInTimeData;
}
clcokInTimeData.remove(resetClcokInTimeData);
resetClcokInTimeData = Maps.newHashMap();
resetClcokInTimeData.put(newPonit,newClockTimeMap);
clcokInTimeData.add(index,resetClcokInTimeData);
}
}else {
clcokInTimeData.remove(resetClcokInTimeData);
resetClcokInTimeData = Maps.newHashMap();
resetClcokInTimeData.put(newPonit,newClockTimeMap);
clcokInTimeData.add(index,resetClcokInTimeData);
}
}else {
if (resetClcokInTimeData == beforeClcokInTimeData){
resetClcokInTime = afterClcokInTime;
resetClcokInTimeData = afterClcokInTimeData;
}else if (resetClcokInTimeData == afterClcokInTimeData){
resetClcokInTime=beforeClcokInTime;
resetClcokInTimeData = beforeClcokInTimeData;
}
if (!resetClcokInTimeData(analysisDate,resetClcokInTime,resetClcokInTimeData,clockInTimeList,needClockDateList,clcokInTimeData,scheduleResult)){
if (resetClcokInTimeData == beforeClcokInTimeData){
resetClcokInTime = afterClcokInTime;
resetClcokInTimeData = afterClcokInTimeData;
}else if (resetClcokInTimeData == afterClcokInTimeData){
resetClcokInTime=beforeClcokInTime;
resetClcokInTimeData = beforeClcokInTimeData;
}
resetClcokInTimeData.put(resetClcokInTime, null);
}
}
}
}
}
return clcokInTimeData;
}
public String getNextClockTime(List<String> needClockDateList,String time){
int index = 0;
for (int i=0;i<needClockDateList.size();i++){
if (needClockDateList.get(i).equals(time)){
index = i+1;
break;
}
}
if (index < needClockDateList.size() && index!=0){
return needClockDateList.get(index);
}else {
return "";
}
}
public String getBeforeClockTime(List<String> needClockDateList,String time){
int index = 0;
for (int i=0;i<needClockDateList.size();i++){
if (needClockDateList.get(i).equals(time)){
index = i-1;
break;
}
}
if (index >= 0){
return needClockDateList.get(index);
}else {
return "";
}
}
public boolean resetClcokInTimeData(String analysisDate,String resetClcokInTime,Map<String, Map<String, Object>> resetClcokInTimeData,List<Map<String, Object>> clockInTimeList, List<String> needClockDateList,List<Map<String, Map<String, Object>>> clcokInTimeData,List<Map<String, Object>> scheduleResult){
String restTime = resetClcokInTime.split("\\|")[0];
if (resetClcokInTime.split("\\|").length ==4 && !"0".equals(resetClcokInTime.split("\\|")[3])){
restTime = resetClcokInTime.split("\\|")[3];
}
Map<String, Map<String, Object>> nearestClcokInTime = Utils.getNearestClcokInTimeCmd(restTime, clockInTimeList);
//start开始打卡时间点end结束打卡时间点
String pointType = resetClcokInTime.split("\\|")[1];
//empty:漏卡equal:打卡时间和班次时间相等before打卡时间在班次时间之前after打卡时间在班次时间之后
String timeType = resetClcokInTime.split("\\|")[2];
String time = resetClcokInTime.split("\\|")[0];
String newPonit = time+"|"+pointType;
String newtimeType = "";
if (timeType.equals(ClockPointEnum.BEFORE.getKey())){
newtimeType = ClockPointEnum.AFTER.getKey();
}else if (timeType.equals(ClockPointEnum.AFTER.getKey())){
newtimeType = ClockPointEnum.BEFORE.getKey();
}
if (nearestClcokInTime.get(newtimeType) != null){
newPonit = newPonit +"|"+newtimeType;
if (resetClcokInTime.split("\\|").length ==4){
newPonit = newPonit +"|"+resetClcokInTime.split("\\|")[3];
}
Map<String, Object> newClockTimeMap = nearestClcokInTime.get(newtimeType);
String newClockTime = newClockTimeMap.get("signdate")+ " "+newClockTimeMap.get("signtime");
int index = clcokInTimeData.indexOf(resetClcokInTimeData);
if (newtimeType.equals(ClockPointEnum.BEFORE.getKey())){
if (pointType.equals(ClockPointEnum.START.getKey())){
//开始卡点
Map<String,Object> needClockIn = scheduleResult.stream().filter(e -> {
String dtkssj = Utils.getkssjTime(e,analysisDate);
if (time.equals(dtkssj)){
return true;
}else {
return false;
}
}).collect(Collectors.toList()).get(0);
//计算最大提前打卡分钟数
int tqdkfzs = 60;
if (Util.null2String(needClockIn.get("tqdkfzs")).equals("") && !"".equals(getBeforeClockTime(needClockDateList,restTime))){
tqdkfzs = DateUtil.getBetWeenMinutes(getBeforeClockTime(needClockDateList,restTime),restTime);
}else {
tqdkfzs = Util.null2String(needClockIn.get("tqdkfzs")).equals("")?60:Integer.valueOf(needClockIn.get("tqdkfzs").toString());
}
if (DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(DateUtil.beforeMinutes(restTime, tqdkfzs))) < 0){
newClockTimeMap =null;
}
}
if (!getBeforeClockTime(needClockDateList,time).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,time))) <= 0){
newClockTimeMap = null;
}
if ((index-1) >= 0){
//当重新需要打卡的时间戳与打卡时间之前的打卡集合时,进行比对
Map<String, Map<String, Object>> resetBeforeData = clcokInTimeData.get(index-1);
Map<String, Object> resetBeforeClcokInTimeMap = null;
for (Map.Entry<String, Map<String, Object>> resetBeforeEntry : resetBeforeData.entrySet()) {
resetBeforeClcokInTimeMap = resetBeforeEntry.getValue();
}
if (newClockTimeMap == resetBeforeClcokInTimeMap){
newClockTimeMap = null;
}
}
}else if (newtimeType.equals(ClockPointEnum.AFTER.getKey())){
if (pointType.equals(ClockPointEnum.END.getKey())){
//结束卡点
Map<String,Object> needClockIn = scheduleResult.stream().filter(e -> {
String dtjssj = Utils.getjssjTime(e,analysisDate);
if (time.equals(dtjssj)){
return true;
}else {
return false;
}
}).collect(Collectors.toList()).get(0);
//计算最大退后打卡分钟数
int thdkfzs = 60;
if (Util.null2String(needClockIn.get("thdkfzs")).equals("") && !"".equals(getNextClockTime(needClockDateList,restTime))){
thdkfzs = DateUtil.getBetWeenMinutes(restTime,getNextClockTime(needClockDateList,restTime));
}else {
thdkfzs = Util.null2String(needClockIn.get("thdkfzs")).equals("")?60:Integer.valueOf(needClockIn.get("thdkfzs").toString());
}
if (DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(DateUtil.AfterMinutes(restTime, thdkfzs))) > 0){
newClockTimeMap = null;
}
}
if (!getNextClockTime(needClockDateList,time).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,time))) >= 0){
newClockTimeMap = null;
}
}
if (newClockTimeMap != null){
clcokInTimeData.remove(resetClcokInTimeData);
resetClcokInTimeData = Maps.newHashMap();
resetClcokInTimeData.put(newPonit,newClockTimeMap);
clcokInTimeData.add(index,resetClcokInTimeData);
return true;
}
}
return false;
}
}