|
|
|
@ -14,6 +14,8 @@ 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.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -22,10 +24,11 @@ import java.util.stream.Collectors;
|
|
|
|
|
* 获取打卡卡点
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class GetClockInPointCmd extends AbstractCommonCommand<Map<String,Object>> {
|
|
|
|
|
public GetClockInPointCmd(Map<String,Object> params){
|
|
|
|
|
this.params=params;
|
|
|
|
|
public class GetClockInPointCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
public GetClockInPointCmd(Map<String, Object> params) {
|
|
|
|
|
this.params = params;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BizLogContext getLogContext() {
|
|
|
|
|
return null;
|
|
|
|
@ -35,241 +38,417 @@ public class GetClockInPointCmd extends AbstractCommonCommand<Map<String,Object>
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
if (needClockInList.size() > 0 && askForLeaveAndEvctionScheduleList.size() > 0) {
|
|
|
|
|
String startTime = analysisDate + " " + needClockInList.get(0).get("dtkssj").toString();
|
|
|
|
|
String endStartTime = analysisDate + " " + needClockInList.get(needClockInList.size()-1).get("dtkssj").toString();
|
|
|
|
|
String endTime = analysisDate + " " + needClockInList.get(needClockInList.size()-1).get("dtjssj").toString();
|
|
|
|
|
if (DateUtil.getTime(endStartTime).compareTo(DateUtil.getTime(endTime)) > 0) {
|
|
|
|
|
endTime = DateUtil.AfterDay(analysisDate, 1) + " " + needClockInList.get(needClockInList.size()-1).get("dtjssj");
|
|
|
|
|
}
|
|
|
|
|
for (Map<String, Object> askForLeaveAndEvctionSchedule :askForLeaveAndEvctionScheduleList){
|
|
|
|
|
String dtkssj = analysisDate + " " + askForLeaveAndEvctionSchedule.get("dtkssj");
|
|
|
|
|
String dtjssj = analysisDate + " " + askForLeaveAndEvctionSchedule.get("dtjssj");
|
|
|
|
|
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0) {
|
|
|
|
|
dtjssj = DateUtil.AfterDay(analysisDate, 1) + " " + askForLeaveAndEvctionSchedule.get("dtjssj");
|
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 当请假或外出包含打卡卡点时,判断该卡点是否需要打卡
|
|
|
|
|
*/
|
|
|
|
|
for (Map<String, Object> askForLeaveAndEvctionMap :askForLeaveAndEvctionScheduleList){
|
|
|
|
|
String evctiondtkssj = analysisDate + " " +Util.null2String(askForLeaveAndEvctionMap.get("dtkssj"));
|
|
|
|
|
String evctionksdk = Util.null2String(askForLeaveAndEvctionMap.get("ksdk"));
|
|
|
|
|
String evctiondtjssj = analysisDate + " " +Util.null2String(askForLeaveAndEvctionMap.get("dtjssj"));
|
|
|
|
|
String evctionjsdk = Util.null2String(askForLeaveAndEvctionMap.get("jsdk"));
|
|
|
|
|
if (DateUtil.getTime(evctiondtkssj).compareTo(DateUtil.getTime(evctiondtjssj)) > 0) {
|
|
|
|
|
evctiondtjssj = DateUtil.AfterDay(analysisDate, 1) + " " + Util.null2String(askForLeaveAndEvctionMap.get("dtjssj"));
|
|
|
|
|
}
|
|
|
|
|
List<String> lists = Lists.newArrayList();
|
|
|
|
|
for (int i=0;i<scheduleResult.size();i++){
|
|
|
|
|
String dtkssj = analysisDate + " " +Util.null2String(scheduleResult.get(i).get("dtkssj"));
|
|
|
|
|
String dtjssj = analysisDate + " " +Util.null2String(scheduleResult.get(i).get("dtjssj"));
|
|
|
|
|
String bdlx = Util.null2String(scheduleResult.get(i).get("bdlx"));
|
|
|
|
|
if (DateUtil.getTime(dtkssj).compareTo(DateUtil.getTime(dtjssj)) > 0) {
|
|
|
|
|
dtjssj = DateUtil.AfterDay(analysisDate, 1) + " " + Util.null2String(scheduleResult.get(i).get("dtjssj"));
|
|
|
|
|
}
|
|
|
|
|
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(scheduleResult.get(i).get("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(scheduleResult.get(i).get("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 = Util.null2String(scheduleResult.get(i).get("dtkssj"));
|
|
|
|
|
String dtjssj = Util.null2String(scheduleResult.get(i).get("dtjssj"));
|
|
|
|
|
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]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("经过重新计算卡点时 新的scheduleResult : [{}],askForLeaveAndEvctionScheduleList:[{}]",scheduleResult,askForLeaveAndEvctionScheduleList);
|
|
|
|
|
if (askForLeaveAndEvctionScheduleList.size() > 0){
|
|
|
|
|
scheduleResult.addAll(askForLeaveAndEvctionScheduleList);
|
|
|
|
|
scheduleResult = scheduleResult.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, scheduleResult, clockInTimeList);
|
|
|
|
|
resultMap.put("clcokInTimeData", clcokInTimeData);
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取打卡卡点
|
|
|
|
|
* @param analysisDate 分析日期
|
|
|
|
|
* @param needClockInSchedule 需要打卡的班次
|
|
|
|
|
* @param clockInTimeList 打卡集合
|
|
|
|
|
* @return
|
|
|
|
|
*
|
|
|
|
|
* @param analysisDate 分析日期
|
|
|
|
|
* @param scheduleResult 需要打卡的班次
|
|
|
|
|
* @param clockInTimeList 打卡集合
|
|
|
|
|
* @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}}
|
|
|
|
|
* 班次时间|打卡类型(上班卡或下班卡)|打卡时间处所在位置|弹性时间 = 打卡时间map集合
|
|
|
|
|
*/
|
|
|
|
|
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");
|
|
|
|
|
public static List<Map<String, Map<String, Object>>> getClockInPoint(String analysisDate, List<Map<String, Object>> scheduleResult, List<Map<String, Object>> clockInTimeList) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 正常排班进行卡点
|
|
|
|
|
*/
|
|
|
|
|
List<Map<String, Map<String, Object>>> clcokInTimeData = Lists.newArrayList();
|
|
|
|
|
for (Map<String, Object> needClockIn : scheduleResult) {
|
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
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){
|
|
|
|
|
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();
|
|
|
|
|
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){
|
|
|
|
|
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();
|
|
|
|
|
timeType = ClockPointEnum.AFTER.getKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
clcokInTimeMap.put(dtkssj+"|"+ClockPointEnum.START.getKey()+"|"+timeType,ksdkNearestClcokInTime.get(timeType));
|
|
|
|
|
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");
|
|
|
|
|
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");
|
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
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.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();
|
|
|
|
|
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));
|
|
|
|
|
clcokInTimeMap.put(dtjssj + "|" + ClockPointEnum.END.getKey() + "|" + timeType, jsdkNearestClcokInTime.get(timeType));
|
|
|
|
|
clcokInTimeData.add(clcokInTimeMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//当弹性上下班时
|
|
|
|
|
if (needClockInSchedule.size() > 0){
|
|
|
|
|
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());
|
|
|
|
|
/**
|
|
|
|
|
* 计算弹性上下班
|
|
|
|
|
*/
|
|
|
|
|
if (scheduleResult.size() > 0) {
|
|
|
|
|
//上下班弹性,
|
|
|
|
|
List<Map<String, Object>> workScheduleList = scheduleResult.stream().filter(e -> ClassSegmentTypeEnum.WORK_TIME.getKey().equals(e.get("bdlx")) || ClassSegmentTypeEnum.EXTENDED_OVERTIME.getKey().equals(e.get("bdlx"))
|
|
|
|
|
|| ClassSegmentTypeEnum.EARLY_OVERTIME.getKey().equals(e.get("bdlx"))).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//请假和外出集合
|
|
|
|
|
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(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")));
|
|
|
|
|
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 (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());
|
|
|
|
|
//第一条工作时段、早上加班必须要求打卡并且上班之前没有请假
|
|
|
|
|
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 = analysisDate + " " + Util.null2String(ksdkMap.get("dtkssj"));
|
|
|
|
|
String jssjStart = analysisDate + " " + Util.null2String(ksdkMap.get("dtjssj"));
|
|
|
|
|
|
|
|
|
|
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 = workScheduleList.get(workScheduleList.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"));
|
|
|
|
|
|
|
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ksdkMap != jsdkMap){
|
|
|
|
|
if (DateUtil.getTime(kssjStart).compareTo(DateUtil.getTime(jssjStart)) > 0){
|
|
|
|
|
kssjStart = DateUtil.beforeDay(analysisDate,1)+" "+Util.null2String(ksdkMap.get("dtkssj"));
|
|
|
|
|
//弹性上班时间
|
|
|
|
|
String flexibleWorkTime = "";
|
|
|
|
|
//弹性下班时间
|
|
|
|
|
String flexibleOffWorkTime="";
|
|
|
|
|
if (leaveAndEvctionList.size() >0){
|
|
|
|
|
//第一笔请假、外出时间
|
|
|
|
|
Map<String, Object> leaveAndEvctionMap = leaveAndEvctionList.get(0);
|
|
|
|
|
String leaveAndEvctionkssj = analysisDate + " " + Util.null2String(leaveAndEvctionMap.get("dtkssj"));
|
|
|
|
|
//最大开始弹性时间
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
if (DateUtil.getTime(kssjEnd).compareTo(DateUtil.getTime(jssjEnd)) > 0){
|
|
|
|
|
jssjEnd = DateUtil.AfterDay(analysisDate,1)+" "+Util.null2String(jsdkMap.get("dtjssj"));
|
|
|
|
|
|
|
|
|
|
//弹性下班时间点
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}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];
|
|
|
|
|
}
|
|
|
|
|
//弹性上班卡
|
|
|
|
|
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);
|
|
|
|
|
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(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);
|
|
|
|
|
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)){
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
clcokInTimeMap.put(newPonit, clcokInTime);
|
|
|
|
|
}
|
|
|
|
|
}else if (pointTime.equals(jssjEnd) && ClockPointEnum.END.getKey().equals(pointType) && clcokInTime != null){
|
|
|
|
|
//该卡点是弹性下班点
|
|
|
|
|
|
|
|
|
|
int betweenToWorkTime = DateUtil.getBetWeenMinutes(flexibleWork,kssjStart);
|
|
|
|
|
}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);
|
|
|
|
|
//弹性下班时间点
|
|
|
|
|
String flexibleOffWork = jssjEnd;
|
|
|
|
|
if (betweenToWorkTime >=0){
|
|
|
|
|
flexibleOffWork = DateUtil.beforeMinutes(flexibleOffWork,Math.abs(betweenToWorkTime));
|
|
|
|
|
}else if (betweenToWorkTime < 0){
|
|
|
|
|
flexibleOffWork = DateUtil.AfterMinutes(flexibleOffWork,Math.abs(betweenToWorkTime));
|
|
|
|
|
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(flexibleOffWork,clockInTimeList);
|
|
|
|
|
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 (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.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(kssjEnd)) >0){
|
|
|
|
|
newtimeType=ClockPointEnum.BEFORE.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;
|
|
|
|
|
String newPonit = jssjEnd + "|" + ClockPointEnum.END.getKey() + "|" + newtimeType + "|" + flexibleOffWorkTime;
|
|
|
|
|
|
|
|
|
|
clcokInTimeMap.remove(point);
|
|
|
|
|
clcokInTimeMap.put(newPonit,jsdkNearestClcokInTime.get(newtimeType));
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 当有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()){
|
|
|
|
|
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()){
|
|
|
|
|
for (Map.Entry<String, Map<String, Object>> afterEntry : afterClcokInTimeData.entrySet()) {
|
|
|
|
|
afterClcokInTimeMap = afterEntry.getValue();
|
|
|
|
|
afterClcokInTime = afterEntry.getKey();
|
|
|
|
|
}
|
|
|
|
|
//重复
|
|
|
|
|
if (beforeClcokInTimeMap != null && beforeClcokInTimeMap == afterClcokInTimeMap ){
|
|
|
|
|
if (beforeClcokInTimeMap != null && beforeClcokInTimeMap == afterClcokInTimeMap) {
|
|
|
|
|
String beforeTime = beforeClcokInTime.split("\\|")[0];
|
|
|
|
|
String afterTime = afterClcokInTime.split("\\|")[0];
|
|
|
|
|
long betWeenMinutes = DateUtil.getBetWeenMinutes(beforeTime,afterTime);
|
|
|
|
|
long betWeenMinutes = DateUtil.getBetWeenMinutes(beforeTime, afterTime);
|
|
|
|
|
|
|
|
|
|
String middileTime = DateUtil.AfterMinutes(beforeTime,betWeenMinutes/2);
|
|
|
|
|
String middileTime = DateUtil.AfterMinutes(beforeTime, betWeenMinutes / 2);
|
|
|
|
|
|
|
|
|
|
String signdateTime = beforeClcokInTimeMap.get("signdate") +" "+beforeClcokInTimeMap.get("signtime");
|
|
|
|
|
String signdateTime = beforeClcokInTimeMap.get("signdate") + " " + beforeClcokInTimeMap.get("signtime");
|
|
|
|
|
|
|
|
|
|
if (DateUtil.getTime(signdateTime).compareTo(DateUtil.getTime(middileTime)) <=0){
|
|
|
|
|
if (DateUtil.getTime(signdateTime).compareTo(DateUtil.getTime(middileTime)) <= 0) {
|
|
|
|
|
//该打卡归属前一个打卡点
|
|
|
|
|
afterClcokInTimeData.put(afterClcokInTime,null);
|
|
|
|
|
}else 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);
|
|
|
|
|
beforeClcokInTimeData.put(beforeClcokInTime, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|