|
@@ -9,25 +9,22 @@ import com.xjrsoft.common.enums.StudyStatusEnum;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
|
|
|
+import com.xjrsoft.module.attendance.dto.TeacherDetailsDto;
|
|
|
+import com.xjrsoft.module.attendance.service.ITeacherAttendanceRecordService;
|
|
|
+import com.xjrsoft.module.attendance.vo.TeacherStatisticsPageVo;
|
|
|
import com.xjrsoft.module.attendance.vo.TeacherStatisticsVo;
|
|
|
import com.xjrsoft.module.attendance.vo.VisitorInfoVo;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.concat.service.IXjrUserService;
|
|
|
import com.xjrsoft.module.organization.entity.UserDeptRelation;
|
|
|
-import com.xjrsoft.module.outint.entity.CarOutInRecord;
|
|
|
import com.xjrsoft.module.outint.entity.StudentOutInRecord;
|
|
|
-import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
|
|
|
import com.xjrsoft.module.outint.service.IStudentOutInRecordService;
|
|
|
-import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
|
|
|
-import com.xjrsoft.module.personnel.entity.CarMessageApply;
|
|
|
-import com.xjrsoft.module.personnel.service.ICarMessageApplyService;
|
|
|
import com.xjrsoft.module.personnel.service.IReservationSchoolService;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudent;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.student.service.IStudentLeaveService;
|
|
|
import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
-import com.xjrsoft.module.teacher.service.IWfTeacherleaveService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -41,7 +38,6 @@ import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -60,12 +56,10 @@ public class StatisticsController {
|
|
|
|
|
|
|
|
|
private final IXjrUserService xjrUserService;
|
|
|
- private final ITeacherOutInRecordService teacherOutInRecordService;
|
|
|
private final IStudentOutInRecordService studentOutInRecordService;
|
|
|
- private final IWfTeacherleaveService wfTeacherleaveService;
|
|
|
private final IStudentLeaveService studentLeaveService;
|
|
|
private final IReservationSchoolService reservationSchoolService;
|
|
|
- private final ICarMessageApplyService carMessageApplyService;
|
|
|
+ private final ITeacherAttendanceRecordService attendanceRecordService;
|
|
|
|
|
|
@GetMapping(value = "/teacher-statistics")
|
|
|
@ApiOperation(value="教职工考勤统计")
|
|
@@ -80,82 +74,42 @@ public class StatisticsController {
|
|
|
.innerJoin(UserDeptRelation.class, UserDeptRelation::getUserId, XjrUser::getId);
|
|
|
long allCount = xjrUserService.count(queryWrapper);
|
|
|
statisticsVo.setAllCount(allCount);
|
|
|
- if(dto.getDate() != null && !"".equals(dto.getDate())){
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE;
|
|
|
- LocalDate queryDate = LocalDate.parse(dto.getDate(), formatter);
|
|
|
- LocalDateTime startTime, endTime, amEndTime = null;
|
|
|
- if(dto.getTimePeriod() != null && dto.getTimePeriod() == 1){
|
|
|
- startTime = queryDate.atTime(5, 0, 0);
|
|
|
- endTime = queryDate.atTime(12, 0, 0);
|
|
|
- }else if(dto.getTimePeriod() != null && dto.getTimePeriod() == 2){
|
|
|
- startTime = queryDate.atTime(12, 0, 0);
|
|
|
- endTime = queryDate.atTime(18, 0, 0);
|
|
|
- amEndTime = queryDate.atTime(12, 0, 0);
|
|
|
- }else if(dto.getTimePeriod() != null && dto.getTimePeriod() == 3){
|
|
|
- startTime = queryDate.atTime(18, 0, 0);
|
|
|
- endTime = queryDate.atTime(23, 59, 59);
|
|
|
- amEndTime = queryDate.atTime(18, 0, 0);
|
|
|
- }else{
|
|
|
- startTime = queryDate.atTime(0, 0, 0);
|
|
|
- endTime = queryDate.atTime(23, 59, 59);
|
|
|
- }
|
|
|
-
|
|
|
- List<TeacherOutInRecord> outInRecords = teacherOutInRecordService.list(
|
|
|
- new MPJLambdaWrapper<TeacherOutInRecord>()
|
|
|
- .le(TeacherOutInRecord::getRecordTime, endTime)
|
|
|
- .select(TeacherOutInRecord::getId)
|
|
|
- .select(TeacherOutInRecord.class, x -> VoToColumnUtil.fieldsToColumns(TeacherOutInRecord.class).contains(x.getProperty()))
|
|
|
- .eq(TeacherOutInRecord::getStatus, 1)
|
|
|
- .eq(dto.getDeptId() != null, UserDeptRelation::getDeptId, dto.getDeptId())
|
|
|
- .eq("DATE_FORMAT(record_time, '%Y-%m-%d')", endTime.toLocalDate())
|
|
|
- .ge(dto.getTimePeriod() == 2 && amEndTime != null, CarOutInRecord::getRecordTime, amEndTime)
|
|
|
- .leftJoin(UserDeptRelation.class, UserDeptRelation::getUserId, TeacherOutInRecord::getUserId)
|
|
|
- .orderByAsc(TeacherOutInRecord::getRecordTime)
|
|
|
- );
|
|
|
-
|
|
|
- long count = carMessageApplyService.count(
|
|
|
- new MPJLambdaWrapper<CarMessageApply>()
|
|
|
- .innerJoin(CarOutInRecord.class, CarOutInRecord::getCarMessageApplyId, CarMessageApply::getId)
|
|
|
- .leftJoin(UserDeptRelation.class, UserDeptRelation::getUserId, CarMessageApply::getUserId)
|
|
|
- .le(CarOutInRecord::getRecordTime, endTime)
|
|
|
- .eq(dto.getDeptId() != null, UserDeptRelation::getDeptId, dto.getDeptId())
|
|
|
- .eq("DATE_FORMAT(record_time, '%Y-%m-%d')", endTime.toLocalDate())
|
|
|
- .ge(dto.getTimePeriod() == 2 && amEndTime != null, CarOutInRecord::getRecordTime, amEndTime)
|
|
|
- .eq(CarOutInRecord::getStatus, OutInStatusEnum.enter.getCode())
|
|
|
- .orderByAsc(CarOutInRecord::getRecordTime)
|
|
|
- );
|
|
|
|
|
|
- Set<Long> collect = outInRecords.stream().map(TeacherOutInRecord::getUserId).collect(Collectors.toSet());
|
|
|
- //实到人数
|
|
|
- statisticsVo.setActualCount(Long.valueOf(collect.size()) + count);
|
|
|
-
|
|
|
- //查询教师请假人数
|
|
|
- Long leaveCount = wfTeacherleaveService.getLeaveCount(startTime, endTime);
|
|
|
- if(leaveCount == null){
|
|
|
- leaveCount = 0L;
|
|
|
- }
|
|
|
- statisticsVo.setLeaveCount(leaveCount);
|
|
|
- //通过考勤规则和实到人数信息,计算迟到的
|
|
|
- Set<Long> userIds = new HashSet<>();
|
|
|
- Long lateCount = 0L;
|
|
|
- for (TeacherOutInRecord outInRecord : outInRecords) {
|
|
|
- if("迟到".equals(outInRecord.getAttendanceStatus()) && !userIds.contains(outInRecord.getUserId())){
|
|
|
- lateCount ++;
|
|
|
- userIds.add(outInRecord.getUserId());
|
|
|
- }
|
|
|
+ TeacherDetailsDto detailsDto = new TeacherDetailsDto();
|
|
|
+ detailsDto.setDate(dto.getDate());
|
|
|
+ detailsDto.setTimePeriod(dto.getTimePeriod());
|
|
|
+ List<TeacherStatisticsPageVo> list = attendanceRecordService.getList(detailsDto);
|
|
|
+
|
|
|
+ Long actualCount = 0L;
|
|
|
+ Long lateCount = 0L;
|
|
|
+ Long leaveCount = 0L;
|
|
|
+ Long absenteeismCount = 0L;
|
|
|
+ for (TeacherStatisticsPageVo recordVo : list) {
|
|
|
+ if("迟到".equals(recordVo.getStatus())){
|
|
|
+ lateCount ++;
|
|
|
+ }else if("请假".equals(recordVo.getStatus())){
|
|
|
+ leaveCount ++;
|
|
|
+ }else if("缺勤".equals(recordVo.getStatus())){
|
|
|
+ absenteeismCount ++;
|
|
|
}
|
|
|
- statisticsVo.setLateCount(lateCount);
|
|
|
-
|
|
|
- //最后通过总人数-实到人数-请假人数计算出缺勤人数
|
|
|
- statisticsVo.setAbsenteeismCount(statisticsVo.getAllCount() - statisticsVo.getLeaveCount() - statisticsVo.getActualCount());
|
|
|
-
|
|
|
- //计算出勤率
|
|
|
- BigDecimal divide = BigDecimal.ZERO;
|
|
|
- if(statisticsVo.getAllCount() != null && statisticsVo.getAllCount() != 0){
|
|
|
- divide = BigDecimal.valueOf(statisticsVo.getActualCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 4, RoundingMode.HALF_UP);
|
|
|
+ if(recordVo.getRecordTime() != null){
|
|
|
+ actualCount ++;
|
|
|
}
|
|
|
- statisticsVo.setAttendanceRate(divide.doubleValue() + "");
|
|
|
}
|
|
|
+ statisticsVo.setLateCount(lateCount);
|
|
|
+ statisticsVo.setActualCount(actualCount);
|
|
|
+ statisticsVo.setLeaveCount(leaveCount);
|
|
|
+ statisticsVo.setAbsenteeismCount(absenteeismCount);
|
|
|
+
|
|
|
+ //最后通过总人数-实到人数-请假人数计算出缺勤人数
|
|
|
+ statisticsVo.setAbsenteeismCount(statisticsVo.getAllCount() - statisticsVo.getLeaveCount() - statisticsVo.getActualCount());
|
|
|
+
|
|
|
+ //计算出勤率
|
|
|
+ BigDecimal divide = BigDecimal.ZERO;
|
|
|
+ if(statisticsVo.getAllCount() != null && statisticsVo.getAllCount() != 0){
|
|
|
+ divide = BigDecimal.valueOf(statisticsVo.getActualCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ statisticsVo.setAttendanceRate(divide.doubleValue() + "");
|
|
|
|
|
|
return RT.ok(statisticsVo);
|
|
|
}
|