|
|
|
|
@ -62,7 +62,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.security.PermitAll;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
@ -164,7 +163,6 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case REGISTER:
|
|
|
|
|
//设备注册
|
|
|
|
|
// 根据
|
|
|
|
|
String deviceId = registerDevice(device, (DeviceRegister) action, null);
|
|
|
|
|
deviceUpdateLastTime(deviceId, lastTime);
|
|
|
|
|
|
|
|
|
|
@ -369,9 +367,8 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
.deviceStatus(device.getDeviceStatus())
|
|
|
|
|
.occurred(System.currentTimeMillis())
|
|
|
|
|
.build();
|
|
|
|
|
//增加启用未启用条件查询
|
|
|
|
|
List<AlertConfig> config = iAlertConfigData.findByDeviceName(device.getDeviceName());
|
|
|
|
|
//在设备列表中,添加了手机号并且选择了通知方式、语音、短信等。其实是添加到了告警事件配置里面。
|
|
|
|
|
|
|
|
|
|
// List<AlertRecord> alerts = idAlertRecordData.selectAlertConfigPage(AlertRecordBo.builder().details(device.getDeviceName()).build());
|
|
|
|
|
System.out.println("设备告警 您的设备【" + device.getDeviceName() + "】触发事件 事件类型为:【" + map.get("eventTypeValue").toString() + "】。");
|
|
|
|
|
if (ObjectUtil.isEmpty(config)) {
|
|
|
|
|
@ -382,12 +379,7 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
executor.execute(() -> {
|
|
|
|
|
List<Rule> rules = ruleMessageHandler.processMessage1(thingModelMessage);
|
|
|
|
|
for (Rule rule : rules) {
|
|
|
|
|
//这里也要加增加启用未启用条件查询
|
|
|
|
|
|
|
|
|
|
List<AlertConfig> config1 = iAlertConfigData.findByRuleInfoIdAndDeviceName(rule.getId(),device.getDeviceName());
|
|
|
|
|
if(CollectionUtils.isEmpty(config1)){
|
|
|
|
|
config1 = iAlertConfigData.findByRuleInfoIdAndDeviceName(rule.getId(),null);
|
|
|
|
|
}
|
|
|
|
|
List<AlertConfig> config1 = iAlertConfigData.findByRuleInfoId(rule.getId());
|
|
|
|
|
for (int i = 0; i < config1.size(); i++) {
|
|
|
|
|
idAlertRecordData.save(AlertRecord.builder()
|
|
|
|
|
.level(config1.get(i).getLevel())
|
|
|
|
|
@ -402,28 +394,28 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
.deptAreaId(device.getDeptAreaId())
|
|
|
|
|
.readFlg(false)
|
|
|
|
|
.alertTime(System.currentTimeMillis())
|
|
|
|
|
.details("您的设备【" + device.getDeviceName() + "】,位置【" + device.getSite() + "】触发事件 事件类型为:【" + map.get("eventTypeValue").toString() + "】。")
|
|
|
|
|
.details("您的设备【" + device.getDeviceName() + "】触发事件 事件类型为:【" + map.get("eventTypeValue").toString() + "】。")
|
|
|
|
|
.build());
|
|
|
|
|
// if (ObjectUtil.isNotEmpty(deviceInfoArrayList1)) {
|
|
|
|
|
// for (int j = 0; j < deviceInfoArrayList1.size(); j++) {
|
|
|
|
|
// String deviceName = deviceInfoArrayList1.get(j).getNodeStatus().equals("1")?device.getDeviceName(): deviceInfoArrayList1.get(j).getNodeDevice();
|
|
|
|
|
// idAlertRecordData.save(AlertRecord.builder()
|
|
|
|
|
// .level(config1.get(i).getLevel())
|
|
|
|
|
// .name(config1.get(i).getName())
|
|
|
|
|
// .reasonForRemovalFlag(0)
|
|
|
|
|
// .productKey(device.getProductKey())
|
|
|
|
|
// .levelStatus(eventTypeValue1)
|
|
|
|
|
// .deviceName(deviceInfoArrayList1.get(j).getDeviceName())
|
|
|
|
|
// .site(deviceInfoArrayList1.get(j).getSite())
|
|
|
|
|
// .tenantId(deviceInfoArrayList1.get(j).getTenantId())
|
|
|
|
|
// .uid(deviceInfoArrayList1.get(j).getUid())
|
|
|
|
|
// .deptAreaId(deviceInfoArrayList1.get(j).getDeptAreaId())
|
|
|
|
|
// .readFlg(false)
|
|
|
|
|
// .alertTime(System.currentTimeMillis())
|
|
|
|
|
// .details("您的设备【" + deviceInfoArrayList1.get(j).getDeviceName() + "】,节点" + deviceInfoArrayList1.get(j).getNode() + "触发事件,事件类型:【联动箱输出】," + "告警设备:" + deviceName)
|
|
|
|
|
// .build());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (ObjectUtil.isNotEmpty(deviceInfoArrayList1)) {
|
|
|
|
|
for (int j = 0; j < deviceInfoArrayList1.size(); j++) {
|
|
|
|
|
String deviceName = deviceInfoArrayList1.get(j).getNodeStatus().equals("1")?device.getDeviceName(): deviceInfoArrayList1.get(j).getNodeDevice();
|
|
|
|
|
idAlertRecordData.save(AlertRecord.builder()
|
|
|
|
|
.level(config1.get(i).getLevel())
|
|
|
|
|
.name(config1.get(i).getName())
|
|
|
|
|
.reasonForRemovalFlag(0)
|
|
|
|
|
.productKey(device.getProductKey())
|
|
|
|
|
.levelStatus(eventTypeValue1)
|
|
|
|
|
.deviceName(deviceInfoArrayList1.get(j).getDeviceName())
|
|
|
|
|
.site(deviceInfoArrayList1.get(j).getSite())
|
|
|
|
|
.tenantId(deviceInfoArrayList1.get(j).getTenantId())
|
|
|
|
|
.uid(deviceInfoArrayList1.get(j).getUid())
|
|
|
|
|
.deptAreaId(deviceInfoArrayList1.get(j).getDeptAreaId())
|
|
|
|
|
.readFlg(false)
|
|
|
|
|
.alertTime(System.currentTimeMillis())
|
|
|
|
|
.details("您的设备【" + deviceInfoArrayList1.get(j).getDeviceName() + "】,节点" + deviceInfoArrayList1.get(j).getNode() + "触发事件,事件类型:【联动箱输出】," + "告警设备:" + deviceName)
|
|
|
|
|
.build());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ruleExecutor.execute1(thingModelMessage, config1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -451,28 +443,28 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
.deptAreaId(device.getDeptAreaId())
|
|
|
|
|
.readFlg(false)
|
|
|
|
|
.alertTime(System.currentTimeMillis())
|
|
|
|
|
.details("您的设备【" + device.getDeviceName() + "】,位置【" + device.getSite() + "】触发事件 事件类型为:【" + map.get("eventTypeValue").toString() + "】。")
|
|
|
|
|
.details("您的设备【" + device.getDeviceName() + "】触发事件 事件类型为:【" + map.get("eventTypeValue").toString() + "】。")
|
|
|
|
|
.build());
|
|
|
|
|
// if (ObjectUtil.isNotEmpty(deviceInfoArrayList1)) {
|
|
|
|
|
// for (int j = 0; j < deviceInfoArrayList1.size(); j++) {
|
|
|
|
|
// String deviceName = deviceInfoArrayList1.get(j).getNodeStatus().equals("1")?device.getDeviceName(): deviceInfoArrayList1.get(j).getNodeDevice();
|
|
|
|
|
// idAlertRecordData.save(AlertRecord.builder()
|
|
|
|
|
// .level(config.get(i).getLevel())
|
|
|
|
|
// .name(config.get(i).getName())
|
|
|
|
|
// .site(deviceInfoArrayList1.get(j).getSite())
|
|
|
|
|
// .reasonForRemovalFlag(0)
|
|
|
|
|
// .productKey(device.getProductKey())
|
|
|
|
|
// .levelStatus(eventTypeValue1)
|
|
|
|
|
// .deviceName(deviceInfoArrayList1.get(j).getDeviceName())
|
|
|
|
|
// .tenantId(deviceInfoArrayList1.get(j).getTenantId())
|
|
|
|
|
// .uid(deviceInfoArrayList1.get(j).getUid())
|
|
|
|
|
// .deptAreaId(deviceInfoArrayList1.get(j).getDeptAreaId())
|
|
|
|
|
// .readFlg(false)
|
|
|
|
|
// .alertTime(System.currentTimeMillis())
|
|
|
|
|
// .details("您的设备【" + deviceInfoArrayList1.get(j).getDeviceName() + "】,节点" + deviceInfoArrayList1.get(j).getNode() + "触发事件,事件类型:【联动箱输出】," + "告警设备:" + deviceName)
|
|
|
|
|
// .build());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (ObjectUtil.isNotEmpty(deviceInfoArrayList1)) {
|
|
|
|
|
for (int j = 0; j < deviceInfoArrayList1.size(); j++) {
|
|
|
|
|
String deviceName = deviceInfoArrayList1.get(j).getNodeStatus().equals("1")?device.getDeviceName(): deviceInfoArrayList1.get(j).getNodeDevice();
|
|
|
|
|
idAlertRecordData.save(AlertRecord.builder()
|
|
|
|
|
.level(config.get(i).getLevel())
|
|
|
|
|
.name(config.get(i).getName())
|
|
|
|
|
.site(deviceInfoArrayList1.get(j).getSite())
|
|
|
|
|
.reasonForRemovalFlag(0)
|
|
|
|
|
.productKey(device.getProductKey())
|
|
|
|
|
.levelStatus(eventTypeValue1)
|
|
|
|
|
.deviceName(deviceInfoArrayList1.get(j).getDeviceName())
|
|
|
|
|
.tenantId(deviceInfoArrayList1.get(j).getTenantId())
|
|
|
|
|
.uid(deviceInfoArrayList1.get(j).getUid())
|
|
|
|
|
.deptAreaId(deviceInfoArrayList1.get(j).getDeptAreaId())
|
|
|
|
|
.readFlg(false)
|
|
|
|
|
.alertTime(System.currentTimeMillis())
|
|
|
|
|
.details("您的设备【" + deviceInfoArrayList1.get(j).getDeviceName() + "】,节点" + deviceInfoArrayList1.get(j).getNode() + "触发事件,事件类型:【联动箱输出】," + "告警设备:" + deviceName)
|
|
|
|
|
.build());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ruleExecutor.execute1(thingModelMessage, config);
|
|
|
|
|
}
|
|
|
|
|
// RuleExecutor ruleExecutor = new RuleExecutor();
|
|
|
|
|
@ -499,21 +491,7 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
flag = false;
|
|
|
|
|
if (deviceInfo2.getNodeOneStatus().equals("1")) {
|
|
|
|
|
//选中的任意一个设备报警就发送联动控制指令
|
|
|
|
|
String[] deviceNames = {
|
|
|
|
|
deviceInfo2.getNodeOneDevice(),
|
|
|
|
|
deviceInfo2.getNodeTwoDevice(),
|
|
|
|
|
deviceInfo2.getNodeThreeDevice(),
|
|
|
|
|
deviceInfo2.getNodeFourDevice(),
|
|
|
|
|
deviceInfo2.getNodeFiveDevice()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boolean matchFound = Arrays.stream(deviceNames)
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.anyMatch(name -> name.equals(device.getDeviceName()));
|
|
|
|
|
|
|
|
|
|
if (matchFound) {
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeOne());
|
|
|
|
|
}
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeOne());
|
|
|
|
|
} else {
|
|
|
|
|
//满足所有的设备告警才触发联动控制
|
|
|
|
|
String[] nodeOneDevice = deviceInfo2.getNodeOneDevice().split(",");
|
|
|
|
|
@ -535,21 +513,7 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
flag = false;
|
|
|
|
|
if (deviceInfo2.getNodeTwoStatus().equals("1")) {
|
|
|
|
|
//选中的任意一个设备报警就发送联动控制指令
|
|
|
|
|
String[] deviceNames = {
|
|
|
|
|
deviceInfo2.getNodeOneDevice(),
|
|
|
|
|
deviceInfo2.getNodeTwoDevice(),
|
|
|
|
|
deviceInfo2.getNodeThreeDevice(),
|
|
|
|
|
deviceInfo2.getNodeFourDevice(),
|
|
|
|
|
deviceInfo2.getNodeFiveDevice()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boolean matchFound = Arrays.stream(deviceNames)
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.anyMatch(name -> name.equals(device.getDeviceName()));
|
|
|
|
|
|
|
|
|
|
if (matchFound) {
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeOne());
|
|
|
|
|
}
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeTwo());
|
|
|
|
|
} else {
|
|
|
|
|
//满足所有的设备告警才触发联动控制
|
|
|
|
|
String[] nodeOneDevice = deviceInfo2.getNodeTwoDevice().split(",");
|
|
|
|
|
@ -568,21 +532,7 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
flag = false;
|
|
|
|
|
if (deviceInfo2.getNodeThreeStatus().equals("1")) {
|
|
|
|
|
//选中的任意一个设备报警就发送联动控制指令
|
|
|
|
|
String[] deviceNames = {
|
|
|
|
|
deviceInfo2.getNodeOneDevice(),
|
|
|
|
|
deviceInfo2.getNodeTwoDevice(),
|
|
|
|
|
deviceInfo2.getNodeThreeDevice(),
|
|
|
|
|
deviceInfo2.getNodeFourDevice(),
|
|
|
|
|
deviceInfo2.getNodeFiveDevice()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boolean matchFound = Arrays.stream(deviceNames)
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.anyMatch(name -> name.equals(device.getDeviceName()));
|
|
|
|
|
|
|
|
|
|
if (matchFound) {
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeOne());
|
|
|
|
|
}
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeThree());
|
|
|
|
|
} else {
|
|
|
|
|
//满足所有的设备告警才触发联动控制
|
|
|
|
|
String[] nodeOneDevice = deviceInfo2.getNodeThreeDevice().split(",");
|
|
|
|
|
@ -601,21 +551,7 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
flag = false;
|
|
|
|
|
if (deviceInfo2.getNodeFourStatus().equals("1")) {
|
|
|
|
|
//选中的任意一个设备报警就发送联动控制指令
|
|
|
|
|
String[] deviceNames = {
|
|
|
|
|
deviceInfo2.getNodeOneDevice(),
|
|
|
|
|
deviceInfo2.getNodeTwoDevice(),
|
|
|
|
|
deviceInfo2.getNodeThreeDevice(),
|
|
|
|
|
deviceInfo2.getNodeFourDevice(),
|
|
|
|
|
deviceInfo2.getNodeFiveDevice()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boolean matchFound = Arrays.stream(deviceNames)
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.anyMatch(name -> name.equals(device.getDeviceName()));
|
|
|
|
|
|
|
|
|
|
if (matchFound) {
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeOne());
|
|
|
|
|
}
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeFour());
|
|
|
|
|
} else {
|
|
|
|
|
//满足所有的设备告警才触发联动控制
|
|
|
|
|
String[] nodeOneDevice = deviceInfo2.getNodeFourDevice().split(",");
|
|
|
|
|
@ -634,21 +570,7 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
flag = false;
|
|
|
|
|
if (deviceInfo2.getNodeFiveStatus().equals("1")) {
|
|
|
|
|
//选中的任意一个设备报警就发送联动控制指令
|
|
|
|
|
String[] deviceNames = {
|
|
|
|
|
deviceInfo2.getNodeOneDevice(),
|
|
|
|
|
deviceInfo2.getNodeTwoDevice(),
|
|
|
|
|
deviceInfo2.getNodeThreeDevice(),
|
|
|
|
|
deviceInfo2.getNodeFourDevice(),
|
|
|
|
|
deviceInfo2.getNodeFiveDevice()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boolean matchFound = Arrays.stream(deviceNames)
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.anyMatch(name -> name.equals(device.getDeviceName()));
|
|
|
|
|
|
|
|
|
|
if (matchFound) {
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeOne());
|
|
|
|
|
}
|
|
|
|
|
flag = deviceLinkageControlSend(deviceInfo2, deviceInfo2.getNodeFive());
|
|
|
|
|
} else {
|
|
|
|
|
//满足所有的设备告警才触发联动控制
|
|
|
|
|
String[] nodeOneDevice = deviceInfo2.getNodeFiveDevice().split(",");
|
|
|
|
|
@ -745,27 +667,12 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
"controlOutput", node + "0001"
|
|
|
|
|
))
|
|
|
|
|
.build();
|
|
|
|
|
idAlertRecordData.save(AlertRecord.builder()
|
|
|
|
|
.level("1")
|
|
|
|
|
.name("联动控制箱下发")
|
|
|
|
|
.reasonForRemovalFlag(0)
|
|
|
|
|
.productKey(device.getProductKey())
|
|
|
|
|
.levelStatus("联动控制箱下发")
|
|
|
|
|
.deviceName(device.getDeviceName())
|
|
|
|
|
.site(device.getSite())
|
|
|
|
|
.tenantId(device.getTenantId())
|
|
|
|
|
.uid(device.getUid())
|
|
|
|
|
.deptAreaId(device.getDeptAreaId())
|
|
|
|
|
.readFlg(false)
|
|
|
|
|
.alertTime(System.currentTimeMillis())
|
|
|
|
|
.details("您的设备【" + device.getDeviceName() + "】,节点" + node + "触发事件,事件类型:【联动箱输出】。")
|
|
|
|
|
.build());
|
|
|
|
|
//联动控制箱下发指令
|
|
|
|
|
deviceService.invoke(thingService);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//浓度变化,事件类型:
|
|
|
|
|
//浓度变化
|
|
|
|
|
public void extractDetectorData(DeviceInfo device, Map<String, Object> baseInfo) {
|
|
|
|
|
for (Map.Entry<String, Object> entry : baseInfo.entrySet()) {
|
|
|
|
|
if (entry.getKey().startsWith("dataDetectorValue")) {
|
|
|
|
|
@ -980,7 +887,7 @@ public class ThingServiceImpl implements IThingService {
|
|
|
|
|
if (productKey != null && device.getProductKey() != null
|
|
|
|
|
&& !device.getProductKey().equals(productKey)) {
|
|
|
|
|
//防止设备变更了产品key
|
|
|
|
|
// device.setProductKey(productKey);
|
|
|
|
|
device.setProductKey(productKey);
|
|
|
|
|
// device.setModel(register.getModel());
|
|
|
|
|
deviceInfoData.save(device);
|
|
|
|
|
}
|
|
|
|
|
|