dzx vor 1 Jahr
Ursprung
Commit
9d99e30e35

+ 1 - 1
src/main/java/com/xjrsoft/module/attendance/controller/StudentStatisticsController.java

@@ -182,7 +182,7 @@ public class StudentStatisticsController {
             LocalDateTime lastSundayStart = startTime.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).plusDays(-1);
             LocalDateTime lastSundayEnd = endTime.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).plusDays(-1);
 
-            Map<Long, AttendanceRuleDetailsUserVo> allTodyRule = ruleCategoryService.getAllTeacherTodyRule(queryDate.getDayOfWeek().name());
+            Map<Long, AttendanceRuleDetailsUserVo> allTodyRule = ruleCategoryService.getAllStudentTodyRule(queryDate.getDayOfWeek().name());
             //查询当前时间段存在请假的学生
             Map<Long, StudentLeave> leaveList = studentLeaveService.getLeaveList(startTime, endTime);
             //查询进入记录

+ 123 - 0
src/main/java/com/xjrsoft/module/attendance/controller/TeacherStatisticsController.java

@@ -0,0 +1,123 @@
+package com.xjrsoft.module.attendance.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.model.result.RT;
+import com.xjrsoft.common.page.ConventPage;
+import com.xjrsoft.common.page.PageOutput;
+import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
+import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
+import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
+import com.xjrsoft.module.attendance.vo.TeacherStatisticsPageVo;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
+import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
+import com.xjrsoft.module.personnel.service.IReservationSchoolService;
+import com.xjrsoft.module.teacher.entity.BaseTeacher;
+import com.xjrsoft.module.teacher.entity.WfTeacherleave;
+import com.xjrsoft.module.teacher.service.IWfTeacherleaveService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+* @title: 教师考勤
+* @Author dzx
+* @Date: 2024-05-29
+* @Version 1.0
+*/
+@RestController
+@RequestMapping("/teacherStatistics")
+@Api(value = "/teacherStatistics" ,tags = "教师考勤统计")
+@AllArgsConstructor
+public class TeacherStatisticsController {
+
+
+    private final IUserService xjrUserService;
+    private final ITeacherOutInRecordService teacherOutInRecordService;
+    private final IAttendanceRuleCategoryService ruleCategoryService;
+    private final IWfTeacherleaveService wfTeacherleaveService;
+    private final IReservationSchoolService reservationSchoolService;
+
+
+    @GetMapping(value = "/teacher-details")
+    @ApiOperation(value="学生考勤")
+    @SaCheckPermission("statistics:detail")
+    public RT<PageOutput<TeacherStatisticsPageVo>> studentDetails(@Valid AttendanceStatisticDto dto){
+        MPJLambdaWrapper<User> queryUser = new MPJLambdaWrapper<>();
+        queryUser.disableSubLogicDel().distinct()
+                .selectAs(User::getName, TeacherStatisticsPageVo::getTeacherName)
+                .selectAs(User::getId, TeacherStatisticsPageVo::getUserId)
+                .selectAs(User::getMobile, TeacherStatisticsPageVo::getMobile)
+                .innerJoin(BaseTeacher.class, BaseTeacher::getUserId, User::getId);
+        IPage<TeacherStatisticsPageVo> voIPage = xjrUserService.selectJoinListPage(ConventPage.getPage(dto), TeacherStatisticsPageVo.class, queryUser);
+
+        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);
+            }
+
+            Map<Long, AttendanceRuleDetailsUserVo> allTodyRule = ruleCategoryService.getAllTeacherTodyRule(queryDate.getDayOfWeek().name());
+            //查询当前时间段存在请假的教师
+            Map<Long, WfTeacherleave> leaveList = wfTeacherleaveService.getLeaveList(startTime, endTime);
+            //查询进入记录
+            List<TeacherOutInRecord> outInRecords = teacherOutInRecordService.list(
+                    new QueryWrapper<TeacherOutInRecord>().lambda()
+                            .between(TeacherOutInRecord::getRecordTime, startTime, endTime)
+                            .eq(TeacherOutInRecord::getStatus, 0)
+            );
+            Map<Long, TeacherOutInRecord> outInMap = new HashMap<>();
+            for (TeacherOutInRecord inRecord : outInRecords) {
+                outInMap.put(inRecord.getUserId(), inRecord);
+            }
+            for (TeacherStatisticsPageVo record : voIPage.getRecords()) {
+                WfTeacherleave studentLeave = leaveList.get(record.getUserId());
+                if(studentLeave != null){
+                    record.setStatus(studentLeave.getLeaveType());
+                }else{
+                    AttendanceRuleDetailsUserVo ruleUserVo = allTodyRule.get(record.getUserId());
+                    TeacherOutInRecord outInRecord = outInMap.get(record.getUserId());
+                    if(ruleUserVo.getIsAllowInOutSchool() != null && ruleUserVo.getIsAllowInOutSchool() == 0){
+                        record.setStatus("不考核");
+                    }else{
+                        if(dto.getTimePeriod() == 1 && outInRecord.getRecordTime().toLocalTime().compareTo(ruleUserVo.getAmStartTime()) > 0){
+                            record.setStatus("迟到");
+                        }else if(dto.getTimePeriod() == 2 && outInRecord.getRecordTime().toLocalTime().compareTo(ruleUserVo.getPmStartTime()) > 0){
+                            record.setStatus("迟到");
+                        }else{
+                            record.setStatus("到校");
+                        }
+                    }
+                }
+            }
+        }
+        PageOutput<TeacherStatisticsPageVo> pageOutput = ConventPage.getPageOutput(voIPage, TeacherStatisticsPageVo.class);
+        return RT.ok(pageOutput);
+    }
+
+}

+ 26 - 0
src/main/java/com/xjrsoft/module/attendance/vo/TeacherStatisticsPageVo.java

@@ -0,0 +1,26 @@
+package com.xjrsoft.module.attendance.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* @title: 教师考勤统计列表
+* @Author dzx
+* @Date: 2024年5月29日
+* @Version 1.0
+*/
+@Data
+public class TeacherStatisticsPageVo {
+
+    @ApiModelProperty("教职工姓名")
+    private String teacherName;
+
+    @ApiModelProperty("手机号")
+    private String mobile;
+
+    @ApiModelProperty("考勤状态")
+    private String status;
+
+    @ApiModelProperty("教师userId")
+    private Long userId;
+}

+ 4 - 0
src/main/java/com/xjrsoft/module/teacher/mapper/WfTeacherleaveMapper.java

@@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
 
 /**
 * @title: 教职工请假流程
@@ -17,4 +19,6 @@ import java.time.LocalDateTime;
 public interface WfTeacherleaveMapper extends MPJBaseMapper<WfTeacherleave> {
 
     Long getLeaveCount(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
+
+    List<WfTeacherleave> getLeaveList(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/teacher/service/IWfTeacherleaveService.java

@@ -5,6 +5,7 @@ import com.xjrsoft.module.personnel.entity.ReservationSchool;
 import com.xjrsoft.module.teacher.entity.WfTeacherleave;
 
 import java.time.LocalDateTime;
+import java.util.Map;
 
 /**
 * @title: 教职工请假流程
@@ -24,4 +25,6 @@ public interface IWfTeacherleaveService extends MPJBaseService<WfTeacherleave> {
     Boolean hikvisionLeave(Long id);
 
     Long getLeaveCount(LocalDateTime startTime, LocalDateTime endTime);
+
+    Map<Long, WfTeacherleave> getLeaveList(LocalDateTime startTime, LocalDateTime endTime);
 }

+ 13 - 0
src/main/java/com/xjrsoft/module/teacher/service/impl/WfTeacherleaveServiceImpl.java

@@ -189,6 +189,19 @@ public class WfTeacherleaveServiceImpl extends MPJBaseServiceImpl<WfTeacherleave
         return wfTeacherleaveMapper.getLeaveCount(startTime, endTime);
     }
 
+    @Override
+    public Map<Long, WfTeacherleave> getLeaveList(LocalDateTime startTime, LocalDateTime endTime) {
+        List<WfTeacherleave> leaveList = wfTeacherleaveMapper.getLeaveList(startTime, endTime);
+        Map<Long, WfTeacherleave> result = new HashMap<>();
+        for (WfTeacherleave teacherleave : leaveList) {
+            String[] teacherIds = teacherleave.getUserId().split(",");
+            for (String teacherId : teacherIds) {
+                result.put(Long.valueOf(teacherId), teacherleave);
+            }
+        }
+        return result;
+    }
+
     JsonArray selectResource(ApiUtil apiUtil){
         String apiPath = "/api/irds/v2/resource/resourcesByParams";
         JsonObject jsonObject = new JsonObject();