|
@@ -3,6 +3,7 @@ package com.sckw.slope.detection.consumer;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
|
import com.sckw.core.model.enums.AlarmTitleEnum;
|
|
import com.sckw.core.model.enums.AlarmTitleEnum;
|
|
|
import com.sckw.core.model.enums.AlarmTypeEnum;
|
|
import com.sckw.core.model.enums.AlarmTypeEnum;
|
|
@@ -12,6 +13,7 @@ import com.sckw.core.utils.DateUtils;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.log.TraceLog.TraceLog;
|
|
import com.sckw.log.TraceLog.TraceLog;
|
|
|
|
|
+import com.sckw.redis.utils.RedissonUtils;
|
|
|
import com.sckw.slope.detection.dao.mysql.*;
|
|
import com.sckw.slope.detection.dao.mysql.*;
|
|
|
import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
|
|
import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.*;
|
|
import com.sckw.slope.detection.model.dos.mysql.*;
|
|
@@ -26,11 +28,13 @@ import com.sckw.slope.detection.service.CommonService;
|
|
|
import com.sckw.slope.detection.service.TdengineService;
|
|
import com.sckw.slope.detection.service.TdengineService;
|
|
|
import com.sckw.slope.detection.service.api.DetectionApiService;
|
|
import com.sckw.slope.detection.service.api.DetectionApiService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.dubbo.common.utils.MD5Utils;
|
|
import org.apache.dubbo.common.utils.MD5Utils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -135,7 +139,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
// ts = ts * 1000;
|
|
// ts = ts * 1000;
|
|
|
// }
|
|
// }
|
|
|
//判断是否满足设备超时离线报警
|
|
//判断是否满足设备超时离线报警
|
|
|
- checkDeviceAlarm(deviceCode, device, itemValue, ts);
|
|
|
|
|
|
|
+// checkDeviceAlarm(deviceCode, device, itemValue, ts);
|
|
|
//判断是否满足数值超阈值报警
|
|
//判断是否满足数值超阈值报警
|
|
|
Map<String, String> map = checkThresholdAlarm(devicesItem, kwsThresholds, device);
|
|
Map<String, String> map = checkThresholdAlarm(devicesItem, kwsThresholds, device);
|
|
|
if ("2".equals(map.get("flag"))) {
|
|
if ("2".equals(map.get("flag"))) {
|
|
@@ -145,26 +149,14 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
long id = insertAlarmAndDetail(level, device, thresholdId, itemValue, ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
|
|
long id = insertAlarmAndDetail(level, device, thresholdId, itemValue, ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
|
|
|
//todo 不适用redis存统计 使用新字段处理
|
|
//todo 不适用redis存统计 使用新字段处理
|
|
|
/**阈值次数存redis*/
|
|
/**阈值次数存redis*/
|
|
|
-// String key = Global.REDIS_SYS_ALARM_PREFIX + Global.POUND + String.valueOf(id) + Global.POUND + AlarmTypeEnum.ALARM_ONE.getStatus()
|
|
|
|
|
-// + Global.POUND + AlarmTitleEnum.ALARM_TITLE_TWO.getStatus();
|
|
|
|
|
-// String number = RedissonUtils.getString(key);
|
|
|
|
|
-// Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
|
|
|
-// .eq(KwsAlarmDetail::getAlarmId, id)
|
|
|
|
|
-// .eq(KwsAlarmDetail::getStatus, 0)
|
|
|
|
|
-// );
|
|
|
|
|
-// if (StringUtils.isBlank(number)) {
|
|
|
|
|
-// RedissonUtils.putString(key, "1", Global.COMMON_EXPIRE);
|
|
|
|
|
-// } else {
|
|
|
|
|
-// RedissonUtils.putString(key, count.toString(), Global.COMMON_EXPIRE);
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
|
|
+// redisPutAlarmCount(id);
|
|
|
/*【露天矿山边坡监测系统】尊敬的管理员,2023-10-01 12:23:34监测到一级告警。
|
|
/*【露天矿山边坡监测系统】尊敬的管理员,2023-10-01 12:23:34监测到一级告警。
|
|
|
设备名称:位移监测设备-gnss一号机,监测数值:55。123456789N,请尽快处理问题。*/
|
|
设备名称:位移监测设备-gnss一号机,监测数值:55。123456789N,请尽快处理问题。*/
|
|
|
Map<String, Object> messageMap = new HashMap<>();
|
|
Map<String, Object> messageMap = new HashMap<>();
|
|
|
pushSmsMessage(messageUrl, device, level, thresholdId, messageMap);
|
|
pushSmsMessage(messageUrl, device, level, thresholdId, messageMap);
|
|
|
}
|
|
}
|
|
|
//集成要素阈值告警
|
|
//集成要素阈值告警
|
|
|
-// deviceIntegrationsAlarm(device);
|
|
|
|
|
|
|
+ deviceIntegrationsAlarm(device,ts);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -173,7 +165,22 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
return HttpResult.ok();
|
|
return HttpResult.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void deviceIntegrationsAlarm(KwsDevice device) {
|
|
|
|
|
|
|
+ private void redisPutAlarmCount(long id) {
|
|
|
|
|
+ String key = Global.REDIS_SYS_ALARM_PREFIX + Global.POUND + String.valueOf(id) + Global.POUND + AlarmTypeEnum.ALARM_ONE.getStatus()
|
|
|
|
|
+ + Global.POUND + AlarmTitleEnum.ALARM_TITLE_TWO.getStatus();
|
|
|
|
|
+ String number = RedissonUtils.getString(key);
|
|
|
|
|
+ Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
|
|
|
+ .eq(KwsAlarmDetail::getAlarmId, id)
|
|
|
|
|
+ .eq(KwsAlarmDetail::getStatus, 0)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (StringUtils.isBlank(number)) {
|
|
|
|
|
+ RedissonUtils.putString(key, "1", Global.COMMON_EXPIRE);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ RedissonUtils.putString(key, count.toString(), Global.COMMON_EXPIRE);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void deviceIntegrationsAlarm(KwsDevice device,Long ts) {
|
|
|
List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(
|
|
List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(
|
|
|
new LambdaQueryWrapper<KwsDeviceIntegration>()
|
|
new LambdaQueryWrapper<KwsDeviceIntegration>()
|
|
|
.eq(KwsDeviceIntegration::getDeviceId, device.getId())
|
|
.eq(KwsDeviceIntegration::getDeviceId, device.getId())
|
|
@@ -197,13 +204,25 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
String snCode = device.getSnCode();
|
|
String snCode = device.getSnCode();
|
|
|
intergData = deviceIntegrationMapper.selectListParamsAndInterNameByDeviceId(device.getId());
|
|
intergData = deviceIntegrationMapper.selectListParamsAndInterNameByDeviceId(device.getId());
|
|
|
if (!Objects.isNull(intergData)) {
|
|
if (!Objects.isNull(intergData)) {
|
|
|
- for (DeviceIntegrationVo inter : intergData) {
|
|
|
|
|
|
|
+ for (DeviceIntegrationVo deviceIntegration : intergData) {
|
|
|
//获取到当前测量值--现在只有单一值
|
|
//获取到当前测量值--现在只有单一值
|
|
|
- List<SlopeData> slopeData = slopeDataMapper.selectListByTwoLine(snCode, inter.getPartNames());
|
|
|
|
|
|
|
+ List<SlopeData> slopeData = slopeDataMapper.selectListByTwoLine(snCode, deviceIntegration.getPartNames());
|
|
|
if (!Objects.isNull(slopeData)) {
|
|
if (!Objects.isNull(slopeData)) {
|
|
|
- double offset = commonService.returnIntegrationData(snCode, slopeData, inter);
|
|
|
|
|
|
|
+ List<KwsThreshold> thresholdList = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
|
|
+ .eq(KwsThreshold::getDeviceId, device.getId())
|
|
|
|
|
+ .eq(KwsThreshold::getItemName, deviceIntegration.getPartNames())
|
|
|
|
|
+ );
|
|
|
|
|
+ double offset = commonService.returnIntegrationData(snCode, slopeData, deviceIntegration);
|
|
|
|
|
+ Map<String, String> map = newAlarmCompute(new BigDecimal(offset), thresholdList);
|
|
|
|
|
+ if ("2".equals(map.get("flag"))) {
|
|
|
|
|
+ Long level = Long.valueOf(map.get("level"));
|
|
|
|
|
+ Long thresholdId = Long.valueOf(map.get("thresholdId"));
|
|
|
|
|
+ //阈值表以及明细表存储
|
|
|
|
|
+ long id = insertAlarmAndDetail(level, device, thresholdId, deviceIntegration.getPartNames(), ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
|
|
|
|
|
+ Map<String, Object> messageMap = new HashMap<>();
|
|
|
|
|
+ pushSmsMessage(messageUrl, device, level, thresholdId, messageMap);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -533,9 +552,10 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
* @param alarmTitle 设备类型明细
|
|
* @param alarmTitle 设备类型明细
|
|
|
* @param type 设备类型
|
|
* @param type 设备类型
|
|
|
*/
|
|
*/
|
|
|
- private long insertAlarmAndDetail(Long level, KwsDevice device, Long thresholdId,
|
|
|
|
|
- String itemValue, Long ts,
|
|
|
|
|
- String alarmTitle, Integer type
|
|
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public long insertAlarmAndDetail(Long level, KwsDevice device, Long thresholdId,
|
|
|
|
|
+ String itemValue, Long ts,
|
|
|
|
|
+ String alarmTitle, Integer type
|
|
|
) {
|
|
) {
|
|
|
Long deviceId = device.getId();
|
|
Long deviceId = device.getId();
|
|
|
KwsProjectDevice projectDevice = projectDeviceMapper.selectOne(new LambdaQueryWrapper<KwsProjectDevice>()
|
|
KwsProjectDevice projectDevice = projectDeviceMapper.selectOne(new LambdaQueryWrapper<KwsProjectDevice>()
|
|
@@ -552,12 +572,15 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
return alarmId;
|
|
return alarmId;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void insertHistoryRead(Long level, KwsDevice device, Long thresholdId, String itemValue, Long ts, String alarmTitle, Integer type, Long deviceId, KwsProjectDevice projectDevice) {
|
|
|
|
|
|
|
+ public void insertHistoryRead(Long level, KwsDevice device, Long thresholdId, String itemValue, Long ts, String alarmTitle, Integer type, Long deviceId, KwsProjectDevice projectDevice) {
|
|
|
LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<KwsAlarm>()
|
|
LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<KwsAlarm>()
|
|
|
- .eq(KwsAlarm::getLevel, level.intValue())
|
|
|
|
|
- .eq(KwsAlarm::getDeviceId, deviceId)
|
|
|
|
|
.eq(KwsAlarm::getStatus, NumberConstant.ONE)
|
|
.eq(KwsAlarm::getStatus, NumberConstant.ONE)
|
|
|
.eq(KwsAlarm::getType, type)
|
|
.eq(KwsAlarm::getType, type)
|
|
|
|
|
+ .eq(KwsAlarm::getLevel, level.intValue())
|
|
|
|
|
+ .eq(KwsAlarm::getDeviceId, deviceId)
|
|
|
|
|
+ .eq(KwsAlarm::getIsHistory, 1)
|
|
|
|
|
+ .eq(KwsAlarm::getTitle, alarmTitle)
|
|
|
|
|
+ .eq(KwsAlarm::getDelFlag, 0)
|
|
|
.orderByDesc(KwsAlarm::getCreateTime);
|
|
.orderByDesc(KwsAlarm::getCreateTime);
|
|
|
if (projectDevice != null) {
|
|
if (projectDevice != null) {
|
|
|
wrapper.eq(KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
wrapper.eq(KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
@@ -567,8 +590,8 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
long alarmId = new IdWorker(NumberConstant.ONE).nextId();
|
|
long alarmId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
- List<KwsAlarm> alarms = alarmMapper.selectList(wrapper);
|
|
|
|
|
- if (CollectionUtils.isEmpty(alarms)) {
|
|
|
|
|
|
|
+ KwsAlarm alarms = alarmMapper.selectOne(wrapper);
|
|
|
|
|
+ if (alarms == null) {
|
|
|
KwsAlarm alarm = new KwsAlarm();
|
|
KwsAlarm alarm = new KwsAlarm();
|
|
|
String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
|
|
String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
|
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
@@ -592,27 +615,18 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private long insertUnread(Long level, KwsDevice device, Long thresholdId,
|
|
|
|
|
- String itemValue, Long ts,
|
|
|
|
|
- String alarmTitle, Integer type, Long deviceId, KwsProjectDevice projectDevice) {
|
|
|
|
|
- LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<KwsAlarm>()
|
|
|
|
|
- .eq(KwsAlarm::getLevel, level.intValue())
|
|
|
|
|
- .eq(KwsAlarm::getDeviceId, deviceId)
|
|
|
|
|
- .eq(KwsAlarm::getStatus, NumberConstant.ZERO)
|
|
|
|
|
- .eq(KwsAlarm::getType, type)
|
|
|
|
|
- .eq(KwsAlarm::getIsHistory, NumberConstant.ZERO)
|
|
|
|
|
- .eq(KwsAlarm::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
- .orderByDesc(KwsAlarm::getCreateTime);
|
|
|
|
|
- if (projectDevice != null) {
|
|
|
|
|
- wrapper.eq(KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
|
|
|
- .eq(KwsAlarm::getMountainId, projectDevice.getMountainId());
|
|
|
|
|
- if (projectDevice.getProjectId() != null) {
|
|
|
|
|
- wrapper.eq(KwsAlarm::getCompanyId, projectDevice.getCompanyId());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public long insertUnread(Long level, KwsDevice device, Long thresholdId,
|
|
|
|
|
+ String itemValue, Long ts,
|
|
|
|
|
+ String alarmTitle, Integer type, Long deviceId, KwsProjectDevice projectDevice) {
|
|
|
|
|
+
|
|
|
long alarmId = new IdWorker(NumberConstant.ONE).nextId();
|
|
long alarmId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
- List<KwsAlarm> alarms = alarmMapper.selectList(wrapper);
|
|
|
|
|
- if (CollectionUtils.isEmpty(alarms)) {
|
|
|
|
|
|
|
+ KwsAlarm alarms = selectAlarmData(level, deviceId, type, alarmTitle, projectDevice);
|
|
|
|
|
+// if (!CollectionUtils.isEmpty() && alarms.size() > 1) {
|
|
|
|
|
+// //去重
|
|
|
|
|
+// checkAlarmData(alarms, level, deviceId, type, alarmTitle, projectDevice);
|
|
|
|
|
+// }
|
|
|
|
|
+// alarms = selectAlarmData(level, deviceId, type, alarmTitle, projectDevice);
|
|
|
|
|
+ if (alarms == null) {
|
|
|
KwsAlarm alarm = new KwsAlarm();
|
|
KwsAlarm alarm = new KwsAlarm();
|
|
|
String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
|
|
String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
|
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
|
|
@@ -650,8 +664,8 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
alarmDetail.setIsHistory(NumberConstant.ZERO);
|
|
alarmDetail.setIsHistory(NumberConstant.ZERO);
|
|
|
alarmDetailMapper.insert(alarmDetail);
|
|
alarmDetailMapper.insert(alarmDetail);
|
|
|
} else {
|
|
} else {
|
|
|
- alarmId = alarms.get(0).getId();
|
|
|
|
|
- KwsAlarm alarm = alarms.get(0);
|
|
|
|
|
|
|
+ alarmId = alarms.getId();
|
|
|
|
|
+ KwsAlarm alarm = alarms;
|
|
|
LocalDateTime localDateTime = Instant.ofEpochSecond(ts).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
LocalDateTime localDateTime = Instant.ofEpochSecond(ts).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
// LocalDateTime localDateTime = new Date(ts).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
|
|
// LocalDateTime localDateTime = new Date(ts).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
|
|
|
alarm.setUpdateTime(localDateTime);
|
|
alarm.setUpdateTime(localDateTime);
|
|
@@ -688,6 +702,53 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
return alarmId;
|
|
return alarmId;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private KwsAlarm selectAlarmData(Long level, Long deviceId, Integer type, String alarmTitle, KwsProjectDevice projectDevice) {
|
|
|
|
|
+ LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<KwsAlarm>()
|
|
|
|
|
+ .eq(KwsAlarm::getLevel, level.intValue())
|
|
|
|
|
+ .eq(KwsAlarm::getDeviceId, deviceId)
|
|
|
|
|
+ .eq(KwsAlarm::getStatus, NumberConstant.ZERO)
|
|
|
|
|
+ .eq(KwsAlarm::getType, type)
|
|
|
|
|
+ .eq(KwsAlarm::getTitle, alarmTitle)
|
|
|
|
|
+ .eq(KwsAlarm::getIsHistory, NumberConstant.ZERO)
|
|
|
|
|
+ .eq(KwsAlarm::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ .orderByDesc(KwsAlarm::getCreateTime);
|
|
|
|
|
+ if (projectDevice != null) {
|
|
|
|
|
+ wrapper.eq(KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
|
|
|
+ .eq(KwsAlarm::getMountainId, projectDevice.getMountainId());
|
|
|
|
|
+ if (projectDevice.getProjectId() != null) {
|
|
|
|
|
+ wrapper.eq(KwsAlarm::getCompanyId, projectDevice.getCompanyId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ KwsAlarm alarms = alarmMapper.selectOne(wrapper);
|
|
|
|
|
+ return alarms;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void checkAlarmData(List<KwsAlarm> alarms, Long level, Long deviceId, Integer type, String alarmTitle, KwsProjectDevice projectDevice) {
|
|
|
|
|
+ for (KwsAlarm alarm : alarms) {
|
|
|
|
|
+ List<KwsAlarmDetail> details = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>().eq(KwsAlarmDetail::getAlarmId, alarm.getDeviceId()));
|
|
|
|
|
+ if (org.springframework.util.CollectionUtils.isEmpty(details) && details.size() == 0) {
|
|
|
|
|
+ alarm.setDelFlag(1);
|
|
|
|
|
+ alarmMapper.updateById(alarm);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<KwsAlarm>()
|
|
|
|
|
+ .eq(KwsAlarm::getLevel, level.intValue())
|
|
|
|
|
+ .eq(KwsAlarm::getDeviceId, deviceId)
|
|
|
|
|
+ .eq(KwsAlarm::getStatus, NumberConstant.ZERO)
|
|
|
|
|
+ .eq(KwsAlarm::getType, type)
|
|
|
|
|
+ .eq(KwsAlarm::getTitle, alarmTitle)
|
|
|
|
|
+ .eq(KwsAlarm::getIsHistory, NumberConstant.ZERO)
|
|
|
|
|
+ .eq(KwsAlarm::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ .orderByDesc(KwsAlarm::getCreateTime);
|
|
|
|
|
+ if (projectDevice != null) {
|
|
|
|
|
+ wrapper.eq(KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
|
|
|
+ .eq(KwsAlarm::getMountainId, projectDevice.getMountainId());
|
|
|
|
|
+ if (projectDevice.getProjectId() != null) {
|
|
|
|
|
+ wrapper.eq(KwsAlarm::getCompanyId, projectDevice.getCompanyId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 计算最小值
|
|
* 计算最小值
|
|
|
*
|
|
*
|