|
|
@@ -22,6 +22,7 @@ import com.xunmei.common.redis.utils.RedisUtils;
|
|
|
import com.xunmei.host.iot.mapper.IotDeviceInfoMapper;
|
|
|
import com.xunmei.host.iot.service.IIotDeviceInfoExtendService;
|
|
|
import com.xunmei.host.iot.service.IIotDeviceInfoService;
|
|
|
+import com.xunmei.host.iot.service.SysDeviceService;
|
|
|
import com.xunmei.host.protection.service.IotAlarmDefenceAreaService;
|
|
|
import com.xunmei.host.protection.service.IotAlarmSubsystemService;
|
|
|
import com.xunmei.host.server.service.IotServerInfoService;
|
|
|
@@ -70,6 +71,9 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
@Autowired
|
|
|
private IotAlarmSubsystemService iotAlarmSubsystemService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysDeviceService sysDeviceService;
|
|
|
+
|
|
|
/**
|
|
|
* 根据设备类型和设备编码,获取设备信息
|
|
|
*
|
|
|
@@ -329,8 +333,13 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
case WebSocketConstants.DEVICES_EVENT:
|
|
|
case WebSocketConstants.GET_DEVICES_SERVICES:
|
|
|
List<DvsBaseInfo> dataList = dataArray.toJavaList(DvsBaseInfo.class);
|
|
|
- handleDvsAndFSUDeviceInfo(dataList, serverInfo);
|
|
|
- handleAlarmHostDeviceInfo(dataList, serverInfo);
|
|
|
+
|
|
|
+ List<IotDeviceInfo> syncToAssetDeviceList = new ArrayList<>();
|
|
|
+ handleDvsAndFSUDeviceInfo(dataList, serverInfo, syncToAssetDeviceList);
|
|
|
+ handleAlarmHostDeviceInfo(dataList, serverInfo, syncToAssetDeviceList);
|
|
|
+
|
|
|
+ handelAssetDeviceInfo(syncToAssetDeviceList);
|
|
|
+
|
|
|
return WebsocketResult.replySuccess(req.getTopic(), req.getId(), req.getProductName(), req.getDeviceName());
|
|
|
case WebSocketConstants.DEVICES_STATUS_EVENT:
|
|
|
List<DeviceStatusInfo> statusInfos = dataArray.toJavaList(DeviceStatusInfo.class);
|
|
|
@@ -342,8 +351,17 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private void handelAssetDeviceInfo(List<IotDeviceInfo> syncToAssetDeviceList) {
|
|
|
+ if (syncToAssetDeviceList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ sysDeviceService.addDevice(syncToAssetDeviceList);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void handleAlarmHostDeviceInfo(List<DvsBaseInfo> dataList, IotServerInfo serverInfo) {
|
|
|
+ public void handleAlarmHostDeviceInfo(List<DvsBaseInfo> dataList, IotServerInfo serverInfo, List<IotDeviceInfo> syncToAssetDeviceList) {
|
|
|
List<DvsBaseInfo> alarmHostList = dataList.stream().filter(r -> ObjectUtil.equal(r.getType(), BaseDeviceTypeEnum.AlarmHost.name())).collect(Collectors.toList());
|
|
|
if (ObjectUtil.isEmpty(alarmHostList)) {
|
|
|
return;
|
|
|
@@ -384,7 +402,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
updateHostInfo(dvsBaseInfo, hostInfo, BaseDeviceTypeEnum.AlarmHost.getCode());
|
|
|
updateHostList.add(hostInfo);
|
|
|
}
|
|
|
-
|
|
|
+ syncToAssetDeviceList.add(hostInfo);
|
|
|
//处理报警主机扩展信息
|
|
|
IotDeviceInfoExtend extend = iIotDeviceInfoExtendService.selectByProductDeviceNameAndToken(serverInfo.getIotCode(), BaseDeviceTypeEnum.AlarmHost.getCode(), dvsBaseInfo.getDeviceCode());
|
|
|
if (extend == null) {
|
|
|
@@ -422,6 +440,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
dealDefenceArea(defenceAreaInfo, defenceArea, serverInfo);
|
|
|
updateDefenceAreaList.add(defenceArea);
|
|
|
}
|
|
|
+ // syncToAssetDeviceList.add(defenceArea);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -457,7 +476,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
- public void handleDvsAndFSUDeviceInfo(List<DvsBaseInfo> dataList, IotServerInfo serverInfo) {
|
|
|
+ public void handleDvsAndFSUDeviceInfo(List<DvsBaseInfo> dataList, IotServerInfo serverInfo, List<IotDeviceInfo> syncToAssetDeviceList) {
|
|
|
|
|
|
//逻辑删除所有设备
|
|
|
deleteDeviceByToken(serverInfo.getIotCode());
|
|
|
@@ -495,6 +514,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
updateHostInfo(dvsBaseInfo, hostInfo, code);
|
|
|
updateHostList.add(hostInfo);
|
|
|
}
|
|
|
+ syncToAssetDeviceList.add(hostInfo);
|
|
|
if (BaseDeviceTypeEnum.Dvs.name().equals(dvsBaseInfo.getType())) {
|
|
|
//处理主机扩展信息
|
|
|
IotDeviceInfoExtend extend = iIotDeviceInfoExtendService.selectByProductDeviceNameAndToken(serverInfo.getIotCode(), BaseDeviceTypeEnum.Dvs.getCode(), dvsBaseInfo.getDeviceCode());
|
|
|
@@ -513,16 +533,21 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
}
|
|
|
//处理通道或者动环传感器信息
|
|
|
for (SubDeviceInfo subDeviceInfo : subDeviceList) {
|
|
|
- String productName = ProductEnums.FSU_GATEWAY.getProductName().contains(dvsBaseInfo.getProductName()) ? subDeviceInfo.getType() : dvsBaseInfo.getProductName();
|
|
|
+ boolean isFusDevice = ProductEnums.FSU_GATEWAY.getProductName().contains(dvsBaseInfo.getProductName());
|
|
|
+ String productName = isFusDevice ? subDeviceInfo.getType() : dvsBaseInfo.getProductName();
|
|
|
IotDeviceInfo channelInfo = selectByTypeAndHostAndCode(serverInfo.getIotCode(), subDeviceInfo.getParentCode(), productName, subDeviceInfo.getDeviceCode());
|
|
|
|
|
|
if (ObjectUtil.isNull(channelInfo)) {
|
|
|
- IotDeviceInfo channel = createChannelInfo(subDeviceInfo, serverInfo, hostInfo);
|
|
|
- addChnnelList.add(channel);
|
|
|
+ channelInfo = createChannelInfo(subDeviceInfo, serverInfo, hostInfo);
|
|
|
+ addChnnelList.add(channelInfo);
|
|
|
} else {
|
|
|
updateChannelInfo(subDeviceInfo, channelInfo, hostInfo);
|
|
|
updateChnnelList.add(channelInfo);
|
|
|
}
|
|
|
+ if (isFusDevice) {
|
|
|
+ syncToAssetDeviceList.add(channelInfo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -766,7 +791,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
|
|
|
final IotServerInfo serverInfo = iotServerInfoService.selectByOrgId(eto.getOrgId());
|
|
|
final String iotCode = serverInfo.getIotCode();
|
|
|
- final String topic = TopicTypeEnums.formatUrl(TopicTypeEnums.PRODUCT_SERVICE_INVOKE.getUrl(),WebSocketConstants.DETECTION_HOST, WebSocketConstants.DETECTION_HOST_DEVICE);
|
|
|
+ final String topic = TopicTypeEnums.formatUrl(TopicTypeEnums.PRODUCT_SERVICE_INVOKE.getUrl(), WebSocketConstants.DETECTION_HOST, WebSocketConstants.DETECTION_HOST_DEVICE);
|
|
|
final JSONObject object = new JSONObject();
|
|
|
object.put("dataType", eto.getDataType());
|
|
|
final WebsocketResult result = IotServerUtils.invokeHostServer(topic, new JSONObject(), WebSocketConstants.DO_WORK, object);
|