浏览代码

班级考勤

dzx 1 年之前
父节点
当前提交
d450c70d78
共有 18 个文件被更改,包括 509 次插入11 次删除
  1. 2 0
      src/main/java/com/xjrsoft/module/attendance/controller/StatisticsController.java
  2. 218 0
      src/main/java/com/xjrsoft/module/attendance/controller/StudentStatisticsController.java
  3. 2 1
      src/main/java/com/xjrsoft/module/attendance/dto/AttendanceStatisticDto.java
  4. 48 0
      src/main/java/com/xjrsoft/module/attendance/vo/ClassStatisticsVo.java
  5. 5 0
      src/main/java/com/xjrsoft/module/base/mapper/BaseClassMapper.java
  6. 4 0
      src/main/java/com/xjrsoft/module/base/service/IBaseClassService.java
  7. 7 0
      src/main/java/com/xjrsoft/module/base/service/impl/BaseClassServiceImpl.java
  8. 13 0
      src/main/java/com/xjrsoft/module/outint/mapper/StudentOutInRecordMapper.java
  9. 28 0
      src/main/java/com/xjrsoft/module/outint/service/IStudentOutInRecordService.java
  10. 65 0
      src/main/java/com/xjrsoft/module/outint/service/impl/StudentOutInRecordServiceImpl.java
  11. 22 0
      src/main/java/com/xjrsoft/module/outint/vo/IdCountVo.java
  12. 3 1
      src/main/java/com/xjrsoft/module/outint/vo/StudentOutInRecordVo.java
  13. 4 0
      src/main/java/com/xjrsoft/module/student/mapper/StudentLeaveMapper.java
  14. 3 0
      src/main/java/com/xjrsoft/module/student/service/IStudentLeaveService.java
  15. 13 1
      src/main/java/com/xjrsoft/module/student/service/impl/StudentLeaveServiceImpl.java
  16. 17 1
      src/main/resources/mapper/base/BaseClass.xml
  17. 37 0
      src/main/resources/mapper/outin/StudentOutInRecordMapper.xml
  18. 18 7
      src/main/resources/mapper/student/StudentLeaveMapper.xml

+ 2 - 0
src/main/java/com/xjrsoft/module/attendance/controller/StatisticsController.java

@@ -90,6 +90,7 @@ public class StatisticsController {
             List<TeacherOutInRecord> outInRecords = teacherOutInRecordService.list(
                     new QueryWrapper<TeacherOutInRecord>().lambda()
                             .between(TeacherOutInRecord::getRecordTime, startTime, endTime)
+                            .eq(TeacherOutInRecord::getStatus, 0)
             );
             //实到人数
             statisticsVo.setActualCount(Long.valueOf(outInRecords.size()));
@@ -159,6 +160,7 @@ public class StatisticsController {
             List<StudentOutInRecord> outInRecords = studentOutInRecordService.list(
                     new QueryWrapper<StudentOutInRecord>().lambda()
                             .between(StudentOutInRecord::getRecordTime, startTime, endTime)
+                            .eq(StudentOutInRecord::getStatus, 0)
             );
             //实到人数
             statisticsVo.setActualCount(Long.valueOf(outInRecords.size()));

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

@@ -0,0 +1,218 @@
+package com.xjrsoft.module.attendance.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+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.IAttendanceRuleCategoryService;
+import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
+import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
+import com.xjrsoft.module.attendance.vo.TeacherStatisticsVo;
+import com.xjrsoft.module.attendance.vo.VisitorInfoVo;
+import com.xjrsoft.module.base.service.IBaseClassService;
+import com.xjrsoft.module.concat.service.IXjrUserService;
+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.BaseStudent;
+import com.xjrsoft.module.student.service.IStudentLeaveService;
+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;
+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.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+* @title: 考勤消息设置
+* @Author dzx
+* @Date: 2024-05-21
+* @Version 1.0
+*/
+@RestController
+@RequestMapping("/studentStatistics")
+@Api(value = "/studentStatistics" ,tags = "学生考勤统计")
+@AllArgsConstructor
+public class StudentStatisticsController {
+
+
+    private final IXjrUserService 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<Page<ClassStatisticsVo>> teacherStatistics(@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.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);
+            }
+            LocalDateTime lastSundayStart = startTime.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).plusDays(-1);
+            LocalDateTime lastSundayEnd = endTime.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).plusDays(-1);
+
+            //查询每个班的走读生实到人数
+            Map<Long, List<StudentOutInRecordVo>> notStayMap = studentOutInRecordService.getNotStayList(startTime, endTime, classIds);
+            //查询住校生的实到情况
+            Map<Long, List<StudentOutInRecordVo>> stayMap = studentOutInRecordService.getStayList(lastSundayStart, lastSundayEnd, classIds);
+
+            //查询各班的请假人数
+            Map<Long, Integer> classLeaveCount = studentLeaveService.getClassLeaveCount(startTime, endTime);
+
+            //查询走读生的考勤规则
+            Map<Long, AttendanceRuleDetailsUserVo> notStayTodyRule = ruleCategoryService.getAllStudentTodyRule(queryDate.getDayOfWeek().name());
+            //查询住校生生的考勤规则
+            Map<Long, AttendanceRuleDetailsUserVo> staySundayRule = ruleCategoryService.getAllStudentTodyRule(lastSundayStart.getDayOfWeek().name());
+
+            for (ClassStatisticsVo record: attendancePage.getRecords()) {
+                record.setLeaveCount(classLeaveCount.get(record.getId()));
+                record.setActualCount(notStayMap.get(record.getId()).size() + stayMap.get(record.getId()).size());
+
+                Integer lateCount = 0;
+                for (StudentOutInRecordVo outInRecord : notStayMap.get(record.getId())) {
+                    AttendanceRuleDetailsUserVo ruleDetails = notStayTodyRule.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(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());
+            }
+        }
+
+        return RT.ok(attendancePage);
+    }
+
+
+    @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()
+                .disableSubLogicDel()
+                .innerJoin(BaseStudent.class, BaseStudent::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<StudentOutInRecord> outInRecords = studentOutInRecordService.list(
+                    new QueryWrapper<StudentOutInRecord>().lambda()
+                            .between(StudentOutInRecord::getRecordTime, startTime, endTime)
+            );
+            //实到人数
+            statisticsVo.setActualCount(Long.valueOf(outInRecords.size()));
+
+            //查询教师请假人数
+            Long leaveCount = studentLeaveService.getLeaveCount(startTime, endTime);
+            if(leaveCount == null){
+                leaveCount = 0L;
+            }
+            statisticsVo.setLeaveCount(leaveCount);
+
+            //查询每个人当天的考勤规则
+            Map<Long, AttendanceRuleDetailsUserVo> allTeacherTodyRule = ruleCategoryService.getAllStudentTodyRule(queryDate.getDayOfWeek().name());
+            //通过考勤规则和实到人数信息,计算迟到的
+            Long lateCount = 0L;
+            for (StudentOutInRecord outInRecord : outInRecords) {
+                AttendanceRuleDetailsUserVo ruleDetails = allTeacherTodyRule.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 ++;
+                }
+            }
+            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 = "/visitor-list")
+    @ApiOperation(value="访客列表")
+    @SaCheckPermission("statistics:detail")
+    public RT<List<VisitorInfoVo>> visitorList(@Valid AttendanceStatisticDto dto){
+        List<VisitorInfoVo> visionList = reservationSchoolService.getVisionList(dto.getDate());
+        return RT.ok(visionList);
+    }
+
+}

+ 2 - 1
src/main/java/com/xjrsoft/module/attendance/dto/AttendanceStatisticDto.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.attendance.dto;
 
+import com.xjrsoft.common.page.PageInput;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -8,7 +9,7 @@ import java.time.LocalDate;
 
 @Data
 @EqualsAndHashCode(callSuper = false)
-public class AttendanceStatisticDto {
+public class AttendanceStatisticDto extends PageInput {
 
     @ApiModelProperty("时间段(1:上午 2:下午)")
     private Integer timePeriod;

+ 48 - 0
src/main/java/com/xjrsoft/module/attendance/vo/ClassStatisticsVo.java

@@ -0,0 +1,48 @@
+package com.xjrsoft.module.attendance.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* @title: 教职工统计
+* @Author dzx
+* @Date: 2024年5月24日
+* @Version 1.0
+*/
+@Data
+public class ClassStatisticsVo {
+
+    @ApiModelProperty("班级id")
+    private Long id;
+
+    @ApiModelProperty("班级名称")
+    private String name;
+
+    @ApiModelProperty("班主任姓名")
+    private String teacherName;
+
+    @ApiModelProperty("学生总人数")
+    private Integer studentCount;
+
+    @ApiModelProperty("住校人数")
+    private Integer stayCount;
+
+    @ApiModelProperty("走读人数")
+    private Integer notStayCount;
+
+    @ApiModelProperty("请假人数")
+    private Integer leaveCount;
+
+    @ApiModelProperty("迟到人数")
+    private Integer lateCount;
+
+    @ApiModelProperty("实到人数")
+    private Integer actualCount;
+
+    @ApiModelProperty("缺勤人数")
+    private Integer absenteeismCount;
+
+    @ApiModelProperty("出勤率")
+    private Double attendanceRate;
+
+}

+ 5 - 0
src/main/java/com/xjrsoft/module/base/mapper/BaseClassMapper.java

@@ -2,6 +2,8 @@ package com.xjrsoft.module.base.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
+import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
 import com.xjrsoft.module.base.dto.BaseClassPageDto;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.vo.BaseClassPageVo;
@@ -24,4 +26,7 @@ public interface BaseClassMapper extends MPJBaseMapper<BaseClass> {
     Page<BaseClassPageVo> getPage(Page<BaseClassPageVo> page, BaseClassPageDto dto);
 
     List<StudentClassVo> getStudentClass();
+
+
+    Page<ClassStatisticsVo> getAttendanceClass(Page<ClassStatisticsVo> page, AttendanceStatisticDto dto);
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/base/service/IBaseClassService.java

@@ -2,6 +2,8 @@ package com.xjrsoft.module.base.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
+import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
 import com.xjrsoft.module.base.dto.BaseClassPageDto;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.vo.BaseClassPageVo;
@@ -17,4 +19,6 @@ public interface IBaseClassService extends MPJBaseService<BaseClass> {
     Page<BaseClassPageVo> getPage(Page<BaseClassPageVo> page, BaseClassPageDto dto);
 
     List<StudentClassVo> getStudentClass();
+
+    Page<ClassStatisticsVo> getAttendancePage(Page<ClassStatisticsVo> page, AttendanceStatisticDto dto);
 }

+ 7 - 0
src/main/java/com/xjrsoft/module/base/service/impl/BaseClassServiceImpl.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
+import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
 import com.xjrsoft.module.base.dto.BaseClassPageDto;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.mapper.BaseClassMapper;
@@ -87,4 +89,9 @@ public class BaseClassServiceImpl extends MPJBaseServiceImpl<BaseClassMapper, Ba
     public List<StudentClassVo> getStudentClass() {
         return baseClassMapper.getStudentClass();
     }
+
+    @Override
+    public Page<ClassStatisticsVo> getAttendancePage(Page<ClassStatisticsVo> page, AttendanceStatisticDto dto){
+        return baseClassMapper.getAttendanceClass(page, dto);
+    };
 }

+ 13 - 0
src/main/java/com/xjrsoft/module/outint/mapper/StudentOutInRecordMapper.java

@@ -2,7 +2,13 @@ package com.xjrsoft.module.outint.mapper;
 
 import com.github.yulichang.base.MPJBaseMapper;
 import com.xjrsoft.module.outint.entity.StudentOutInRecord;
+import com.xjrsoft.module.outint.vo.IdCountVo;
+import com.xjrsoft.module.outint.vo.StudentOutInRecordVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+import java.util.List;
 
 /**
 * @title: 学生出入记录
@@ -13,4 +19,11 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface StudentOutInRecordMapper extends MPJBaseMapper<StudentOutInRecord> {
 
+    List<IdCountVo> getNotStayClassCount(@Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime);
+
+    List<IdCountVo> getStayClassCount(@Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime);
+
+    List<StudentOutInRecordVo> getNotStayList(@Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime);
+
+    List<StudentOutInRecordVo> getStayList(@Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime);
 }

+ 28 - 0
src/main/java/com/xjrsoft/module/outint/service/IStudentOutInRecordService.java

@@ -2,6 +2,12 @@ package com.xjrsoft.module.outint.service;
 
 import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.outint.entity.StudentOutInRecord;
+import com.xjrsoft.module.outint.vo.StudentOutInRecordVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
 
 /**
 * @title: 学生出入记录
@@ -11,4 +17,26 @@ import com.xjrsoft.module.outint.entity.StudentOutInRecord;
 */
 
 public interface IStudentOutInRecordService extends MPJBaseService<StudentOutInRecord> {
+
+    Map<Long, Integer> getNotStayClassCount(LocalDateTime startTime, LocalDateTime endTime);
+
+    Map<Long, Integer> getStayClassCount(LocalDateTime startTime, LocalDateTime endTime);
+
+    /**
+     * 查询每个班级指定时间段内走读生到校人数
+     * @param startTime
+     * @param endTime
+     * @param classIds
+     * @return
+     */
+    Map<Long, List<StudentOutInRecordVo>> getNotStayList(LocalDateTime startTime, LocalDateTime endTime, List<Long> classIds);
+
+    /**
+     * 查询每个班级指定时间段内住校生到校人数
+     * @param startTime
+     * @param endTime
+     * @param classIds
+     * @return
+     */
+    Map<Long, List<StudentOutInRecordVo>> getStayList(LocalDateTime startTime, LocalDateTime endTime, List<Long> classIds);
 }

+ 65 - 0
src/main/java/com/xjrsoft/module/outint/service/impl/StudentOutInRecordServiceImpl.java

@@ -4,9 +4,17 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.xjrsoft.module.outint.entity.StudentOutInRecord;
 import com.xjrsoft.module.outint.mapper.StudentOutInRecordMapper;
 import com.xjrsoft.module.outint.service.IStudentOutInRecordService;
+import com.xjrsoft.module.outint.vo.IdCountVo;
+import com.xjrsoft.module.outint.vo.StudentOutInRecordVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
 * @title: 学生出入记录
 * @Author dzx
@@ -16,4 +24,61 @@ import org.springframework.stereotype.Service;
 @Service
 @AllArgsConstructor
 public class StudentOutInRecordServiceImpl extends MPJBaseServiceImpl<StudentOutInRecordMapper, StudentOutInRecord> implements IStudentOutInRecordService {
+    @Override
+    public Map<Long, Integer> getNotStayClassCount(LocalDateTime startTime, LocalDateTime endTime) {
+        List<IdCountVo> classCount = this.baseMapper.getNotStayClassCount(startTime, endTime);
+        Map<Long, Integer> result = new HashMap<>();
+        for (IdCountVo idCountVo : classCount) {
+            result.put(idCountVo.getId(), idCountVo.getCount());
+        }
+
+        return result;
+    }
+
+    @Override
+    public Map<Long, Integer> getStayClassCount(LocalDateTime startTime, LocalDateTime endTime) {
+        List<IdCountVo> classCount = this.baseMapper.getStayClassCount(startTime, endTime);
+        Map<Long, Integer> result = new HashMap<>();
+        for (IdCountVo idCountVo : classCount) {
+            result.put(idCountVo.getId(), idCountVo.getCount());
+        }
+
+        return result;
+    }
+
+    @Override
+    public Map<Long, List<StudentOutInRecordVo>> getNotStayList(LocalDateTime startTime, LocalDateTime endTime, List<Long> classIds) {
+        List<StudentOutInRecordVo> notStayList = this.baseMapper.getNotStayList(startTime, endTime);
+        Map<Long, List<StudentOutInRecordVo>> result = new HashMap<>();
+        for (Long classId : classIds) {
+            List<StudentOutInRecordVo> dataList = new ArrayList<>();
+            for (StudentOutInRecordVo recordVo : notStayList) {
+                if(!classId.equals(recordVo.getClassId())){
+                    continue;
+                }
+                dataList.add(recordVo);
+            }
+            result.put(classId, dataList);
+        }
+
+        return result;
+    }
+
+    @Override
+    public Map<Long, List<StudentOutInRecordVo>> getStayList(LocalDateTime startTime, LocalDateTime endTime, List<Long> classIds) {
+        List<StudentOutInRecordVo> notStayList = this.baseMapper.getStayList(startTime, endTime);
+        Map<Long, List<StudentOutInRecordVo>> result = new HashMap<>();
+        for (Long classId : classIds) {
+            List<StudentOutInRecordVo> dataList = new ArrayList<>();
+            for (StudentOutInRecordVo recordVo : notStayList) {
+                if(!classId.equals(recordVo.getClassId())){
+                    continue;
+                }
+                dataList.add(recordVo);
+            }
+            result.put(classId, dataList);
+        }
+
+        return result;
+    }
 }

+ 22 - 0
src/main/java/com/xjrsoft/module/outint/vo/IdCountVo.java

@@ -0,0 +1,22 @@
+package com.xjrsoft.module.outint.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* @title: id数量
+* @Author dzx
+* @Date: 2024年5月28日
+* @Version 1.0
+*/
+@Data
+public class IdCountVo {
+
+
+    @ApiModelProperty("主键")
+    private Long id;
+
+    @ApiModelProperty("数量")
+    private Integer count;
+
+}

+ 3 - 1
src/main/java/com/xjrsoft/module/outint/vo/StudentOutInRecordVo.java

@@ -3,6 +3,8 @@ package com.xjrsoft.module.outint.vo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.time.LocalDateTime;
+
 /**
 * @title: 学生出入记录表单出参
 * @Author dzx
@@ -36,7 +38,7 @@ public class StudentOutInRecordVo {
     * 记录时间
     */
     @ApiModelProperty("记录时间")
-    private String recordTime;
+    private LocalDateTime recordTime;
     /**
     * 人脸照片
     */

+ 4 - 0
src/main/java/com/xjrsoft/module/student/mapper/StudentLeaveMapper.java

@@ -1,12 +1,14 @@
 package com.xjrsoft.module.student.mapper;
 
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.outint.vo.IdCountVo;
 import com.xjrsoft.module.student.entity.StudentDropOut;
 import com.xjrsoft.module.student.entity.StudentLeave;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
 * @title: 学生请假
@@ -18,4 +20,6 @@ import java.time.LocalDateTime;
 public interface StudentLeaveMapper extends MPJBaseMapper<StudentLeave> {
 
     Long getLeaveCount(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
+
+    List<IdCountVo> getClassLeaveCount(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/student/service/IStudentLeaveService.java

@@ -4,6 +4,7 @@ import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.student.entity.StudentLeave;
 
 import java.time.LocalDateTime;
+import java.util.Map;
 
 /**
 * @title: 学生荣誉
@@ -17,4 +18,6 @@ public interface IStudentLeaveService extends MPJBaseService<StudentLeave> {
     Boolean hikvisionLeave(Long id);
 
     Long getLeaveCount(LocalDateTime startTime, LocalDateTime endTime);
+
+    Map<Long, Integer> getClassLeaveCount(LocalDateTime startTime, LocalDateTime endTime);
 }

+ 13 - 1
src/main/java/com/xjrsoft/module/student/service/impl/StudentLeaveServiceImpl.java

@@ -9,6 +9,7 @@ import com.google.gson.JsonParser;
 import com.xjrsoft.module.hikvision.entity.HikvisionData;
 import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
 import com.xjrsoft.module.hikvision.util.ApiUtil;
+import com.xjrsoft.module.outint.vo.IdCountVo;
 import com.xjrsoft.module.student.entity.StudentLeave;
 import com.xjrsoft.module.student.mapper.StudentLeaveMapper;
 import com.xjrsoft.module.student.service.IStudentLeaveService;
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Service;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -78,7 +80,17 @@ public class StudentLeaveServiceImpl extends MPJBaseServiceImpl<StudentLeaveMapp
 
     @Override
     public Long getLeaveCount(LocalDateTime startTime, LocalDateTime endTime) {
-        return null;
+        return this.baseMapper.getLeaveCount(startTime, endTime);
+    }
+
+    @Override
+    public Map<Long, Integer> getClassLeaveCount(LocalDateTime startTime, LocalDateTime endTime) {
+        List<IdCountVo> classLeaveCount = this.baseMapper.getClassLeaveCount(startTime, endTime);
+        Map<Long, Integer> result = new HashMap<>();
+        for (IdCountVo idCountVo : classLeaveCount) {
+            result.put(idCountVo.getId(), idCountVo.getCount());
+        }
+        return result;
     }
 
     JsonArray selectResource(ApiUtil apiUtil){

+ 17 - 1
src/main/resources/mapper/base/BaseClass.xml

@@ -76,5 +76,21 @@
         INNER JOIN base_student_school_roll t2 ON t1.id = t2.class_id
         WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
     </select>
-
+    <select id="getAttendanceClass" resultType="com.xjrsoft.module.attendance.vo.ClassStatisticsVo">
+        SELECT t1.id,t1.name AS class_name,t2.name AS teacher_name,
+        (SELECT COUNT(*) FROM base_student_school_roll c1
+        INNER JOIN xjr_user c2 ON c1.user_id = c2.id
+        WHERE c1.delete_mark = 0 AND c1.delete_mark = 0
+        AND c1.class_id = t1.id AND c1.archives_status = 'FB2901') AS student_count,
+        (SELECT COUNT(*) FROM base_student_school_roll c1
+        INNER JOIN xjr_user c2 ON c1.user_id = c2.id
+        WHERE c1.delete_mark = 0 AND c1.delete_mark = 0
+        AND c1.class_id = t1.id AND c1.archives_status = 'FB2901' AND c1.stduy_status = 'FB3001') AS stay_count,
+        (SELECT COUNT(*) FROM base_student_school_roll c1
+        INNER JOIN xjr_user c2 ON c1.user_id = c2.id
+        WHERE c1.delete_mark = 0 AND c1.delete_mark = 0
+        AND c1.class_id = t1.id AND c1.archives_status = 'FB2901' AND c1.stduy_status = 'FB3002') AS not_stay_count FROM base_class t1
+        LEFT JOIN xjr_user t2 ON t1.teacher_id = t2.id
+        WHERE t1.delete_mark = 0
+    </select>
 </mapper>

+ 37 - 0
src/main/resources/mapper/outin/StudentOutInRecordMapper.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xjrsoft.module.outint.mapper.StudentOutInRecordMapper">
+    <select id="getNotStayClassCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
+        SELECT t1.class_id AS id,COUNT(t1.user_id) FROM student_out_in_record t1
+        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
+        WHERE t1.delete_mark = 0 AND t1.status = 0 AND t2.delete_mark = 0
+        AND t1.stduy_status = 'FB3002'
+        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
+        GROUP BY t1.class_id
+    </select>
+    <select id="getStayClassCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
+        SELECT t1.class_id AS id,COUNT(t1.user_id) FROM student_out_in_record t1
+        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
+        WHERE t1.delete_mark = 0 AND t1.status = 0 AND t2.delete_mark = 0
+        AND t1.stduy_status = 'FB3001'
+        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
+        GROUP BY t1.class_id
+    </select>
+
+    <select id="getNotStayList" resultType="com.xjrsoft.module.outint.vo.StudentOutInRecordVo">
+        SELECT t1.* FROM student_out_in_record t1
+        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
+        WHERE t1.delete_mark = 0 AND t1.status = 0 AND t2.delete_mark = 0
+        AND t1.stduy_status = 'FB3002'
+        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
+    </select>
+    <select id="getStayList" resultType="com.xjrsoft.module.outint.vo.StudentOutInRecordVo">
+        SELECT t1.* FROM student_out_in_record t1
+        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
+        WHERE t1.delete_mark = 0 AND t1.status = 0 AND t2.delete_mark = 0
+        AND t1.stduy_status = 'FB3001'
+        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
+    </select>
+</mapper>

+ 18 - 7
src/main/resources/mapper/student/StudentLeaveMapper.xml

@@ -5,13 +5,24 @@
 <mapper namespace="com.xjrsoft.module.student.mapper.StudentLeaveMapper">
     <select id="getLeaveCount" resultType="java.lang.Long">
         SELECT COUNT(*) FROM student_leave t1
-                                 INNER JOIN xjr_user t2 ON t1.user_id = t2.id
+        INNER JOIN xjr_user t2 ON t1.user_id = t2.id
         WHERE t1.status = 1 AND t2.delete_mark = 0
-          AND (
-                (start_date BETWEEN #{startTime} and #{endTime})
-                OR (end_date BETWEEN #{startTime} and #{endTime})
-                OR (start_date > #{startTime} and #{endTime} > end_date)
-                OR (#{startTime} > start_date and end_date > #{endTime})
-            )
+        AND (
+        (start_date BETWEEN #{startTime} and #{endTime})
+        OR (end_date BETWEEN #{startTime} and #{endTime})
+        OR (start_date > #{startTime} and #{endTime} > end_date)
+        OR (#{startTime} > start_date and end_date > #{endTime})
+        )
+    </select>
+    <select id="getClassLeaveCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
+        SELECT t1.class_id as id, COUNT(*) FROM student_leave t1
+        INNER JOIN xjr_user t2 ON t1.user_id = t2.id
+        WHERE t1.status = 1 AND t2.delete_mark = 0
+        AND (
+        (start_date BETWEEN #{startTime} and #{endTime})
+        OR (end_date BETWEEN #{startTime} and #{endTime})
+        OR (start_date > #{startTime} and #{endTime} > end_date)
+        OR (#{startTime} > start_date and end_date > #{endTime})
+        ) group by t1.class_id
     </select>
 </mapper>