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

Merge remote-tracking branch 'origin/dev' into dev

大数据与最优化研究所 пре 9 месеци
родитељ
комит
e0cb919822

+ 10 - 0
src/main/java/com/xjrsoft/common/utils/WeChatUtil.java

@@ -57,6 +57,16 @@ public class WeChatUtil {
     @Value("${xjrsoft.weChatMessageTemplate.assessmentTemplate}")
     public String assessmentTemplate;
 
+    //考勤结果通知模板
+    @Value("${xjrsoft.weChatMessageTemplate.attendanceMessageTemplate}")
+    public String attendanceMessageTemplate;
+
+    @Value("${xjrsoft.weChatMessageTemplate.outInTemplate}")
+    public String outInTemplate;
+
+    @Value("${xjrsoft.weChatMessageTemplate.attenDanceWarnTemplate}")
+    public String attenDanceWarnTemplate;
+
     //公众号获取Openid
     public WeChatUserInfo getMpOpenid(String code) {
         HashMap<String, Object> paramMap = new HashMap<>();

+ 0 - 109
src/main/java/com/xjrsoft/module/attendance/entity/AttendanceMessageSet.java.1716253865126.bak

@@ -1,109 +0,0 @@
-package com.xjrsoft.module.attendance.entity;
-
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableLogic;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.github.yulichang.annotation.EntityMapping;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import java.io.Serializable;
-import java.time.LocalTime;
-import java.time.LocalDateTime;
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Date;
-
-
-/**
-* @title: 考勤消息设置
-* @Author dzx
-* @Date: 2024-05-20
-* @Version 1.0
-*/
-@Data
-@TableName("attendance_message_set")
-@ApiModel(value = "attendance_message_set", description = "考勤消息设置")
-public class AttendanceMessageSet implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableId
-    private Long id;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.INSERT)
-    private Long createUserId;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.INSERT)
-    private Date createDate;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.UPDATE)
-    private Long modifyUserId;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.UPDATE)
-    private Date modifyDate;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.INSERT)
-    @TableLogic
-    private Integer deleteMark;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.INSERT)
-    private Integer enabledMark;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    private Integer sortCode;
-    /**
-    * 消息类别(1:迟到消息 2:旷课消息 3:缺勤消息)
-    */
-    @ApiModelProperty("消息类别(1:迟到消息 2:旷课消息 3:缺勤消息)")
-    private Integer messageCategory;
-    /**
-    * 时间段(1:上午 2:下午 3:晚上 4:返校)
-    */
-    @ApiModelProperty("时间段(1:上午 2:下午 3:晚上 4:返校)")
-    private Integer timePeriod;
-    /**
-    * 指定人员
-    */
-    @ApiModelProperty("指定人员")
-    private String userRelation;
-    /**
-     * 人员类别(1:教职工 2:学生)
-     */
-    @ApiModelProperty("人员类别(1:教职工 2:学生)")
-    private  Integer roleType;
-    /**
-    * attendanceMessageUserRelation
-    */
-    @ApiModelProperty("attendanceMessageUserRelation子表")
-    @TableField(exist = false)
-    @EntityMapping(thisField = "id", joinField = "attendanceMessageSetId")
-    private List<AttendanceMessageUserRelation> attendanceMessageUserRelationList;
-
-}

+ 0 - 103
src/main/java/com/xjrsoft/module/attendance/entity/AttendanceMessageUserRelation.java.1716253865128.bak

@@ -1,103 +0,0 @@
-package com.xjrsoft.module.attendance.entity;
-
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableLogic;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.github.yulichang.annotation.EntityMapping;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import java.io.Serializable;
-import java.time.LocalTime;
-import java.time.LocalDateTime;
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Date;
-
-
-/**
-* @title: 考勤消息提醒人员
-* @Author dzx
-* @Date: 2024-05-20
-* @Version 1.0
-*/
-@Data
-@TableName("attendance_message_user_relation")
-@ApiModel(value = "attendance_message_user_relation", description = "考勤消息提醒人员")
-public class AttendanceMessageUserRelation implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableId
-    private Long id;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.INSERT)
-    private Long createUserId;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.INSERT)
-    private Date createDate;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.UPDATE)
-    private Long modifyUserId;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.UPDATE)
-    private Date modifyDate;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.INSERT)
-    @TableLogic
-    private Integer deleteMark;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    @TableField(fill = FieldFill.INSERT)
-    private Integer enabledMark;
-    /**
-    * 
-    */
-    @ApiModelProperty("")
-    private Integer sortCode;
-    /**
-    * 所属班级id
-    */
-    @ApiModelProperty("所属班级id")
-    private Integer classId;
-    /**
-    * 所属部门id
-    */
-    @ApiModelProperty("所属部门id")
-    private Integer deptId;
-    /**
-    * 用户id
-    */
-    @ApiModelProperty("用户id")
-    private String userId;
-    /**
-    * 考勤消息设置(attendance_message_set)
-    */
-    @ApiModelProperty("考勤消息设置(attendance_message_set)")
-    private Long attendanceMessageSetId;
-
-
-}

+ 3 - 1
src/main/java/com/xjrsoft/module/hikvision/controller/EventController.java

@@ -10,6 +10,7 @@ import com.google.gson.JsonParser;
 import com.xjrsoft.common.constant.GlobalConstant;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.utils.DatasourceUtil;
+import com.xjrsoft.common.utils.WeChatUtil;
 import com.xjrsoft.config.HikvisionConfig;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.service.IBaseClassService;
@@ -53,6 +54,7 @@ public class EventController {
     private final IBaseClassService classService;
     private final IWeChatService weChatService;
     private final IXjrUserService xjrUserService;
+    private final WeChatUtil weChatUtil;
 
     @PostMapping("/receiveCar")
     @ApiOperation(value = "接收车辆事件")
@@ -114,7 +116,7 @@ public class EventController {
 
                         WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
                         weChatSendMessageDto.setUserId(member.getOpenId());
-                        weChatSendMessageDto.setTemplateId("ERkMebHjsziZO6WBrlzsbENiEuRR4vrlhJw5LR4aDr8");
+                        weChatSendMessageDto.setTemplateId(weChatUtil.getOutInTemplate());
                         weChatSendMessageDto.setMsgId(member.getId().toString());
                         JSONObject paramJson = new JSONObject();
 

+ 16 - 6
src/main/java/com/xjrsoft/module/hikvision/util/FaceImportUtil.java

@@ -3,8 +3,7 @@ package com.xjrsoft.module.hikvision.util;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-import com.xjrsoft.module.personnel.entity.TeacherFaceProcess;
-import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
+import com.xjrsoft.common.utils.ImageUtil;
 
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
@@ -34,8 +33,12 @@ public class FaceImportUtil {
         if("0".equals(personInfoData.get("code").getAsString()) && "success".equals(personInfoData.get("msg").getAsString())){
             JsonObject dataJson = personInfoData.get("data").getAsJsonObject();
             if(dataJson.get("total").getAsInt() > 0){
-                faceId = dataJson.get("list").getAsJsonArray().get(0)
-                        .getAsJsonObject().get("personPhoto").getAsJsonObject().get("personPhotoIndexCode").getAsString();
+                JsonArray personPhoto = dataJson.get("list").getAsJsonArray().get(0)
+                        .getAsJsonObject().get("personPhoto").getAsJsonArray();
+                if(personPhoto.size() > 0){
+                    faceId = personPhoto.get(0).getAsJsonObject().get("personPhotoIndexCode").getAsString();
+                }
+
             }
         }
         String response = null;
@@ -76,8 +79,12 @@ public class FaceImportUtil {
         if("0".equals(personInfoData.get("code").getAsString()) && "success".equals(personInfoData.get("msg").getAsString())){
             JsonObject dataJson = personInfoData.get("data").getAsJsonObject();
             if(dataJson.get("total").getAsInt() > 0){
-                faceId = dataJson.get("list").getAsJsonArray().get(0)
-                        .getAsJsonObject().get("personPhoto").getAsJsonObject().get("personPhotoIndexCode").getAsString();
+                JsonArray personPhoto = dataJson.get("list").getAsJsonArray().get(0)
+                        .getAsJsonObject().get("personPhoto").getAsJsonArray();
+                if(personPhoto.size() > 0){
+                    faceId = personPhoto.get(0).getAsJsonObject().get("personPhotoIndexCode").getAsString();
+                }
+
             }
         }
         String response = null;
@@ -114,6 +121,9 @@ public class FaceImportUtil {
                 outputStream.write(buffer, 0, bytesRead);
             }
             byte[] imageBytes = outputStream.toByteArray();
+            //压缩到200k
+            imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
+
             base64String = Base64.getEncoder().encodeToString(imageBytes);
             inputStream.close();
             outputStream.close();

+ 21 - 0
src/main/java/com/xjrsoft/module/hikvision/vo/AttendanceTimeVo.java

@@ -0,0 +1,21 @@
+package com.xjrsoft.module.hikvision.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @Author: tzx
+ * @Date: 2023/3/8 14:32
+ */
+@Data
+public class AttendanceTimeVo {
+
+
+    @ApiModelProperty("开始时间")
+    private LocalDateTime startTime;
+
+    @ApiModelProperty("结束时间")
+    private LocalDateTime endTime;
+}

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

@@ -2,6 +2,7 @@ package com.xjrsoft.module.job;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xjrsoft.common.utils.WeChatUtil;
 import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
 import com.xjrsoft.module.attendance.entity.AttendanceUserRelation;
 import com.xjrsoft.module.attendance.mapper.AttendanceUserRelationMapper;
@@ -43,6 +44,9 @@ public class AttenDanceWarnNoticeTask {
     @Autowired
     private IWeChatService weChatService;
 
+    @Autowired
+    private WeChatUtil weChatUtil;
+
     @Scheduled(cron = "0 */10 * * * ?")
     public void RefreshConnectionPool() {
         //获取当前时间
@@ -86,7 +90,7 @@ public class AttenDanceWarnNoticeTask {
 
             WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
             weChatSendMessageDto.setUserId(xjrUser.getOpenId());
-            weChatSendMessageDto.setTemplateId("Fg4AWVQRGernl0PiJQ8gRgCUFHEGZuizlClQNuVhqu4");
+            weChatSendMessageDto.setTemplateId(weChatUtil.getAttenDanceWarnTemplate());
             weChatSendMessageDto.setMsgId(xjrUser.getId().toString());
             JSONObject paramJson = new JSONObject();
 
@@ -98,6 +102,8 @@ public class AttenDanceWarnNoticeTask {
                 paramJson.put("const12", "出校");
             }
 
+
+
             weChatSendMessageDto.setContent(paramJson);
             weChatService.sendTemplateMessage(weChatSendMessageDto);
         }

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

@@ -1,23 +1,51 @@
 package com.xjrsoft.module.job;
 
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
-import com.xjrsoft.common.constant.GlobalConstant;
-import com.xjrsoft.common.utils.DatasourceUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.utils.WeChatUtil;
+import com.xjrsoft.config.CommonPropertiesConfig;
+import com.xjrsoft.module.attendance.entity.AttendanceMessageSet;
+import com.xjrsoft.module.attendance.entity.AttendanceMessageUserRelation;
 import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
 import com.xjrsoft.module.attendance.service.IAttendanceMessageSetService;
 import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
+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.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.UserRoleRelation;
+import com.xjrsoft.module.organization.service.IWeChatService;
+import com.xjrsoft.module.outint.entity.StudentOutInRecord;
+import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
+import com.xjrsoft.module.outint.service.IStudentOutInRecordService;
+import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
+import com.xjrsoft.module.student.entity.BaseStudent;
+import com.xjrsoft.module.teacher.entity.BaseTeacher;
+import com.xjrsoft.module.teacher.entity.XjrUser;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import javax.sql.DataSource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 考勤消息通知
  * @author dzx
- * @date 2024年5月21日
+ * @date 2024年6月7
  */
 @Component
 @Slf4j
@@ -27,6 +55,28 @@ public class AttendanceMessageTask {
 
     @Autowired
     private IAttendanceRuleCategoryService ruleCategoryService;
+
+    @Autowired
+    private IHolidayDateService holidayDateService;
+
+    @Autowired
+    private IXjrUserService userService;
+
+    @Autowired
+    private IStudentOutInRecordService studentOutInRecordService;
+
+    @Autowired
+    private ITeacherOutInRecordService teachertOutInRecordService;
+
+    @Autowired
+    private IWeChatService weChatService;
+
+    @Autowired
+    private CommonPropertiesConfig commonPropertiesConfig;
+
+    @Autowired
+    private WeChatUtil weChatUtil;
+
     @Scheduled(cron = "0 */15 * * * ?")
     public void RefreshConnectionPool() {
         String active = SpringUtil.getActiveProfile();
@@ -34,12 +84,169 @@ public class AttendanceMessageTask {
             log.info("非正式环境,无法执行数据推送");
             return;
         }
-
+        LocalDateTime now = LocalDateTime.now();
+        HolidayDate holidayDate = holidayDateService.getOne(
+                new QueryWrapper<HolidayDate>().lambda()
+                        .eq(HolidayDate::getDate, now.toLocalDate())
+        );
+        if(holidayDate.getWay() != null && holidayDate.getWay() != 0){
+            log.info("非工作日,不需要提醒");
+            return;
+        }
+        //查询今天的考勤规则
         List<AttendanceRuleDetails> ruleDetails = ruleCategoryService.getTodayRules();
+        //获取最近的时间
+        LocalDateTime recentlyTime = getRecentlyTime(ruleDetails, now);
+
+        List<AttendanceMessageSet> list = messageSetService.list(
+            new QueryWrapper<AttendanceMessageSet>().lambda()
+        );
+        //判断是上午还是下午
+        Integer timePeriod = null;
+        String timePeriodStr = null;
+        if(now.getHour() <= 12){
+            timePeriod = 1;
+            timePeriodStr = "上午考勤";
+        }else if(now.getHour() <= 18){
+            timePeriod = 2;
+            timePeriodStr = "下午考勤";
+        }else{
+            timePeriod = 3;
+            timePeriodStr = "晚上考勤";
+        }
+
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String format = recentlyTime.format(formatter);
 
-        try {
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
+        for (AttendanceMessageSet messageSet : list) {
+            if(!messageSet.getTimePeriod().contains(timePeriod + "")){
+                continue;
+            }
+            //查询需要通知的人
+            List<XjrUser> userList = userService.list(
+                new MPJLambdaWrapper<XjrUser>()
+                .leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
+                .leftJoin(AttendanceMessageUserRelation.class, AttendanceMessageUserRelation::getUserId, XjrUser::getId)
+                .eq(UserRoleRelation::getRoleId, messageSet.getRoleType())
+                .eq(AttendanceMessageUserRelation::getAttendanceMessageSetId, messageSet.getId())
+            );
+            //没有需要通知的,直接跳过
+            if(userList.isEmpty()){
+                continue;
+            }
+            if(messageSet.getRoleType() != null && messageSet.getRoleType() == 2){
+                //教师总人数
+                long teacherCout = userService.count(
+                    new MPJLambdaWrapper<XjrUser>()
+                    .leftJoin(BaseTeacher.class, BaseTeacher::getUserId, XjrUser::getId)
+                );
+                //查询进入记录,就是实际到校的人数
+                long outInRecords = teachertOutInRecordService.count(
+                    new MPJLambdaWrapper<TeacherOutInRecord>()
+                    .le(TeacherOutInRecord::getRecordTime, recentlyTime)
+                    .eq(TeacherOutInRecord::getStatus, 1)
+                );
+
+                //计算出勤率
+                BigDecimal divide = BigDecimal.ZERO;
+                if(teacherCout != 0){
+                    divide = BigDecimal.valueOf(outInRecords).divide(BigDecimal.valueOf(teacherCout), 4, RoundingMode.HALF_UP);
+                }
+
+                WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+                weChatSendMessageDto.setTemplateId(weChatUtil.getAttendanceMessageTemplate());
+                JSONObject paramJson = new JSONObject();
+
+                paramJson.put("thing6", "教职工");
+                paramJson.put("time11", format);
+                paramJson.put("const23", timePeriodStr);
+                paramJson.put("character_string18", teacherCout - outInRecords);
+                paramJson.put("const3", divide.doubleValue());
+
+                weChatSendMessageDto.setContent(paramJson);
+                weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/teacher/index", commonPropertiesConfig.getDomainApp()));
+
+                for (XjrUser xjrUser : userList) {
+                    weChatSendMessageDto.setMsgId(xjrUser.getId().toString());
+                    weChatSendMessageDto.setUserId(xjrUser.getOpenId());
+                    weChatService.sendTemplateMessage(weChatSendMessageDto);
+                }
+            }else if(messageSet.getRoleType() != null && messageSet.getRoleType() == 3){
+                //教师总人数
+                long teacherCout = userService.count(
+                    new MPJLambdaWrapper<XjrUser>()
+                    .leftJoin(BaseStudent.class, BaseStudent::getUserId, XjrUser::getId)
+                );
+                //查询进入记录,就是实际到校的人数
+                long outInRecords = studentOutInRecordService.count(
+                    new MPJLambdaWrapper<StudentOutInRecord>()
+                    .le(StudentOutInRecord::getRecordTime, recentlyTime)
+                    .eq(StudentOutInRecord::getStatus, 1)
+                );
+
+                //计算出勤率
+                BigDecimal divide = BigDecimal.ZERO;
+                if(teacherCout != 0){
+                    divide = BigDecimal.valueOf(outInRecords).divide(BigDecimal.valueOf(teacherCout), 4, RoundingMode.HALF_UP);
+                }
+
+
+                WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+                weChatSendMessageDto.setTemplateId(weChatUtil.getAttendanceMessageTemplate());
+                JSONObject paramJson = new JSONObject();
+
+                paramJson.put("thing6", "学生");
+                paramJson.put("time11", format);
+                paramJson.put("const23", timePeriodStr);
+                paramJson.put("character_string18", teacherCout - outInRecords);
+                paramJson.put("const3", divide.doubleValue());
+
+                weChatSendMessageDto.setContent(paramJson);
+                weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/class/index", commonPropertiesConfig.getDomainApp()));
+
+                for (XjrUser xjrUser : userList) {
+                    weChatSendMessageDto.setMsgId(xjrUser.getId().toString());
+                    weChatSendMessageDto.setUserId(xjrUser.getOpenId());
+                    weChatService.sendTemplateMessage(weChatSendMessageDto);
+                }
+            }
         }
+
+    }
+
+    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());
+                    result.add(amStartTime);
+                }
+                if(ruleDetail.getPmStartTime() != null){
+                    LocalDateTime pmStartTime = now.with(ruleDetail.getPmStartTime());
+                    result.add(pmStartTime);
+                }
+
+                if(ruleDetail.getEveningStartTime() != null){
+                    LocalDateTime eveningStartTime = now.with(ruleDetail.getEveningStartTime());
+                    result.add(eveningStartTime);
+                }
+            }
+        }
+        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));
     }
+
+
 }

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

@@ -25,7 +25,7 @@ public class InsertOutInRecordTask {
 
     OutInRecordUtil out_in_recordUtil = new OutInRecordUtil();
 
-    @Scheduled(cron = "*/15 * * * * ?")
+    @Scheduled(cron = "*/60 * * * * ?")
     public void RefreshConnectionPool() {
         String active = SpringUtil.getActiveProfile();
         if(!"prod".equals(active)){

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

@@ -20,6 +20,7 @@ import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.common.utils.FileZipUtil;
+import com.xjrsoft.common.utils.ImageUtil;
 import com.xjrsoft.common.utils.UploadUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.base.entity.BaseClass;
@@ -232,6 +233,9 @@ public class StundentFaceProcessController {
                 outputStream.write(buffer, 0, bytesRead);
             }
             byte[] imageBytes = outputStream.toByteArray();
+            //压缩到200k
+            imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
+
             String base64String = Base64.getEncoder().encodeToString(imageBytes);
             inputStream.close();
             outputStream.close();

+ 4 - 3
src/main/java/com/xjrsoft/module/schedule/util/DataUtil.java

@@ -52,6 +52,7 @@ public class DataUtil {
             paramJson.addProperty("not", department.getRemark());
             paramJson.addProperty("sort", department.getSortCode());
             paramJson.addProperty("shortName", department.getName());
+            paramJson.addProperty("extendId", department.getId());
             long timestamp = System.currentTimeMillis();
             String sign = ScheduleUtil.createSign(timestamp);
             ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
@@ -271,7 +272,7 @@ public class DataUtil {
             paramJson.addProperty("name", courseSubject.getName());
             paramJson.addProperty("code", courseSubject.getCode());
             paramJson.addProperty("extendId", courseSubject.getId().toString());
-            if(tagMap.get(courseSubject.getBaseLabelId().toString()) != null){
+            if(courseSubject.getBaseLabelId() != null && tagMap.get(courseSubject.getBaseLabelId().toString()) != null){
                 JsonArray jsonArray = new JsonArray();
                 jsonArray.add(tagMap.get(courseSubject.getBaseLabelId().toString()));
                 paramJson.add("tagSerialNos", jsonArray);
@@ -419,8 +420,8 @@ public class DataUtil {
                 //生成签名
                 String sign = ScheduleUtil.createSign(timestamp);
 
-                if(ids !=null && ids.get(baseGrade.getId().toString()) != null){
-                    paramJson.addProperty("serialNo", ids.get(baseGrade.getId().toString()));
+                if(ids != null && ids.get(gradeId + "_" + baseGrade.getId().toString()) != null){
+                    paramJson.addProperty("serialNo", ids.get(gradeId + "_" + baseGrade.getId().toString()));
                     url = ScheduleUtil.apiUrl + "eduyear/update";
                     ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
                     continue;

+ 3 - 0
src/main/resources/application-dev.yml

@@ -137,6 +137,9 @@ xjrsoft:
   weChatMessageTemplate:
     commonTemplate: qmpXORPM1Cocqn503Qa4OkNNQ0uxlj2-ed9m6uWO-v4
     assessmentTemplate: ehYfXni7exZUmt6dJX4Ukbm9ETarFfKLfXVYwNnjKMc
+    attendanceMessageTemplate: uPPJkWOSronnB_GJolcnatrQzGjJREIKL7JZzOieoew
+    outInTemplate: ERkMebHjsziZO6WBrlzsbENiEuRR4vrlhJw5LR4aDr8
+    attenDanceWarnTemplate: Fg4AWVQRGernl0PiJQ8gRgCUFHEGZuizlClQNuVhqu4
   dingtalk:
     appKey: dingaex2gok1rllumlqs
     appSecret: Nv2pe-UoR0Z_Iw8d29laZfL3kH6ElmhZpRdPwI7SvmKJmaCI29qCrSlFEiMM88MB

+ 3 - 0
src/main/resources/application-pre.yml

@@ -118,6 +118,9 @@ xjrsoft:
   weChatMessageTemplate:
     commonTemplate: qmpXORPM1Cocqn503Qa4OkNNQ0uxlj2-ed9m6uWO-v4
     assessmentTemplate: ehYfXni7exZUmt6dJX4Ukbm9ETarFfKLfXVYwNnjKMc
+    attendanceMessageTemplate: uPPJkWOSronnB_GJolcnatrQzGjJREIKL7JZzOieoew
+    outInTemplate: ERkMebHjsziZO6WBrlzsbENiEuRR4vrlhJw5LR4aDr8
+    attenDanceWarnTemplate: Fg4AWVQRGernl0PiJQ8gRgCUFHEGZuizlClQNuVhqu4
   appletWeChat:
     appKey: wx72e974483a9174e4
     appSecret: 3bbe99f6964c9f4fc11a8aa1224ac4b3

+ 3 - 0
src/main/resources/application-prod.yml

@@ -114,6 +114,9 @@ xjrsoft:
   weChatMessageTemplate:
     commonTemplate: qmpXORPM1Cocqn503Qa4OkNNQ0uxlj2-ed9m6uWO-v4
     assessmentTemplate: ehYfXni7exZUmt6dJX4Ukbm9ETarFfKLfXVYwNnjKMc
+    attendanceMessageTemplate: uPPJkWOSronnB_GJolcnatrQzGjJREIKL7JZzOieoew
+    outInTemplate: ERkMebHjsziZO6WBrlzsbENiEuRR4vrlhJw5LR4aDr8
+    attenDanceWarnTemplate: Fg4AWVQRGernl0PiJQ8gRgCUFHEGZuizlClQNuVhqu4
   appletWeChat:
     appKey: wx72e974483a9174e4
     appSecret: 3bbe99f6964c9f4fc11a8aa1224ac4b3

+ 86 - 0
src/test/java/com/xjrsoft/module/hikvision/util/FaceImportUtilTest.java

@@ -0,0 +1,86 @@
+package com.xjrsoft.module.hikvision.util;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xjrsoft.XjrSoftApplication;
+import com.xjrsoft.common.utils.ImageUtil;
+import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
+import com.xjrsoft.module.personnel.entity.TeacherFaceProcess;
+import com.xjrsoft.module.personnel.service.IFaceManagementService;
+import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
+import com.xjrsoft.module.personnel.service.ITeacherFaceProcessService;
+import com.xjrsoft.module.system.entity.File;
+import com.xjrsoft.module.system.service.IFileService;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @author dzx
+ * @date 2024/6/7
+ */
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = XjrSoftApplication.class)
+class FaceImportUtilTest {
+    @Autowired
+    private IStundentFaceProcessService stundentFaceProcessService;
+
+    @Autowired
+    private ITeacherFaceProcessService teacherFaceProcessService;
+
+    @Autowired
+    private IFileService fileService;
+    @Test
+    void test(){
+        List<TeacherFaceProcess> list = teacherFaceProcessService.list(
+            new QueryWrapper<TeacherFaceProcess>().lambda()
+            .notLike(TeacherFaceProcess::getHikvisionResult, "{\"code\":\"0\",\"msg\":\"success\",")
+        );
+
+
+        for (TeacherFaceProcess process : list) {
+//            byte[] imageBytes = fileService.downloadFileByZip(process.getFacePhoto());
+//            //压缩到200k
+//            imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
+            File file = fileService.getOne(
+                    new QueryWrapper<File>().lambda().eq(File::getFolderId, process.getFacePhoto())
+            );
+
+            String result = FaceImportUtil.ImportStudentFace(process.getUserId() + "", file.getFileUrl());
+
+            process.setHikvisionResult(result);
+            teacherFaceProcessService.updateById(process);
+        }
+    }
+
+
+    @Test
+    void test2(){
+        List<StundentFaceProcess> list = stundentFaceProcessService.list(
+                new QueryWrapper<StundentFaceProcess>().lambda()
+                        .notLike(StundentFaceProcess::getHikvisionResult, "{\"code\":\"0\",\"msg\":\"success\",")
+        );
+
+
+        for (StundentFaceProcess process : list) {
+//            byte[] imageBytes = fileService.downloadFileByZip(process.getFacePhoto());
+//            //压缩到200k
+//            imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
+            File file = fileService.getOne(
+                    new QueryWrapper<File>().lambda().eq(File::getFolderId, process.getFacePhoto())
+            );
+
+            String result = FaceImportUtil.ImportStudentFace(process.getUserId() + "", file.getFileUrl());
+
+            process.setHikvisionResult(result);
+            stundentFaceProcessService.updateById(process);
+        }
+    }
+
+}

+ 313 - 101
src/test/java/com/xjrsoft/module/job/JianyuekbBaseDataTaskTest.java

@@ -1,105 +1,317 @@
-//package com.xjrsoft.module.job;
+package com.xjrsoft.module.job;
+
+import cn.hutool.db.Db;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.xjrsoft.XjrSoftApplication;
+import com.xjrsoft.common.constant.GlobalConstant;
+import com.xjrsoft.common.utils.DatasourceUtil;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.entity.BaseGrade;
+import com.xjrsoft.module.schedule.entity.JianyueData;
+import com.xjrsoft.module.schedule.util.DataUtil;
+import com.xjrsoft.module.schedule.util.ScheduleUtil;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author dzx
+ * @date 2024/4/30
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = XjrSoftApplication.class)
+class JianyuekbBaseDataTaskTest {
+
+
+    @Test
+    public void RefreshConnectionPool() {
+        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+        try {
+            Db use = Db.use(datasource);
+            String sql = "SELECT distinct table_name FROM jianyue_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 jianyue_data WHERE 0 = 0";
+            List<JianyueData> list = use.query(sql, JianyueData.class);
+            Map<String, Map<String, String>> dataMap = new HashMap<>();
+            for (String table : tables) {
+                Map<String, String> tableData = new HashMap<>();
+                for (JianyueData jianyueData : list) {
+                    if(!table.equals(jianyueData.getTableName())){
+                        continue;
+                    }
+                    tableData.put(jianyueData.getSourceId(), jianyueData.getJianyueId());
+                }
+                dataMap.put(table, tableData);
+            }
+            DataUtil dataUtil = new DataUtil();
+            //查询校区
+            String tableName = "xjr_department";
+            Map<String, String> districtMap = dataUtil.insertSchoolDistrict(use, tableName, dataMap.get(tableName));
+            if(districtMap.isEmpty() && dataMap.get(tableName) != null){
+                districtMap = dataMap.get(tableName);
+            }
+
+            //推送年级
+            JsonArray schoolDistrictData = dataUtil.getSchoolDistrictData();
+            tableName = "base_grade";
+            Map<String, String> grade = dataUtil.insertGrade(use, tableName, districtMap, dataMap.get(tableName));
+            if(grade.isEmpty() && dataMap.get(tableName) != null){
+                grade = dataMap.get(tableName);
+            }
+
+            //推送学期
+            tableName = "base_semester";
+            dataUtil.insertSemester(use, tableName, dataMap.get(tableName));
+            //推送标签
+            tableName = "base_label";
+            Map<String, String> tagMap = dataUtil.insertCourseTag(use, tableName, dataMap.get(tableName));
+            if(tagMap.isEmpty() && dataMap.get(tableName) != null){
+                tagMap = dataMap.get(tableName);
+            }
+            //推送课程
+            tableName = "base_course_subject";
+            dataUtil.insertCourse(use, tableName, dataMap.get(tableName), tagMap);
+            //推送教职工
+            tableName = "base_teacher";
+            Map<String, String> teacherMap = dataUtil.insertTeacher(use, tableName, dataMap.get(tableName));
+            if(teacherMap.isEmpty() && dataMap.get(tableName) != null){
+                teacherMap = dataMap.get(tableName);
+            }
+            //推送学生
+            tableName = "base_student";
+            dataUtil.insertStudent(use, tableName, grade, dataMap.get(tableName));
+            //推送教室
+            tableName = "base_classroom";
+            Map<String, String> classroomMap = dataUtil.insertClassRoom(use, tableName, schoolDistrictData.get(0).getAsString(), dataMap.get(tableName));
+            if(classroomMap.isEmpty() && dataMap.get(tableName) != null){
+                classroomMap = dataMap.get(tableName);
+            }
+            //推送行政班,先查询当前学期id
+            String currenSemeter = dataUtil.getCurrenSemeter();
+            tableName = "base_class";
+            dataUtil.insertClass(use, tableName, grade, teacherMap, currenSemeter, dataMap.get(tableName), classroomMap);
+
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    void deleteData() throws SQLException {
+        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+        Db use = Db.use(datasource);
+        //删除学生
+        String sql = "SELECT * FROM jianyue_data WHERE table_name = 'base_student'";
+        List<JianyueData> studentList = use.query(sql, JianyueData.class);
+
+        String url  = ScheduleUtil.apiUrl + "student/del";
+        for (JianyueData jianyueData : studentList) {
+
+        }
+        //先查询班级,再查询学生
+    }
+
+    @Test
+    void updateGrade() throws Exception {
+        String url  = ScheduleUtil.apiUrl + "EduYear/page";
+        JsonObject paramJson = new JsonObject();
+        paramJson.addProperty("pageSize", 40);
+        paramJson.addProperty("pageIndex", 1);
+
+        long timestamp = System.currentTimeMillis();
+        //生成签名
+        String sign = ScheduleUtil.createSign(timestamp);
+
+        String doPost = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+        System.out.println(doPost);
+
+//        JsonParser parser = new JsonParser();
+//        JsonObject jsonObject = parser.parse(doPost).getAsJsonObject();
+//        JsonArray jsonArray = jsonObject.get("data").getAsJsonObject().get("dataList").getAsJsonArray();
 //
-//import cn.hutool.db.Db;
-//import cn.hutool.extra.spring.SpringUtil;
-//import com.google.gson.JsonArray;
-//import com.xjrsoft.XjrSoftApplication;
-//import com.xjrsoft.common.constant.GlobalConstant;
-//import com.xjrsoft.common.utils.DatasourceUtil;
-//import com.xjrsoft.module.schedule.entity.JianyueData;
-//import com.xjrsoft.module.schedule.util.DataUtil;
-//import org.junit.jupiter.api.Test;
-//import org.junit.runner.RunWith;
-//import org.springframework.boot.test.context.SpringBootTest;
-//import org.springframework.scheduling.annotation.Scheduled;
-//import org.springframework.test.context.junit4.SpringRunner;
+//        url = ScheduleUtil.apiUrl + "eduyear/update";
+//        for (JsonElement jsonElement : jsonArray) {
+//            JsonObject dataOne = jsonElement.getAsJsonObject();
+//            dataOne.addProperty("schoolDistrictId", "48e0a5ae-6d0b-34dd-f31a-3a12feca72d1");
 //
-//import javax.sql.DataSource;
-//import java.util.HashMap;
-//import java.util.HashSet;
-//import java.util.List;
-//import java.util.Map;
-//import java.util.Set;
+//            timestamp = System.currentTimeMillis();
+//            //生成签名
+//            sign = ScheduleUtil.createSign(timestamp);
+//            String result = ScheduleUtil.doPost(url, dataOne.toString(), sign, timestamp);
 //
-//import static org.junit.jupiter.api.Assertions.*;
-//
-///**
-// * @author dzx
-// * @date 2024/4/30
-// */
-//@RunWith(SpringRunner.class)
-//@SpringBootTest(classes = XjrSoftApplication.class)
-//class JianyuekbBaseDataTaskTest {
-//
-//
-//    @Test
-//    public void RefreshConnectionPool() {
-//        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
-//        try {
-//            Db use = Db.use(datasource);
-//            String sql = "SELECT distinct table_name FROM jianyue_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 jianyue_data WHERE 0 = 0";
-//            List<JianyueData> list = use.query(sql, JianyueData.class);
-//            Map<String, Map<Long, String>> dataMap = new HashMap<>();
-//            for (String table : tables) {
-//                Map<Long, String> tableData = new HashMap<>();
-//                for (JianyueData jianyueData : list) {
-//                    if(!table.equals(jianyueData.getTableName())){
-//                        continue;
-//                    }
-//                    tableData.put(jianyueData.getSourceId(), jianyueData.getJianyueId());
-//                }
-//                dataMap.put(table, tableData);
-//            }
-//            DataUtil dataUtil = new DataUtil();
-//            //查询校区
-//            JsonArray schoolDistrictData = dataUtil.getSchoolDistrictData();
-//            //推送年级
-//            String tableName = "base_grade";
-//            Map<Long, String> grade = dataUtil.insertGrade(use, tableName, null, dataMap.get(tableName));
-//            if(grade.isEmpty() && dataMap.get(tableName) != null){
-//                grade = dataMap.get(tableName);
-//            }
-//
-//            //推送学期
-//            tableName = "base_semester";
-//            dataUtil.insertSemester(use, tableName, dataMap.get(tableName));
-//            //推送标签
-//            tableName = "base_label";
-//            Map<Long, String> tagMap = dataUtil.insertCourseTag(use, tableName, dataMap.get(tableName));
-//            if(tagMap.isEmpty() && dataMap.get(tableName) != null){
-//                tagMap = dataMap.get(tableName);
-//            }
-//            //推送课程
-//            tableName = "base_course_subject";
-//            dataUtil.insertCourse(use, tableName, dataMap.get(tableName), tagMap);
-//            //推送教职工
-//            tableName = "base_teacher";
-//            Map<Long, String> teacherMap = dataUtil.insertTeacher(use, tableName, dataMap.get(tableName));
-//            if(teacherMap.isEmpty() && dataMap.get(tableName) != null){
-//                teacherMap = dataMap.get(tableName);
-//            }
-//            //推送学生
-//            tableName = "base_student";
-//            dataUtil.insertStudent(use, tableName, grade, dataMap.get(tableName));
-//            //推送教室
-//            tableName = "base_classroom";
-//            Map<Long, String> classroomMap = dataUtil.insertClassRoom(use, tableName, schoolDistrictData.get(0).getAsString(), dataMap.get(tableName));
-//            if(classroomMap.isEmpty() && dataMap.get(tableName) != null){
-//                classroomMap = dataMap.get(tableName);
-//            }
-//            //推送行政班,先查询当前学期id
-//            String currenSemeter = dataUtil.getCurrenSemeter();
-//            tableName = "base_class";
-//            dataUtil.insertClass(use, tableName, grade, teacherMap, currenSemeter, dataMap.get(tableName), classroomMap);
-//
-//        } catch (Exception e) {
+//            System.out.println(result);
 //        }
-//    }
-//
-//}
+    }
+
+    @Test
+    void insertGrade() throws Exception {
+        String url  = ScheduleUtil.apiUrl + "eduyear/create";
+        JsonObject paramJson = new JsonObject();
+        paramJson.addProperty("pageSize", 40);
+        paramJson.addProperty("pageIndex", 1);
+
+        long timestamp = System.currentTimeMillis();
+        //生成签名
+        String sign = ScheduleUtil.createSign(timestamp);
+
+        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+        Db use = Db.use(datasource);
+
+        JsonParser jsonParser = new JsonParser();
+
+        Map<String, String> idMap = new HashMap<>();
+        //删除学生
+        String sql = "SELECT * FROM jianyue_data WHERE table_name = 'xjr_department'";
+        List<JianyueData> gradeList = use.query(sql, JianyueData.class);
+        for (JianyueData jianyueData : gradeList) {
+            if("48e0a5ae-6d0b-34dd-f31a-3a12feca72d1".equals(jianyueData.getJianyueId())){
+                continue;
+            }
+
+            sql = "select * from base_grade where delete_mark = 0 and status = 1";
+            List<BaseGrade> list = use.query(sql, BaseGrade.class);
+            for (BaseGrade baseGrade : list) {
+                url = ScheduleUtil.apiUrl + "eduyear/create";
+                JsonObject dataJson = new JsonObject();
+                dataJson.addProperty("schoolDistrictId", jianyueData.getJianyueId());
+                dataJson.addProperty("period", 4);
+                dataJson.addProperty("startYear", baseGrade.getTitle().replaceAll("年", ""));
+                dataJson.addProperty("extendId", baseGrade.getId().toString());
+                dataJson.addProperty("year", 3);
+
+                //获取时间戳
+                timestamp = System.currentTimeMillis();
+                //生成签名
+                sign = ScheduleUtil.createSign(timestamp);
+
+                String result = ScheduleUtil.doPost(url, dataJson.toString(), sign, timestamp);
+
+                JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+
+                idMap.put(jianyueData.getSourceId() + "_" + baseGrade.getId().toString(), resultJson.get("data").getAsString());
+            }
+        }
+        DataUtil dataUtil = new DataUtil();
+        dataUtil.insertRecord(use, "base_grade", idMap);
+    }
+
+    @Test
+    void selectSchoolDistrict() throws Exception {
+        String url  = ScheduleUtil.apiUrl + "SchoolDistrict/page";
+        JsonObject paramJson = new JsonObject();
+        paramJson.addProperty("pageSize", 40);
+        paramJson.addProperty("pageIndex", 1);
+
+        long timestamp = System.currentTimeMillis();
+        //生成签名
+        String sign = ScheduleUtil.createSign(timestamp);
+
+        String doPost = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+        System.out.println(doPost);
+
+    }
+
+    @Test
+    void updateClass() throws Exception {
+        String url  = ScheduleUtil.apiUrl + "EduYear/page";
+        JsonObject paramJson = new JsonObject();
+        paramJson.addProperty("pageSize", 40);
+        paramJson.addProperty("pageIndex", 1);
+
+        long timestamp = System.currentTimeMillis();
+        //生成签名
+        String sign = ScheduleUtil.createSign(timestamp);
+
+        String doPost = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+
+
+        JsonParser parser = new JsonParser();
+        JsonObject jsonObject = parser.parse(doPost).getAsJsonObject();
+        JsonArray jsonArray = jsonObject.get("data").getAsJsonObject().get("dataList").getAsJsonArray();
+
+        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+        Db use = Db.use(datasource);
+        String sql = "SELECT * FROM jianyue_data WHERE table_name = 'base_grade'";
+        List<JianyueData> gradeList = use.query(sql, JianyueData.class);
+        Map<String, String> gradeMap = new HashMap<>();
+        for (JianyueData jianyueData : gradeList) {
+            gradeMap.put(jianyueData.getSourceId(), jianyueData.getJianyueId());
+        }
+
+        url  = ScheduleUtil.apiUrl + "class/update";
+        paramJson = new JsonObject();
+        paramJson.addProperty("pageSize", 200);
+        paramJson.addProperty("pageIndex", 1);
+
+        timestamp = System.currentTimeMillis();
+        //生成签名
+        sign = ScheduleUtil.createSign(timestamp);
+
+        doPost = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+
+        sql = "SELECT * FROM base_class WHERE delete_mark = 0 and is_graduate = 1";
+        List<BaseClass> dataList = use.query(sql, BaseClass.class);
+        Map<String, BaseClass> classMap = new HashMap<>();
+        for (BaseClass baseClass : dataList) {
+            classMap.put(baseClass.getId().toString(), baseClass);
+        }
+
+        sql = "SELECT * FROM jianyue_data WHERE table_name = 'base_class'";
+        List<JianyueData> classList = use.query(sql, JianyueData.class);
+        Map<String, BaseClass> classMap2 = new HashMap<>();
+        Map<String, String> classMap3 = new HashMap<>();
+        for (JianyueData jianyueData : classList) {
+            classMap2.put(jianyueData.getJianyueId(), classMap.get(jianyueData.getSourceId()));
+            classMap3.put(jianyueData.getSourceId(), jianyueData.getJianyueId());
+        }
+
+        sql = "SELECT * FROM jianyue_data WHERE table_name = 'base_classroom'";
+        List<JianyueData> classroomList = use.query(sql, JianyueData.class);
+        Map<String, String> classroomMap = new HashMap<>();
+        for (JianyueData jianyueData : classroomList) {
+            classroomMap.put(jianyueData.getSourceId(), jianyueData.getJianyueId());
+        }
+
+        url  = ScheduleUtil.apiUrl + "class/update";
+        DataUtil dataUtil = new DataUtil();
+        String currenSemeter = dataUtil.getCurrenSemeter();
+
+        for (BaseClass baseClass : classMap2.values()) {
+            if(baseClass == null){
+                continue;
+            }
+            paramJson = new JsonObject();
+            paramJson.addProperty("name", baseClass.getName());
+
+            paramJson.addProperty("semesterSerialNo", currenSemeter);
+            paramJson.addProperty("eduYearSerialNo", gradeMap.get(baseClass.getOrgId() + "_" + baseClass.getGradeId().toString()));
+            paramJson.addProperty("extendId", baseClass.getId());
+            paramJson.addProperty("classRoomSerialNo", classroomMap.get(baseClass.getClassroomId().toString()));
+            paramJson.addProperty("serialNo", classMap3.get(baseClass.getId().toString()));
+
+            timestamp = System.currentTimeMillis();
+            //生成签名
+            sign = ScheduleUtil.createSign(timestamp);
+            String result = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+
+            System.out.println(baseClass.getName() + " -> " + result);
+        }
+    }
+
+
+}

+ 24 - 0
src/test/java/com/xjrsoft/module/personnel/controller/StundentFaceProcessControllerTest.java

@@ -3,6 +3,7 @@ package com.xjrsoft.module.personnel.controller;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xjrsoft.XjrSoftApplication;
 import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.utils.ImageUtil;
 import com.xjrsoft.common.utils.UploadUtil;
 import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
 import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
@@ -19,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
@@ -87,4 +89,26 @@ class StundentFaceProcessControllerTest {
 
     }
 
+    @Test
+    void imgTest() throws IOException {
+        String newFilePath = "C:\\Users\\14263\\Downloads\\2023级剩余学籍找\\20240607-194930.jpg";
+        File sourceFile = new File(newFilePath);
+        FileInputStream fileInputStream = new FileInputStream(sourceFile);
+
+        byte[] imageBytes = new byte[(int) sourceFile.length()];
+        fileInputStream.read(imageBytes);
+
+        fileInputStream.close();
+
+        imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
+
+        File file = new File("C:\\Users\\14263\\Downloads\\2023级剩余学籍找\\20240607-194930-压缩.jpg");
+        try (FileOutputStream fos = new FileOutputStream(file)) {
+            fos.write(imageBytes);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
 }