Lijy 1 dag geleden
bovenliggende
commit
a0d2711ddb

+ 34 - 3
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/AttendanceStaffServiceImpl.java

@@ -151,7 +151,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                             if (applyForm.getSumTime().compareTo(BigDecimal.valueOf(8))>=0){
                                 staff.setClockStartTime(LocalDateTime.of(date, LocalTime.of(8, 0)));
                                 staff.setClockEndTime(LocalDateTime.of(date, LocalTime.of(17, 0)));
-                                staff.setWorkHour(BigDecimal.valueOf(8));
+                                staff.setWorkHour(applyForm.getSumTime());//以加班申请的时长为准
                                 staff.setAttendanceType(JIA_BAN);
                                 staff.setAttendanceTypeName("加班");
                             }
@@ -360,6 +360,19 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                                     && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue+1, dayeBanRule.getEndWorkEndTime().getHour(), dayeBanRule.getEndWorkEndTime().getMinute()))
                             ).max(Comparator.comparing(Attendance::getClockTime));
 
+                    //当天只有一次打卡的情况,为班次异常
+                    boolean onlyOnce = attendances.stream().filter(a->a.getClockTime().toLocalDate().isEqual(date)).count() == 1;
+                    if (onlyOnce) {
+                        //仅仅一次打卡,为异常班次
+                        attendances.stream().filter(a->a.getClockTime().toLocalDate().isEqual(date)).findFirst().ifPresent(a->{
+                           LocalDateTime time = a.getClockTime();
+                           staff.setClockStartTime(time);
+                           staff.setAttendanceType(YI_CHANG);
+                           staff.setAttendanceTypeName("班次异常");
+                           staff.setWorkHour(new BigDecimal(0));
+                        });
+                    }
+
                     //1先判断白班
                     if (zaoShangCount.isPresent()&&zaoXiaCount.isPresent()) {
                         LocalDateTime startClockTime = zaoShangCount.get().getClockTime();
@@ -461,7 +474,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         staff.setAttendanceTypeName("大夜班");
                     }
                     //过滤掉空数据
-                    if (staff.getClockStartTime()!=null){
+                    if (!StringUtils.isEmpty(staff.getJobNumber()) && (staff.getClockStartTime()!=null || staff.getClockEndTime()!=null)) {
                         addList.add(staff);
                     }
                 }
@@ -668,7 +681,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
 
             LocalDateTime clockStartTime = staff.getClockStartTime();
             LocalDateTime clockEndTime = staff.getClockEndTime();
-            if (clockStartTime!=null&&clockEndTime!=null) {
+            if (clockStartTime!=null && clockEndTime!=null) {
                 DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
                 LocalTime startTime = clockStartTime.toLocalTime();
                 LocalTime endTime = clockEndTime.toLocalTime();
@@ -1274,6 +1287,24 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                     map.put("res", stringBuilder.toString());
                     map.put("color","#F56C6C");
                     mapList.add(map);
+                } else if (clockStartTime != null) {
+                    DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
+                    LocalTime startTime = clockStartTime.toLocalTime();
+                    String startStr = startTime.format(timeFormatter);
+                    HashMap<String, Object> map = new HashMap<>();
+                    map.put("msg", startStr + "上班考勤打卡");
+                    map.put("res", "未知");
+                    mapList.add(map);
+                } else if (clockEndTime != null) {
+                    DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
+                    LocalTime endTime = clockEndTime.toLocalTime();
+                    String endStr = endTime.format(timeFormatter);
+                    HashMap<String, Object> map = new HashMap<>();
+                    map.put("res", "未知");
+                    String str = endStr + "下班考勤打卡:";
+                    map.put("msg",str );
+                    map.put("color","#F56C6C");
+                    mapList.add(map);
                 }
                 staff.setMaplist(mapList);
             }