|
@@ -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;
|
|
@@ -77,7 +78,6 @@ public class StudentStatisticsController {
|
|
|
private final IStudentLeaveService studentLeaveService;
|
|
|
private final IBaseClassService classService;
|
|
|
private final IHolidayDateService holidayDateService;
|
|
|
- private final IAttendanceRuleCategoryService ruleCategoryService;
|
|
|
private final IBaseClassService baseClassService;
|
|
|
@GetMapping(value = "/class-statistics")
|
|
|
@ApiOperation(value="班级考勤统计")
|
|
@@ -293,41 +293,58 @@ public class StudentStatisticsController {
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE;
|
|
|
LocalDateTime startTime = LocalDate.parse(dto.getStartTime(), formatter).atTime(0, 0, 0);
|
|
|
LocalDateTime endTime = LocalDate.parse(dto.getEndTime(), formatter).atTime(23, 59, 59);
|
|
|
+ //如果查询天数只有一天
|
|
|
+ if(startTime.toLocalDate().isEqual(endTime.toLocalDate())){
|
|
|
+ HolidayDate holidayDate = holidayDateService.getOne(
|
|
|
+ new QueryWrapper<HolidayDate>().lambda()
|
|
|
+ .eq(HolidayDate::getDate, endTime.toLocalDate())
|
|
|
+ );
|
|
|
+ if(holidayDate != null && holidayDate.getWay() != null && holidayDate.getWay() != 0){
|
|
|
+ return RT.ok(ConventPage.getPageOutput(attendancePage, ClassStatisticsVo.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//查询每个班的走读生实到人数
|
|
|
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 ++;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -393,7 +410,7 @@ public class StudentStatisticsController {
|
|
|
|
|
|
Integer lateCount = 0;
|
|
|
for (StudentOutInRecordVo outInRecord : notStayMap.get(record.getId())) {
|
|
|
- if(outInRecord.getStatus() == 1){
|
|
|
+ if(outInRecord.getStatus() == OutInStatusEnum.enter.getCode()){
|
|
|
continue;
|
|
|
}
|
|
|
if("迟到".equals(outInRecord.getAttendanceStatus())){
|
|
@@ -401,7 +418,7 @@ public class StudentStatisticsController {
|
|
|
}
|
|
|
}
|
|
|
for (StudentOutInRecordVo outInRecord : stayMap.get(record.getId())) {
|
|
|
- if(outInRecord.getStatus() == 1){
|
|
|
+ if(outInRecord.getStatus() == OutInStatusEnum.enter.getCode()){
|
|
|
continue;
|
|
|
}
|
|
|
if("迟到".equals(outInRecord.getAttendanceStatus())){
|