yusm 1 тиждень тому
батько
коміт
b78cdec490

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

@@ -54,6 +54,9 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
     @Resource
     private SysRoleFunctionService sysRoleFunctionService;
 
+    @Resource
+    private HighTemperatureSetService highTemperatureSetService;
+
     @Override
     public HttpRespMsg refreshData(String month) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -334,8 +337,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                     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().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> xiaoYeXiaYiChang2Count =isLastDay ?
+                            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+1, 1, yichangxiaoyeBan2Rule.getEndWorkEndTime().getHour(), yichangxiaoyeBan2Rule.getEndWorkEndTime().getMinute()))).max(Comparator.comparing(Attendance::getClockTime))
+                            :
+                            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+1, yichangxiaoyeBan2Rule.getEndWorkEndTime().getHour(), yichangxiaoyeBan2Rule.getEndWorkEndTime().getMinute()))).max(Comparator.comparing(Attendance::getClockTime));
 
                     //大夜班上下班时间判断
                     Optional<Attendance> daYeShangCount =isLastDay ?
@@ -487,21 +494,67 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
         }else {
             wrapper.eq("job_number", u.getJobNumber());
         }
+        List<HighTemperatureSet> dateSetList = highTemperatureSetService.list();
+
+        // 定义午休时间段的开始和结束
+        LocalTime noonBreakStart = LocalTime.of(12, 0);
+        LocalTime noonBreakEndHotDay = LocalTime.of(13, 30); // 高温日结束时间
+        LocalTime noonBreakEndNormalDay = LocalTime.of(13, 0); // 普通日结束时间
 
         IPage<AttendanceStaff> iPage = page(new Page(pageIndex, pageSize), wrapper);
         HashMap<String, Object> map = new HashMap<>();
         map.put("total", iPage.getTotal());
         List<AttendanceStaff> records = iPage.getRecords();
         for (AttendanceStaff record : records) {
-            if (record.getAttendanceType()==0){
-                record.setWorkHour(record.getWorkHour().subtract(BigDecimal.ONE));
+            boolean isHotDay = dateSetList.stream().anyMatch(d -> d != null && !d.getStartDate().isBefore(record.getClockDate())&&!d.getEndDate().isAfter(record.getClockDate()));
+            // 获取当天的打卡时间(转换为当天的时间)
+            LocalDateTime clockStart = record.getClockStartTime();
+            LocalDateTime clockEnd = record.getClockEndTime();
+            // 检查是否跨过午休时间
+            if (clockStart.toLocalTime().isBefore(noonBreakStart) &&
+                    clockEnd.toLocalTime().isAfter(isHotDay ? noonBreakEndHotDay : noonBreakEndNormalDay)) {
+
+                // 完整午休时间扣除
+                if (isHotDay) {
+                    record.setWorkHour(record.getWorkHour().subtract(BigDecimal.valueOf(1.5))); // 高温日扣1.5小时
+                } else {
+                    record.setWorkHour(record.getWorkHour().subtract(BigDecimal.valueOf(1))); // 普通日扣1小时
+                }
             }
+            // 部分重叠的情况
+            else {
+                // 计算重叠的午休时间(分钟)
+                long overlapMinutes = calculateOverlapMinutes(
+                        clockStart.toLocalTime(),
+                        clockEnd.toLocalTime(),
+                        noonBreakStart,
+                        isHotDay ? noonBreakEndHotDay : noonBreakEndNormalDay
+                );
+
+                if (overlapMinutes > 0) {
+                    double overlapHours = overlapMinutes / 60.0;
+                    record.setWorkHour(record.getWorkHour().subtract(BigDecimal.valueOf(overlapHours)));
+                }
+            }
+            record.setWorkHour(record.getWorkHour().setScale(1, RoundingMode.HALF_UP));
         }
         map.put("records",records );
         msg.setData(map);
         return msg;
     }
 
+    // 计算时间重叠的辅助方法
+    private long calculateOverlapMinutes(LocalTime start, LocalTime end, LocalTime breakStart, LocalTime breakEnd) {
+        if (start.isAfter(breakEnd) || end.isBefore(breakStart)) {
+            return 0; // 没有重叠
+        }
+
+        LocalTime overlapStart = start.isBefore(breakStart) ? breakStart : start;
+        LocalTime overlapEnd = end.isAfter(breakEnd) ? breakEnd : end;
+
+        return Duration.between(overlapStart, overlapEnd).toMinutes();
+    }
+
     @Override
     public HttpRespMsg getAttendanceUserData(String month, String date, String userId, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -720,12 +773,13 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         maplist.add(map);
                     } else {
                         HashMap<String, Object> map = new HashMap<>();
-                        map.put("msg", endStr + "下班考勤打卡");
                         map.put("res", "正常");
+                        String str = endStr + "下班考勤打卡:";
                         double v = calculateOvertimeHours(LocalTime.of(21, 0, 0), endTime);
                         if (v > 0) {
-                            map.put("extra", "(21:00:00-" + endTime + "加班" + v + "小时)");
+                            str +="(21:00:00-" + endTime + "加班" + v + "小时)";
                         }
+                        map.put("msg",str );
                         maplist.add(map);
                     }
                     staff.setAttendanceTypeName("中班");
@@ -770,12 +824,13 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         maplist.add(map);
                     } else {
                         HashMap<String, Object> map = new HashMap<>();
-                        map.put("msg", endStr + "下班考勤打卡");
+                        String str = endStr + "下班考勤打卡:";
                         map.put("res", "正常");
                         double v = calculateOvertimeHours(LocalTime.of(0, 0, 0), endTime);
                         if (v > 0) {
-                            map.put("extra", "(00:00:00-" + endTime + "加班" + v + "小时)");
+                            str += "(00:00:00-" + endTime + "加班" + v + "小时)";
                         }
+                        map.put("msg", str);
                         maplist.add(map);
                     }
                     staff.setAttendanceTypeName("小夜班");
@@ -803,7 +858,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         maplist.add(map);
                     }
 
-                    if (endTime.isBefore(LocalTime.of(23, 59, 59)) && endTime.isAfter(LocalTime.of(15, 0, 0))) {
+                    if (endTime.isBefore(LocalTime.of(23, 59, 59)) && endTime.isAfter(LocalTime.of(17, 0, 0))) {
                         HashMap<String, Object> map = new HashMap<>();
                         map.put("res", "早退");
                         String str = endStr + "下班考勤打卡:";
@@ -834,18 +889,19 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         maplist.add(map);
                     } else {
                         HashMap<String, Object> map = new HashMap<>();
-                        map.put("msg", endStr + "下班考勤打卡");
+                        String str = endStr + "下班考勤打卡:";
                         map.put("res", "正常");
                         double v = calculateOvertimeHours(LocalTime.of(1, 0, 0), endTime);
                         if (v > 0) {
-                            map.put("extra", "(00:00:00-" + endTime + "加班" + v + "小时)");
+                            str += "(00:01:00-" + endTime + "加班" + v + "小时)";
                         }
+                        map.put("msg", str);
                         maplist.add(map);
                     }
                     staff.setAttendanceTypeName("小夜班");
                 }
                 else if (type == DA_YE_BAN) {
-                    if (startTime.isAfter(LocalTime.of(0, 0, 0))) {
+                    if (startTime.isAfter(LocalTime.of(0, 0, 0))&&startTime.isBefore(LocalTime.of(4, 0, 0))) {
                         HashMap<String, Object> map = new HashMap<>();
                         map.put("res", "晚点");
                         String str = startStr + "上班考勤打卡:";
@@ -884,12 +940,13 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         maplist.add(map);
                     } else {
                         HashMap<String, Object> map = new HashMap<>();
-                        map.put("msg", endStr + "下班考勤打卡");
+                        String str = endStr + "下班考勤打卡:";
                         map.put("res", "正常");
                         double v = calculateOvertimeHours(LocalTime.of(8, 0, 0), endTime);
                         if (v > 0) {
-                            map.put("extra", "(08:00:00-" + endTime + "加班" + v + "小时)");
+                            str += "(08:00:00-" + endTime + "加班" + v + "小时)";
                         }
+                        map.put("msg", str);
                         maplist.add(map);
                     }
                     staff.setAttendanceTypeName("大夜班");
@@ -1035,12 +1092,13 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         maplist.add(map);
                     } else {
                         HashMap<String, Object> map = new HashMap<>();
-                        map.put("msg", endStr + "下班考勤打卡");
+                        String str = endStr + "下班考勤打卡:";
                         map.put("res", "正常");
                         double v = calculateOvertimeHours(LocalTime.of(22, 0, 0), endTime);
                         if (v > 0) {
-                            map.put("extra", "(22:00:00-" + endTime + "加班" + v + "小时)");
+                            str += "(22:00:00-" + endTime + "加班" + v + "小时)";
                         }
+                        map.put("msg", str);
                         maplist.add(map);
                     }
                     staff.setAttendanceTypeName("异常小夜班1");
@@ -1068,7 +1126,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         maplist.add(map);
                     }
 
-                    if (endTime.isBefore(LocalTime.of(23, 0, 0))) {
+                    if (endTime.isBefore(LocalTime.of(23, 0, 0))&&endTime.isAfter(LocalTime.of(15,0,0))) {
                         HashMap<String, Object> map = new HashMap<>();
                         map.put("res", "早退");
                         String str = endStr + "下班考勤打卡:";
@@ -1083,14 +1141,26 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
                         map.put("msg",str );
                         map.put("color","#F56C6C");
                         maplist.add(map);
-                    } else {
+                    }else if (!endTime.isBefore(LocalTime.of(23, 0, 0))&&!endTime.isAfter(LocalTime.of(23,59,59))) {
                         HashMap<String, Object> map = new HashMap<>();
-                        map.put("msg", endStr + "下班考勤打卡");
+                        String str = endStr + "下班考勤打卡:";
                         map.put("res", "正常");
                         double v = calculateOvertimeHours(LocalTime.of(23, 0, 0), endTime);
                         if (v > 0) {
-                            map.put("extra", "(23:00:00-" + endTime + "加班" + v + "小时)");
+                            str +=  "(23:00:00-" + endTime + "加班" + v + "小时)";
                         }
+                        map.put("msg", str);
+                        maplist.add(map);
+                    }
+                    else {
+                        HashMap<String, Object> map = new HashMap<>();
+                        String str = endStr + "下班考勤打卡:";
+                        map.put("res", "正常");
+                        double v = calculateOvertimeHours(LocalTime.of(23, 0, 0), endTime);
+                        if (v > 0) {
+                            str +=  "(23:00:00-" + endTime + "加班" + v + "小时)";
+                        }
+                        map.put("msg", str);
                         maplist.add(map);
                     }
                     staff.setAttendanceTypeName("异常小夜班2");

+ 1 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/application.yml

@@ -128,6 +128,7 @@ referer:
     - mobdevworkshop.ttkuaiban.com
     - devworkshop.ttkuaiban.com
     - 47.101.180.183
+    - 192.168.2.28
 excludeUrls: /wxcorp/*,/wxcorp/*/*,/dingding/*,/feishu-info/*,/error,/testClient,/corpWXAuth,/corpWXScanningAuth,/corpInsideWXAuth,/wx-corp-info/*,/clean/*,/innerRoles/*,/report/getReportListByToken,/report/getProcessErrorData,/project/synchronizationProject,/user/updateUserDeptHierarchy
 
 #企业微信相关参数