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 105bf73..ffa434b 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 @@ -146,9 +146,8 @@ public class MessageServiceImpl implements MessageService { log.error("微信消息发送失败:站点code获取失败 : {}",entity); return; } - Long dept = station.getData().getCreateDept(); // 获取站点用户 - R> result = userClient.userList("200000",dept); + R> result = userClient.userByDeptIdLevel(station.getData().getRefDept(),0); if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { log.error("微信消息发送失败:用户获取失败 : {}",entity); return; @@ -168,9 +167,9 @@ public class MessageServiceImpl implements MessageService { message.setTaskId(entity.getId()); // 微信参数键值对 HashMap map = new HashMap<>(); - map.put("thing18",entity.getStationName()); + map.put("thing18",getTruncateString(entity.getStationName(), 29)); // map.put("thing5",Optional.ofNullable(entity.getDeviceCode()).orElse("未知设备")); - map.put("thing11",entity.getAlarmContext()); + map.put("thing11",getTruncateString(entity.getAlarmContext(), 29)); map.put("time2",entity.getAlarmTime()); map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmSource())); message.setMap(map); @@ -186,4 +185,11 @@ public class MessageServiceImpl implements MessageService { message.setTenantId(station.getData().getTenantId()); messageClient.sendWxMessage(message); } + private String getTruncateString(String ruleDefName, int maxSize) { + if (ruleDefName.length()<= maxSize){ + return ruleDefName; + }else { + return ruleDefName.substring(0, maxSize - 3) + "..."; + } + } } \ No newline at end of file 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 cb04c86..dd4e03e 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 @@ -92,7 +92,10 @@ public class WxMessageServiceImpl implements IMessageService { template.setUserIds(Arrays.stream(message.getUserIds().split(",")).collect(Collectors.toList())); template.setTenantId("200000"); R result = wxPushClient.sendPushTemplateByUserId(template); - return result.isSuccess(); + if(result.isSuccess()&&ObjectUtil.isNotEmpty(result.getData())){ + return true; + } + return false; } private String getTruncateString(String ruleDefName, int maxSize) {