فهرست منبع

1.日考勤页面中增加显示工作时长。

zhengqiang 3 سال پیش
والد
کامیت
3980032871
1فایلهای تغییر یافته به همراه20 افزوده شده و 15 حذف شده
  1. 20 15
      web/src/main/java/com/jpsoft/shinestar/scheduled/UpdateWorkMinuteTask.java

+ 20 - 15
web/src/main/java/com/jpsoft/shinestar/scheduled/UpdateWorkMinuteTask.java

@@ -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);
         }
     }
 }