Преглед изворни кода

1、学生处分查询调整
2、数据面板调整

dzx пре 1 година
родитељ
комит
ed1b3487ba

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

@@ -2,6 +2,7 @@ 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;
@@ -10,21 +11,39 @@ import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
 import com.xjrsoft.module.attendance.dto.TeacherDetailsDto;
+import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
+import com.xjrsoft.module.attendance.entity.AttendanceUserRelation;
+import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
 import com.xjrsoft.module.attendance.service.ITeacherAttendanceRecordService;
+import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
 import com.xjrsoft.module.attendance.vo.TeacherStatisticsPageVo;
 import com.xjrsoft.module.attendance.vo.TeacherStatisticsVo;
 import com.xjrsoft.module.attendance.vo.VisitorInfoVo;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.concat.service.IXjrUserService;
+import com.xjrsoft.module.holiday.entity.HolidayDate;
+import com.xjrsoft.module.holiday.service.IHolidayDateService;
+import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserDeptRelation;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.outint.dto.TeacherOutInRecordDto;
+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.IReservationSchoolService;
 import com.xjrsoft.module.student.entity.BaseStudent;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.service.IStudentLeaveService;
 import com.xjrsoft.module.teacher.entity.BaseTeacher;
+import com.xjrsoft.module.teacher.entity.WfHeadTeacherLeave;
+import com.xjrsoft.module.teacher.entity.WfTeacherleave;
 import com.xjrsoft.module.teacher.entity.XjrUser;
+import com.xjrsoft.module.teacher.service.IWfHeadTeacherLeaveService;
+import com.xjrsoft.module.teacher.service.IWfTeacherleaveService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -38,7 +57,10 @@ import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -56,10 +78,17 @@ public class StatisticsController {
 
 
     private final IXjrUserService xjrUserService;
+    private final IUserService userService;
     private final IStudentOutInRecordService studentOutInRecordService;
     private final IStudentLeaveService studentLeaveService;
     private final IReservationSchoolService reservationSchoolService;
     private final ITeacherAttendanceRecordService attendanceRecordService;
+    private final ITeacherOutInRecordService teacherOutInRecordService;
+    private final IAttendanceRuleCategoryService attendanceRuleCategoryService;
+    private final IHolidayDateService holidayDateService;
+    private final IWfTeacherleaveService wfTeacherleaveService;
+    private final IWfHeadTeacherLeaveService headTeacherLeaveService;
+    private final ICarOutInRecordService carOutInRecordService;
 
     @GetMapping(value = "/teacher-statistics")
     @ApiOperation(value="教职工考勤统计")
@@ -79,7 +108,182 @@ public class StatisticsController {
         detailsDto.setDate(dto.getDate());
         detailsDto.setDeptId(dto.getDeptId());
         detailsDto.setTimePeriod(dto.getTimePeriod());
-        List<TeacherStatisticsPageVo> list = attendanceRecordService.getList(detailsDto);
+        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        String today = LocalDate.now().format(dtf);
+        List<TeacherStatisticsPageVo> list = new ArrayList<>();
+        if(!today.equals(dto.getDate())){
+            list.addAll(attendanceRecordService.getList(detailsDto));
+        }else{
+            MPJLambdaWrapper<User> queryUser = new MPJLambdaWrapper<>();
+            queryUser.disableSubLogicDel().distinct()
+                    .select(" (SELECT GROUP_CONCAT(t1.name) FROM xjr_department t1" +
+                            " INNER JOIN xjr_user_dept_relation t2 ON t1.id = t2.dept_id" +
+                            " WHERE t1.delete_mark = 0 AND t2.user_id = t.id) as dept_name")
+                    .eq(ObjectUtil.isNotNull(dto.getDeptId()), UserDeptRelation::getDeptId, dto.getDeptId())
+                    .selectAs(User::getName, TeacherStatisticsPageVo::getTeacherName)
+                    .selectAs(User::getId, TeacherStatisticsPageVo::getUserId)
+                    .selectAs(User::getMobile, TeacherStatisticsPageVo::getMobile)
+                    .innerJoin(BaseTeacher.class, BaseTeacher::getUserId, User::getId)
+                    .innerJoin(UserDeptRelation.class, UserDeptRelation::getUserId, User::getId)
+                    .leftJoin(AttendanceUserRelation.class, AttendanceUserRelation::getUserId, User::getId);
+            List<TeacherStatisticsPageVo> voIPage = userService.selectJoinList(TeacherStatisticsPageVo.class, queryUser);
+
+            if(dto.getDate() != null && !"".equals(dto.getDate())){
+                DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE;
+                LocalDate queryDate = LocalDate.parse(dto.getDate(), formatter);
+
+                HolidayDate holidayDate = holidayDateService.getOne(
+                        new QueryWrapper<HolidayDate>().lambda()
+                                .eq(HolidayDate::getDate, queryDate)
+                );
+                if(holidayDate != null && holidayDate.getWay() != null && holidayDate.getWay() != 0){
+                    return RT.ok(statisticsVo);
+                }
+
+                List<Long> userIds = voIPage.stream().map(TeacherStatisticsPageVo::getUserId).collect(Collectors.toList());
+                Map<Long, AttendanceRuleDetailsUserVo> teacherTodyRuleByUserId = attendanceRuleCategoryService.getTeacherTodyRuleByUserId(userIds);
+                List<String> weekList = Arrays.asList("SUNDAY", "SATURDAY");
+
+                List<HolidayDate> workHolidayDates = holidayDateService.list(
+                        new QueryWrapper<HolidayDate>().lambda()
+                                .eq(HolidayDate::getStatus, 2)
+                );
+                List<String> workHolidayDateListg = workHolidayDates.stream().map(HolidayDate::getDate).collect(Collectors.toList());
+
+                List<Integer> holidayTypes = Arrays.asList(1, 3);
+                List<HolidayDate> holidayDates = holidayDateService.list(
+                        new QueryWrapper<HolidayDate>().lambda()
+                                .in(HolidayDate::getStatus, holidayTypes)
+                );
+                List<String> holidayDateList = holidayDates.stream().map(HolidayDate::getDate).collect(Collectors.toList());
+
+                for (TeacherStatisticsPageVo record : voIPage) {
+                    LocalDateTime startTime, endTime, amEndTime = null;
+                    AttendanceRuleDetailsUserVo detailsUserVo = teacherTodyRuleByUserId.get(record.getUserId());
+                    if(detailsUserVo == null){
+                        record.setStatus("不考勤");
+                        continue;
+                    }
+                    AttendanceRuleDetails holidayRule = attendanceRuleCategoryService.getHolidayRuleByParam(record.getUserId());
+                    if(((!workHolidayDateListg.contains(queryDate.format(formatter)) && weekList.contains(queryDate.getDayOfWeek().name()))
+                            || holidayDateList.contains(queryDate.format(formatter))) && (holidayRule.getIsAttendance() == null || holidayRule.getIsAttendance() == 0)){
+                        record.setStatus("不考勤");
+                        continue;
+                    }
+                    if(dto.getTimePeriod() != null && dto.getTimePeriod() == 1){
+                        startTime = queryDate.atTime(5, 0, 0);
+                        if(detailsUserVo.getAmStartTime() != null){
+                            startTime = queryDate.atTime(detailsUserVo.getAmStartTime());
+                        }
+                        endTime = queryDate.atTime(12, 0, 0);
+                        if(detailsUserVo.getAmEndTime() != null){
+                            endTime = queryDate.atTime(detailsUserVo.getAmEndTime());
+                        }
+                    }else if(dto.getTimePeriod() != null && dto.getTimePeriod() == 2){
+                        startTime = queryDate.atTime(12, 0, 0);
+                        if(detailsUserVo.getPmStartTime() != null){
+                            startTime = queryDate.atTime(detailsUserVo.getPmStartTime());
+                        }
+                        endTime = queryDate.atTime(18, 0, 0);
+                        if(detailsUserVo.getPmEndTime() != null){
+                            endTime = queryDate.atTime(detailsUserVo.getPmEndTime());
+                        }
+                        amEndTime  = queryDate.atTime(12, 0, 0);
+                        if(detailsUserVo.getAmEndTime() != null){
+                            amEndTime = queryDate.atTime(detailsUserVo.getAmEndTime());
+                        }
+                    }else{
+                        startTime = queryDate.atTime(0, 0, 0);
+                        if(detailsUserVo.getEveningStartTime() != null){
+                            startTime = queryDate.atTime(detailsUserVo.getEveningStartTime());
+                        }
+                        endTime = queryDate.atTime(23, 59, 59);
+                        if(detailsUserVo.getEveningEndTime() != null){
+                            endTime = queryDate.atTime(detailsUserVo.getEveningEndTime());
+                        }
+                    }
+
+                    WfTeacherleave studentLeave = wfTeacherleaveService.getLeaveByUserId(startTime, endTime, record.getUserId());
+                    if(studentLeave != null){
+                        record.setStatus(studentLeave.getLeaveType());
+                        continue;
+                    }
+
+                    WfHeadTeacherLeave teacherLeave = headTeacherLeaveService.selectJoinOne(WfHeadTeacherLeave.class,
+                            new MPJLambdaWrapper<WfHeadTeacherLeave>()
+                                    .select(WfHeadTeacherLeave.class, x -> VoToColumnUtil.fieldsToColumns(WfHeadTeacherLeave.class).contains(x.getProperty()))
+                                    .innerJoin(XjrUser.class, XjrUser::getId, WfHeadTeacherLeave::getApplicantUserId)
+                                    .eq(WfHeadTeacherLeave::getStatus, 1)
+                                    .eq(WfHeadTeacherLeave::getApplicantUserId, record.getUserId())
+                                    .between(WfHeadTeacherLeave::getStartTime, startTime, endTime)
+                    );
+                    if(teacherLeave != null){
+                        record.setStatus(teacherLeave.getLeaveReason());
+                        continue;
+                    }
+                    TeacherOutInRecordDto outInDto = new TeacherOutInRecordDto();
+                    outInDto.setQueryDate(startTime.toLocalDate());
+                    outInDto.setStartTime(startTime);
+                    outInDto.setEndTime(endTime);
+                    outInDto.setStatus(OutInStatusEnum.enter.getCode());
+                    outInDto.setUserId(record.getUserId());
+                    List<TeacherOutInRecord> outInRecords = teacherOutInRecordService.getListByParam(outInDto);
+
+                    //查询该教师是否通过车辆进入
+                    List<CarOutInRecord> carList = carOutInRecordService.list(
+                            new MPJLambdaWrapper<CarOutInRecord>()
+                                    .select(CarOutInRecord.class, x -> VoToColumnUtil.fieldsToColumns(CarOutInRecord.class).contains(x.getProperty()))
+                                    .leftJoin(CarMessageApply.class, CarMessageApply::getId, CarOutInRecord::getCarMessageApplyId)
+                                    .le(CarOutInRecord::getRecordTime, endTime)
+                                    .eq("DATE_FORMAT(record_time, '%Y-%m-%d')", endTime.toLocalDate())
+                                    .eq(CarMessageApply::getUserId, record.getUserId())
+                                    .ge(dto.getTimePeriod() != null && dto.getTimePeriod() == 2 && amEndTime != null, CarOutInRecord::getRecordTime, amEndTime)
+                                    .eq(CarOutInRecord::getStatus, OutInStatusEnum.enter.getCode())
+                                    .orderByAsc(CarOutInRecord::getRecordTime)
+                    );
+
+                    //最早进入方式:1人脸 2车辆
+                    Integer inStatus = 0;
+                    if(!outInRecords.isEmpty() && !carList.isEmpty()){
+                        TeacherOutInRecord teacherOutInRecord = outInRecords.get(0);
+                        CarOutInRecord carOutInRecord = carList.get(0);
+                        int result = teacherOutInRecord.getRecordTime().compareTo(carOutInRecord.getRecordTime());
+                        if(result < 0){//人脸进入
+                            inStatus = 1;
+                        }else if(result == 0){//同时
+                            inStatus = 0;
+                        }else{//车辆进入
+                            inStatus = 2;
+                        }
+                    }else if(!outInRecords.isEmpty()){
+                        inStatus = 1;
+                    }
+
+                    if(inStatus == 1){
+                        TeacherOutInRecord outInRecord = outInRecords.get(0);
+                        if(outInRecord != null){
+                            record.setRecordTime(outInRecord.getRecordTime());
+                            record.setStatus(outInRecord.getAttendanceStatus());
+                        }
+                    }else if(inStatus == 2){
+                        CarOutInRecord outInRecord = carList.get(0);
+                        if(outInRecord != null && outInRecord.getRecordTime().isBefore(startTime)){
+                            record.setRecordTime(outInRecord.getRecordTime());
+                            record.setStatus("到校");
+                        }else if(outInRecord != null && outInRecord.getRecordTime().isAfter(startTime)){
+                            record.setRecordTime(outInRecord.getRecordTime());
+                            record.setStatus("迟到");
+                            record.setCarNumber(outInRecord.getPlanNo());
+                        }
+                    }
+
+                    if(record.getStatus() == null){
+                        record.setStatus("缺勤");
+                    }
+                    list.add(record);
+                }
+            }
+        }
 
         Long actualCount = 0L;
         Long lateCount = 0L;

+ 1 - 1
src/main/java/com/xjrsoft/module/job/StudentLeaveNoticeTask.java

@@ -49,7 +49,7 @@ public class StudentLeaveNoticeTask {
 
     @Scheduled(cron = "0 */15 * * * ?")
     public void execute() {
-        doExecute();
+        //doExecute();
     }
 
     public void doExecute(){

+ 1 - 1
src/main/resources/application.yml

@@ -5,7 +5,7 @@ server:
 spring:
   # 环 io境 dev|pre|prod
   profiles:
-    active: dev
+    active: prod
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

+ 2 - 5
src/main/resources/mapper/student/BaseStudentPunishmentInfoMapper.xml

@@ -78,11 +78,8 @@
                 #{punishmentTypeId}
             </foreach>
         </if>
-        <if test="dto.startDate != null and dto.startDate != ''">
-            and t1.start_time &gt;= #{dto.startDate}
-        </if>
-        <if test="dto.endDate != null and dto.endDate != ''">
-            and t1.start_time &lt;= #{dto.endDate}
+        <if test="dto.startDate != null and dto.startDate != '' and dto.endDate != null and dto.endDate != ''">
+            and t1.start_time between date_format(#{dto.startDate}, '%Y-%m-%d') and date_format(#{dto.endDate}, '%Y-%m-%d')
         </if>
         <if test="dto.isHandle != null">
             and t1.adjust_type is not null

+ 2 - 2
src/main/resources/mapper/teacher/WfTeacherleaveMapper.xml

@@ -29,7 +29,7 @@
             )
     </select>
     <select id="getLeaveByUserId" resultType="com.xjrsoft.module.teacher.entity.WfTeacherleave">
-        SELECT * FROM wf_teacherleave t1
+        SELECT t1.* FROM wf_teacherleave t1
         INNER JOIN xjr_user t2 ON t1.user_id = t2.id
         inner JOIN xjr_workflow_form_relation t3 ON t3.form_key_value = t1.id
         WHERE t3.current_state = 'COMPLETED' AND t2.delete_mark = 0
@@ -39,7 +39,7 @@
                 OR (leave_start_time > #{startTime} and #{endTime} > leave_end_time)
                 OR (#{startTime} > leave_start_time and leave_end_time > #{endTime})
             )
-        and t2.id = #{userId}
+        and t2.id = #{userId} order by leave_start_time limit 1
     </select>
 
     <select id="getUserLeaveList" resultType="com.xjrsoft.module.teacher.entity.WfTeacherleave">