소스 검색

Merge branch 'dev' of https://git.yingcaibx.com/tl/api into dev

brealinxx 5 달 전
부모
커밋
6247a4a0bc

+ 8 - 11
src/main/java/com/xjrsoft/module/attendance/controller/StatisticsController.java

@@ -2,7 +2,6 @@ package com.xjrsoft.module.attendance.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.util.ObjectUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.OutInStatusEnum;
@@ -18,10 +17,10 @@ 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.ICarOutInRecordService;
 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;
@@ -66,7 +65,7 @@ public class StatisticsController {
     private final IWfTeacherleaveService wfTeacherleaveService;
     private final IStudentLeaveService studentLeaveService;
     private final IReservationSchoolService reservationSchoolService;
-    private final ICarOutInRecordService carOutInRecordService;
+    private final ICarMessageApplyService carMessageApplyService;
 
     @GetMapping(value = "/teacher-statistics")
     @ApiOperation(value="教职工考勤统计")
@@ -110,10 +109,9 @@ public class StatisticsController {
                             .orderByAsc(TeacherOutInRecord::getRecordTime)
             );
 
-            List<CarOutInRecord> list = carOutInRecordService.list(
-                    new MPJLambdaWrapper<CarOutInRecord>()
-                            .select(CarOutInRecord.class, x -> VoToColumnUtil.fieldsToColumns(CarOutInRecord.class).contains(x.getProperty()))
-                            .leftJoin(CarMessageApply.class, CarMessageApply::getId, CarOutInRecord::getCarMessageApplyId)
+            long count = carMessageApplyService.count(
+                    new MPJLambdaWrapper<CarMessageApply>()
+                            .innerJoin(CarOutInRecord.class, CarOutInRecord::getCarMessageApplyId, CarMessageApply::getId)
                             .le(CarOutInRecord::getRecordTime, endTime)
                             .eq("DATE_FORMAT(record_time, '%Y-%m-%d')", endTime.toLocalDate())
                             .ge(dto.getTimePeriod() == 2 && amEndTime != null, CarOutInRecord::getRecordTime, amEndTime)
@@ -122,9 +120,8 @@ public class StatisticsController {
             );
 
             Set<Long> collect = outInRecords.stream().map(TeacherOutInRecord::getUserId).collect(Collectors.toSet());
-            Set<Long> userIds = new HashSet<>(collect);
             //实到人数
-            statisticsVo.setActualCount(Long.valueOf(collect.size()));
+            statisticsVo.setActualCount(Long.valueOf(collect.size()) + count);
 
             //查询教师请假人数
             Long leaveCount = wfTeacherleaveService.getLeaveCount(startTime, endTime);
@@ -133,7 +130,7 @@ public class StatisticsController {
             }
             statisticsVo.setLeaveCount(leaveCount);
             //通过考勤规则和实到人数信息,计算迟到的
-            userIds = new HashSet<>();
+            Set<Long> userIds = new HashSet<>();
             Long lateCount = 0L;
             for (TeacherOutInRecord outInRecord : outInRecords) {
                 if("迟到".equals(outInRecord.getAttendanceStatus()) && !userIds.contains(outInRecord.getUserId())){
@@ -208,7 +205,7 @@ public class StatisticsController {
             Set<Long> collect = outInRecords.stream().map(StudentOutInRecord::getUserId).collect(Collectors.toSet());
             statisticsVo.setActualCount(Long.valueOf(collect.size()));
 
-            //查询教师请假人数
+            //查询学生请假人数
             Long leaveCount = studentLeaveService.getLeaveCount(startTime, endTime, dto);
             if(leaveCount == null){
                 leaveCount = 0L;

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

@@ -20,6 +20,7 @@ import com.xjrsoft.module.attendance.dto.StudentDetailsDto;
 import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
 import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
 import com.xjrsoft.module.attendance.vo.StudentStatisticsPageVo;
+import com.xjrsoft.module.attendance.vo.TimeRangeVo;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.holiday.entity.HolidayDate;
@@ -77,7 +78,6 @@ public class StudentStatisticsController {
     private final IStudentLeaveService studentLeaveService;
     private final IBaseClassService classService;
     private final IHolidayDateService holidayDateService;
-    private final IAttendanceRuleCategoryService ruleCategoryService;
     private final IBaseClassService baseClassService;
     @GetMapping(value = "/class-statistics")
     @ApiOperation(value="班级考勤统计")
@@ -293,41 +293,58 @@ public class StudentStatisticsController {
             DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE;
             LocalDateTime startTime = LocalDate.parse(dto.getStartTime(), formatter).atTime(0, 0, 0);
             LocalDateTime endTime = LocalDate.parse(dto.getEndTime(), formatter).atTime(23, 59, 59);
+            //如果查询天数只有一天
+            if(startTime.toLocalDate().isEqual(endTime.toLocalDate())){
+                HolidayDate holidayDate = holidayDateService.getOne(
+                        new QueryWrapper<HolidayDate>().lambda()
+                                .eq(HolidayDate::getDate, endTime.toLocalDate())
+                );
+                if(holidayDate != null && holidayDate.getWay() != null && holidayDate.getWay() != 0){
+                    return RT.ok(ConventPage.getPageOutput(attendancePage, ClassStatisticsVo.class));
+                }
+            }
 
 
             //查询每个班的走读生实到人数
             Map<Long, List<StudentOutInRecordVo>> notStayMap = studentOutInRecordService.getNotStayList(startTime, endTime, classIds);
             //查询住校生的实到情况
-            Map<Long, List<StudentOutInRecordVo>> stayMap = studentOutInRecordService.getStayList(startTime, endTime, classIds);
+//            Map<Long, List<StudentOutInRecordVo>> stayMap = studentOutInRecordService.getStayList(startTime, endTime, classIds);
 
             //查询各班的请假人数
-            Map<Long, Integer> classLeaveCount = studentLeaveService.getClassLeaveCount(startTime, endTime);
+            //Map<Long, Integer> classLeaveCount = studentLeaveService.getClassLeaveCount(startTime, endTime);
 
             //计算2个时间相差的天数
             long days = ChronoUnit.DAYS.between(startTime.toLocalDate(), endTime.toLocalDate());
             List<String> dayOfWeeks = new ArrayList<>();
+            List<TimeRangeVo> timeRangeList = new ArrayList<>();
             for (int i = 0; i <= days; i ++){
                 dayOfWeeks.add(startTime.plusDays(i).getDayOfWeek().name());
+                TimeRangeVo rangeVo = new TimeRangeVo();
+                rangeVo.setStartTime(startTime.plusDays(i));
+                rangeVo.setStartTime(startTime.plusDays(i).withHour(23).withMinute(59).withSecond(59));
+                timeRangeList.add(rangeVo);
             }
 
             for (ClassStatisticsVo record: attendancePage.getRecords()) {
-                record.setLeaveCount(classLeaveCount.get(record.getId()) == null ? 0:classLeaveCount.get(record.getId()));
+                //查询班级的请假总人次
+                Integer allLeaveCount = 0;
+                for (TimeRangeVo rangeVo : timeRangeList) {
+                    AttendanceStatisticDto statisticDto = new AttendanceStatisticDto();
+                    statisticDto.setClassId(record.getId());
+                    Long leaveCount = studentLeaveService.getLeaveCount(rangeVo.getStartTime(), rangeVo.getEndTime(), statisticDto);
+                    allLeaveCount += (leaveCount.intValue() * 3);
+                }
+                record.setLeaveCount(allLeaveCount);
+
                 Set<Long> collect = notStayMap.get(record.getId()).stream().map(StudentOutInRecordVo::getUserId).collect(Collectors.toSet());
 
                 record.setActualCount(collect.size());
                 record.setStudentCount(record.getStudentCount() * dayOfWeeks.size() * 3);
 
                 Integer lateCount = 0;
-                for (String dayOfWeek : dayOfWeeks) {
-                    for (StudentOutInRecordVo outInRecord : notStayMap.get(record.getId())) {
-                        if("迟到".equals(outInRecord.getAttendanceStatus())){
-                            lateCount ++;
-                        }
-                    }
-                    for (StudentOutInRecordVo outInRecord : stayMap.get(record.getId())) {
-                        if("迟到".equals(outInRecord.getAttendanceStatus())){
-                            lateCount ++;
-                        }
+                for (StudentOutInRecordVo outInRecord : notStayMap.get(record.getId())) {
+                    if("迟到".equals(outInRecord.getAttendanceStatus())){
+                        lateCount ++;
                     }
                 }
 
@@ -393,7 +410,7 @@ public class StudentStatisticsController {
 
                 Integer lateCount = 0;
                 for (StudentOutInRecordVo outInRecord : notStayMap.get(record.getId())) {
-                    if(outInRecord.getStatus() == 1){
+                    if(outInRecord.getStatus() == OutInStatusEnum.enter.getCode()){
                         continue;
                     }
                     if("迟到".equals(outInRecord.getAttendanceStatus())){
@@ -401,7 +418,7 @@ public class StudentStatisticsController {
                     }
                 }
                 for (StudentOutInRecordVo outInRecord : stayMap.get(record.getId())) {
-                    if(outInRecord.getStatus() == 1){
+                    if(outInRecord.getStatus() == OutInStatusEnum.enter.getCode()){
                         continue;
                     }
                     if("迟到".equals(outInRecord.getAttendanceStatus())){

+ 4 - 4
src/main/java/com/xjrsoft/module/job/AttendanceMessageTask.java

@@ -100,7 +100,7 @@ public class AttendanceMessageTask {
             new QueryWrapper<HolidayDate>().lambda()
             .eq(HolidayDate::getDate, now.toLocalDate())
         );
-        if(holidayDate != null && holidayDate.getWay() != null && holidayDate.getWay() != 0){
+        if(holidayDate != null && holidayDate.getWay() != null && holidayDate.getWay() != 0 && holidayDate.getWay() != 2){
             log.info("非工作日,不需要提醒");
             return;
         }
@@ -153,7 +153,7 @@ public class AttendanceMessageTask {
             );
 
             LocalDateTime recentlyTime = null;
-            String characterKey = "character_string16";
+            String characterKey = "character_string18";
             String wechatTemplate = weChatUtil.getAttendanceMsgLateTemplate();
             if(messageSet.getMessageCategory() != null && messageSet.getMessageCategory() == 1){
                 wechatTemplate = weChatUtil.getAttendanceMsgLateTemplate();
@@ -255,7 +255,7 @@ public class AttendanceMessageTask {
                 JSONObject paramJson = new JSONObject();
 
                 JSONObject thing6 = new JSONObject();
-                thing6.put("value", "教职工");
+                thing6.put("value", "学生");
                 paramJson.put("thing6", thing6);
 
                 JSONObject time11 = new JSONObject();
@@ -268,7 +268,7 @@ public class AttendanceMessageTask {
 
                 JSONObject character_string18 = new JSONObject();
                 character_string18.put("value", teacherCout - outInRecords);
-                paramJson.put("character_string18", character_string18);
+                paramJson.put(characterKey, character_string18);
 
                 JSONObject character_string16 = new JSONObject();
                 character_string16.put("value", teacherCout);

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

@@ -26,6 +26,10 @@
         WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
         AND t2.stduy_status = 'FB3002'
         AND t1.record_time BETWEEN #{startTime} AND #{endTime}
+        and DATE_FORMAT(t1.record_time, '%Y-%m-%d') not in (
+            SELECT holiday_date.date FROM holiday_date WHERE STATUS IN (0, 2) AND delete_status = 0
+            AND holiday_date.date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') AND DATE_FORMAT(#{endTime}, '%Y-%m-%d')
+        )
     </select>
     <select id="getStayList" resultType="com.xjrsoft.module.outint.vo.StudentOutInRecordVo">
         SELECT t1.* FROM student_out_in_record t1
@@ -33,6 +37,10 @@
         WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
         AND t2.stduy_status = 'FB3001'
         AND t1.record_time BETWEEN #{startTime} AND #{endTime}
+        and DATE_FORMAT(t1.record_time, '%Y-%m-%d') not in (
+            SELECT holiday_date.date FROM holiday_date WHERE STATUS IN (0, 2) AND delete_status = 0
+            AND holiday_date.date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') AND DATE_FORMAT(#{endTime}, '%Y-%m-%d')
+        )
     </select>
     <select id="getList" resultType="com.xjrsoft.module.outint.vo.StudentOutInRecordVo">
         SELECT t1.* FROM student_out_in_record t1