|
@@ -1,10 +1,12 @@
|
|
|
package com.usky.alarm.service.mqtt.alarm;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.alarm.service.enums.TopListener;
|
|
|
+import com.usky.alarm.service.job.alarmLinkageJob;
|
|
|
import com.usky.common.core.util.JsonUtils;
|
|
|
import com.usky.alarm.domain.*;
|
|
|
import com.usky.alarm.service.*;
|
|
@@ -31,6 +33,12 @@ public class Alarm implements MqttStrategy {
|
|
|
@Autowired
|
|
|
private DmpDeviceService dmpDeviceService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DmpDeviceLinkageService dmpDeviceLinkageService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private alarmLinkageJob AlarmLinkageJob;
|
|
|
+
|
|
|
@Override
|
|
|
public String disposeMessage(MqttBaseVO mqttBaseVO) {
|
|
|
Map map = JsonUtils.fromJson(mqttBaseVO.getData().toString(), Map.class);
|
|
@@ -42,7 +50,7 @@ public class Alarm implements MqttStrategy {
|
|
|
String topic = mqttBaseVO.getTopic();
|
|
|
String[] code4 = TopListener.VIDEO_ALERT.getCode().split("/");
|
|
|
LambdaQueryWrapper<DmpDevice> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
- queryWrapper1.select(DmpDevice::getProductCode)
|
|
|
+ queryWrapper1.select(DmpDevice::getProductCode,DmpDevice::getDeviceUuid)
|
|
|
.eq(DmpDevice::getDeviceId, map.get("devId").toString())
|
|
|
.eq(DmpDevice::getDeleteFlag, 0);
|
|
|
List<DmpDevice> list = dmpDeviceService.list(queryWrapper1);
|
|
@@ -60,10 +68,33 @@ public class Alarm implements MqttStrategy {
|
|
|
baseAlarm.setAlarmContent(dp.get(0).get("property").toString()+","+dp.get(0).get("value").toString());
|
|
|
baseAlarm.setAlarmGrade(2);
|
|
|
baseAlarm.setAlarmAddress(alarams.get(0).get("deviceName").toString());
|
|
|
- }else if (alarams.get(0).get("deviceType").equals("3")){
|
|
|
+ }else if (alarams.get(0).get("deviceType").equals("3")||alarams.get(0).get("deviceType").equals("137")){
|
|
|
baseAlarm.setAlarmContent(dp.get(0).get("property").toString());
|
|
|
baseAlarm.setAlarmGrade(2);
|
|
|
baseAlarm.setAlarmAddress(alarams.get(0).get("deviceName").toString());
|
|
|
+ LambdaQueryWrapper<DmpDeviceLinkage> queryWrapper5 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper5.eq(DmpDeviceLinkage::getDeviceId,map.get("devId").toString());
|
|
|
+ List<DmpDeviceLinkage> list5 = dmpDeviceLinkageService.list(queryWrapper5);
|
|
|
+ if(CollectionUtils.isNotEmpty(list5)){
|
|
|
+ LambdaQueryWrapper<DmpDevice> queryWrapper6 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper6.select(DmpDevice::getDeviceId,DmpDevice::getProductCode,DmpDevice::getDeviceUuid)
|
|
|
+ .eq(DmpDevice::getGroupId, list5.get(0).getGroupId())
|
|
|
+ .eq(DmpDevice::getDeviceType, 138)
|
|
|
+ .eq(DmpDevice::getDeleteFlag, 0);
|
|
|
+ List<DmpDevice> list6 = dmpDeviceService.list(queryWrapper6);
|
|
|
+ JsonObject jsonObject = new JsonObject();
|
|
|
+ int index = list6.get(0).getProductCode().indexOf("_");
|
|
|
+ String result = list6.get(0).getProductCode().substring(index+1,
|
|
|
+ list6.get(0).getProductCode().toString().length());
|
|
|
+ if (CollectionUtils.isNotEmpty(list6)) {
|
|
|
+ jsonObject.addProperty("productId", result);
|
|
|
+ jsonObject.addProperty("tcDeviceId",list6.get(0).getDeviceUuid());
|
|
|
+ jsonObject.addProperty("deviceId",list6.get(0).getDeviceId());
|
|
|
+ jsonObject.addProperty("deviceType","JH");
|
|
|
+ jsonObject.addProperty("linkageAddress",list5.get(0).getLinkageAddress());
|
|
|
+ JSONObject resultVo = AlarmLinkageJob.addLinkage(jsonObject.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}else if (alarams.get(0).get("deviceType").equals("6")){
|
|
|
baseAlarm.setAlarmContent(dp.get(0).get("property").toString()+","+dp.get(0).get("stuname").toString());
|
|
|
baseAlarm.setAlarmGrade(2);
|