diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index bb125ac..cff87ff 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -46,7 +46,7 @@ public class AlarmListener implements IQueueConsume { // 步骤4.微信公众号发送 if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){ - //messageService.weChatMessage(alarm); + messageService.weChatMessage(alarm); } } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index 8ef2624..3415705 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -148,7 +148,7 @@ public class MessageServiceImpl implements MessageService { } WxMessageDTO message = new WxMessageDTO(); // 模板Id - message.setTemplateId("hIgINCsjpG-gyCKh8wzwBWjR-hkbjkNLFTXQEsnR_Z8"); + message.setTemplateId("Ce2YAZtX0UyoNrAag6CANtC8XQeLuil7domvJrUivhM"); // 微信消息跳转地址 message.setSkipUrl("http://baidu.com"); // 机构Id @@ -164,7 +164,7 @@ public class MessageServiceImpl implements MessageService { map.put("thing18",entity.getStationName()); map.put("thing5",Optional.ofNullable(entity.getDeviceCode()).orElse("未知设备")); map.put("thing11",entity.getAlarmContext()); - map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmType())); + map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmSource())); map.put("time2",entity.getAlarmTime()); message.setMap(map); // 消息内容 diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java index aea5845..cb04c86 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java @@ -86,9 +86,20 @@ public class WxMessageServiceImpl implements IMessageService { PushTemplate template = new PushTemplate(); template.setTemplateId(message.getTemplateId()); template.setSkipUrl(message.getSkipUrl()); - template.setMap(message.getMap()); + Map map = message.getMap(); + map.replaceAll((key,value)->getTruncateString(value.toString(),27)); + template.setMap(map); template.setUserIds(Arrays.stream(message.getUserIds().split(",")).collect(Collectors.toList())); + template.setTenantId("200000"); R result = wxPushClient.sendPushTemplateByUserId(template); return result.isSuccess(); } + + private String getTruncateString(String ruleDefName, int maxSize) { + if (ruleDefName.length()<= maxSize){ + return ruleDefName; + }else { + return ruleDefName.substring(0, maxSize - 3) + "..."; + } + } }