|
@@ -22,31 +22,36 @@ public class UpdateWorkMinuteTask {
|
|
|
@Autowired
|
|
|
private WorkScheduleAttendanceService workScheduleAttendanceService;
|
|
|
|
|
|
- @Scheduled(cron = "0 0/10 * * * ?")
|
|
|
+ @Scheduled(cron = "0 0/5 * * * ?")
|
|
|
public void run() {
|
|
|
- List<WorkScheduleAttendance> list = workScheduleAttendanceService.findEmptyWorkMinuteList(50);
|
|
|
+ List<WorkScheduleAttendance> list = workScheduleAttendanceService.findEmptyWorkMinuteList(100);
|
|
|
|
|
|
for (WorkScheduleAttendance wsa : list) {
|
|
|
+ int workMinutes = 0;
|
|
|
+
|
|
|
List<WorkScheduleAttendance> onWorkList = workScheduleAttendanceService.findByPersonScheduleIdAndClassify(wsa.getPersonScheduleId(), wsa.getWorkShiftId(), "1");
|
|
|
|
|
|
if(onWorkList.size()>0){
|
|
|
WorkScheduleAttendance workStartAttendance = onWorkList.get(0);
|
|
|
|
|
|
- int workMinutes = 0;
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(workStartAttendance.getResult())
|
|
|
- && !"0".equals(workStartAttendance.getResult())
|
|
|
- && workStartAttendance.getRecordTime()!=null
|
|
|
- ){
|
|
|
- workMinutes = Minutes.minutesBetween(
|
|
|
- new DateTime(workStartAttendance.getRecordTime()),new DateTime(wsa.getRecordTime()))
|
|
|
- .getMinutes();
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotEmpty(workStartAttendance.getResult())
|
|
|
+ && !"0".equals(workStartAttendance.getResult())
|
|
|
+ && workStartAttendance.getRecordTime() != null
|
|
|
+ ) {
|
|
|
+ workMinutes = Minutes.minutesBetween(
|
|
|
+ new DateTime(workStartAttendance.getRecordTime()), new DateTime(wsa.getRecordTime()))
|
|
|
+ .getMinutes();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
}
|
|
|
-
|
|
|
- wsa.setWorkMinute(new BigDecimal(workMinutes));
|
|
|
- wsa.setUpdateTime(new Date());
|
|
|
- workScheduleAttendanceService.updateWorkMinute(wsa);
|
|
|
}
|
|
|
+
|
|
|
+ wsa.setWorkMinute(new BigDecimal(workMinutes));
|
|
|
+ wsa.setUpdateTime(new Date());
|
|
|
+ workScheduleAttendanceService.updateWorkMinute(wsa);
|
|
|
}
|
|
|
}
|
|
|
}
|