Jelajahi Sumber

修复报错

dzx 5 bulan lalu
induk
melakukan
cee5eec769

+ 1 - 1
src/main/java/com/xjrsoft/module/attendance/controller/StatisticsController.java

@@ -205,7 +205,7 @@ public class StatisticsController {
             Set<Long> collect = outInRecords.stream().map(StudentOutInRecord::getUserId).collect(Collectors.toSet());
             statisticsVo.setActualCount(Long.valueOf(collect.size()));
 
-            //查询教师请假人数
+            //查询学生请假人数
             Long leaveCount = studentLeaveService.getLeaveCount(startTime, endTime, dto);
             if(leaveCount == null){
                 leaveCount = 0L;

+ 21 - 13
src/main/java/com/xjrsoft/module/attendance/controller/StudentStatisticsController.java

@@ -20,6 +20,7 @@ import com.xjrsoft.module.attendance.dto.StudentDetailsDto;
 import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
 import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
 import com.xjrsoft.module.attendance.vo.StudentStatisticsPageVo;
+import com.xjrsoft.module.attendance.vo.TimeRangeVo;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.holiday.entity.HolidayDate;
@@ -307,36 +308,43 @@ public class StudentStatisticsController {
             //查询每个班的走读生实到人数
             Map<Long, List<StudentOutInRecordVo>> notStayMap = studentOutInRecordService.getNotStayList(startTime, endTime, classIds);
             //查询住校生的实到情况
-            Map<Long, List<StudentOutInRecordVo>> stayMap = studentOutInRecordService.getStayList(startTime, endTime, classIds);
+//            Map<Long, List<StudentOutInRecordVo>> stayMap = studentOutInRecordService.getStayList(startTime, endTime, classIds);
 
             //查询各班的请假人数
-            Map<Long, Integer> classLeaveCount = studentLeaveService.getClassLeaveCount(startTime, endTime);
+            //Map<Long, Integer> classLeaveCount = studentLeaveService.getClassLeaveCount(startTime, endTime);
 
             //计算2个时间相差的天数
             long days = ChronoUnit.DAYS.between(startTime.toLocalDate(), endTime.toLocalDate());
             List<String> dayOfWeeks = new ArrayList<>();
+            List<TimeRangeVo> timeRangeList = new ArrayList<>();
             for (int i = 0; i <= days; i ++){
                 dayOfWeeks.add(startTime.plusDays(i).getDayOfWeek().name());
+                TimeRangeVo rangeVo = new TimeRangeVo();
+                rangeVo.setStartTime(startTime.plusDays(i));
+                rangeVo.setStartTime(startTime.plusDays(i).withHour(23).withMinute(59).withSecond(59));
+                timeRangeList.add(rangeVo);
             }
 
             for (ClassStatisticsVo record: attendancePage.getRecords()) {
-                record.setLeaveCount(classLeaveCount.get(record.getId()) == null ? 0:classLeaveCount.get(record.getId()));
+                //查询班级的请假总人次
+                Integer allLeaveCount = 0;
+                for (TimeRangeVo rangeVo : timeRangeList) {
+                    AttendanceStatisticDto statisticDto = new AttendanceStatisticDto();
+                    statisticDto.setClassId(record.getId());
+                    Long leaveCount = studentLeaveService.getLeaveCount(rangeVo.getStartTime(), rangeVo.getEndTime(), statisticDto);
+                    allLeaveCount += (leaveCount.intValue() * 3);
+                }
+                record.setLeaveCount(allLeaveCount);
+
                 Set<Long> collect = notStayMap.get(record.getId()).stream().map(StudentOutInRecordVo::getUserId).collect(Collectors.toSet());
 
                 record.setActualCount(collect.size());
                 record.setStudentCount(record.getStudentCount() * dayOfWeeks.size() * 3);
 
                 Integer lateCount = 0;
-                for (String dayOfWeek : dayOfWeeks) {
-                    for (StudentOutInRecordVo outInRecord : notStayMap.get(record.getId())) {
-                        if("迟到".equals(outInRecord.getAttendanceStatus())){
-                            lateCount ++;
-                        }
-                    }
-                    for (StudentOutInRecordVo outInRecord : stayMap.get(record.getId())) {
-                        if("迟到".equals(outInRecord.getAttendanceStatus())){
-                            lateCount ++;
-                        }
+                for (StudentOutInRecordVo outInRecord : notStayMap.get(record.getId())) {
+                    if("迟到".equals(outInRecord.getAttendanceStatus())){
+                        lateCount ++;
                     }
                 }