bug修复
This commit is contained in:
parent
d407d558af
commit
8f7a2c206e
@ -1,11 +1,14 @@
|
||||
package com.zhgd.xmgl.async;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.mqtt.bean.PushPayload;
|
||||
import com.zhgd.mqtt.server.IMqttSender;
|
||||
import com.zhgd.xmgl.call.api.MessageManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.DevSmsManufacturerFactory;
|
||||
import com.zhgd.xmgl.call.factory.MessageManufacturerFactory;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.enums.ParamEnum;
|
||||
import com.zhgd.xmgl.modules.basicdata.constant.DictionaryConstant;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.CompanyConfig;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.DictionaryItem;
|
||||
@ -16,8 +19,12 @@ import com.zhgd.xmgl.modules.basicdata.service.ICompanyConfigService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.DictionaryItemServiceImpl;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
import com.zhgd.xmgl.modules.project.entity.EnableMessageDevRule;
|
||||
import com.zhgd.xmgl.modules.project.service.IEnableMessageDevRuleService;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzAiDeductRule;
|
||||
import com.zhgd.xmgl.modules.xz.service.IXzAiDeductRuleService;
|
||||
import com.zhgd.xmgl.push.service.UniPushService;
|
||||
import com.zhgd.xmgl.util.MapBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -32,9 +39,9 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @program: wisdomSite
|
||||
@ -72,6 +79,15 @@ public class AsyncAiAnalyse {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private MessageManufacturerFactory messageManufacturerFactory;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private DevSmsManufacturerFactory devSmsManufacturerFactory;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IEnableMessageDevRuleService enableMessageDevRuleService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IXzAiDeductRuleService xzAiDeductRuleService;
|
||||
|
||||
/**
|
||||
* @param record
|
||||
@ -97,33 +113,43 @@ public class AsyncAiAnalyse {
|
||||
}
|
||||
// sendAppNotice(record.getProjectSn(), title, msg, systemUserList, "/pages/potentialRisk/potentialRisk?id=" + record.getId());
|
||||
}
|
||||
sendMsg(systemUserList, typeName, record.getLocation(), record.getProjectSn());
|
||||
sendMessage(typeName, record.getLocation(), record.getProjectSn(), record.getHardwareId(), record.getAlarmType());
|
||||
} catch (Exception e) {
|
||||
log.error("error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
* 发送消息
|
||||
*
|
||||
* @param systemUserList
|
||||
* @param typeName
|
||||
* @param location
|
||||
* @param projectSn
|
||||
* @param hardwareId
|
||||
* @param alarmType
|
||||
*/
|
||||
private void sendMsg(List<SystemUser> systemUserList, String typeName, String location, String projectSn) {
|
||||
private void sendMessage(String typeName, String location, String projectSn, String hardwareId, Integer alarmType) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
MessageManufacturer messageManufacturer = messageManufacturerFactory.getMessageManufacturer(projectSn);
|
||||
if (messageManufacturer != null) {
|
||||
List<String> phoneNums = systemUserList.stream().map(SystemUser::getUserTel).collect(Collectors.toList());
|
||||
Map<String, DictionaryItem> dictDataMap = dictionaryItemService.getDictDataMapByProjectSn(DictionaryConstant.AI_ANALYSE_HARD_WARE_ALARM_RECORD_TYPE, projectSn);
|
||||
DictionaryItem dictionaryItem = dictDataMap.get(Convert.toStr(alarmType));
|
||||
if (dictionaryItem == null) {
|
||||
return;
|
||||
}
|
||||
XzAiDeductRule rule = xzAiDeductRuleService.getOne(new LambdaQueryWrapper<XzAiDeductRule>()
|
||||
.eq(XzAiDeductRule::getDictionaryItemId, dictionaryItem.getId())
|
||||
.eq(XzAiDeductRule::getProjectSn, dictionaryItem.getProjectSn())
|
||||
);
|
||||
String monitoringLevelName = xzAiDeductRuleService.getLevelName(rule.getLevel());
|
||||
EnableMessageDevRule messageDevRule = enableMessageDevRuleService.getRule(ParamEnum.MessageModuleNameEnum.AIJC, hardwareId, dictionaryItem.getName(), monitoringLevelName);
|
||||
if (Objects.equals(messageDevRule.getEnableSmsNotification(), 1)) {
|
||||
List<String> templateParams = new ArrayList<>();
|
||||
//报警类型,报警名称,设备名称,报警值,阈值,超标时间,超标量
|
||||
templateParams.add(typeName);
|
||||
templateParams.add(location);
|
||||
String text = StrUtil.format("【{}】AI警报!{},位置{}",
|
||||
messageManufacturer.getConfig().getSignature(), typeName, location);
|
||||
messageManufacturer.sendMsgByConfig(phoneNums, "", templateParams, text);
|
||||
String text = StrUtil.format("AI警报!{},位置{}", typeName, location);
|
||||
enableMessageDevRuleService.sendSms(messageDevRule, templateParams, text, null);
|
||||
}
|
||||
enableMessageDevRuleService.sendSystemMessage(messageDevRule, "8");
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ public class TencentCloudMessageCall implements MessageManufacturer {
|
||||
|
||||
|
||||
@Override
|
||||
public void sendMsgByConfig(List<String> phoneNums, String templateId, List<String> templateParams, String text) {
|
||||
public void sendMsg(List<String> phoneNums, String templateId, List<String> templateParams, String text) {
|
||||
try {
|
||||
doSendMsg(phoneNums, templateId, templateParams.toArray(new String[]{}));
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.call;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.xmgl.call.api.MessageManufacturer;
|
||||
@ -32,13 +33,13 @@ public class YunPianMessageCall implements MessageManufacturer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsgByConfig(List<String> phoneNums, String templateId, List<String> templateParams, String text) {
|
||||
public void sendMsg(List<String> phoneNums, String templateId, List<String> templateParams, String text) {
|
||||
try {
|
||||
for (String phoneNum : phoneNums) {
|
||||
HashMap<String, Object> formMap = new HashMap<>();
|
||||
formMap.put("apikey", config.getApiKey());
|
||||
formMap.put("mobile", phoneNum);
|
||||
formMap.put("text", text);
|
||||
formMap.put("text", StrUtil.format("【{}】{}", config.getSignature(), text));
|
||||
String url = "https://sms.yunpian.com/v2/sms/single_send.json";
|
||||
log.info("云片短信按短信配置发送短信,url:{},body:{}", url, JSON.toJSONString(formMap));
|
||||
String body = HttpRequest.post(url).form(formMap).execute().body();
|
||||
|
||||
@ -21,5 +21,5 @@ public interface MessageManufacturer {
|
||||
* @param templateParams 模板参数(腾讯云)
|
||||
* @param text 消息(云片)
|
||||
*/
|
||||
void sendMsgByConfig(List<String> phoneNums, String templateId, List<String> templateParams, String text);
|
||||
void sendMsg(List<String> phoneNums, String templateId, List<String> templateParams, String text);
|
||||
}
|
||||
|
||||
@ -255,11 +255,10 @@ public class LoginController {
|
||||
hashValue.put("t", DateUtil.now());
|
||||
redisRepository.set(key, hashValue, 60L);
|
||||
templateParams.add(randomNum);
|
||||
String text = StrUtil.format("【{}】您的登录验证码是:{},有效期5分钟。请勿泄露给他人。",
|
||||
messageManufacturer.getConfig().getSignature(), randomNum);
|
||||
String text = StrUtil.format("您的登录验证码是:{},有效期5分钟。请勿泄露给他人。", randomNum);
|
||||
List<String> phoneNums = new ArrayList<>();
|
||||
phoneNums.add(user.getUserTel());
|
||||
messageManufacturer.sendMsgByConfig(phoneNums, messageManufacturer.getConfig().getSecretId(), templateParams, text);
|
||||
messageManufacturer.sendMsg(phoneNums, messageManufacturer.getConfig().getSecretId(), templateParams, text);
|
||||
return Result.ok();
|
||||
} else {
|
||||
throw new OpenAlertException("短信没配置或没启动短信登录");
|
||||
|
||||
@ -22,7 +22,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
@ApiModel(value="EnvironmentAlarm实体类",description="EnvironmentAlarm")
|
||||
public class EnvironmentAlarm implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**绿色设备报警预警表*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value="绿色设备报警预警表")
|
||||
@ -30,7 +30,6 @@ public class EnvironmentAlarm implements Serializable {
|
||||
/**报警类型外键*/
|
||||
@Excel(name = "报警类型外键", width = 15)
|
||||
@ApiModelProperty(value="报警类型外键")
|
||||
|
||||
private java.lang.Long alarmTypeId ;
|
||||
/**平均值数据*/
|
||||
@Excel(name = "平均值数据", width = 15)
|
||||
|
||||
@ -11,8 +11,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.async.AsyncEnvironment;
|
||||
import com.zhgd.xmgl.call.api.MessageManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.MessageManufacturerFactory;
|
||||
import com.zhgd.xmgl.enums.ParamEnum;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
|
||||
@ -28,7 +28,10 @@ import com.zhgd.xmgl.modules.environment.entity.vo.NewEnvironmentAlarmVo;
|
||||
import com.zhgd.xmgl.modules.environment.mapper.EnvironmentAlarmMapper;
|
||||
import com.zhgd.xmgl.modules.environment.mapper.EnvironmentWarningMapper;
|
||||
import com.zhgd.xmgl.modules.environment.service.IEnvironmentAlarmService;
|
||||
import com.zhgd.xmgl.modules.environment.service.IEnvironmentAlarmTypeService;
|
||||
import com.zhgd.xmgl.modules.project.entity.EnableMessageDevRule;
|
||||
import com.zhgd.xmgl.modules.project.entity.qo.QueryProjectTodayAlarmInfoQO;
|
||||
import com.zhgd.xmgl.modules.project.service.IEnableMessageDevRuleService;
|
||||
import com.zhgd.xmgl.modules.project.service.IMessageConfigV2Service;
|
||||
import com.zhgd.xmgl.modules.sprayrt.service.ISprayRtDevService;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
|
||||
@ -96,6 +99,12 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
|
||||
@Autowired
|
||||
@Qualifier("doubleCarbonExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IEnableMessageDevRuleService enableMessageDevRuleService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IEnvironmentAlarmTypeService environmentAlarmTypeService;
|
||||
|
||||
@Override
|
||||
public IPage<EnvironmentAlarmVo> queryEnvironmentAlarmPageList(Map<String, Object> map) {
|
||||
@ -813,26 +822,26 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
|
||||
*/
|
||||
private void sendMsg(String devname, EnvironmentAlarm environmentAlarm, String alarmName, String pushPerson) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
MessageManufacturer messageManufacturer = messageManufacturerFactory.getMessageManufacturer(environmentAlarm.getProjectSn());
|
||||
if (messageManufacturer != null) {
|
||||
String alarmType = environmentAlarm.getType() == 1 ? "预警" : "报警";
|
||||
String threshold = NumberUtil.sub(environmentAlarm.getAlarmValue(), environmentAlarm.getExceed()) + "";
|
||||
String time = DateUtil.formatDateTime(environmentAlarm.getAlarmTime());
|
||||
List<String> phoneNums = systemUserService.list(new LambdaQueryWrapper<SystemUser>()
|
||||
.in(SystemUser::getId, StrUtil.split(pushPerson, ","))).stream().map(SystemUser::getUserTel).collect(Collectors.toList());
|
||||
String monitoringLevelName = environmentAlarm.getType() == 1 ? "预警" : "报警";
|
||||
String threshold = NumberUtil.sub(environmentAlarm.getAlarmValue(), environmentAlarm.getExceed()) + "";
|
||||
String time = DateUtil.formatDateTime(environmentAlarm.getAlarmTime());
|
||||
String monitoringParameterName = environmentAlarmTypeService.getById(environmentAlarm.getAlarmTypeId()).getAlarmType();
|
||||
EnableMessageDevRule messageDevRule = enableMessageDevRuleService.getRule(ParamEnum.MessageModuleNameEnum.YCJC, environmentAlarm.getDeviceId(), monitoringParameterName, monitoringLevelName);
|
||||
if (Objects.equals(messageDevRule.getEnableSmsNotification(), 1)) {
|
||||
List<String> templateParams = new ArrayList<>();
|
||||
//报警类型,报警名称,设备名称,报警值,阈值,超标时间,超标量
|
||||
templateParams.add(alarmType);
|
||||
templateParams.add(monitoringLevelName);
|
||||
templateParams.add(alarmName);
|
||||
templateParams.add(devname);
|
||||
templateParams.add(environmentAlarm.getAlarmValue() + "");
|
||||
templateParams.add(threshold);
|
||||
templateParams.add(time);
|
||||
templateParams.add(environmentAlarm.getExceed() + "");
|
||||
String text = StrUtil.format("【{}】扬尘超标警报!报警类型:{},报警名称:{},设备名称:{},报警值:{},阈值:{},超标时间:{},超标量:{}",
|
||||
messageManufacturer.getConfig().getSignature(), alarmType, alarmName, devname, environmentAlarm.getAlarmValue() + "", threshold, time, environmentAlarm.getExceed() + "");
|
||||
messageManufacturer.sendMsgByConfig(phoneNums, "", templateParams, text);
|
||||
String text = StrUtil.format("扬尘超标警报!报警类型:{},报警名称:{},设备名称:{},报警值:{},阈值:{},超标时间:{},超标量:{}",
|
||||
monitoringLevelName, alarmName, devname, environmentAlarm.getAlarmValue() + "", threshold, time, environmentAlarm.getExceed() + "");
|
||||
enableMessageDevRuleService.sendSms(messageDevRule, templateParams, text, null);
|
||||
}
|
||||
enableMessageDevRuleService.sendSystemMessage(messageDevRule, "7");
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
|
||||
|
||||
@ -146,9 +146,9 @@ public class EnableMessageDevRule implements Serializable {
|
||||
@ApiModelProperty(value = "语音文件配置")
|
||||
private java.lang.String voiceFileConfiguration;
|
||||
/**
|
||||
* 广播设备sn(多个,分割)
|
||||
* 广播设备编号(多个,分割)
|
||||
*/
|
||||
@ApiModelProperty(value = "广播设备sn(多个,分割)")
|
||||
@ApiModelProperty(value = "广播设备编号(多个,分割)")
|
||||
private java.lang.String broadcastDevices;
|
||||
/**
|
||||
* 创建时间
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package com.zhgd.xmgl.modules.project.service;
|
||||
|
||||
import com.zhgd.xmgl.modules.project.entity.EnableMessageDevRule;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.EnableMessageDevRuleVo;
|
||||
import com.zhgd.xmgl.modules.project.entity.dto.EnableMessageDevRuleDto;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.zhgd.xmgl.enums.ParamEnum;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.project.entity.EnableMessageDevRule;
|
||||
import com.zhgd.xmgl.modules.project.entity.dto.EnableMessageDevRuleDto;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.EnableMessageDevRuleVo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 通知设备规则
|
||||
@ -64,4 +68,34 @@ public interface IEnableMessageDevRuleService extends IService<EnableMessageDevR
|
||||
*/
|
||||
EnableMessageDevRuleVo queryById(String id);
|
||||
|
||||
/**
|
||||
* 是否开启实时推送
|
||||
*
|
||||
* @param moduleEnum
|
||||
* @param devSn
|
||||
* @param monitoringParameterName
|
||||
* @param monitoringLevelName
|
||||
* @return
|
||||
*/
|
||||
EnableMessageDevRule getRule(ParamEnum.MessageModuleNameEnum moduleEnum, String devSn, String monitoringParameterName, String monitoringLevelName);
|
||||
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
*
|
||||
* @param rule
|
||||
* @param templateParams
|
||||
* @param text
|
||||
* @param userMap 不传就会查数据库
|
||||
* @return
|
||||
*/
|
||||
void sendSms(EnableMessageDevRule rule, List<String> templateParams, String text, @Nullable Map<Long, SystemUser> userMap);
|
||||
|
||||
/**
|
||||
* 发送系统站内消息
|
||||
*
|
||||
* @param rule
|
||||
* @param type
|
||||
*/
|
||||
void sendSystemMessage(EnableMessageDevRule rule, String type);
|
||||
}
|
||||
|
||||
@ -1,25 +1,41 @@
|
||||
package com.zhgd.xmgl.modules.project.service.impl;
|
||||
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.project.entity.EnableMessageDevRule;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.EnableMessageDevRuleVo;
|
||||
import com.zhgd.xmgl.modules.project.entity.dto.EnableMessageDevRuleDto;
|
||||
import com.zhgd.xmgl.modules.project.mapper.EnableMessageDevRuleMapper;
|
||||
import com.zhgd.xmgl.modules.project.service.IEnableMessageDevRuleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.call.api.DevSmsManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.DevSmsManufacturerFactory;
|
||||
import com.zhgd.xmgl.enums.ParamEnum;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.bo.NoticeMessagePromptTone;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
import com.zhgd.xmgl.modules.project.entity.EnableMessageDev;
|
||||
import com.zhgd.xmgl.modules.project.entity.EnableMessageDevRule;
|
||||
import com.zhgd.xmgl.modules.project.entity.dto.EnableMessageDevRuleDto;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.EnableMessageDevRuleVo;
|
||||
import com.zhgd.xmgl.modules.project.mapper.EnableMessageDevRuleMapper;
|
||||
import com.zhgd.xmgl.modules.project.service.IEnableMessageDevRuleService;
|
||||
import com.zhgd.xmgl.modules.project.service.IEnableMessageDevService;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 通知设备规则
|
||||
@ -29,8 +45,20 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
@Service
|
||||
public class EnableMessageDevRuleServiceImpl extends ServiceImpl<EnableMessageDevRuleMapper, EnableMessageDevRule> implements IEnableMessageDevRuleService {
|
||||
@Lazy
|
||||
@Autowired
|
||||
ISystemUserService systemUserService;
|
||||
@Autowired
|
||||
private EnableMessageDevRuleMapper enableMessageDevRuleMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IEnableMessageDevService enableMessageDevService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private DevSmsManufacturerFactory devSmsManufacturerFactory;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private NoticeServiceImpl noticeService;
|
||||
|
||||
@Override
|
||||
public IPage<EnableMessageDevRuleVo> queryPageList(HashMap<String, Object> param) {
|
||||
@ -90,4 +118,68 @@ public class EnableMessageDevRuleServiceImpl extends ServiceImpl<EnableMessageDe
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnableMessageDevRule getRule(ParamEnum.MessageModuleNameEnum moduleEnum, String devSn, String monitoringParameterName, String monitoringLevelName) {
|
||||
EnableMessageDev messageDev = enableMessageDevService.getOne(new LambdaQueryWrapper<EnableMessageDev>()
|
||||
.eq(EnableMessageDev::getMonitoringModule, moduleEnum.getValue())
|
||||
.eq(EnableMessageDev::getDevSn, devSn)
|
||||
);
|
||||
if (messageDev == null || Objects.equals(messageDev.getIsEnable(), 0)) {
|
||||
return null;
|
||||
}
|
||||
return this.getOne(new LambdaQueryWrapper<EnableMessageDevRule>()
|
||||
.eq(EnableMessageDevRule::getMonitoringModuleName, moduleEnum.getDesc())
|
||||
.eq(EnableMessageDevRule::getDevSn, devSn)
|
||||
.eq(EnableMessageDevRule::getMonitoringParameterName, monitoringParameterName)
|
||||
.eq(EnableMessageDevRule::getMonitoringLevelName, monitoringLevelName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发送短信的号码
|
||||
*
|
||||
* @param smsAlarmRecipientIds
|
||||
* @return
|
||||
*/
|
||||
private List<String> getPhoneNums(String smsAlarmRecipientIds, Map<Long, SystemUser> userMap) {
|
||||
if (StrUtil.isBlank(smsAlarmRecipientIds)) {
|
||||
return null;
|
||||
}
|
||||
return StrUtil.split(smsAlarmRecipientIds, ",").stream().filter(id -> userMap.containsKey(Convert.toLong(id))).map(id -> userMap.get(Convert.toLong(id)).getUserTel())
|
||||
.filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSms(EnableMessageDevRule rule, List<String> templateParams, String text, Map<Long, SystemUser> userMap) {
|
||||
DevSmsManufacturer messageManufacturer = devSmsManufacturerFactory.getMessageManufacturer(rule.getProjectSn());
|
||||
if (messageManufacturer != null) {
|
||||
if (userMap == null) {
|
||||
userMap = systemUserService.list(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getSn, rule.getProjectSn())).stream().collect(Collectors.toMap(SystemUser::getUserId, Function.identity(), (o1, o2) -> o1));
|
||||
}
|
||||
List<String> phoneNums = this.getPhoneNums(rule.getSmsAlarmRecipientIds(), userMap);
|
||||
if (CollUtil.isNotEmpty(phoneNums)) {
|
||||
messageManufacturer.sendMsg(phoneNums, rule.getNotificationSmsTemplateId(), templateParams, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSystemMessage(EnableMessageDevRule rule, String type) {
|
||||
if (rule == null) {
|
||||
return;
|
||||
}
|
||||
if (Objects.equals(rule.getEnableSystemMessagePush(), 1) && StrUtil.isNotBlank(rule.getAlarmRecipientIds())) {
|
||||
List<Long> ids = StrUtil.split(rule.getAlarmRecipientIds(), ",").stream().map(Convert::toLong).collect(Collectors.toList());
|
||||
NoticeMessagePromptTone tone = null;
|
||||
//系统站内声音提示
|
||||
if (Objects.equals(rule.getEnableSystemMessagePromptTone(), 1)) {
|
||||
tone = new NoticeMessagePromptTone(rule.getMessagePromptToneConfig(), rule.getPlaybackFrequency());
|
||||
}
|
||||
for (Long id : ids) {
|
||||
noticeService.addUserNoticeAndApp(id, "设备报警通知", rule.getMessageTemplateContent(), type, tone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -119,7 +119,8 @@ public class RiskListSourceController {
|
||||
})
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<RiskListSourceVo>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
return Result.success(riskListSourceService.queryPageList(param));
|
||||
return Result.success(riskListSourceService.
|
||||
queryPageList(param));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -236,7 +236,7 @@ public class RiskListSourceServiceImpl extends ServiceImpl<RiskListSourceMapper,
|
||||
List<XzSecurityQualityInspectionRecord> securityList1 = securityList.stream().filter(r -> StrUtil.isNotBlank(r.getInspectTime()) && Objects.equals(r.getEngineeringId(), sourceVo.getId())).collect(Collectors.toList());
|
||||
List<RiskListSourceUnbuilt> unbuilts1 = unbuilts.stream().filter(r -> r.getInspectionTime() != null && Objects.equals(r.getSourceId(), sourceVo.getId())).collect(Collectors.toList());
|
||||
return StrUtil.split(sourceVo.getSpecificResponsibilityAreaIds(), ",").stream().map(Convert::toLong).filter(regionId -> {
|
||||
int totalCalNum = getTotalCalNum(sourceVo, String.valueOf(regionId), securityList1, unbuilts1);
|
||||
int totalCalNum = getCalNum(sourceVo, String.valueOf(regionId), securityList1, unbuilts1);
|
||||
int remainingNum = sourceVo.getCheckNum() - totalCalNum;
|
||||
return remainingNum > 0;
|
||||
}).collect(Collectors.toList());
|
||||
@ -260,7 +260,7 @@ public class RiskListSourceServiceImpl extends ServiceImpl<RiskListSourceMapper,
|
||||
int totalNum = sourceVo.getSpecificResponsibilityAreaIds().split(",").length * sourceVo.getCheckNum();
|
||||
int totalCalNum = 0;
|
||||
for (String regionId : sourceVo.getSpecificResponsibilityAreaIds().split(",")) {
|
||||
totalCalNum = getTotalCalNum(sourceVo, regionId, securityList1, unbuilts1);
|
||||
totalCalNum = getCalNum(sourceVo, regionId, securityList1, unbuilts1);
|
||||
}
|
||||
return totalNum - totalCalNum;
|
||||
}
|
||||
@ -276,7 +276,7 @@ public class RiskListSourceServiceImpl extends ServiceImpl<RiskListSourceMapper,
|
||||
* @param unbuilts
|
||||
* @return
|
||||
*/
|
||||
private int getTotalCalNum(RiskListSourceVo sourceVo, String regionId, List<XzSecurityQualityInspectionRecord> securityList, List<RiskListSourceUnbuilt> unbuilts) {
|
||||
private int getCalNum(RiskListSourceVo sourceVo, String regionId, List<XzSecurityQualityInspectionRecord> securityList, List<RiskListSourceUnbuilt> unbuilts) {
|
||||
String today = DateUtil.today();
|
||||
Date date = new Date();
|
||||
String year = DateUtil.format(date, "yyyy");
|
||||
|
||||
@ -59,4 +59,12 @@ public interface IXzAiDeductRuleService extends IService<XzAiDeductRule> {
|
||||
* @return
|
||||
*/
|
||||
List<XzAiDeductRule> getListByDicId(List<Long> dicIdList, String projectSn);
|
||||
|
||||
/**
|
||||
* 获取等级中文名称
|
||||
*
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
public String getLevelName(Integer level);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Description: 星纵-AI扣分规则
|
||||
@ -94,5 +95,20 @@ public class XzAiDeductRuleServiceImpl extends ServiceImpl<XzAiDeductRuleMapper,
|
||||
return baseMapper.getListByDicId(dicIdList, projectSn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLevelName(Integer level) {
|
||||
String monitoringLevelName;
|
||||
if (Objects.equals(level, 1)) {
|
||||
monitoringLevelName = "一级";
|
||||
} else if (Objects.equals(level, 2)) {
|
||||
monitoringLevelName = "二级";
|
||||
} else if (Objects.equals(level, 3)) {
|
||||
monitoringLevelName = "三级";
|
||||
} else {
|
||||
monitoringLevelName = "四级";
|
||||
}
|
||||
return monitoringLevelName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -5,13 +5,11 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.xmgl.call.api.DevSmsManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.DevSmsManufacturerFactory;
|
||||
import com.zhgd.xmgl.enums.ParamEnum;
|
||||
import com.zhgd.xmgl.modules.basicdata.constant.DictionaryConstant;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.DictionaryItem;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.bo.NoticeMessagePromptTone;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.DictionaryItemServiceImpl;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
@ -109,15 +107,7 @@ public class MessageDevRuleTask {
|
||||
}).collect(Collectors.groupingBy(AiAnalyseHardWareAlarmRecord::getHardwareId,
|
||||
Collectors.groupingBy(r1 -> dictDataMap.get(Convert.toStr(r1.getAlarmType())).getName(),
|
||||
Collectors.groupingBy(r -> Optional.of(dictDataMap.get(Convert.toStr(r.getAlarmType()))).map(m -> dicIdMap.get(m.getId())).map(r1 -> {
|
||||
if (Objects.equals(r1.getLevel(), 1)) {
|
||||
return "一级";
|
||||
} else if (Objects.equals(r1.getLevel(), 2)) {
|
||||
return "二级";
|
||||
} else if (Objects.equals(r1.getLevel(), 3)) {
|
||||
return "三级";
|
||||
} else {
|
||||
return "四级";
|
||||
}
|
||||
return xzAiDeductRuleService.getLevelName(r1.getLevel());
|
||||
}).orElse(null)))));
|
||||
for (Map.Entry<String, List<EnableMessageDevRule>> moduleEntry : moduleMap.entrySet()) {
|
||||
List<EnableMessageDevRule> entryRules = moduleEntry.getValue();
|
||||
@ -165,29 +155,14 @@ public class MessageDevRuleTask {
|
||||
*/
|
||||
private void sendNotice(EnableMessageDevRule rule, int filterAlarms, Map<Long, SystemUser> userMap, String type) {
|
||||
if (Objects.equals(rule.getEnableSmsNotification(), 1) && isSmsSendTime(rule)) {
|
||||
DevSmsManufacturer messageManufacturer = devSmsManufacturerFactory.getMessageManufacturer(rule.getProjectSn());
|
||||
if (messageManufacturer != null) {
|
||||
String text = StrUtil.format("{}{}{}异常,近{}小时累计报警{}次!",
|
||||
rule.getMonitoringModuleName(), rule.getMonitoringParameterName(), rule.getMonitoringLevelName(), rule.getSmsPushFrequency(), filterAlarms);
|
||||
List<String> phoneNums = getPhoneNums(rule.getSmsAlarmRecipientIds(), userMap);
|
||||
if (CollUtil.isNotEmpty(phoneNums)) {
|
||||
messageManufacturer.sendMsg(phoneNums, rule.getNotificationSmsTemplateId(), null, text);
|
||||
}
|
||||
}
|
||||
String text = StrUtil.format("{}{}{}异常,近{}小时累计报警{}次!",
|
||||
rule.getMonitoringModuleName(), rule.getMonitoringParameterName(), rule.getMonitoringLevelName(), rule.getSmsPushFrequency(), filterAlarms);
|
||||
List<String> templateParams = Arrays.asList(rule.getMonitoringModuleName(), rule.getMonitoringParameterName(), rule.getMonitoringLevelName(), Convert.toStr(rule.getSmsPushFrequency()), Convert.toStr(filterAlarms));
|
||||
enableMessageDevRuleService.sendSms(rule, templateParams, text, userMap);
|
||||
}
|
||||
//系统站内
|
||||
if (Objects.equals(rule.getEnableSystemMessagePush(), 1) && isSystemSendTime(rule)) {
|
||||
if (StrUtil.isNotBlank(rule.getAlarmRecipientIds())) {
|
||||
List<Long> ids = StrUtil.split(rule.getAlarmRecipientIds(), ",").stream().map(Convert::toLong).collect(Collectors.toList());
|
||||
NoticeMessagePromptTone tone = null;
|
||||
//系统站内声音提示
|
||||
if (Objects.equals(rule.getEnableSystemMessagePromptTone(), 1)) {
|
||||
tone = new NoticeMessagePromptTone(rule.getMessagePromptToneConfig(), rule.getPlaybackFrequency());
|
||||
}
|
||||
for (Long id : ids) {
|
||||
noticeService.addUserNoticeAndApp(id, "设备报警通知", rule.getMessageTemplateContent(), type, tone);
|
||||
}
|
||||
}
|
||||
enableMessageDevRuleService.sendSystemMessage(rule, type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,19 +192,5 @@ public class MessageDevRuleTask {
|
||||
&& rule.getSmsPushTimeBegin().getHour() <= hour && rule.getSmsPushTimeEnd().getHour() >= hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发送短信的号码
|
||||
*
|
||||
* @param smsAlarmRecipientIds
|
||||
* @param userMap
|
||||
* @return
|
||||
*/
|
||||
private List<String> getPhoneNums(String smsAlarmRecipientIds, Map<Long, SystemUser> userMap) {
|
||||
if (StrUtil.isBlank(smsAlarmRecipientIds)) {
|
||||
return null;
|
||||
}
|
||||
return StrUtil.split(smsAlarmRecipientIds, ",").stream().filter(id -> userMap.containsKey(Convert.toLong(id))).map(id -> userMap.get(Convert.toLong(id)).getUserTel())
|
||||
.filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user