Browse Source

修正:微信公众号消息推送逻辑

zhongwei
ty 6 months ago
parent
commit
54457c3261
  1. 14
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java
  2. 5
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java

14
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<List<User>> result = userClient.userList("200000",dept);
R<List<User>> 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<String,Object> 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) + "...";
}
}
}

5
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<WxPushFeignVO> 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) {

Loading…
Cancel
Save