dzx преди 1 месец
родител
ревизия
08ba417b72
променени са 1 файла, в които са добавени 16 реда и са изтрити 3 реда
  1. 16 3
      src/main/java/com/xjrsoft/module/attendance/service/impl/AttendanceStatisticsServiceImpl.java

+ 16 - 3
src/main/java/com/xjrsoft/module/attendance/service/impl/AttendanceStatisticsServiceImpl.java

@@ -28,6 +28,8 @@ import com.xjrsoft.module.attendance.service.IAttendanceStatisticsService;
 import com.xjrsoft.module.attendance.service.ITeacherAttendanceRecordService;
 import com.xjrsoft.module.attendance.vo.AttendanceStatisticsPageVo;
 import com.xjrsoft.module.attendance.vo.AttendanceStatisticsRecordVo;
+import com.xjrsoft.module.holiday.entity.HolidayDate;
+import com.xjrsoft.module.holiday.service.IHolidayDateService;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.organization.vo.UserIdDeptNameVo;
@@ -54,6 +56,7 @@ import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -81,6 +84,8 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
 
     private final IAttendanceRuleCategoryService ruleCategoryService;
 
+    private final IHolidayDateService holidayDateService;
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -89,9 +94,7 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
         attendanceStatistics.setCreateDate(new Date());
         attendanceStatistics.setStatus(0);
         statisticsMapper.insert(attendanceStatistics);
-        CompletableFuture.runAsync(() -> {
-            refreshRecord(attendanceStatistics.getId());
-        });
+        refreshRecord(attendanceStatistics.getId());
         return true;
     }
 
@@ -306,9 +309,19 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
     private List<LocalDate> getDatesBetween(LocalDate startDate, LocalDate endDate, Map<String, AttendanceRuleDetails> ruleMap, Map<String, String> weekEnMap) {
         List<LocalDate> dates = new ArrayList<>();
 
+        List<HolidayDate> holidayDates = holidayDateService.list(
+                new QueryWrapper<HolidayDate>().lambda()
+                        .eq(HolidayDate::getStatus, 3)
+        );
+        List<String> holidayDateList = holidayDates.stream().map(HolidayDate::getDate).collect(Collectors.toList());
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         long numOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate) + 1; // +1 包含结束日期
         for (long i = 0; i < numOfDaysBetween; i++) {
             LocalDate localDate = startDate.plusDays(i);
+            AttendanceRuleDetails holidays = ruleMap.get("holidays");
+            if(holidayDateList.contains(localDate.format(formatter)) && (holidays.getIsAttendance() == null || holidays.getIsAttendance() == 0)){
+                continue;
+            }
             AttendanceRuleDetails ruleDetails = ruleMap.get(weekEnMap.get(localDate.getDayOfWeek().name()));
             if(ruleDetails != null && ruleDetails.getIsAttendance() != null && ruleDetails.getIsAttendance() == 1){
                 dates.add(localDate);