|
|
@@ -68,7 +68,7 @@ public class AttendanceRecordTask {
|
|
|
private IHolidayDateService holidayDateService;
|
|
|
|
|
|
|
|
|
- @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ @Scheduled(cron = "0 30 * * * ?")
|
|
|
public void execute() {
|
|
|
String active = SpringUtil.getActiveProfile();
|
|
|
if(!"prod".equals(active)){
|
|
|
@@ -77,15 +77,33 @@ public class AttendanceRecordTask {
|
|
|
}
|
|
|
//获取时间,并计算出前一天的开始时间和结束时间
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
- LocalDateTime startDateTime = now.plusDays(-1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ LocalDateTime noon = now.withHour(12).withMinute(0).withSecond(0);
|
|
|
+ LocalDateTime evening = now.withHour(18).withMinute(0).withSecond(0);
|
|
|
+
|
|
|
+ LocalDateTime startDateTime = now.withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
LocalDateTime endDateTime = startDateTime.plusDays(1).plusSeconds(-1);
|
|
|
|
|
|
- //计算上午考勤
|
|
|
- teacherAttendanceRecord(startDateTime, endDateTime, 1);
|
|
|
+ if(now.isBefore(noon)){
|
|
|
+ //计算上午考勤
|
|
|
+ teacherAttendanceRecord(startDateTime, endDateTime, 1);
|
|
|
+ }else if(now.isAfter(noon) && now.isBefore(evening)){
|
|
|
+ //计算上午考勤
|
|
|
+ teacherAttendanceRecord(startDateTime, endDateTime, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDateTime beginTime = now.withHour(0).withMinute(58).withSecond(0);
|
|
|
+ LocalDateTime endTime = now.withHour(1).withMinute(3).withSecond(0);
|
|
|
|
|
|
- //计算上午考勤
|
|
|
- teacherAttendanceRecord(startDateTime, endDateTime, 2);
|
|
|
+ //凌晨1点计算前一天的数据
|
|
|
+ if(now.isAfter(beginTime) && now.isBefore(endTime)){
|
|
|
+ startDateTime = now.plusDays(-1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ endDateTime = startDateTime.plusDays(1).plusSeconds(-1);
|
|
|
|
|
|
+ //计算上午考勤
|
|
|
+ teacherAttendanceRecord(startDateTime, endDateTime, 1);
|
|
|
+ //计算上午考勤
|
|
|
+ teacherAttendanceRecord(startDateTime, endDateTime, 2);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|