Browse Source

考勤查询调整

dzx 1 year ago
parent
commit
fa92b32ced

+ 4 - 3
src/main/java/com/xjrsoft/module/attendance/controller/StatisticsController.java

@@ -160,7 +160,7 @@ public class StatisticsController {
             statisticsVo.setActualCount(Long.valueOf(outInRecords.size()));
 
             //查询教师请假人数
-            Long leaveCount = studentLeaveService.getLeaveCount(startTime, endTime);
+            Long leaveCount = studentLeaveService.getLeaveCount(startTime, endTime, dto);
             if(leaveCount == null){
                 leaveCount = 0L;
             }
@@ -175,15 +175,16 @@ public class StatisticsController {
             }
             statisticsVo.setLateCount(lateCount);
 
-            //最后通过总人数-实到人数-请假人数计算出缺勤人数
-            statisticsVo.setAbsenteeismCount(statisticsVo.getAllCount() - statisticsVo.getLeaveCount() - statisticsVo.getActualCount());
 
             //计算出勤率
             if(statisticsVo.getAllCount() != null && statisticsVo.getAllCount() != 0){
+                //最后通过总人数-实到人数-请假人数计算出缺勤人数
+                statisticsVo.setAbsenteeismCount(statisticsVo.getAllCount() - statisticsVo.getLeaveCount() - statisticsVo.getActualCount());
                 BigDecimal divide = BigDecimal.valueOf(statisticsVo.getActualCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 4, RoundingMode.HALF_UP);
                 statisticsVo.setAttendanceRate(divide.doubleValue());
             }else{
                 statisticsVo.setAttendanceRate(0D);
+                statisticsVo.setAbsenteeismCount(0L);
             }
 
         }

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

@@ -82,7 +82,7 @@ public class StudentStatisticsController {
 
 
             if(dto.getTimePeriod() != null && dto.getTimePeriod() == 1){
-                startTime = queryDate.atTime(9, 0, 0);
+                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);
@@ -170,7 +170,7 @@ public class StudentStatisticsController {
             LocalDateTime startTime, endTime;
 
             if(dto.getTimePeriod() != null && dto.getTimePeriod() == 1){
-                startTime = queryDate.atTime(9, 0, 0);
+                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);
@@ -289,7 +289,7 @@ public class StudentStatisticsController {
 
 
             if(dto.getTimePeriod() != null && dto.getTimePeriod() == 1){
-                startTime = queryDate.atTime(9, 0, 0);
+                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);

+ 2 - 1
src/main/java/com/xjrsoft/module/student/mapper/StudentLeaveMapper.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.student.mapper;
 
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
 import com.xjrsoft.module.outint.vo.IdCountVo;
 import com.xjrsoft.module.student.entity.StudentDropOut;
 import com.xjrsoft.module.student.entity.StudentLeave;
@@ -19,7 +20,7 @@ import java.util.List;
 @Mapper
 public interface StudentLeaveMapper extends MPJBaseMapper<StudentLeave> {
 
-    Long getLeaveCount(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
+    Long getLeaveCount(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("dto") AttendanceStatisticDto dto);
 
     List<IdCountVo> getClassLeaveCount(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
 

+ 2 - 1
src/main/java/com/xjrsoft/module/student/service/IStudentLeaveService.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.student.service;
 
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
 import com.xjrsoft.module.student.entity.StudentLeave;
 import org.apache.ibatis.annotations.Param;
 
@@ -19,7 +20,7 @@ public interface IStudentLeaveService extends MPJBaseService<StudentLeave> {
 
     Boolean hikvisionLeave(Long id);
 
-    Long getLeaveCount(LocalDateTime startTime, LocalDateTime endTime);
+    Long getLeaveCount(LocalDateTime startTime, LocalDateTime endTime, AttendanceStatisticDto dto);
 
     Map<Long, Integer> getClassLeaveCount(LocalDateTime startTime, LocalDateTime endTime);
 

+ 3 - 2
src/main/java/com/xjrsoft/module/student/service/impl/StudentLeaveServiceImpl.java

@@ -6,6 +6,7 @@ import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
 import com.xjrsoft.module.hikvision.entity.HikvisionData;
 import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
 import com.xjrsoft.module.hikvision.util.ApiUtil;
@@ -79,8 +80,8 @@ public class StudentLeaveServiceImpl extends MPJBaseServiceImpl<StudentLeaveMapp
     }
 
     @Override
-    public Long getLeaveCount(LocalDateTime startTime, LocalDateTime endTime) {
-        return this.baseMapper.getLeaveCount(startTime, endTime);
+    public Long getLeaveCount(LocalDateTime startTime, LocalDateTime endTime, AttendanceStatisticDto dto) {
+        return this.baseMapper.getLeaveCount(startTime, endTime, dto);
     }
 
     @Override

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

@@ -6,6 +6,7 @@
     <select id="getLeaveCount" resultType="java.lang.Long">
         SELECT COUNT(*) as count FROM student_leave t1
         INNER JOIN xjr_user t2 ON t1.student_user_id = t2.id
+        INNER JOIN base_student_school_roll t3 ON t3.user_id = t2.id
         WHERE t1.status = 1 AND t2.delete_mark = 0
         AND (
                 (start_date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
@@ -13,6 +14,12 @@
                 OR (start_date > DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d') > end_date)
                 OR (DATE_FORMAT(#{startTime}, '%Y-%m-%d') > start_date and end_date > DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
         )
+        <if test="dto.gradeId != null">
+            and t3.grade_id = #{dto.gradeId}
+        </if>
+        <if test="dto.classId != null">
+            and t3.class_id = #{dto.classId}
+        </if>
     </select>
     <select id="getClassLeaveCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
         SELECT t1.class_id as id, COUNT(*) as count FROM student_leave t1