|
@@ -20,6 +20,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
|
|
+import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -43,8 +44,30 @@ public class SyncAttendanceSignToOaTask {
|
|
|
@Resource
|
|
@Resource
|
|
|
private SystemConfigItemService systemConfigItemService;
|
|
private SystemConfigItemService systemConfigItemService;
|
|
|
|
|
|
|
|
- @Scheduled(cron ="0 */5 6-23 * * ? ")
|
|
|
|
|
|
|
+ @Scheduled(cron ="0 * * * * ? ")
|
|
|
public void syncSignData() throws ParseException {
|
|
public void syncSignData() throws ParseException {
|
|
|
|
|
+
|
|
|
|
|
+ LocalTime now = LocalTime.now();
|
|
|
|
|
+ // ===== 总时间窗:06:00 – 22:30 =====
|
|
|
|
|
+ if (now.isBefore(LocalTime.of(6, 0))
|
|
|
|
|
+ || now.isAfter(LocalTime.of(22, 30))) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ boolean morningHighFrequency =
|
|
|
|
|
+ (now.getHour() == 8 && now.getMinute() >= 30)
|
|
|
|
|
+ || (now.getHour() == 9 && now.getMinute() <= 10);
|
|
|
|
|
+
|
|
|
|
|
+ boolean eveningHighFrequency =
|
|
|
|
|
+ (now.getHour() == 18)
|
|
|
|
|
+ || (now.getHour() == 19 && now.getMinute() <= 40);
|
|
|
|
|
+
|
|
|
|
|
+ boolean highFrequency = morningHighFrequency || eveningHighFrequency;
|
|
|
|
|
+ // 非高频时间:只允许 5 分钟一次
|
|
|
|
|
+ if (!highFrequency && now.getMinute() % 5 != 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 获取未同步的数据到
|
|
// 获取未同步的数据到
|
|
|
LambdaQueryWrapper<AttendanceSignRecordEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<AttendanceSignRecordEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.eq(AttendanceSignRecordEntity::getSyncOa,Integer.valueOf(0));
|
|
lambdaQueryWrapper.eq(AttendanceSignRecordEntity::getSyncOa,Integer.valueOf(0));
|