소스 검색

教师考勤调整

dzx 1 개월 전
부모
커밋
e1592e0eeb

+ 13 - 1
src/main/java/com/xjrsoft/module/attendance/service/impl/AttendanceStatisticsServiceImpl.java

@@ -314,6 +314,13 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
                         .in(HolidayDate::getStatus, list)
         );
         List<String> holidayDateList = holidayDates.stream().map(HolidayDate::getDate).collect(Collectors.toList());
+
+        List<HolidayDate> workHolidayDates = holidayDateService.list(
+                new QueryWrapper<HolidayDate>().lambda()
+                        .eq(HolidayDate::getStatus, 2)
+        );
+        List<String> workHolidayDateListg = workHolidayDates.stream().map(HolidayDate::getDate).collect(Collectors.toList());
+
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         List<String> weekList =Arrays.asList("SUNDAY", "SATURDAY");
         long numOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate) + 1; // +1 包含结束日期
@@ -321,7 +328,12 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
             LocalDate localDate = startDate.plusDays(i);
             AttendanceRuleDetails holidays = ruleMap.get("holidays");
             Integer holidaysIsAttendance = holidays.getIsAttendance();
-            if((weekList.contains(localDate.getDayOfWeek().name()) || holidayDateList.contains(localDate.format(formatter))) && (holidaysIsAttendance == null || holidaysIsAttendance == 0)){
+            if(
+                    (
+                    (!workHolidayDateListg.contains(localDate.format(formatter)) && weekList.contains(localDate.getDayOfWeek().name()))
+                    || holidayDateList.contains(localDate.format(formatter)))
+                    && (holidaysIsAttendance == null || holidaysIsAttendance == 0)
+            ){
                 continue;
             }
             AttendanceRuleDetails ruleDetails = ruleMap.get(weekEnMap.get(localDate.getDayOfWeek().name()));

+ 9 - 1
src/main/java/com/xjrsoft/module/job/AttendanceRecordTask.java

@@ -119,6 +119,13 @@ public class AttendanceRecordTask {
         LocalDate queryDate = startDateTime.toLocalDate();
         List<TeacherAttendanceRecord> insertList = new ArrayList<>();
         List<String> weekList =Arrays.asList("SUNDAY", "SATURDAY");
+
+        List<HolidayDate> workHolidayDates = holidayDateService.list(
+                new QueryWrapper<HolidayDate>().lambda()
+                        .eq(HolidayDate::getStatus, 2)
+        );
+        List<String> workHolidayDateListg = workHolidayDates.stream().map(HolidayDate::getDate).collect(Collectors.toList());
+
         for (User user : teacherList) {
             TeacherAttendanceRecord record = new TeacherAttendanceRecord();
             record.setCreateDate(LocalDateTime.now());
@@ -133,7 +140,8 @@ public class AttendanceRecordTask {
                 continue;
             }
             AttendanceRuleDetails holidayRule = ruleCategoryService.getHolidayRuleByParam(user.getId());
-            if((weekList.contains(queryDate.getDayOfWeek().name()) || holidayDateList.contains(queryDate.format(formatter))) && (holidayRule.getIsAttendance() == null || holidayRule.getIsAttendance() == 0)){
+            if(((!workHolidayDateListg.contains(queryDate.format(formatter)) && weekList.contains(queryDate.getDayOfWeek().name()))
+                    || holidayDateList.contains(queryDate.format(formatter))) && (holidayRule.getIsAttendance() == null || holidayRule.getIsAttendance() == 0)){
                 record.setAttendanceStatus("不考勤");
                 insertList.add(record);
                 continue;

+ 10 - 5
src/test/java/com/xjrsoft/module/job/AttendanceRecordTaskTest.java

@@ -75,7 +75,7 @@ class AttendanceRecordTaskTest {
     @Test
     public void execute() {
 
-        LocalDateTime now = LocalDateTime.of(2024, 10, 20, 0, 0, 0);
+        LocalDateTime now = LocalDateTime.of(2024, 10, 12, 0, 0, 0);
         for (int i = 0; i < 1; i ++){
             LocalDateTime startDateTime = now.plusDays(i).withHour(0).withMinute(0).withSecond(0).withNano(0);
             LocalDateTime endDateTime = startDateTime.plusDays(i).withHour(23).withMinute(59).withSecond(59);
@@ -112,6 +112,13 @@ class AttendanceRecordTaskTest {
         LocalDate queryDate = startDateTime.toLocalDate();
         List<TeacherAttendanceRecord> insertList = new ArrayList<>();
         List<String> weekList =Arrays.asList("SUNDAY", "SATURDAY");
+
+        List<HolidayDate> workHolidayDates = holidayDateService.list(
+                new QueryWrapper<HolidayDate>().lambda()
+                        .eq(HolidayDate::getStatus, 2)
+        );
+        List<String> workHolidayDateListg = workHolidayDates.stream().map(HolidayDate::getDate).collect(Collectors.toList());
+
         for (User user : teacherList) {
             TeacherAttendanceRecord record = new TeacherAttendanceRecord();
             record.setCreateDate(LocalDateTime.now());
@@ -125,11 +132,9 @@ class AttendanceRecordTaskTest {
                 insertList.add(record);
                 continue;
             }
-            if(14954799823302L == user.getId()){
-                System.out.println(user.getName());
-            }
             AttendanceRuleDetails holidayRule = ruleCategoryService.getHolidayRuleByParam(user.getId());
-            if((weekList.contains(queryDate.getDayOfWeek().name()) || holidayDateList.contains(queryDate.format(formatter))) && (holidayRule.getIsAttendance() == null || holidayRule.getIsAttendance() == 0)){
+            if(((!workHolidayDateListg.contains(queryDate.format(formatter)) && weekList.contains(queryDate.getDayOfWeek().name()))
+                    || holidayDateList.contains(queryDate.format(formatter))) && (holidayRule.getIsAttendance() == null || holidayRule.getIsAttendance() == 0)){
                 record.setAttendanceStatus("不考勤");
                 insertList.add(record);
                 continue;