|
|
@@ -6,14 +6,11 @@ import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
|
|
|
-import com.xjrsoft.module.attendance.service.IAttendanceMessageSetService;
|
|
|
import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
|
|
|
import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
|
|
|
import com.xjrsoft.module.attendance.vo.TeacherStatisticsVo;
|
|
|
-import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.concat.service.IXjrUserService;
|
|
|
import com.xjrsoft.module.organization.entity.UserDeptRelation;
|
|
|
-import com.xjrsoft.module.organization.service.IDepartmentService;
|
|
|
import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
|
|
|
import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
|
|
|
import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
|
@@ -27,6 +24,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
@@ -46,17 +45,82 @@ import java.util.Map;
|
|
|
public class StatisticsController {
|
|
|
|
|
|
|
|
|
- private final IAttendanceMessageSetService attendanceMessageSetService;
|
|
|
- private final IBaseClassService classService;
|
|
|
- private final IDepartmentService departmentService;
|
|
|
private final IXjrUserService xjrUserService;
|
|
|
private final ITeacherOutInRecordService teacherOutInRecordService;
|
|
|
private final IAttendanceRuleCategoryService ruleCategoryService;
|
|
|
private final IWfTeacherleaveService wfTeacherleaveService;
|
|
|
+
|
|
|
@GetMapping(value = "/teacher-statistics")
|
|
|
@ApiOperation(value="教职工考勤统计")
|
|
|
@SaCheckPermission("statistics:detail")
|
|
|
public RT<TeacherStatisticsVo> teacherStatistics(@Valid AttendanceStatisticDto dto){
|
|
|
+ TeacherStatisticsVo statisticsVo = new TeacherStatisticsVo();
|
|
|
+ //查询总人数
|
|
|
+ MPJLambdaWrapper<XjrUser> queryWrapper = MPJWrappers.<XjrUser>lambdaJoin()
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .innerJoin(BaseTeacher.class,BaseTeacher::getUserId,XjrUser::getId)
|
|
|
+ .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;
|
|
|
+ if(dto.getTimePeriod() == 1){
|
|
|
+ startTime = queryDate.atTime(9, 0, 0);
|
|
|
+ endTime = queryDate.atTime(12, 0, 0);
|
|
|
+ }else if(dto.getTimePeriod() == 2){
|
|
|
+ startTime = queryDate.atTime(12, 0, 0);
|
|
|
+ endTime = queryDate.atTime(18, 0, 0);
|
|
|
+ }else{
|
|
|
+ startTime = queryDate.atTime(0, 0, 0);
|
|
|
+ endTime = queryDate.atTime(23, 59, 59);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TeacherOutInRecord> outInRecords = teacherOutInRecordService.list(
|
|
|
+ new QueryWrapper<TeacherOutInRecord>().lambda()
|
|
|
+ .between(TeacherOutInRecord::getRecordTime, startTime, endTime)
|
|
|
+ );
|
|
|
+ //实到人数
|
|
|
+ statisticsVo.setActualCount(Long.valueOf(outInRecords.size()));
|
|
|
+
|
|
|
+ //查询教师请假人数
|
|
|
+ Long leaveCount = wfTeacherleaveService.getLeaveCount(startTime, endTime);
|
|
|
+ statisticsVo.setLeaveCount(leaveCount);
|
|
|
+
|
|
|
+ //查询每个人当天的考勤规则
|
|
|
+ Map<Long, AttendanceRuleDetailsUserVo> allTeacherTodyRule = ruleCategoryService.getAllTeacherTodyRule(queryDate.getDayOfWeek().name());
|
|
|
+ //通过考勤规则和实到人数信息,计算迟到的
|
|
|
+ Long lateCount = 0L;
|
|
|
+ for (TeacherOutInRecord outInRecord : outInRecords) {
|
|
|
+ AttendanceRuleDetailsUserVo ruleDetails = allTeacherTodyRule.get(outInRecord.getUserId());
|
|
|
+ if(ruleDetails == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ 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 ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ statisticsVo.setLateCount(lateCount);
|
|
|
+
|
|
|
+ //最后通过总人数-实到人数-请假人数计算出缺勤人数
|
|
|
+ statisticsVo.setAbsenteeismCount(statisticsVo.getAllCount() - statisticsVo.getLeaveCount() - statisticsVo.getActualCount());
|
|
|
+
|
|
|
+ //计算出勤率
|
|
|
+ BigDecimal divide = BigDecimal.valueOf(statisticsVo.getActualCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 2, RoundingMode.HALF_UP);
|
|
|
+ statisticsVo.setAttendanceRate(divide.doubleValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ return RT.ok(statisticsVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/student-statistics")
|
|
|
+ @ApiOperation(value="教职工考勤统计")
|
|
|
+ @SaCheckPermission("statistics:detail")
|
|
|
+ public RT<TeacherStatisticsVo> studentStatistics(@Valid AttendanceStatisticDto dto){
|
|
|
TeacherStatisticsVo statisticsVo = new TeacherStatisticsVo();
|
|
|
//查询总人数
|
|
|
MPJLambdaWrapper<XjrUser> queryWrapper = MPJWrappers.<XjrUser>lambdaJoin()
|
|
|
@@ -107,6 +171,10 @@ public class StatisticsController {
|
|
|
|
|
|
//最后通过总人数-实到人数-请假人数计算出缺勤人数
|
|
|
statisticsVo.setAbsenteeismCount(statisticsVo.getAllCount() - statisticsVo.getLeaveCount() - statisticsVo.getActualCount());
|
|
|
+
|
|
|
+ //计算出勤率
|
|
|
+ BigDecimal divide = BigDecimal.valueOf(statisticsVo.getActualCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 2, RoundingMode.HALF_UP);
|
|
|
+ statisticsVo.setAttendanceRate(divide.doubleValue());
|
|
|
}
|
|
|
|
|
|
return RT.ok(statisticsVo);
|