|
@@ -109,6 +109,9 @@ public class RepServiceImpl implements IRepService {
|
|
|
}
|
|
|
return base;
|
|
|
}
|
|
|
+ private boolean isSendMsg(FadMessageConf conf){
|
|
|
+ return conf.getMainSwitch() || conf.getWxSwitch();
|
|
|
+ }
|
|
|
// 设备断网断电消息推送
|
|
|
@Override
|
|
|
public void sendOffLineTerminalMessage(String terminalNo) {
|
|
@@ -121,16 +124,18 @@ public class RepServiceImpl implements IRepService {
|
|
|
FadMessageConf conf = new FadMessageConf();
|
|
|
conf.setSiteId(base.getSiteId());
|
|
|
conf = fadMessageConfDao.templateOne(conf);
|
|
|
- if(conf != null && conf.getMainSwitch() && conf.getOfflineSwitch()){
|
|
|
+ if(conf != null && conf.getMainSwitch() && isSendMsg(conf) && conf.getOfflineSwitch()){
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
// todo 这里只发送了短信消息~ 后期需要增加公众号消息
|
|
|
log.error("发生断点断网告警通知....");
|
|
|
List<String> collect = messageList.stream().map(s -> s.getPhoneNo()).distinct().collect(Collectors.toList());
|
|
|
- collect.forEach(s->{
|
|
|
- // 这个告警需要查询数据
|
|
|
- MessageUtils.sendSafeMessage(s,base.getSiteName(),terminalNo,startTime,"设备掉电或掉网");
|
|
|
- });
|
|
|
- if(!collect.isEmpty()){
|
|
|
+ if(conf.getMainSwitch()){
|
|
|
+ collect.forEach(s->{
|
|
|
+ // 这个告警需要查询数据
|
|
|
+ MessageUtils.sendSafeMessage(s,base.getSiteName(),terminalNo,startTime,"设备掉电或掉网");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(conf.getWxSwitch() && !collect.isEmpty()){
|
|
|
// 发生公众号消息
|
|
|
Map<String,Object> condition = new HashMap<>(4);
|
|
|
condition.put("phoneList",collect);
|
|
@@ -259,25 +264,30 @@ public class RepServiceImpl implements IRepService {
|
|
|
conf.setSiteId(res.getSiteId());
|
|
|
conf = fadMessageConfDao.templateOne(conf);
|
|
|
// 有配置文件,并且设置告警消息
|
|
|
- if(conf != null && conf.getMainSwitch()){
|
|
|
+ if(conf != null && isSendMsg(conf) && conf.getMainSwitch()){
|
|
|
log.error("推送告警数据....");
|
|
|
// 这里说明需要发送消息
|
|
|
- list.forEach(s->{
|
|
|
- // 这个告警需要查询数据
|
|
|
- MessageUtils.sendSafeMessage(s,res.getSiteName(),res.getTerminalNo(),res.getCreateTime(),content);
|
|
|
- });
|
|
|
+ if(conf.getMainSwitch()){
|
|
|
+ list.forEach(s->{
|
|
|
+ // 这个告警需要查询数据
|
|
|
+ MessageUtils.sendSafeMessage(s,res.getSiteName(),res.getTerminalNo(),res.getCreateTime(),content);
|
|
|
+ });
|
|
|
+ }
|
|
|
// 这里需要根据手机号码,查询已经授权的公众号
|
|
|
- Map<String,Object> condition = new HashMap<>(4);
|
|
|
- condition.put("phoneList",list);
|
|
|
- List<String> openList = iNewestDataDao.findOpenList(condition);
|
|
|
- if (!openList.isEmpty()) {
|
|
|
- WarnMessageHelp help = new WarnMessageHelp();//这里推送告警消息
|
|
|
- help.setTerminalNo(res.getTerminalNo());
|
|
|
- help.setTerminalType(res.getTypeName());
|
|
|
- help.setSiteName(res.getSiteName());
|
|
|
- help.setWarnMsg(content);
|
|
|
- wxChatUtil.sendWarnMessageToUser(help,openList,null);
|
|
|
+ if(conf.getWxSwitch()){
|
|
|
+ Map<String,Object> condition = new HashMap<>(4);
|
|
|
+ condition.put("phoneList",list);
|
|
|
+ List<String> openList = iNewestDataDao.findOpenList(condition);
|
|
|
+ if (!openList.isEmpty()) {
|
|
|
+ WarnMessageHelp help = new WarnMessageHelp();//这里推送告警消息
|
|
|
+ help.setTerminalNo(res.getTerminalNo());
|
|
|
+ help.setTerminalType(res.getTypeName());
|
|
|
+ help.setSiteName(res.getSiteName());
|
|
|
+ help.setWarnMsg(content);
|
|
|
+ wxChatUtil.sendWarnMessageToUser(help,openList,null);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|