|
|
@@ -7,6 +7,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.ParseException;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
@@ -27,9 +28,30 @@ public class AttendanceSignDispatchTask {
|
|
|
* 同步考勤数据
|
|
|
* @throws ParseException
|
|
|
*/
|
|
|
- @Scheduled(cron ="0 */5 6-23 * * ? ")
|
|
|
+ @Scheduled(cron ="0 * * * * ? ")
|
|
|
public void syncSignData() throws ParseException {
|
|
|
- log.error("开始时间--"+new Date());
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
log.info("oa company dept job user sync task starting ----");
|
|
|
try {
|
|
|
attendanceSignRecordService.getSaveSignRecord();
|
|
|
@@ -43,4 +65,5 @@ public class AttendanceSignDispatchTask {
|
|
|
log.error("----syncSignData------error-"+e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|