Prechádzať zdrojové kódy

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

brealinxx 5 mesiacov pred
rodič
commit
f3daf50ff1

+ 9 - 5
src/main/java/com/xjrsoft/module/attendance/controller/StatisticsController.java

@@ -5,6 +5,7 @@ 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.StudyStatusEnum;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
 import com.xjrsoft.module.attendance.vo.TeacherStatisticsVo;
@@ -98,10 +99,10 @@ public class StatisticsController {
                             .orderByAsc(TeacherOutInRecord::getRecordTime)
             );
 
-            List<Long> collect = outInRecords.stream().map(TeacherOutInRecord::getUserId).collect(Collectors.toList());
+            Set<Long> collect = outInRecords.stream().map(TeacherOutInRecord::getUserId).collect(Collectors.toSet());
             Set<Long> userIds = new HashSet<>(collect);
             //实到人数
-            statisticsVo.setActualCount(Long.valueOf(userIds.size()));
+            statisticsVo.setActualCount(Long.valueOf(collect.size()));
 
             //查询教师请假人数
             Long leaveCount = wfTeacherleaveService.getLeaveCount(startTime, endTime);
@@ -150,6 +151,9 @@ public class StatisticsController {
                 .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, XjrUser::getId)
                 .innerJoin(BaseStudent.class, BaseStudent::getUserId, XjrUser::getId);
         long allCount = xjrUserService.count(queryWrapper);
+
+        queryWrapper.eq(BaseStudentSchoolRoll::getStduyStatus, StudyStatusEnum.AttendDaySchool.getCode());
+        long attendDaySchoolCount = xjrUserService.count(queryWrapper);
         statisticsVo.setAllCount(allCount);
         if(dto.getDate() != null && !"".equals(dto.getDate())){
             DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE;
@@ -172,7 +176,7 @@ public class StatisticsController {
                             .eq(StudentOutInRecord::getStatus, 1)
             );
             //实到人数
-            List<Long> collect = outInRecords.stream().map(StudentOutInRecord::getUserId).collect(Collectors.toList());
+            Set<Long> collect = outInRecords.stream().map(StudentOutInRecord::getUserId).collect(Collectors.toSet());
             statisticsVo.setActualCount(Long.valueOf(collect.size()));
 
             //查询教师请假人数
@@ -199,8 +203,8 @@ public class StatisticsController {
             //计算出勤率
             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.setAbsenteeismCount(attendDaySchoolCount - statisticsVo.getLeaveCount() - statisticsVo.getActualCount());
+                BigDecimal divide = BigDecimal.valueOf(statisticsVo.getActualCount()).divide(BigDecimal.valueOf(attendDaySchoolCount), 4, RoundingMode.HALF_UP);
                 statisticsVo.setAttendanceRate(divide.doubleValue() + "");
             }else{
                 statisticsVo.setAttendanceRate("0");

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

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.ArchivesStatusEnum;
+import com.xjrsoft.common.enums.StudyStatusEnum;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
@@ -50,6 +51,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
 * @title: 考勤消息设置
@@ -144,12 +147,12 @@ public class StudentStatisticsController {
                 record.setLateCount(lateCount);
 
                 //最后通过总人数-实到人数-请假人数计算出缺勤人数
-                record.setAbsenteeismCount(record.getStudentCount() - record.getLeaveCount() - record.getActualCount());
+                record.setAbsenteeismCount(record.getNotStayCount() - record.getLeaveCount() - record.getActualCount());
 
                 //计算出勤率
                 BigDecimal divide = BigDecimal.ZERO;
-                if(record.getStudentCount() != null && record.getStudentCount() != 0){
-                    divide = BigDecimal.valueOf(record.getActualCount()).divide(BigDecimal.valueOf(record.getStudentCount()), 4, RoundingMode.HALF_UP);
+                if(record.getNotStayCount() != null && record.getNotStayCount() != 0){
+                    divide = BigDecimal.valueOf(record.getActualCount()).divide(BigDecimal.valueOf(record.getNotStayCount()), 4, RoundingMode.HALF_UP);
                 }
                 record.setAttendanceRate(divide.doubleValue() + "");
             }
@@ -236,6 +239,9 @@ public class StudentStatisticsController {
                         record.setStatus("缺勤");
                     }
                 }
+                if(StudyStatusEnum.InResidence.getValue().equals(record.getStduyStatusCn())){
+                    record.setStatus("不考勤");
+                }
             }
         }
         PageOutput<StudentStatisticsPageVo> pageOutput = ConventPage.getPageOutput(voIPage, StudentStatisticsPageVo.class);
@@ -275,7 +281,9 @@ public class StudentStatisticsController {
 
             for (ClassStatisticsVo record: attendancePage.getRecords()) {
                 record.setLeaveCount(classLeaveCount.get(record.getId()) == null ? 0:classLeaveCount.get(record.getId()));
-                record.setActualCount(notStayMap.get(record.getId()).size() + stayMap.get(record.getId()).size());
+                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;

+ 41 - 4
src/main/java/com/xjrsoft/module/attendance/controller/TeacherStatisticsController.java

@@ -20,8 +20,11 @@ import com.xjrsoft.module.organization.entity.Department;
 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.entity.CarOutInRecord;
 import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
+import com.xjrsoft.module.outint.service.ICarOutInRecordService;
 import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
+import com.xjrsoft.module.personnel.entity.CarMessageApply;
 import com.xjrsoft.module.teacher.entity.BaseTeacher;
 import com.xjrsoft.module.teacher.entity.WfHeadTeacherLeave;
 import com.xjrsoft.module.teacher.entity.WfTeacherleave;
@@ -62,6 +65,7 @@ public class TeacherStatisticsController {
     private final IHolidayDateService holidayDateService;
     private final IWfHeadTeacherLeaveService headTeacherLeaveService;
     private final IAttendanceRuleCategoryService attendanceRuleCategoryService;
+    private final ICarOutInRecordService carOutInRecordService;
 
     @GetMapping(value = "/teacher-details")
     @ApiOperation(value="教师考勤")
@@ -114,7 +118,7 @@ public class TeacherStatisticsController {
 //                outInMap.put(inRecord.getUserId(), inRecord);
 //            }
             for (TeacherStatisticsPageVo record : voIPage.getRecords()) {
-                LocalDateTime startTime, endTime;
+                LocalDateTime startTime, endTime, amEndTime = null;
                 AttendanceRuleDetailsUserVo detailsUserVo = teacherTodyRuleByUserId.get(record.getUserId());
                 if(dto.getTimePeriod() == 1){
                     startTime = queryDate.atTime(5, 0, 0);
@@ -134,6 +138,10 @@ public class TeacherStatisticsController {
                     if(detailsUserVo != null && detailsUserVo.getPmEndTime() != null){
                         endTime = queryDate.atTime(detailsUserVo.getPmEndTime());
                     }
+                    amEndTime  = queryDate.atTime(12, 0, 0);
+                    if(detailsUserVo != null && detailsUserVo.getAmEndTime() != null){
+                        amEndTime = queryDate.atTime(detailsUserVo.getAmEndTime());
+                    }
                 }else{
                     startTime = queryDate.atTime(0, 0, 0);
                     if(detailsUserVo != null && detailsUserVo.getEveningStartTime() != null){
@@ -164,9 +172,10 @@ public class TeacherStatisticsController {
                     continue;
                 }
                 List<TeacherOutInRecord> outInRecords = teacherOutInRecordService.list(
-                    new QueryWrapper<TeacherOutInRecord>().lambda()
-                            .between(TeacherOutInRecord::getRecordTime, startTime, endTime)
+                    new MPJLambdaWrapper<TeacherOutInRecord>()
+                            .le(TeacherOutInRecord::getRecordTime, startTime)
                             .eq(TeacherOutInRecord::getStatus, 1)
+                            .eq("DATE_FORMAT(record_time, '%Y-%m-%d')", startTime.toLocalDate())
                             .eq(TeacherOutInRecord::getUserId, record.getUserId())
                             .orderByAsc(TeacherOutInRecord::getRecordTime)
                 );
@@ -175,12 +184,40 @@ public class TeacherStatisticsController {
                     if(outInRecord != null){
                         record.setRecordTime(outInRecord.getRecordTime());
                         record.setStatus(outInRecord.getAttendanceStatus());
+                        record.setAttendanceMode("人脸");
+                    }
+                }else{
+                    //查询该教师是否通过车辆进入
+                    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)
+                                    .le(CarOutInRecord::getRecordTime, endTime)
+                                    .eq("DATE_FORMAT(record_time, '%Y-%m-%d')", endTime.toLocalDate())
+                                    .eq(CarMessageApply::getUserId, record.getUserId())
+                                    .ge(dto.getTimePeriod() == 2 && amEndTime != null, CarOutInRecord::getRecordTime, amEndTime)
+                                    .eq(CarOutInRecord::getReleaseResult, 1)
+                                    .orderByAsc(CarOutInRecord::getRecordTime)
+                    );
+                    if(!list.isEmpty()){
+                        CarOutInRecord outInRecord = list.get(0);
+                        if(outInRecord != null && outInRecord.getRecordTime().isBefore(startTime)){
+                            record.setRecordTime(outInRecord.getRecordTime());
+                            record.setStatus("到校");
+                            record.setAttendanceMode("车辆");
+                            record.setCarNumber(outInRecord.getPlanNo());
+                        }else if(outInRecord != null && outInRecord.getRecordTime().isAfter(startTime)){
+                            record.setRecordTime(outInRecord.getRecordTime());
+                            record.setStatus("迟到");
+                            record.setAttendanceMode("车辆");
+                            record.setCarNumber(outInRecord.getPlanNo());
+                        }
                     }
                 }
+
                 if(record.getStatus() == null){
                     record.setStatus("缺勤");
                 }
-
             }
         }
         PageOutput<TeacherStatisticsPageVo> pageOutput = ConventPage.getPageOutput(voIPage, TeacherStatisticsPageVo.class);

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

@@ -31,4 +31,10 @@ public class TeacherStatisticsPageVo {
 
     @ApiModelProperty("考勤时间")
     private LocalDateTime recordTime;
+
+    @ApiModelProperty("考勤方式")
+    private String attendanceMode;
+
+    @ApiModelProperty("车牌号")
+    private String carNumber;
 }

+ 13 - 13
src/main/java/com/xjrsoft/module/hikvision/util/DataUtil.java

@@ -281,9 +281,9 @@ public class DataUtil {
             paramJson.addProperty("personId", objectMap.get("id").toString());
             paramJson.addProperty("personName", objectMap.get("name").toString());
             paramJson.addProperty("orgIndexCode", objectMap.get("orgIndexCode").toString());
-            paramJson.addProperty("phoneNo", objectMap.get("mobile").toString());
+            paramJson.addProperty("phoneNo", objectMap.get("mobile")==null?"":objectMap.get("mobile").toString());
             paramJson.addProperty("jobNo", objectMap.get("user_name").toString());
-            paramJson.addProperty("birthday", objectMap.get("birthday").toString());
+            paramJson.addProperty("birthday", objectMap.get("birthday")==null?"":objectMap.get("birthday").toString());
             paramJson.addProperty("personType", 2);
 
             int gender;
@@ -321,7 +321,7 @@ public class DataUtil {
         return idMap;
     }
 
-    public Map<String, String> insertStudent(String tableName, Map<String, String> tableData) throws Exception {
+    public Map<String, String> insertStudent(String tableName, Map<String, String> tableData) {
         String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',t4.name,'-',t3.class_type,'-',t2.stduy_status)," +
                 " t1.user_name,t1.gender,t1.birth_date,t1.mobile,t1.email,t1.credential_type,t1.credential_number FROM xjr_user t1" +
                 " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
@@ -407,22 +407,22 @@ public class DataUtil {
         JsonArray paramArray = new JsonArray();
         Map<Integer, String> clientMap = new HashMap<>();
         for(int i = 0; i < list.size(); i ++){
-            String[] el = SqlRunnerAdapterUtil.convertMapToStringArray(list.get(i));
-            if(tableData != null && tableData.containsKey(el[0])){
+            Map<String, Object> objectMap = list.get(i);
+            if(tableData != null && tableData.containsKey(objectMap.get("id").toString())){
                 continue;
             }
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("clientId", i);
-            paramJson.addProperty("personId", el[0]);
-            paramJson.addProperty("personName", el[1]);
-            paramJson.addProperty("orgIndexCode", deptMap.get(el[3]));
-            paramJson.addProperty("phoneNo", el[5]);
-            paramJson.addProperty("jobNo", el[9]);
-            paramJson.addProperty("birthday", el[4]);
+            paramJson.addProperty("personId", objectMap.get("id").toString());
+            paramJson.addProperty("personName", objectMap.get("name").toString());
+            paramJson.addProperty("orgIndexCode", objectMap.get("dept_id").toString());
+            paramJson.addProperty("phoneNo", objectMap.get("mobile")==null?"":objectMap.get("mobile").toString());
+            paramJson.addProperty("jobNo", objectMap.get("user_name").toString());
+            paramJson.addProperty("birthday", objectMap.get("birth_date")==null?"":objectMap.get("birth_date").toString());
             paramJson.addProperty("personType", 1);
 
             int gender;
-            switch (el[2]) {
+            switch (objectMap.get("gender").toString()) {
                 case "SB10001":
                     gender = 1;
                     break;
@@ -436,7 +436,7 @@ public class DataUtil {
             paramJson.addProperty("gender", gender);
             paramArray.add(paramJson);
 
-            clientMap.put(i, el[0]);
+            clientMap.put(i, objectMap.get("id").toString());
         }
 
         String apiPath = "/api/resource/v1/person/batch/add";

+ 2 - 2
src/main/java/com/xjrsoft/module/hikvision/util/OutInRecordUtil.java

@@ -181,7 +181,7 @@ public class OutInRecordUtil {
             if (personId == null) continue;
 
             int statusInt = item.get("inAndOutType").getAsInt();
-            int status = -1;
+            int status = 1;
             switch (statusInt){
                 case 0:
                     status = 1;
@@ -562,7 +562,7 @@ public class OutInRecordUtil {
                 String happenTime = eventObject.get("happenTime").getAsString();
                 String extEventPictureURL = dataObject.get("ExtEventPictureURL").getAsString();
                 int statusInt = dataObject.get("ExtEventInOut").getAsInt();
-                int status = statusInt;
+                int status = 1;
                 switch (statusInt){
                     case 0:
                         status = 1;

+ 61 - 28
src/main/java/com/xjrsoft/module/job/AttenDanceWarnNoticeTask.java

@@ -112,9 +112,11 @@ public class AttenDanceWarnNoticeTask {
                         .eq(WechatMessageLog::getSendTime, recentlyTime)
                         .eq(WechatMessageLog::getTemplateId, wechatTemplate)
         );
-        if(!list.isEmpty()){//已经推送过,不再进行推送
-            return;
-        }
+//        if(!list.isEmpty()){//已经推送过,不再进行推送
+//            return;
+//        }
+
+        LocalDateTime attendanceTime = getAttendanceTime(ruleDetailsList, now);
 
         //判断所有当前时间下,哪几条规则需要进行提醒
         Map<Long, Integer> ruleDetailsJudgeMap = judgeExecuteNotice(now, ruleDetailsList, recentlyTime);
@@ -139,7 +141,7 @@ public class AttenDanceWarnNoticeTask {
 
 
             JSONObject time5 = new JSONObject();
-            time5.put("value", recentlyTime.format(formatter));
+            time5.put("value", attendanceTime.format(formatter));
             paramJson.put("time5", time5);
 
             JSONObject thing8 = new JSONObject();
@@ -152,9 +154,9 @@ public class AttenDanceWarnNoticeTask {
 
             JSONObject const12 = new JSONObject();
             if(status == 1){
-                const12.put("value", "未打卡");
-            }else{
                 const12.put("value", "待打卡");
+            }else{
+                const12.put("value", "未打卡");
             }
             //查询这个用户最新的考勤状态
             AttendanceUserRelation userRelation = allUserStatus.get(xjrUser.getId());
@@ -181,7 +183,7 @@ public class AttenDanceWarnNoticeTask {
      * 判断所有规则,哪些需要发送
      * @param judgeTime
      * @param ruleDetailsList
-     * @return 0:不需要提醒,1:未打卡,2:待打卡
+     * @return 0:不需要提醒,1:待打卡,2:未打卡
      */
     Map<Long, Integer> judgeExecuteNotice(LocalDateTime judgeTime, List<AttendanceRuleDetails> ruleDetailsList, LocalDateTime recentlyTime){
         Map<Long, Integer> result = new HashMap<>();
@@ -190,36 +192,30 @@ public class AttenDanceWarnNoticeTask {
                     && ruleDetails.getIsAttendance() != null && ruleDetails.getIsAttendance() == 1){
                 if(ruleDetails.getAmStartTime() != null){
                     LocalDateTime amStartTime = judgeTime.with(ruleDetails.getAmStartTime().toLocalTime());
-                    if(recentlyTime.isEqual(amStartTime)){
-                        Long amBetween = ChronoUnit.MINUTES.between(judgeTime, amStartTime);
-                        if(judgeTime.isBefore(amStartTime) && amBetween >= ruleDetails.getAgoMinutes() - 1 && amBetween <= ruleDetails.getAgoMinutes() + 1){//相差分钟数小于0
-                            result.put(ruleDetails.getId(), 1);
-                        }else if(judgeTime.isAfter(amStartTime) && amBetween >= ruleDetails.getOverMinutes() - 1 && amBetween <= ruleDetails.getOverMinutes() + 1){
-                            result.put(ruleDetails.getId(), 2);
-                        }
+                    Long amBetween = Math.abs(ChronoUnit.MINUTES.between(judgeTime, amStartTime));
+                    if(recentlyTime.isEqual(amStartTime.plusMinutes(- ruleDetails.getAgoMinutes())) && amBetween >= ruleDetails.getAgoMinutes() - 1 && amBetween <= ruleDetails.getAgoMinutes() + 1){//相差分钟数小于0
+                        result.put(ruleDetails.getId(), 1);
+                    }else if(recentlyTime.isEqual(amStartTime.plusMinutes(ruleDetails.getOverMinutes())) && amBetween >= ruleDetails.getOverMinutes() - 1 && amBetween <= ruleDetails.getOverMinutes() + 1){
+                        result.put(ruleDetails.getId(), 2);
                     }
                 }
                 if(ruleDetails.getPmStartTime() != null){
                     LocalDateTime pmStartTime = judgeTime.with(ruleDetails.getPmStartTime().toLocalTime());
-                    if(recentlyTime.isEqual(pmStartTime)){
-                        Long pmBetween = ChronoUnit.MINUTES.between(judgeTime, pmStartTime);
-                        if(judgeTime.isBefore(pmStartTime) && pmBetween >= ruleDetails.getAgoMinutes() - 1 && pmBetween <= ruleDetails.getAgoMinutes() + 1){
-                            result.put(ruleDetails.getId(), 1);
-                        }else if(judgeTime.isAfter(pmStartTime) && pmBetween >= ruleDetails.getOverMinutes() - 1 && pmBetween <= ruleDetails.getOverMinutes() + 1){
-                            result.put(ruleDetails.getId(), 2);
-                        }
+                    Long pmBetween = Math.abs(ChronoUnit.MINUTES.between(judgeTime, pmStartTime));
+                    if(recentlyTime.isEqual(pmStartTime.plusMinutes(- ruleDetails.getAgoMinutes())) && pmBetween >= ruleDetails.getAgoMinutes() - 1 && pmBetween <= ruleDetails.getAgoMinutes() + 1){//相差分钟数小于0
+                        result.put(ruleDetails.getId(), 1);
+                    }else if(recentlyTime.isEqual(pmStartTime.plusMinutes(ruleDetails.getOverMinutes())) && pmBetween >= ruleDetails.getOverMinutes() - 1 && pmBetween <= ruleDetails.getOverMinutes() + 1){
+                        result.put(ruleDetails.getId(), 2);
                     }
                 }
 
                 if(ruleDetails.getEveningStartTime() != null){
                     LocalDateTime eveningStartTime = judgeTime.with(ruleDetails.getEveningStartTime().toLocalTime());
-                    if(recentlyTime.isEqual(eveningStartTime)){
-                        Long eveningBetween = ChronoUnit.MINUTES.between(judgeTime, eveningStartTime);
-                        if(judgeTime.isBefore(eveningStartTime) && eveningBetween >= ruleDetails.getAgoMinutes() - 1 && eveningBetween <= ruleDetails.getAgoMinutes() + 1){
-                            result.put(ruleDetails.getId(), 1);
-                        }else if(judgeTime.isAfter(eveningStartTime)  && eveningBetween >= ruleDetails.getOverMinutes() - 1 && eveningBetween <= ruleDetails.getOverMinutes() + 1){
-                            result.put(ruleDetails.getId(), 2);
-                        }
+                    Long eveningBetween = Math.abs(ChronoUnit.MINUTES.between(judgeTime, eveningStartTime));
+                    if(recentlyTime.isEqual(eveningStartTime.plusMinutes(- ruleDetails.getAgoMinutes())) && eveningBetween >= ruleDetails.getAgoMinutes() - 1 && eveningBetween <= ruleDetails.getAgoMinutes() + 1){//相差分钟数小于0
+                        result.put(ruleDetails.getId(), 1);
+                    }else if(recentlyTime.isEqual(eveningStartTime.plusMinutes(ruleDetails.getOverMinutes())) && eveningBetween >= ruleDetails.getOverMinutes() - 1 && eveningBetween <= ruleDetails.getOverMinutes() + 1){
+                        result.put(ruleDetails.getId(), 2);
                     }
                 }
 
@@ -247,6 +243,43 @@ public class AttenDanceWarnNoticeTask {
     }
 
     LocalDateTime getRecentlyTime(List<AttendanceRuleDetails> ruleDetails, LocalDateTime now){
+        List<LocalDateTime> result = new ArrayList<>();
+        for (AttendanceRuleDetails ruleDetail : ruleDetails) {
+            if(ruleDetail.getIsAllowInOutSchool() != null && ruleDetail.getIsAllowInOutSchool() == 1
+                    && ruleDetail.getIsAttendance() != null && ruleDetail.getIsAttendance() == 1){
+                if(ruleDetail.getAmStartTime() != null){
+                    LocalDateTime amStartTime = now.with(ruleDetail.getAmStartTime().toLocalTime());
+                    result.add(amStartTime.plusMinutes(- ruleDetail.getAgoMinutes()));
+                    result.add(amStartTime.plusMinutes(ruleDetail.getOverMinutes()));
+                }
+                if(ruleDetail.getPmStartTime() != null){
+                    LocalDateTime pmStartTime = now.with(ruleDetail.getPmStartTime().toLocalTime());
+                    result.add(pmStartTime.plusMinutes(- ruleDetail.getAgoMinutes()));
+                    result.add(pmStartTime.plusMinutes(ruleDetail.getOverMinutes()));
+                }
+
+                if(ruleDetail.getEveningStartTime() != null){
+                    LocalDateTime eveningStartTime = now.with(ruleDetail.getEveningStartTime().toLocalTime());
+                    result.add(eveningStartTime.plusMinutes(- ruleDetail.getAgoMinutes()));
+                    result.add(eveningStartTime.plusMinutes(ruleDetail.getOverMinutes()));
+                }
+            }
+        }
+        if(result.isEmpty()){
+            return null;
+        }
+        Map<Long, LocalDateTime> timeMap = new HashMap<>();
+        for (LocalDateTime localDateTime : result) {
+            long between = ChronoUnit.SECONDS.between(now, localDateTime);
+            timeMap.put(Math.abs(between), localDateTime);
+        }
+        List<Long> collect = timeMap.keySet().stream().collect(Collectors.toList());
+        Collections.sort(collect, Long::compare);
+
+        return timeMap.get(collect.get(0));
+    }
+
+    LocalDateTime getAttendanceTime(List<AttendanceRuleDetails> ruleDetails, LocalDateTime now){
         List<LocalDateTime> result = new ArrayList<>();
         for (AttendanceRuleDetails ruleDetail : ruleDetails) {
             if(ruleDetail.getIsAllowInOutSchool() != null && ruleDetail.getIsAllowInOutSchool() == 1

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

@@ -156,7 +156,7 @@ public class AttendanceMessageTask {
             }
             //查询需要通知的人
             List<XjrUser> userList = userService.list(
-                new MPJLambdaWrapper<XjrUser>()
+                new MPJLambdaWrapper<XjrUser>().distinct()
                 .select(XjrUser::getId)
                 .select(XjrUser.class, x -> VoToColumnUtil.fieldsToColumns(XjrUser.class).contains(x.getProperty()))
                 .leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)

+ 5 - 1
src/main/java/com/xjrsoft/module/outint/entity/CarOutInRecord.java

@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
 import java.util.Date;
 
 
@@ -78,7 +79,7 @@ public class CarOutInRecord implements Serializable {
     * 记录时间
     */
     @ApiModelProperty("记录时间")
-    private String recordTime;
+    private LocalDateTime recordTime;
     /**
     * 人脸照片
     */
@@ -130,4 +131,7 @@ public class CarOutInRecord implements Serializable {
      */
     @ApiModelProperty("姓名")
     private String name;
+
+    @ApiModelProperty("车辆id(car_message_apply),固定车辆使用")
+    private Long carMessageApplyId;
 }

+ 1 - 0
src/main/java/com/xjrsoft/module/personnel/controller/StundentFaceProcessController.java

@@ -376,6 +376,7 @@ public class StundentFaceProcessController {
                 FaceManagement faceManagement = faceManagementMap.get(studentUser.getId());
                 faceManagement.setVerifyStatus(2);
                 faceManagement.setRegisterBase64(base64String);
+                faceManagement.setFileId(folderId);
                 faceManagementService.update(faceManagement);
             }
         }

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

@@ -39,5 +39,6 @@
         INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
         WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
         AND t1.record_time BETWEEN #{startTime} AND #{endTime}
+        order by t1.record_time
     </select>
 </mapper>

+ 50 - 50
src/test/java/com/xjrsoft/module/job/HikvisionBaseDataTaskTest.java

@@ -83,29 +83,29 @@ class HikvisionBaseDataTaskTest {
 
     @Test
     void test() throws Exception {
-//        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
-//        Db use = Db.use(datasource);
-//        String sql = "SELECT distinct table_name FROM hikvision_data WHERE 1 = 1";
-//        List<JianyueData> query = use.query(sql, JianyueData.class);
-//        Set<String> tables = new HashSet<>();
-//        for (JianyueData jianyueData : query) {
-//            tables.add(jianyueData.getTableName());
-//        }
-//        sql = "SELECT * FROM hikvision_data WHERE 0 = 0";
-//        List<HikvisionData> list = use.query(sql, HikvisionData.class);
-//        Map<String, Map<String, String>> dataMap = new HashMap<>();
-//        for (String table : tables) {
-//            Map<String, String> tableData = new HashMap<>();
-//            for (HikvisionData hikvisiondata : list) {
-//                if(!table.equals(hikvisiondata.getTableName())){
-//                    continue;
-//                }
-//                tableData.put(hikvisiondata.getSourceId(), hikvisiondata.getHikvisionId());
-//            }
-//            dataMap.put(table, tableData);
-//        }
+        String sql = "SELECT distinct table_name FROM hikvision_data WHERE 1 = 1";
+        List<Map<String, Object>> maps = SqlRunnerAdapter.db().selectList(sql, HikvisionData.class);
+        Set<String> tables = new HashSet<>();
+        for (Map<String, Object> map : maps) {
+            String[] strings = SqlRunnerAdapterUtil.convertMapToStringArray(map);
+            tables.add(strings[0]);
+        }
+        sql = "SELECT * FROM hikvision_data WHERE 0 = 0";
+        List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql, HikvisionData.class);
+        Map<String, Map<String, String>> dataMap = new HashMap<>();
+        for (String table : tables) {
+            Map<String, String> tableData = new HashMap<>();
+            for (Map<String, Object> hikvision : list) {
+
+                if(!table.equals(hikvision.get("table_name").toString())){
+                    continue;
+                }
+                tableData.put(hikvision.get("source_id").toString(), hikvision.get("hikvision_id").toString());
+            }
+            dataMap.put(table, tableData);
+        }
 //        DataUtil dataUtil = new DataUtil();
-//        String tableName = "xjr_department";
+        String tableName = "xjr_department";
 //        Map<String, String> department = dataUtil.insertDepartment(use, tableName, dataMap.get(tableName));
 //        if(department.isEmpty() && dataMap.get(tableName) != null){
 //            department = dataMap.get(tableName);
@@ -127,9 +127,9 @@ class HikvisionBaseDataTaskTest {
 //        Map<String, String> classes = dataUtil.insertClass(use, tableName, baseClass);
 
 
-//        tableName = "base_student";
-//        Map<String, String> baseStudent = dataMap.get(tableName);
-//        Map<String, String> student = dataUtil.insertStudentOne(use, tableName, baseStudent);
+        tableName = "base_student";
+        Map<String, String> baseStudent = dataMap.get(tableName);
+        Map<String, String> student = insertStudentOne(tableName, baseStudent);
 
 //        selectOrg(use, "base_class");
 
@@ -170,43 +170,40 @@ class HikvisionBaseDataTaskTest {
         db.executeBatch(sqls);
     }
 
-    public Map<String, String> insertStudentOne(Db db, String tableName, Map<String, String> tableData) throws Exception {
-        String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',t4.name,'-',t3.class_type,'-',t2.stduy_status)," +
-                " t1.user_name,t1.gender,DATE_FORMAT(t1.birth_date, '%Y-%m-%d'),t1.mobile,t1.email,t1.credential_type,t1.credential_number FROM xjr_user t1" +
+    public Map<String, String> insertStudentOne(String tableName, Map<String, String> tableData) throws Exception {
+        String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',replace(t4.name,'级',''),'-',t3.class_type,'-',t2.stduy_status) as orgIndexCode," +
+                " t1.user_name,t1.gender,DATE_FORMAT(t1.birth_date, '%Y-%m-%d') as birthday,t1.mobile,t1.email,t1.credential_type,t1.credential_number FROM xjr_user t1" +
                 " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
                 " INNER JOIN base_class t3 ON t2.class_id = t3.id" +
                 " INNER JOIN base_grade t4 ON t3.grade_id = t4.id" +
                 " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0" +
-                " AND t3.class_type IS NOT NULL" +
-                " AND t1.id NOT IN (SELECT source_id FROM hikvision_data WHERE table_name = 'base_student'\n" +
-                ") AND t4.name NOT IN ('2021级','2020级')";
-        List<String[]> list = db.query(sql, String[].class);
+                " AND t3.class_type IS NOT NULL";
+                //" AND t1.name IN ('宋成男','白江龙','李松阳')";
+        List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql, String[].class);
         Map<Integer, String> clientMap = new HashMap<>();
 
-        String apiPath = "/api/resource/v2/person/single/add";
         Map<String, String> idMap = new HashMap<>();
         JsonParser jsonParser = new JsonParser();
         ApiUtil apiUtil = new ApiUtil();
         Map<String, String> header = new HashMap<>();
         header.put("tagId", "insert_student");
 
-        for(int i = 0; i < list.size(); i ++){
-            String[] el = list.get(i);
-            if(tableData != null && tableData.containsKey(el[0])){
-                continue;
-            }
+        for(int i = 1; i < list.size(); i ++){
+            Map<String, Object> objectMap = list.get(i);
+            String apiPath = "/api/resource/v2/person/single/add";
+
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("clientId", i);
-            paramJson.addProperty("personId", el[0]);
-            paramJson.addProperty("personName", el[1]);
-            paramJson.addProperty("orgIndexCode", el[2]);
-            paramJson.addProperty("phoneNo", el[6]);
-            paramJson.addProperty("jobNo", el[3]);
-            paramJson.addProperty("birthday", el[5]);
+            paramJson.addProperty("personId", objectMap.get("id").toString());
+            paramJson.addProperty("personName", objectMap.get("name").toString());
+            paramJson.addProperty("orgIndexCode", objectMap.get("orgIndexCode").toString());
+            paramJson.addProperty("phoneNo", objectMap.get("mobile")==null?"":objectMap.get("mobile").toString());
+            paramJson.addProperty("jobNo", objectMap.get("user_name").toString());
+            paramJson.addProperty("birthday", objectMap.get("birthday")==null?"":objectMap.get("birthday").toString());
             paramJson.addProperty("personType", 2);
 
             int gender;
-            switch (el[4]) {
+            switch (objectMap.get("gender").toString()) {
                 case "SB10001":
                     gender = 1;
                     break;
@@ -219,18 +216,21 @@ class HikvisionBaseDataTaskTest {
             }
             paramJson.addProperty("gender", gender);
 
-            clientMap.put(i, el[0]);
-            System.out.println("请求参数:" + paramJson.toString());
+            if(tableData != null && tableData.containsKey(objectMap.get("id").toString())){
+                apiPath = "/api/resource/v1/person/single/update";
+                apiUtil.doPost(apiPath, paramJson.toString(), null, header);
+                continue;
+            }
+
+            clientMap.put(i, objectMap.get("id").toString());
             String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
-            System.out.println("返回结果:" + result);
             JsonElement parse = jsonParser.parse(result);
             JsonObject resultJson = parse.getAsJsonObject();
             if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
                 JsonObject array = resultJson.get("data").getAsJsonObject();
-                idMap.put(el[0], array.get("personId").getAsString());
+                idMap.put(objectMap.get("id").toString(), array.get("personId").getAsString());
             }
         }
-        insertRecord(db, tableName, idMap);
         //插入记录表
         return idMap;
     }