Browse Source

#微信公众号时间参数不支持毫秒

zhongwei
yang_shj 5 months ago
parent
commit
deff12855c
  1. 18
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java

18
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java

@ -1,28 +1,21 @@
package com.hnac.hzims.alarm.source.service.impl;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.service.AlarmConfigService;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.source.service.MessageService;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.dto.SmsImmediatelyPushDTO;
import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.dto.WxMessageDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.cache.DictCache;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
@ -31,6 +24,7 @@ import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -175,7 +169,7 @@ public class MessageServiceImpl implements MessageService {
return;
}
userList.addAll(result.getData());
log.info("短信发送用户列表",userList);
log.info("短信发送用户列表,{}",userList);
}else {
//内测只推给对应的3个用户
List<String> phoneList = Arrays.asList("18351807087", "18163793336", "18285121497");
@ -185,13 +179,13 @@ public class MessageServiceImpl implements MessageService {
userList.add(userByPhone.getData().getUser());
}
}
log.info("短信发送用户列表",userList);
log.info("短信发送用户列表,{}",userList);
}
String userIds = userList.stream().map(o -> String.valueOf(o.getId())).distinct().collect(Collectors.joining(","));
WxMessageDTO message = new WxMessageDTO();
// 模板Id
message.setTemplateId(wxPushTemplate);
// // 微信消息跳转地址
// 微信消息跳转地址
//message.setSkipUrl("http://baidu.com");
// 机构Id
message.setDeptId(station.getData().getRefDept());
@ -204,9 +198,9 @@ public class MessageServiceImpl implements MessageService {
// 微信参数键值对
HashMap<String,Object> map = new HashMap<>();
map.put("thing18",getTruncateString(entity.getStationName(), 20));
// map.put("thing5",Optional.ofNullable(entity.getDeviceCode()).orElse("未知设备"));
map.put("thing11",getTruncateString(entity.getAlarmContext(), 20));
map.put("time2",entity.getAlarmTime());
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
map.put("time2",format.format(entity.getAlarmTime()));
map.put("thing14", DictCache.getValue("alarm_type", entity.getAlarmType()));
message.setMap(map);
// 消息内容

Loading…
Cancel
Save