ToolUtils.java
5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package com.ruoyi.utils;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.global.Result;
import com.ruoyi.common.global.ResultCode;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.domain.DriverScheduling;
import com.ruoyi.domain.DriverSchedulingExpandSmart;
import com.ruoyi.domain.RuleAttendanceMain;
import com.ruoyi.num.domain.RuleNum;
import com.ruoyi.pojo.dto.RuleSchedulingDto;
import com.ruoyi.scheduling.domain.RuleScheduling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN;
import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_TIME_OUT_EX_NUM;
import static com.ruoyi.common.RuleSchedulingProperties.*;
import static com.ruoyi.common.SignStatusEnum.SIGN_STATUS_DELAY_ENUM;
import static com.ruoyi.common.SignStatusEnum.SIGN_STATUS_ZONE_ENUM;
public class ToolUtils {
private static final Logger log = LoggerFactory.getLogger(ToolUtils.class);
public static String getUUID() {
return UUID.randomUUID().toString().replaceAll("-", "");
}
public static void copyRule(RuleScheduling dto, RuleAttendanceMain main) {
if (dto.getSecondFlag().equals(TOMORROW_NO)) {
BeanUtils.copyProperties(dto, main, "secondWorkSignInTime", "secondSignInWorkingRange", "secondQuittingSignInTime", "secondSignInQuittingRange", "secondSignDayTomorrow");
} else {
BeanUtils.copyProperties(dto, main);
}
}
public static void copyRule(RuleSchedulingDto dto, RuleAttendanceMain main) {
if (dto.getSecondFlag().equals(TOMORROW_NO)) {
BeanUtils.copyProperties(dto, main, "secondWorkSignInTime", "secondSignInWorkingRange", "secondQuittingSignInTime", "secondSignInQuittingRange", "secondSignDayTomorrow");
} else {
BeanUtils.copyProperties(dto, main);
}
}
/**
* 更新报表记录
*
* @param scheduling
*/
public static void updateReport(DriverScheduling scheduling) {
// TODO UPDATE 这里是特殊处理 青浦后续修改了签到规则
// 原先正负一小时内 修改为计划签到前一小时内超过就迟到,业主很急就不修改签到规则改为直接修改报表数据
// 签到
if (BC_TYPE_OUT.equals(scheduling.getBcType()) && !Objects.isNull(scheduling.getSignTime()) && SIGN_STATUS_ZONE_ENUM.getStatus().equals(scheduling.getExType())) {
// 实际签到时间
Date date = scheduling.getSignTime();
// 计划签到时间
Long fcsjT = scheduling.getFcsjT();
if (date.getTime() > fcsjT) {
scheduling.setExType(SIGN_TIME_OUT_EX_NUM);
scheduling.setRemark(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType()));
}
}
// 签退客户说把时间约定在负一小时以内
// 签退
if (BC_TYPE_IN.equals(scheduling.getBcType()) && !Objects.isNull(scheduling.getSignTime()) && SIGN_STATUS_ZONE_ENUM.getStatus().equals(scheduling.getExType())) {
// 实际签退时间
Date date = scheduling.getSignTime();
// 计划签退时间
Long zdsjT = scheduling.getZdsjT();
// 一小时内约束
if (date.getTime() - zdsjT > 60 * 60 * 1000) {
scheduling.setExType(SIGN_TIME_OUT_EX_NUM);
scheduling.setRemark(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType()));
}
}
}
public static void handlerRuleNum(RuleNum ruleNum) {
if (RULE_TYPE_FIXED.equals(ruleNum.getRuleType())) {
ruleNum.setRuleWeek("");
}
if (RULE_TYPE_WEEK.equals(ruleNum.getRuleType())) {
ruleNum.setWorkDay(null);
ruleNum.setFreeDay(null);
}
}
public static void handleRuleScheduling(RuleScheduling ruleScheduling) {
if (ruleScheduling.getSecondFlag().equals(NO_SEGMENTATION)) {
ruleScheduling.setSecondSignDayTomorrow(null);
ruleScheduling.setSecondQuittingSignInTime(null);
ruleScheduling.setSecondSignInQuittingRange(null);
ruleScheduling.setSecondWorkSignInTime(null);
ruleScheduling.setSecondSignInWorkingRange(null);
}
}
public static DriverSchedulingExpandSmart computedShowSmart(List<DriverSchedulingExpandSmart> list) {
// 遍历 规则 范围内-》 范围外 往后显示
list.sort(Comparator.comparing(DriverSchedulingExpandSmart::getStartDate));
Date date = new Date();
for (int i = 0; i < list.size(); i++) {
int compare = StringUtils.compare(ConstDateUtil.formatDate(date), ConstDateUtil.formatDate(list.get(i).getEndDate()));
if (compare > 0 && i < list.size() - 1) {
continue;
}
return list.get(i);
}
log.error("没有找到跟班对象:{}", list);
throw new ServiceException("未知错误", ResultCode.CODE_500.getCode());
}
}