소스 검색

Merge branch 'pre'

dzx 6 달 전
부모
커밋
0c2d1e1512
1개의 변경된 파일19개의 추가작업 그리고 19개의 파일을 삭제
  1. 19 19
      src/main/java/com/xjrsoft/module/attendance/controller/StatisticsController.java

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

@@ -115,33 +115,33 @@ public class StatisticsController {
         detailsDto.setRuleCategoryId(dto.getRuleCategoryId());
         List<TeacherStatisticsPageVo> list = attendanceRecordService.getList(detailsDto);
 
-        Long actualCount = 0L;
-        Long lateCount = 0L;
-        Long leaveCount = 0L;
-        Long absenteeismCount = 0L;
-        Integer dividendCount = 0;
+        Set<Long> actualCount = new HashSet<>();
+        Set<Long> lateCount = new HashSet<>();
+        Set<Long> leaveCount = new HashSet<>();
+        Set<Long> absenteeismCount = new HashSet<>();
+        Set<Long> dividendCount = new HashSet<>();
         Set<Long> teacherIds = new HashSet<>();
         for (TeacherStatisticsPageVo recordVo : list) {
             teacherIds.add(recordVo.getUserId());
             if ("迟到".equals(recordVo.getStatus())) {
-                lateCount++;
-                dividendCount++;
+                lateCount.add(recordVo.getUserId());
+                dividendCount.add(recordVo.getUserId());
             } else if ("请假".equals(recordVo.getStatus())) {
-                leaveCount++;
-                dividendCount++;
+                leaveCount.add(recordVo.getUserId());
+                dividendCount.add(recordVo.getUserId());
             } else if ("缺勤".equals(recordVo.getStatus())) {
-                absenteeismCount++;
-                dividendCount++;
+                absenteeismCount.add(recordVo.getUserId());
+                dividendCount.add(recordVo.getUserId());
             }
             if (recordVo.getRecordTime() != null) {
-                actualCount++;
-                dividendCount++;
+                actualCount.add(recordVo.getUserId());
+                dividendCount.add(recordVo.getUserId());
             }
         }
-        statisticsVo.setLateCount(lateCount);
-        statisticsVo.setActualCount(actualCount);
-        statisticsVo.setLeaveCount(leaveCount);
-        statisticsVo.setAbsenteeismCount(absenteeismCount);
+        statisticsVo.setLateCount(lateCount.stream().count());
+        statisticsVo.setActualCount(actualCount.stream().count());
+        statisticsVo.setLeaveCount(leaveCount.stream().count());
+        statisticsVo.setAbsenteeismCount(absenteeismCount.stream().count());
 
 //        //查询不需要考勤的人
 //        List<AttendanceRuleCategory> ruleCategories = ruleCategoryService.list(
@@ -193,8 +193,8 @@ public class StatisticsController {
 
         //计算出勤率
         BigDecimal divide = BigDecimal.ZERO;
-        if (dividendCount != 0) {
-            divide = BigDecimal.valueOf(statisticsVo.getActualCount()).divide(BigDecimal.valueOf(dividendCount), 4, RoundingMode.HALF_UP);
+        if (!dividendCount.isEmpty()) {
+            divide = BigDecimal.valueOf(statisticsVo.getActualCount()).divide(BigDecimal.valueOf(dividendCount.size()), 4, RoundingMode.HALF_UP);
         }
         statisticsVo.setAttendanceRate(divide.doubleValue() + "");