Browse Source

考勤消息通知

dzx 5 tháng trước cách đây
mục cha
commit
d06c4be0b3

+ 5 - 2
src/main/java/com/xjrsoft/common/utils/WeChatUtil.java

@@ -58,8 +58,11 @@ public class WeChatUtil {
     public String assessmentTemplate;
 
     //考勤结果通知模板
-    @Value("${xjrsoft.weChatMessageTemplate.attendanceMessageTemplate}")
-    public String attendanceMessageTemplate;
+    @Value("${xjrsoft.weChatMessageTemplate.attendanceMsgLateTemplate}")
+    public String attendanceMsgLateTemplate;
+
+    @Value("${xjrsoft.weChatMessageTemplate.attendanceMsgAbsenceTemplate}")
+    public String attendanceMsgAbsenceTemplate;
 
     @Value("${xjrsoft.weChatMessageTemplate.outInTemplate}")
     public String outInTemplate;

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

@@ -114,20 +114,16 @@ public class AttendanceMessageTask {
         }
 
 
-        String wechatTemplate = weChatUtil.getAttendanceMessageTemplate();
-        WechatMessageLog log = wechatMessageLogService.getOne(
-                new QueryWrapper<WechatMessageLog>().lambda()
-                        .select(WechatMessageLog.class, x -> VoToColumnUtil.fieldsToColumns(WechatMessageLog.class).contains(x.getProperty()))
-                        .eq(WechatMessageLog::getSendTime, recentlyTime)
-                        .eq(WechatMessageLog::getTemplateId, wechatTemplate)
-        );
-        if(log != null){//已经推送过,不再进行推送
-            return;
-        }
+//        WechatMessageLog log = wechatMessageLogService.getOne(
+//                new QueryWrapper<WechatMessageLog>().lambda()
+//                        .select(WechatMessageLog.class, x -> VoToColumnUtil.fieldsToColumns(WechatMessageLog.class).contains(x.getProperty()))
+//                        .eq(WechatMessageLog::getSendTime, recentlyTime)
+//                        .eq(WechatMessageLog::getTemplateId, wechatTemplate)
+//        );
+//        if(log != null){//已经推送过,不再进行推送
+//            return;
+//        }
 
-        WechatMessageLog messageLog = new WechatMessageLog();
-        messageLog.setTemplateId(wechatTemplate);
-        messageLog.setSendTime(recentlyTime);
 
         List<AttendanceMessageSet> list = messageSetService.list(
                 new QueryWrapper<AttendanceMessageSet>().lambda()
@@ -166,6 +162,13 @@ public class AttendanceMessageTask {
 
 
         for (AttendanceMessageSet messageSet : list) {
+            String wechatTemplate = weChatUtil.getAttendanceMsgLateTemplate();
+            if(messageSet.getMessageCategory() != null && messageSet.getMessageCategory() == 1){
+                wechatTemplate = weChatUtil.getAttendanceMsgLateTemplate();
+            }else if(messageSet.getMessageCategory() != null && messageSet.getMessageCategory() == 3){
+                wechatTemplate = weChatUtil.getAttendanceMsgAbsenceTemplate();
+            }
+
             if(!messageSet.getTimePeriod().contains(timePeriod + "")){
                 continue;
             }
@@ -236,7 +239,7 @@ public class AttendanceMessageTask {
                 );
 
                 WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
-                weChatSendMessageDto.setTemplateId(weChatUtil.getAttendanceMessageTemplate());
+                weChatSendMessageDto.setTemplateId(wechatTemplate);
                 JSONObject paramJson = new JSONObject();
 
                 JSONObject thing6 = new JSONObject();
@@ -268,10 +271,15 @@ public class AttendanceMessageTask {
                     weChatService.sendTemplateMessage(weChatSendMessageDto);
                 }
             }
+
+            WechatMessageLog messageLog = new WechatMessageLog();
+            messageLog.setTemplateId(wechatTemplate);
+            messageLog.setSendTime(recentlyTime);
+
+            messageLog.setCreateDate(new Date());
+            messageLog.setContent("消息推送人数:" + userCount);
+            wechatMessageLogService.save(messageLog);
         }
-        messageLog.setCreateDate(new Date());
-        messageLog.setContent("消息推送人数:" + userCount);
-        wechatMessageLogService.save(messageLog);
     }
 
     LocalDateTime getRecentlyTime(List<AttendanceRuleDetails> ruleDetails, LocalDateTime now){

+ 3 - 2
src/main/java/com/xjrsoft/module/personnel/controller/StundentFaceProcessController.java

@@ -26,6 +26,7 @@ import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.base.vo.StudentClassVo;
+import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
 import com.xjrsoft.module.hikvision.util.ApiUtil;
 import com.xjrsoft.module.personnel.dto.AddStundentFaceProcessDto;
 import com.xjrsoft.module.personnel.dto.StundentFaceProcessPageDto;
@@ -89,7 +90,7 @@ public class StundentFaceProcessController {
     private final IFileService fileService;
     private final IFaceManagementService faceManagementService;
     private final IBaseClassService classService;
-
+    private final HikvisionDataMapper hikvisionDataMapper;
     @GetMapping(value = "/page")
     @ApiOperation(value="学生人脸信息审核列表(分页)")
     @SaCheckPermission("stundentfaceprocess:detail")
@@ -302,7 +303,7 @@ public class StundentFaceProcessController {
 
                 //将人脸上传海康
                 JsonObject paramJson = new JsonObject();
-                paramJson.addProperty("personId", studentUser.getId());
+                paramJson.addProperty("personId", hikvisionDataMapper.getStudentHikvisionId(studentUser.getId()));
                 paramJson.addProperty("faceData", base64String);
 
                 Map<String, String> querys = new HashMap<>();

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

@@ -114,7 +114,8 @@ xjrsoft:
   weChatMessageTemplate:
     commonTemplate: qmpXORPM1Cocqn503Qa4OkNNQ0uxlj2-ed9m6uWO-v4
     assessmentTemplate: ehYfXni7exZUmt6dJX4Ukbm9ETarFfKLfXVYwNnjKMc
-    attendanceMessageTemplate: uPPJkWOSronnB_GJolcnajRSdnIf8GCoCk4c0v1szPA
+    attendanceMsgLateTemplate: uPPJkWOSronnB_GJolcnajRSdnIf8GCoCk4c0v1szPA # 迟到消息
+    attendanceMsgAbsenceTemplate: uPPJkWOSronnB_GJolcnarbl8qosDvsadxl0qL_4jdQ # 缺勤
     outInTemplate: ERkMebHjsziZO6WBrlzsbENiEuRR4vrlhJw5LR4aDr8
     attenDanceWarnTemplate: Fg4AWVQRGernl0PiJQ8gRgCUFHEGZuizlClQNuVhqu4
   appletWeChat: