浏览代码

微信消息推送,消息id每次重新生成

dzx 5 月之前
父节点
当前提交
be812ecbf6

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

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.hikvision.controller;
 
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.db.Db;
 import com.alibaba.fastjson.JSONObject;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -117,7 +118,7 @@ public class EventController {
                         WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
                         weChatSendMessageDto.setUserId(member.getOpenId());
                         weChatSendMessageDto.setTemplateId(weChatUtil.getOutInTemplate());
-                        weChatSendMessageDto.setMsgId(member.getId().toString());
+                        weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
                         JSONObject paramJson = new JSONObject();
 
                         JSONObject thing1 = new JSONObject();

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

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.job;
 
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -110,7 +111,7 @@ public class AttenDanceWarnNoticeTask {
             WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
             weChatSendMessageDto.setUserId(xjrUser.getOpenId());
             weChatSendMessageDto.setTemplateId(wechatTemplate);
-            weChatSendMessageDto.setMsgId(xjrUser.getId().toString());
+            weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
             JSONObject paramJson = new JSONObject();
 
             JSONObject thing8 = new JSONObject();

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

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.job;
 
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -206,7 +207,7 @@ public class AttendanceMessageTask {
                 weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/teacher/index", commonPropertiesConfig.getDomainApp()));
 
                 for (XjrUser xjrUser : userList) {
-                    weChatSendMessageDto.setMsgId(xjrUser.getId().toString());
+                    weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
                     weChatSendMessageDto.setUserId(xjrUser.getOpenId());
                     weChatService.sendTemplateMessage(weChatSendMessageDto);
                 }
@@ -251,7 +252,7 @@ public class AttendanceMessageTask {
                 weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/class/index", commonPropertiesConfig.getDomainApp()));
 
                 for (XjrUser xjrUser : userList) {
-                    weChatSendMessageDto.setMsgId(xjrUser.getId().toString());
+                    weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
                     weChatSendMessageDto.setUserId(xjrUser.getOpenId());
                     weChatService.sendTemplateMessage(weChatSendMessageDto);
                 }

+ 3 - 0
src/main/java/com/xjrsoft/module/organization/dto/WeChatSendMessageDto.java

@@ -8,6 +8,9 @@ public class WeChatSendMessageDto {
     private String userId;
     private String templateId;
     private String url;
+    /**
+     * 不同消息需要
+     */
     private String msgId;
     private JSONObject content;
 }