|
|
@@ -13,21 +13,17 @@ import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
|
|
|
import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
|
|
|
import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
|
|
|
import com.xjrsoft.module.attendance.vo.StudentStatisticsPageVo;
|
|
|
-import com.xjrsoft.module.attendance.vo.VisitorInfoVo;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
|
import com.xjrsoft.module.organization.service.IUserService;
|
|
|
import com.xjrsoft.module.outint.entity.StudentOutInRecord;
|
|
|
import com.xjrsoft.module.outint.service.IStudentOutInRecordService;
|
|
|
-import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
|
|
|
import com.xjrsoft.module.outint.vo.StudentOutInRecordVo;
|
|
|
-import com.xjrsoft.module.personnel.service.IReservationSchoolService;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.student.entity.StudentLeave;
|
|
|
import com.xjrsoft.module.student.service.IStudentLeaveService;
|
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
-import com.xjrsoft.module.teacher.service.IWfTeacherleaveService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -42,6 +38,7 @@ import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
@@ -62,18 +59,15 @@ public class StudentStatisticsController {
|
|
|
|
|
|
|
|
|
private final IUserService xjrUserService;
|
|
|
- private final ITeacherOutInRecordService teacherOutInRecordService;
|
|
|
private final IStudentOutInRecordService studentOutInRecordService;
|
|
|
private final IAttendanceRuleCategoryService ruleCategoryService;
|
|
|
- private final IWfTeacherleaveService wfTeacherleaveService;
|
|
|
private final IStudentLeaveService studentLeaveService;
|
|
|
- private final IReservationSchoolService reservationSchoolService;
|
|
|
private final IBaseClassService classService;
|
|
|
|
|
|
@GetMapping(value = "/class-statistics")
|
|
|
@ApiOperation(value="班级考勤统计")
|
|
|
@SaCheckPermission("statistics:detail")
|
|
|
- public RT<PageOutput<ClassStatisticsVo>> teacherStatistics(@Valid AttendanceStatisticDto dto){
|
|
|
+ public RT<PageOutput<ClassStatisticsVo>> classStatistics(@Valid AttendanceStatisticDto dto){
|
|
|
Page<ClassStatisticsVo> attendancePage = classService.getAttendancePage(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
List<Long> classIds = new ArrayList<>();
|
|
|
for (ClassStatisticsVo record : attendancePage.getRecords()) {
|
|
|
@@ -221,12 +215,77 @@ public class StudentStatisticsController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @GetMapping(value = "/visitor-list")
|
|
|
- @ApiOperation(value="访客列表")
|
|
|
+ @GetMapping(value = "/class-history")
|
|
|
+ @ApiOperation(value="历史考勤")
|
|
|
@SaCheckPermission("statistics:detail")
|
|
|
- public RT<List<VisitorInfoVo>> visitorList(@Valid AttendanceStatisticDto dto){
|
|
|
- List<VisitorInfoVo> visionList = reservationSchoolService.getVisionList(dto.getDate());
|
|
|
- return RT.ok(visionList);
|
|
|
+ public RT<PageOutput<ClassStatisticsVo>> classHistory(@Valid AttendanceStatisticDto dto){
|
|
|
+ Page<ClassStatisticsVo> attendancePage = classService.getAttendancePage(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
+ List<Long> classIds = new ArrayList<>();
|
|
|
+ for (ClassStatisticsVo record : attendancePage.getRecords()) {
|
|
|
+ classIds.add(record.getId());
|
|
|
+ }
|
|
|
+ if(dto.getStartTime() != null && !"".equals(dto.getStartTime()) && dto.getEndTime() != null && !"".equals(dto.getEndTime())){
|
|
|
+ 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);
|
|
|
+
|
|
|
+ //查询每个班的走读生实到人数
|
|
|
+ Map<Long, List<StudentOutInRecordVo>> notStayMap = studentOutInRecordService.getNotStayList(startTime, endTime, classIds);
|
|
|
+ //查询住校生的实到情况
|
|
|
+ Map<Long, List<StudentOutInRecordVo>> stayMap = studentOutInRecordService.getStayList(startTime, endTime, classIds);
|
|
|
+
|
|
|
+ //查询各班的请假人数
|
|
|
+ Map<Long, Integer> classLeaveCount = studentLeaveService.getClassLeaveCount(startTime, endTime);
|
|
|
+
|
|
|
+ //计算2个时间相差的天数
|
|
|
+ long days = ChronoUnit.DAYS.between(startTime.toLocalDate(), endTime.toLocalDate());
|
|
|
+ List<String> dayOfWeeks = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= days; i ++){
|
|
|
+ dayOfWeeks.add(startTime.plusDays(i).getDayOfWeek().name());
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询走读生的考勤规则
|
|
|
+ Map<String, Map<Long, AttendanceRuleDetailsUserVo>> notStayTodyRule = ruleCategoryService.getAllStudentTodyRule(dayOfWeeks);
|
|
|
+ //查询住校生生的考勤规则
|
|
|
+ Map<String, Map<Long, AttendanceRuleDetailsUserVo>> staySundayRule = ruleCategoryService.getAllStudentTodyRule(dayOfWeeks);
|
|
|
+
|
|
|
+ for (ClassStatisticsVo record: attendancePage.getRecords()) {
|
|
|
+ record.setLeaveCount(classLeaveCount.get(record.getId()) == null ? 0:classLeaveCount.get(record.getId()));
|
|
|
+ record.setActualCount(notStayMap.get(record.getId()).size() + stayMap.get(record.getId()).size());
|
|
|
+ record.setStudentCount(record.getStudentCount() * dayOfWeeks.size());
|
|
|
+
|
|
|
+ Integer lateCount = 0;
|
|
|
+ for (String dayOfWeek : dayOfWeeks) {
|
|
|
+ for (StudentOutInRecordVo outInRecord : notStayMap.get(record.getId())) {
|
|
|
+ AttendanceRuleDetailsUserVo ruleDetails = notStayTodyRule.get(dayOfWeek).get(outInRecord.getUserId());
|
|
|
+ if(dto.getTimePeriod() == 1 && outInRecord.getRecordTime().toLocalTime().compareTo(ruleDetails.getAmStartTime()) > 0){
|
|
|
+ lateCount ++;
|
|
|
+ }else if(dto.getTimePeriod() == 2 && outInRecord.getRecordTime().toLocalTime().compareTo(ruleDetails.getPmStartTime()) > 0){
|
|
|
+ lateCount ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (StudentOutInRecordVo outInRecord : stayMap.get(record.getId())) {
|
|
|
+ AttendanceRuleDetailsUserVo ruleDetails = staySundayRule.get(dayOfWeek).get(outInRecord.getUserId());
|
|
|
+ if(dto.getTimePeriod() == 1 && outInRecord.getRecordTime().toLocalTime().compareTo(ruleDetails.getAmStartTime()) > 0){
|
|
|
+ lateCount ++;
|
|
|
+ }else if(dto.getTimePeriod() == 2 && outInRecord.getRecordTime().toLocalTime().compareTo(ruleDetails.getPmStartTime()) > 0){
|
|
|
+ lateCount ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ record.setLateCount(lateCount);
|
|
|
+
|
|
|
+ //最后通过总人数-实到人数-请假人数计算出缺勤人数
|
|
|
+ record.setAbsenteeismCount(record.getStudentCount() - record.getLeaveCount() - record.getActualCount());
|
|
|
+
|
|
|
+ //计算出勤率
|
|
|
+ BigDecimal divide = BigDecimal.valueOf(record.getActualCount()).divide(BigDecimal.valueOf(record.getStudentCount()), 2, RoundingMode.HALF_UP);
|
|
|
+ record.setAttendanceRate(divide.doubleValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PageOutput<ClassStatisticsVo> pageOutput = ConventPage.getPageOutput(attendancePage, ClassStatisticsVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
}
|
|
|
|
|
|
}
|