Quellcode durchsuchen

修改小夜班判断

yusm vor 1 Woche
Ursprung
Commit
0c84738593

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

@@ -267,88 +267,88 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                     Optional<Attendance> zaoShangCount = attendances.stream().filter(a ->!a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, baiBanRule.getBeginWorkStartTime().getHour(),baiBanRule.getBeginWorkStartTime().getMinute()))
                             &&!a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, baiBanRule.getBeginWorkEndTime().getHour(), baiBanRule.getBeginWorkEndTime().getMinute()))
                     ).findFirst();
-                    Optional<Attendance> zaoXiaCount = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, baiBanRule.getEndWorkStartTime().getHour(), baiBanRule.getEndWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, baiBanRule.getEndWorkEndTime().getHour(), baiBanRule.getEndWorkEndTime().getMinute()))
+                    Optional<Attendance> zaoXiaCount = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, baiBanRule.getEndWorkStartTime().getHour(), baiBanRule.getEndWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, baiBanRule.getEndWorkEndTime().getHour(), baiBanRule.getEndWorkEndTime().getMinute()))
                     ).max(Comparator.comparing(Attendance::getClockTime));
                     //异常早班1时间判断
-                    Optional<Attendance> zaoShangYiChang1Count = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan1Rule.getBeginWorkStartTime().getHour(),yichangBaiBan1Rule.getBeginWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan1Rule.getBeginWorkEndTime().getHour(), yichangBaiBan1Rule.getBeginWorkEndTime().getMinute()))
+                    Optional<Attendance> zaoShangYiChang1Count = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan1Rule.getBeginWorkStartTime().getHour(),yichangBaiBan1Rule.getBeginWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan1Rule.getBeginWorkEndTime().getHour(), yichangBaiBan1Rule.getBeginWorkEndTime().getMinute()))
                     ).findFirst();
-                    Optional<Attendance> zaoXiaYiChang1Count = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan1Rule.getEndWorkStartTime().getHour(), yichangBaiBan1Rule.getEndWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan1Rule.getEndWorkEndTime().getHour(), yichangBaiBan1Rule.getEndWorkEndTime().getMinute())))
+                    Optional<Attendance> zaoXiaYiChang1Count = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan1Rule.getEndWorkStartTime().getHour(), yichangBaiBan1Rule.getEndWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan1Rule.getEndWorkEndTime().getHour(), yichangBaiBan1Rule.getEndWorkEndTime().getMinute())))
                             .max(Comparator.comparing(Attendance::getClockTime));
 
                     //异常早班2时间判断
-                    Optional<Attendance> zaoShangYiChang2Count = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan2Rule.getBeginWorkStartTime().getHour(),yichangBaiBan2Rule.getBeginWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan2Rule.getBeginWorkEndTime().getHour(), yichangBaiBan2Rule.getBeginWorkEndTime().getMinute()))
+                    Optional<Attendance> zaoShangYiChang2Count = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan2Rule.getBeginWorkStartTime().getHour(),yichangBaiBan2Rule.getBeginWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan2Rule.getBeginWorkEndTime().getHour(), yichangBaiBan2Rule.getBeginWorkEndTime().getMinute()))
                     ).findFirst();
-                    Optional<Attendance> zaoXiaYiChang2Count = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan2Rule.getEndWorkStartTime().getHour(), yichangBaiBan2Rule.getEndWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan2Rule.getEndWorkEndTime().getHour(), yichangBaiBan2Rule.getEndWorkEndTime().getMinute()))
+                    Optional<Attendance> zaoXiaYiChang2Count = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan2Rule.getEndWorkStartTime().getHour(), yichangBaiBan2Rule.getEndWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangBaiBan2Rule.getEndWorkEndTime().getHour(), yichangBaiBan2Rule.getEndWorkEndTime().getMinute()))
                     ).max(Comparator.comparing(Attendance::getClockTime));
 
                     //中班上下班时间判断
-                    Optional<Attendance> zhongShangCount = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, zhongBanRule.getBeginWorkStartTime().getHour(), zhongBanRule.getBeginWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, zhongBanRule.getBeginWorkEndTime().getHour(), zhongBanRule.getBeginWorkEndTime().getMinute()))
+                    Optional<Attendance> zhongShangCount = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, zhongBanRule.getBeginWorkStartTime().getHour(), zhongBanRule.getBeginWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, zhongBanRule.getBeginWorkEndTime().getHour(), zhongBanRule.getBeginWorkEndTime().getMinute()))
                     ).findFirst();
 
-                    Optional<Attendance> zhongXiaCount = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, zhongBanRule.getEndWorkStartTime().getHour(), zhongBanRule.getEndWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, zhongBanRule.getBeginWorkEndTime().getHour(), zhongBanRule.getBeginWorkEndTime().getMinute()))
+                    Optional<Attendance> zhongXiaCount = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, zhongBanRule.getEndWorkStartTime().getHour(), zhongBanRule.getEndWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, zhongBanRule.getBeginWorkEndTime().getHour(), zhongBanRule.getBeginWorkEndTime().getMinute()))
                     ).max(Comparator.comparing(Attendance::getClockTime));
                     //小夜班(1)上下班时间判断
-                    Optional<Attendance> xiaoYeShangCount = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan1Rule.getBeginWorkStartTime().getHour(), xiaoyeBan1Rule.getBeginWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan1Rule.getBeginWorkEndTime().getHour(), xiaoyeBan1Rule.getBeginWorkEndTime().getMinute()))
+                    Optional<Attendance> xiaoYeShangCount = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan1Rule.getBeginWorkStartTime().getHour(), xiaoyeBan1Rule.getBeginWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan1Rule.getBeginWorkEndTime().getHour(), xiaoyeBan1Rule.getBeginWorkEndTime().getMinute()))
                     ).findFirst();
 
                     boolean isLastDay = endDate.isEqual(LocalDate.of(year, monthValue, dayValue));//是否是该月份最后一天
                     Optional<Attendance> xiaoYeXiaCount = isLastDay ?
-                            attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan1Rule.getEndWorkStartTime().getHour(), xiaoyeBan1Rule.getEndWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue+1, 1, xiaoyeBan1Rule.getEndWorkEndTime().getHour(), xiaoyeBan1Rule.getEndWorkEndTime().getMinute()))
+                            attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan1Rule.getEndWorkStartTime().getHour(), xiaoyeBan1Rule.getEndWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue+1, 1, xiaoyeBan1Rule.getEndWorkEndTime().getHour(), xiaoyeBan1Rule.getEndWorkEndTime().getMinute()))
                     ).max(Comparator.comparing(Attendance::getClockTime)):
-                            attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan1Rule.getEndWorkStartTime().getHour(), xiaoyeBan1Rule.getEndWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue+1, xiaoyeBan1Rule.getEndWorkEndTime().getHour(), xiaoyeBan1Rule.getEndWorkEndTime().getMinute()))
+                            attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan1Rule.getEndWorkStartTime().getHour(), xiaoyeBan1Rule.getEndWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue+1, xiaoyeBan1Rule.getEndWorkEndTime().getHour(), xiaoyeBan1Rule.getEndWorkEndTime().getMinute()))
                     ).max(Comparator.comparing(Attendance::getClockTime));
 
                     //小夜班(2)上下班时间判断
-                    Optional<Attendance> xiaoYeShang2Count = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan2Rule.getEndWorkStartTime().getHour(), xiaoyeBan2Rule.getEndWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan2Rule.getEndWorkEndTime().getHour(), xiaoyeBan2Rule.getEndWorkEndTime().getMinute()))
+                    Optional<Attendance> xiaoYeShang2Count = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan2Rule.getBeginWorkStartTime().getHour(), xiaoyeBan2Rule.getBeginWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan2Rule.getBeginWorkEndTime().getHour(), xiaoyeBan2Rule.getBeginWorkEndTime().getMinute()))
                     ).findFirst();
                     Optional<Attendance> xiaoYeXia2Count = isLastDay ?
-                            attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue+1, 1, xiaoyeBan2Rule.getEndWorkStartTime().getHour(), xiaoyeBan2Rule.getEndWorkStartTime().getMinute()))
-                                    && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue+1, 1, xiaoyeBan2Rule.getEndWorkEndTime().getHour(), xiaoyeBan2Rule.getEndWorkEndTime().getMinute()))
+                            attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, xiaoyeBan2Rule.getEndWorkStartTime().getHour(), xiaoyeBan2Rule.getEndWorkStartTime().getMinute()))
+                                    && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue+1, 1, xiaoyeBan2Rule.getEndWorkEndTime().getHour(), xiaoyeBan2Rule.getEndWorkEndTime().getMinute()))
                             ).max(Comparator.comparing(Attendance::getClockTime)):
-                            attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue+1,  xiaoyeBan2Rule.getEndWorkStartTime().getHour(), xiaoyeBan2Rule.getEndWorkStartTime().getMinute()))
-                                    && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue+1, xiaoyeBan2Rule.getEndWorkEndTime().getHour(), xiaoyeBan2Rule.getEndWorkEndTime().getMinute()))
+                            attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue,  xiaoyeBan2Rule.getEndWorkStartTime().getHour(), xiaoyeBan2Rule.getEndWorkStartTime().getMinute()))
+                                    && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue+1, xiaoyeBan2Rule.getEndWorkEndTime().getHour(), xiaoyeBan2Rule.getEndWorkEndTime().getMinute()))
                             ).max(Comparator.comparing(Attendance::getClockTime));
 
                     //异常小夜班(1)上下班时间判断
-                    Optional<Attendance> xiaoYeShangYiChang1Count = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan1Rule.getBeginWorkStartTime().getHour(), yichangxiaoyeBan1Rule.getBeginWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan1Rule.getBeginWorkEndTime().getHour(), yichangxiaoyeBan1Rule.getBeginWorkEndTime().getMinute()))
+                    Optional<Attendance> xiaoYeShangYiChang1Count = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan1Rule.getBeginWorkStartTime().getHour(), yichangxiaoyeBan1Rule.getBeginWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan1Rule.getBeginWorkEndTime().getHour(), yichangxiaoyeBan1Rule.getBeginWorkEndTime().getMinute()))
                     ).findFirst();
-                    Optional<Attendance> xiaoYeXiaYiChang1Count =attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan1Rule.getEndWorkStartTime().getHour(), yichangxiaoyeBan1Rule.getEndWorkStartTime().getMinute()))
-                                    && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan1Rule.getEndWorkEndTime().getHour(), yichangxiaoyeBan1Rule.getEndWorkEndTime().getMinute()))).max(Comparator.comparing(Attendance::getClockTime));
+                    Optional<Attendance> xiaoYeXiaYiChang1Count =attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan1Rule.getEndWorkStartTime().getHour(), yichangxiaoyeBan1Rule.getEndWorkStartTime().getMinute()))
+                                    && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan1Rule.getEndWorkEndTime().getHour(), yichangxiaoyeBan1Rule.getEndWorkEndTime().getMinute()))).max(Comparator.comparing(Attendance::getClockTime));
 
                     //异常小夜班(2)上下班时间判断
-                    Optional<Attendance> xiaoYeShangYiChang2Count = attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan2Rule.getBeginWorkStartTime().getHour(), yichangxiaoyeBan2Rule.getBeginWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan2Rule.getBeginWorkEndTime().getHour(), yichangxiaoyeBan2Rule.getBeginWorkEndTime().getMinute()))
+                    Optional<Attendance> xiaoYeShangYiChang2Count = attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan2Rule.getBeginWorkStartTime().getHour(), yichangxiaoyeBan2Rule.getBeginWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan2Rule.getBeginWorkEndTime().getHour(), yichangxiaoyeBan2Rule.getBeginWorkEndTime().getMinute()))
                     ).findFirst();
-                    Optional<Attendance> xiaoYeXiaYiChang2Count =attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan2Rule.getEndWorkStartTime().getHour(), yichangxiaoyeBan2Rule.getEndWorkStartTime().getMinute()))
-                            && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan2Rule.getEndWorkEndTime().getHour(), yichangxiaoyeBan2Rule.getEndWorkEndTime().getMinute()))).max(Comparator.comparing(Attendance::getClockTime));
+                    Optional<Attendance> xiaoYeXiaYiChang2Count =attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan2Rule.getEndWorkStartTime().getHour(), yichangxiaoyeBan2Rule.getEndWorkStartTime().getMinute()))
+                            && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, yichangxiaoyeBan2Rule.getEndWorkEndTime().getHour(), yichangxiaoyeBan2Rule.getEndWorkEndTime().getMinute()))).max(Comparator.comparing(Attendance::getClockTime));
 
                     //大夜班上下班时间判断
                     Optional<Attendance> daYeShangCount =isLastDay ?
-                            attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, dayeBanRule.getBeginWorkStartTime().getHour(), dayeBanRule.getBeginWorkStartTime().getMinute()))
-                                    && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue+1, 1, dayeBanRule.getBeginWorkEndTime().getHour(), dayeBanRule.getBeginWorkEndTime().getMinute()))
+                            attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, dayeBanRule.getBeginWorkStartTime().getHour(), dayeBanRule.getBeginWorkStartTime().getMinute()))
+                                    && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue+1, 1, dayeBanRule.getBeginWorkEndTime().getHour(), dayeBanRule.getBeginWorkEndTime().getMinute()))
                             ).findFirst():
-                            attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue, dayeBanRule.getBeginWorkStartTime().getHour(), dayeBanRule.getBeginWorkStartTime().getMinute()))
-                                    && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue+1, dayeBanRule.getBeginWorkEndTime().getHour(), dayeBanRule.getBeginWorkEndTime().getMinute()))
+                            attendances.stream().filter(a ->!a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue, dayeBanRule.getBeginWorkStartTime().getHour(), dayeBanRule.getBeginWorkStartTime().getMinute()))
+                                    && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue+1, dayeBanRule.getBeginWorkEndTime().getHour(), dayeBanRule.getBeginWorkEndTime().getMinute()))
                             ).findFirst();
 
                     Optional<Attendance> daYeXiaCount =isLastDay ?
-                            attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue+1, 1, dayeBanRule.getEndWorkStartTime().getHour(), dayeBanRule.getEndWorkStartTime().getMinute()))
-                                    && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue+1, 1, dayeBanRule.getEndWorkEndTime().getHour(), dayeBanRule.getEndWorkEndTime().getMinute()))
+                            attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue+1, 1, dayeBanRule.getEndWorkStartTime().getHour(), dayeBanRule.getEndWorkStartTime().getMinute()))
+                                    && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue+1, 1, dayeBanRule.getEndWorkEndTime().getHour(), dayeBanRule.getEndWorkEndTime().getMinute()))
                             ).max(Comparator.comparing(Attendance::getClockTime)):
-                            attendances.stream().filter(a -> a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue+1, dayeBanRule.getEndWorkStartTime().getHour(), dayeBanRule.getEndWorkStartTime().getMinute()))
-                                    && a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue+1, dayeBanRule.getEndWorkEndTime().getHour(), dayeBanRule.getEndWorkEndTime().getMinute()))
+                            attendances.stream().filter(a -> !a.getClockTime().isBefore(LocalDateTime.of(year, monthValue, dayValue+1, dayeBanRule.getEndWorkStartTime().getHour(), dayeBanRule.getEndWorkStartTime().getMinute()))
+                                    && !a.getClockTime().isAfter(LocalDateTime.of(year, monthValue, dayValue+1, dayeBanRule.getEndWorkEndTime().getHour(), dayeBanRule.getEndWorkEndTime().getMinute()))
                             ).max(Comparator.comparing(Attendance::getClockTime));
 
                     //1先判断白班
@@ -414,7 +414,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         staff.setClockEndTime(endClockTime);
                         BigDecimal bigDecimal = calculateWorkHours(startClockTime, endClockTime);
                         staff.setWorkHour(bigDecimal);
-                        staff.setAttendanceType(XIAO_YE_BAN);
+                        staff.setAttendanceType(XIAO_YE_BAN_2);
                         staff.setAttendanceTypeName("小夜班");
                     }
                     //3判断小夜班异常1
@@ -572,6 +572,9 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                 else if (staff.getAttendanceType()==XIAO_YE_BAN){
                     staff.setColor("#67C23A");//绿色
                 }
+                else if (staff.getAttendanceType()==XIAO_YE_BAN_2){
+                    staff.setColor("#67C23A");//绿色
+                }
                 else if (staff.getAttendanceType()==XIAO_YE_BAN_YI_CHANG_1){
                     staff.setColor("#67C23A");//绿色
                 }
@@ -619,7 +622,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = startTime + "上班考勤打卡:";
                         Duration duration = Duration.between(LocalTime.of(8,0,0),startTime );
                         long v = duration.toMinutes();
-                        str+= "(晚点"+v+"分钟)";
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -636,7 +644,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = endTime + "下班考勤打卡:";
                         Duration duration = Duration.between(endTime,LocalTime.of(17,0,0) );
                         long v = duration.toMinutes();
-                        str+= "(早退"+v+"分钟)";
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -661,7 +674,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = startTime + "上班考勤打卡:";
                         Duration duration = Duration.between(LocalTime.of(13,0,0),startTime);
                         long v = duration.toMinutes();
-                        str+= "(晚点"+v+"分钟)";
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -678,7 +696,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = endTime + "下班考勤打卡:";
                         Duration duration = Duration.between(endTime,LocalTime.of(21,0,0));
                         long v = duration.toMinutes();
-                        str+= "(早退"+v+"分钟)";
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -701,7 +724,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = startTime + "上班考勤打卡:";
                         Duration duration = Duration.between(LocalTime.of(16,0,0),startTime );
                         long v = duration.toMinutes();
-                        str+= "(晚点"+v+"分钟)";
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -718,7 +746,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = endTime + "下班考勤打卡:";
                         Duration duration = Duration.between(endTime,LocalTime.of(23,59, 59) );
                         long v = duration.toMinutes();
-                        str+= "(早退"+v+"分钟)";
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -734,6 +767,71 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                     }
                     staff.setAttendanceTypeName("小夜班");
                 }
+                else if (type == XIAO_YE_BAN_2) {
+                    if (startTime.isAfter(LocalTime.of(17, 0, 0))) {
+                        HashMap<String, Object> map = new HashMap<>();
+                        map.put("res", "晚点");
+                        String str = startTime + "上班考勤打卡:";
+                        Duration duration = Duration.between(LocalTime.of(17,0,0),startTime );
+                        long v = duration.toMinutes();
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
+                        map.put("msg",str );
+                        map.put("color","#F56C6C");
+                        maplist.add(map);
+                    } else {
+                        HashMap<String, Object> map = new HashMap<>();
+                        map.put("msg", startTime + "上班考勤打卡");
+                        map.put("res", "正常");
+                        maplist.add(map);
+                    }
+
+                    if (endTime.isBefore(LocalTime.of(23, 59, 59)) && endTime.isAfter(LocalTime.of(15, 0, 0))) {
+                        HashMap<String, Object> map = new HashMap<>();
+                        map.put("res", "早退");
+                        String str = endTime + "下班考勤打卡:";
+                        Duration duration = Duration.between(endTime,LocalTime.of(23,59, 59) );
+                        long v = duration.toMinutes();
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
+                        map.put("msg",str );
+                        map.put("color","#F56C6C");
+                        maplist.add(map);
+                    }else if (endTime.isBefore(LocalTime.of(1, 0, 0))) {
+                        HashMap<String, Object> map = new HashMap<>();
+                        map.put("res", "早退");
+                        String str = endTime + "下班考勤打卡:";
+                        Duration duration = Duration.between(endTime,LocalTime.of(1,0, 0) );
+                        long v = duration.toMinutes();
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
+                        map.put("msg",str );
+                        map.put("color","#F56C6C");
+                        maplist.add(map);
+                    } else {
+                        HashMap<String, Object> map = new HashMap<>();
+                        map.put("msg", endTime + "下班考勤打卡");
+                        map.put("res", "正常");
+                        double v = calculateOvertimeHours(LocalTime.of(1, 0, 0), endTime);
+                        if (v > 0) {
+                            map.put("extra", "(00:00-" + endTime + "加班" + v + "小时)");
+                        }
+                        maplist.add(map);
+                    }
+                    staff.setAttendanceTypeName("小夜班");
+                }
                 else if (type == DA_YE_BAN) {
                     if (startTime.isAfter(LocalTime.of(23, 59, 59))) {
                         HashMap<String, Object> map = new HashMap<>();
@@ -741,7 +839,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = startTime + "上班考勤打卡:";
                         Duration duration = Duration.between(LocalTime.of(23, 59, 59),startTime );
                         long v = duration.toMinutes();
-                        str+= "(晚点"+v+"分钟)";
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -758,7 +861,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = endTime + " 下班考勤打卡:";
                         Duration duration = Duration.between(endTime,LocalTime.of(8,0, 0) );
                         long v = duration.toMinutes();
-                        str+= "(早退"+v+"分钟)";
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -781,7 +889,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = startTime + "上班考勤打卡:";
                         Duration duration = Duration.between(LocalTime.of(9,0,0),startTime );
                         long v = duration.toMinutes();
-                        str+= "(晚点"+v+"分钟)";
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -798,7 +911,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = endTime + "下班考勤打卡:";
                         Duration duration = Duration.between(endTime,LocalTime.of(18,0,0) );
                         long v = duration.toMinutes();
-                        str+= "(早退"+v+"分钟)";
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -822,7 +940,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = startTime + "上班考勤打卡:";
                         Duration duration = Duration.between(LocalTime.of(10,0,0),startTime );
                         long v = duration.toMinutes();
-                        str+= "(晚点"+v+"分钟)";
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -839,7 +962,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = endTime + "下班考勤打卡:";
                         Duration duration = Duration.between(endTime,LocalTime.of(19,0,0) );
                         long v = duration.toMinutes();
-                        str+= "(早退"+v+"分钟)";
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -862,7 +990,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = startTime + "上班考勤打卡:";
                         Duration duration = Duration.between(LocalTime.of(14,0,0),startTime );
                         long v = duration.toMinutes();
-                        str+= "(晚点"+v+"分钟)";
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -879,7 +1012,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = endTime + "下班考勤打卡:";
                         Duration duration = Duration.between(endTime,LocalTime.of(22,0, 0) );
                         long v = duration.toMinutes();
-                        str+= "(早退"+v+"分钟)";
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -902,7 +1040,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = startTime + "上班考勤打卡:";
                         Duration duration = Duration.between(LocalTime.of(15,0,0),startTime );
                         long v = duration.toMinutes();
-                        str+= "(晚点"+v+"分钟)";
+                        if (v>0) {
+                            str += "(晚点" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(晚点" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
@@ -919,7 +1062,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         String str = endTime + "下班考勤打卡:";
                         Duration duration = Duration.between(endTime,LocalTime.of(23,0, 0) );
                         long v = duration.toMinutes();
-                        str+= "(早退"+v+"分钟)";
+                        if (v>0) {
+                            str += "(早退" + v + "分钟)";
+                        }else {
+                            v=duration.getSeconds();
+                            str += "(早退" + v + "秒)";
+                        }
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);