|
@@ -202,7 +202,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
if (!CollectionUtils.isEmpty(emailList)) {
|
|
if (!CollectionUtils.isEmpty(emailList)) {
|
|
|
emailAddress = list.stream().map(KwsAlarmInfo::getValueDesc).distinct().collect(Collectors.toList());
|
|
emailAddress = list.stream().map(KwsAlarmInfo::getValueDesc).distinct().collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
- if (!CollectionUtils.isEmpty(emailAddress)){
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(emailAddress)) {
|
|
|
Map<String, Object> templateParam = new HashMap<>();
|
|
Map<String, Object> templateParam = new HashMap<>();
|
|
|
if (StringUtils.isBlank(time)) {
|
|
if (StringUtils.isBlank(time)) {
|
|
|
LocalDateTime localDateTime = Instant.ofEpochSecond(ts).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
LocalDateTime localDateTime = Instant.ofEpochSecond(ts).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
@@ -212,7 +212,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
templateParam.put("level", level.toString());
|
|
templateParam.put("level", level.toString());
|
|
|
templateParam.put("name", device.getName());
|
|
templateParam.put("name", device.getName());
|
|
|
templateParam.put("time", time);
|
|
templateParam.put("time", time);
|
|
|
- templateParam.put("project", vo.getProjectName());
|
|
|
|
|
|
|
+ templateParam.put("project", vo == null ? null : vo.getProjectName());
|
|
|
templateParam.put("value", itemValue);
|
|
templateParam.put("value", itemValue);
|
|
|
commonService.pushEmailMessage(emailAddress
|
|
commonService.pushEmailMessage(emailAddress
|
|
|
, templateParam);
|
|
, templateParam);
|
|
@@ -640,12 +640,13 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
String alarmTitle, Integer type
|
|
String alarmTitle, Integer type
|
|
|
) {
|
|
) {
|
|
|
Long deviceId = device.getId();
|
|
Long deviceId = device.getId();
|
|
|
- KwsProjectDevice projectDevice = projectDeviceMapper.selectOne(new LambdaQueryWrapper<KwsProjectDevice>()
|
|
|
|
|
- .eq(KwsProjectDevice::getDeviceId, deviceId)
|
|
|
|
|
- .eq(KwsProjectDevice::getDelFlag, 0)
|
|
|
|
|
- .orderByDesc(KwsProjectDevice::getCreateTime)
|
|
|
|
|
- .last(" limit 1")
|
|
|
|
|
- );
|
|
|
|
|
|
|
+// KwsProjectDevice projectDevice = projectDeviceMapper.selectOne(new LambdaQueryWrapper<KwsProjectDevice>()
|
|
|
|
|
+// .eq(KwsProjectDevice::getDeviceId, deviceId)
|
|
|
|
|
+// .eq(KwsProjectDevice::getDelFlag, 0)
|
|
|
|
|
+// .orderByDesc(KwsProjectDevice::getCreateTime)
|
|
|
|
|
+// .last(" limit 1")
|
|
|
|
|
+// );
|
|
|
|
|
+ KwsProjectDevice projectDevice = projectDeviceMapper.selectProjectDeviceByDeviceId(deviceId);
|
|
|
//新增未读数据
|
|
//新增未读数据
|
|
|
long alarmId = insertUnread(level, device, thresholdId, itemValue, ts, alarmTitle, type, deviceId, projectDevice);
|
|
long alarmId = insertUnread(level, device, thresholdId, itemValue, ts, alarmTitle, type, deviceId, projectDevice);
|
|
|
//新增历史数据
|
|
//新增历史数据
|
|
@@ -675,7 +676,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
KwsAlarm alarms = alarmMapper.selectOne(wrapper);
|
|
KwsAlarm alarms = alarmMapper.selectOne(wrapper);
|
|
|
if (alarms == null) {
|
|
if (alarms == null) {
|
|
|
KwsAlarm alarm = new KwsAlarm();
|
|
KwsAlarm alarm = new KwsAlarm();
|
|
|
- String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
|
|
|
|
|
|
|
+ String mountainId = device == null ? null : device.getMountainId();
|
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
|
String projectId = projectDevice == null ? null :
|
|
String projectId = projectDevice == null ? null :
|
|
|
(projectDevice.getProjectId() == null ? null : projectDevice.getProjectId().toString());
|
|
(projectDevice.getProjectId() == null ? null : projectDevice.getProjectId().toString());
|
|
@@ -702,7 +703,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
String alarmTitle, Integer type, Long deviceId, KwsProjectDevice projectDevice) {
|
|
String alarmTitle, Integer type, Long deviceId, KwsProjectDevice projectDevice) {
|
|
|
|
|
|
|
|
long alarmId = new IdWorker(NumberConstant.ONE).nextId();
|
|
long alarmId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
- KwsAlarm alarms = selectAlarmData(level, deviceId, type, alarmTitle, projectDevice);
|
|
|
|
|
|
|
+ KwsAlarm alarms = selectAlarmData(level, deviceId, type, alarmTitle, projectDevice, device);
|
|
|
// if (!CollectionUtils.isEmpty() && alarms.size() > 1) {
|
|
// if (!CollectionUtils.isEmpty() && alarms.size() > 1) {
|
|
|
// //去重
|
|
// //去重
|
|
|
// checkAlarmData(alarms, level, deviceId, type, alarmTitle, projectDevice);
|
|
// checkAlarmData(alarms, level, deviceId, type, alarmTitle, projectDevice);
|
|
@@ -710,7 +711,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
// alarms = selectAlarmData(level, deviceId, type, alarmTitle, projectDevice);
|
|
// alarms = selectAlarmData(level, deviceId, type, alarmTitle, projectDevice);
|
|
|
if (alarms == null) {
|
|
if (alarms == null) {
|
|
|
KwsAlarm alarm = new KwsAlarm();
|
|
KwsAlarm alarm = new KwsAlarm();
|
|
|
- String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
|
|
|
|
|
|
|
+ String mountainId = device == null ? null : device.getMountainId();
|
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
|
String projectId = projectDevice == null ? null :
|
|
String projectId = projectDevice == null ? null :
|
|
|
(projectDevice.getProjectId() == null ? null : projectDevice.getProjectId().toString());
|
|
(projectDevice.getProjectId() == null ? null : projectDevice.getProjectId().toString());
|
|
@@ -760,7 +761,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
);
|
|
);
|
|
|
alarm.setTriggerTimes(aLong.intValue() + 1);
|
|
alarm.setTriggerTimes(aLong.intValue() + 1);
|
|
|
alarmMapper.updateById(alarm);
|
|
alarmMapper.updateById(alarm);
|
|
|
- String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
|
|
|
|
|
|
|
+ String mountainId = device == null ? null : device.getMountainId();
|
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
|
String projectId = projectDevice == null ? null :
|
|
String projectId = projectDevice == null ? null :
|
|
|
(projectDevice.getProjectId() == null ? null : projectDevice.getProjectId().toString());
|
|
(projectDevice.getProjectId() == null ? null : projectDevice.getProjectId().toString());
|
|
@@ -784,7 +785,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
return alarmId;
|
|
return alarmId;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private KwsAlarm selectAlarmData(Long level, Long deviceId, Integer type, String alarmTitle, KwsProjectDevice projectDevice) {
|
|
|
|
|
|
|
+ private KwsAlarm selectAlarmData(Long level, Long deviceId, Integer type, String alarmTitle, KwsProjectDevice projectDevice, KwsDevice device) {
|
|
|
LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<KwsAlarm>()
|
|
LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<KwsAlarm>()
|
|
|
.eq(KwsAlarm::getLevel, level.intValue())
|
|
.eq(KwsAlarm::getLevel, level.intValue())
|
|
|
.eq(KwsAlarm::getDeviceId, deviceId)
|
|
.eq(KwsAlarm::getDeviceId, deviceId)
|
|
@@ -795,14 +796,18 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
.eq(KwsAlarm::getDelFlag, NumberConstant.ZERO)
|
|
.eq(KwsAlarm::getDelFlag, NumberConstant.ZERO)
|
|
|
.orderByDesc(KwsAlarm::getCreateTime);
|
|
.orderByDesc(KwsAlarm::getCreateTime);
|
|
|
if (projectDevice != null) {
|
|
if (projectDevice != null) {
|
|
|
- wrapper.eq(KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
|
|
|
- .eq(KwsAlarm::getMountainId, projectDevice.getMountainId());
|
|
|
|
|
|
|
+ wrapper.eq(Objects.nonNull(projectDevice.getProjectId()), KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
|
|
|
+ .eq(StringUtils.isNotBlank(device.getMountainId()), KwsAlarm::getMountainId, device.getMountainId());
|
|
|
if (projectDevice.getProjectId() != null) {
|
|
if (projectDevice.getProjectId() != null) {
|
|
|
- wrapper.eq(KwsAlarm::getCompanyId, projectDevice.getCompanyId());
|
|
|
|
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(projectDevice.getCompanyId()), KwsAlarm::getCompanyId, projectDevice.getCompanyId());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- KwsAlarm alarms = alarmMapper.selectOne(wrapper);
|
|
|
|
|
- return alarms;
|
|
|
|
|
|
|
+ KwsAlarm kwsAlarm = new KwsAlarm();
|
|
|
|
|
+ List<KwsAlarm> alarms = alarmMapper.selectList(wrapper);
|
|
|
|
|
+ if (alarms.size() > 0) {
|
|
|
|
|
+ kwsAlarm = alarms.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return kwsAlarm;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void checkAlarmData(List<KwsAlarm> alarms, Long level, Long deviceId, Integer type, String alarmTitle, KwsProjectDevice projectDevice) {
|
|
private void checkAlarmData(List<KwsAlarm> alarms, Long level, Long deviceId, Integer type, String alarmTitle, KwsProjectDevice projectDevice) {
|