|
|
@@ -2,6 +2,7 @@ package com.xunmei.mediator.api.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.constant.CacheConstants;
|
|
|
@@ -28,6 +29,7 @@ import com.xunmei.system.api.dto.DataPageDto;
|
|
|
import com.xunmei.system.api.dto.protection.DefenceAreaDto;
|
|
|
import com.xunmei.system.api.dto.protection.ProtectionEditDto;
|
|
|
import com.xunmei.system.api.dto.protection.ReceiveErrorDto;
|
|
|
+import com.xunmei.system.api.dto.protection.SensorDto;
|
|
|
import com.xunmei.system.api.enums.DataType;
|
|
|
import com.xunmei.system.api.enums.ProtectionStatus;
|
|
|
import com.xunmei.system.api.util.LogUtils;
|
|
|
@@ -346,48 +348,46 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
, dto, "参数非法:未传sensorArray");
|
|
|
errors.add(error);
|
|
|
//continue;
|
|
|
- } else {
|
|
|
- List<SensorDto> sensorArray = dto.getSensorArray();
|
|
|
-
|
|
|
- for (SensorDto sensorDto : sensorArray) {
|
|
|
- if (StringUtils.isEmpty(sensorDto.getInputName())) {
|
|
|
- error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
- , dto, "参数非法:未传InputName");
|
|
|
- errors.add(error);
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (sensorDto.getInputIndex() == null) {
|
|
|
- error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
- , dto, "参数非法:未传InputIndex");
|
|
|
- errors.add(error);
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(sensorDto.getModuleAddress())) {
|
|
|
- error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
- , dto, "参数非法:未传ModuleAddress");
|
|
|
- errors.add(error);
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(sensorDto.getSensorType())) {
|
|
|
- error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
- , dto, "参数非法:未传SensorType");
|
|
|
- errors.add(error);
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(sensorDto.getSensorTypeName())) {
|
|
|
- error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
- , dto, "参数非法:未传SensorTypeName");
|
|
|
- errors.add(error);
|
|
|
- }
|
|
|
+ } else {*/
|
|
|
+ for (SensorDto sensorDto : dto.getSensorArray()) {
|
|
|
+ if (StringUtils.isEmpty(sensorDto.getInputName())) {
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
+ , dto, "参数非法:未传InputName");
|
|
|
+ errors.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (sensorDto.getInputIndex() == null) {
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
+ , dto, "参数非法:未传InputIndex");
|
|
|
+ errors.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(sensorDto.getModuleAddress())) {
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
+ , dto, "参数非法:未传ModuleAddress");
|
|
|
+ errors.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(sensorDto.getSensorType())) {
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
+ , dto, "参数非法:未传SensorType");
|
|
|
+ errors.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(sensorDto.getSensorTypeName())) {
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
+ , dto, "参数非法:未传SensorTypeName");
|
|
|
+ errors.add(error);
|
|
|
+ }
|
|
|
|
|
|
- List<MediatorCategory> categorysa = categorys.stream().filter(r -> r.getName().equals(sensorDto.getSensorTypeName())).collect(Collectors.toList());//categoryDao.getOne(qw);
|
|
|
- if (categorysa.size() == 0) {
|
|
|
- error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
- , dto, "参数非法:没有找到设备类型,默认归到其他类型中");
|
|
|
- errors.add(error);
|
|
|
- }
|
|
|
+ List<MediatorCategory> categorysa = categorys.stream().filter(r -> r.getName().equals(sensorDto.getSensorTypeName())).collect(Collectors.toList());//categoryDao.getOne(qw);
|
|
|
+ if (categorysa.size() == 0) {
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
+ , dto, "参数非法:没有找到设备类型,默认归到其他类型中");
|
|
|
+ errors.add(error);
|
|
|
}
|
|
|
- }*/
|
|
|
+ }
|
|
|
+ // }
|
|
|
SysOrgVO finalOrg = org;
|
|
|
List<IotDevice> devicesa = devices.stream().filter(r -> r.getEquipmentCode().equals(dto.getAlarmHostCode()) && r.getOrgId().equals(finalOrg.getId())).collect(Collectors.toList());
|
|
|
if (devicesa.size() == 0) {
|
|
|
@@ -398,18 +398,18 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
}
|
|
|
Map<String, Object> map = this.protectionBuild(dto, org);
|
|
|
protectionList.add((IotAlarmSubsystem) map.get("protection"));
|
|
|
- /*List<IotAlarmDefenceArea> list = (List<IotAlarmDefenceArea>) map.get("sensorList");
|
|
|
+ List<IotAlarmDefenceArea> list = (List<IotAlarmDefenceArea>) map.get("sensorList");
|
|
|
if (ObjectUtil.isNotEmpty(list)) {
|
|
|
sensorList.addAll(list);
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
northErrorService.saveErrorData(errors);
|
|
|
baseMapper.updateAllDelete();
|
|
|
this.saveOrUpdateBatch(protectionList);
|
|
|
- /*defenceAreaMapper.delete(new LambdaQueryWrapper<>());
|
|
|
- defenceAreService.saveOrUpdateBatch(sensorList);*/
|
|
|
+ defenceAreaMapper.delete(new LambdaQueryWrapper<>());
|
|
|
+ defenceAreService.saveOrUpdateBatch(sensorList);
|
|
|
this.northStatisticsSyncService.saveOrUpdateBaseCountByDataType(DataType.protectionCount.getIndex(), defenceareaList.size(), true);
|
|
|
}
|
|
|
|
|
|
@@ -437,51 +437,49 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
map.put("protection", protection);
|
|
|
|
|
|
|
|
|
- /* List<SensorDto> sensorArray = dto.getSensorArray();
|
|
|
- if (sensorArray != null && sensorArray.size() > 0) {
|
|
|
- List<IotAlarmDefenceArea> list = new ArrayList<>();
|
|
|
- List<IotAlarmDefenceArea> list1 = new ArrayList<>();
|
|
|
- List<IotAlarmDefenceArea> sensorList = defenceAreService.findBySubSystemCode(dto.getDefenceareaCode());
|
|
|
- for (SensorDto sensorDto : sensorArray) {
|
|
|
- IotAlarmDefenceArea sensor = new IotAlarmDefenceArea();
|
|
|
- sensor.setAlarmHostCode(dto.getAlarmHostCode());
|
|
|
- sensor.setSubSystemCode(dto.getDefenceareaCode());
|
|
|
- sensor.setDefenceAreaName(dto.getDefenceareaName());
|
|
|
- sensor.setOrgId(org.getId());
|
|
|
- sensor.setOrgName(org.getShortName());
|
|
|
- sensor.setOrgPath(org.getPath());
|
|
|
- sensor.setOrganizationGuid(dto.getOrganizationGuid());
|
|
|
- sensor.setDefenceAreaIndex(sensorDto.getInputIndex());
|
|
|
- sensor.setDefenceAreaName(sensorDto.getInputName());
|
|
|
- //sensor.setModuleAddress(sensorDto.getModuleAddress());
|
|
|
- sensor.setSensorType(sensorDto.getSensorType());
|
|
|
- sensor.setSensorTypeName(sensorDto.getSensorTypeName());
|
|
|
+ if (ObjectUtil.isEmpty(dto.getSensorArray())) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ List<IotAlarmDefenceArea> list = new ArrayList<>();
|
|
|
+ List<IotAlarmDefenceArea> list1 = new ArrayList<>();
|
|
|
+ List<IotAlarmDefenceArea> sensorList = defenceAreService.findBySubSystemCode(dto.getDefenceareaCode());
|
|
|
+ for (SensorDto sensorDto : dto.getSensorArray()) {
|
|
|
+ IotAlarmDefenceArea sensor = new IotAlarmDefenceArea();
|
|
|
+ sensor.setAlarmHostCode(dto.getAlarmHostCode());
|
|
|
+ sensor.setSubSystemCode(dto.getDefenceareaCode());
|
|
|
+ sensor.setDefenceAreaName(dto.getDefenceareaName());
|
|
|
+ sensor.setOrgId(org.getId());
|
|
|
+ sensor.setOrgName(org.getShortName());
|
|
|
+ sensor.setOrgPath(org.getPath());
|
|
|
+ sensor.setOrganizationGuid(dto.getOrganizationGuid());
|
|
|
+ sensor.setDefenceAreaIndex(sensorDto.getInputIndex());
|
|
|
+ sensor.setDefenceAreaName(sensorDto.getInputName());
|
|
|
+ //sensor.setModuleAddress(sensorDto.getModuleAddress());
|
|
|
+ sensor.setSensorType(sensorDto.getSensorType());
|
|
|
+ sensor.setSensorTypeName(sensorDto.getSensorTypeName());
|
|
|
+ sensor.setDeleted(0);
|
|
|
+ final Optional<IotAlarmDefenceArea> optional = sensorList.stream()
|
|
|
+ .filter(r -> r.getOrgId().equals(org.getId()))
|
|
|
+ .filter(r -> r.getAlarmHostCode().equals(dto.getAlarmHostCode()))
|
|
|
+ .filter(r -> r.getSubSystemCode().equals(dto.getDefenceareaCode()))
|
|
|
+ .filter(r -> r.getDefenceAreaIndex().equals(sensorDto.getInputIndex()))
|
|
|
+ .max(Comparator.comparing(IotAlarmDefenceArea::getUpdateTime));
|
|
|
+ if (optional.isPresent()) {
|
|
|
+ final IotAlarmDefenceArea iotDefenceAre = optional.get();
|
|
|
+ BeanHelper.copyProperties(iotDefenceAre, sensor);
|
|
|
+ iotDefenceAre.setUpdateTime(LocalDateTime.now());
|
|
|
+ list.add(iotDefenceAre);
|
|
|
+ } else {
|
|
|
+ sensor.setId(IDHelper.id());
|
|
|
+ sensor.setState("unKnown");
|
|
|
+ sensor.setStateText("未知");
|
|
|
+ sensor.setCreateTime(LocalDateTime.now());
|
|
|
sensor.setDeleted(0);
|
|
|
- final Optional<IotAlarmDefenceArea> optional = sensorList.stream()
|
|
|
- .filter(r -> r.getOrgId().equals(org.getId()))
|
|
|
- .filter(r -> r.getAlarmHostCode().equals(dto.getAlarmHostCode()))
|
|
|
- .filter(r -> r.getSubSystemCode().equals(dto.getDefenceareaCode()))
|
|
|
- .filter(r -> r.getDefenceAreaIndex().equals(sensorDto.getInputIndex()))
|
|
|
- .max(Comparator.comparing(IotAlarmDefenceArea::getUpdateTime));
|
|
|
- if (optional.isPresent()) {
|
|
|
- final IotAlarmDefenceArea iotDefenceAre = optional.get();
|
|
|
- BeanHelper.copyProperties(iotDefenceAre, sensor);
|
|
|
- iotDefenceAre.setUpdateTime(LocalDateTime.now());
|
|
|
- list.add(iotDefenceAre);
|
|
|
- } else {
|
|
|
- sensor.setId(IDHelper.id());
|
|
|
- sensor.setState("unKnown");
|
|
|
- sensor.setStateText("未知");
|
|
|
- sensor.setCreateTime(LocalDateTime.now());
|
|
|
- sensor.setDeleted(0);
|
|
|
- list.add(sensor);
|
|
|
- }
|
|
|
+ list.add(sensor);
|
|
|
}
|
|
|
-
|
|
|
- map.put("sensorList", list);
|
|
|
- map.put("deviceList", list1);
|
|
|
- }*/
|
|
|
-
|
|
|
+ }
|
|
|
+ map.put("sensorList", list);
|
|
|
+ map.put("deviceList", list1);
|
|
|
return map;
|
|
|
}
|
|
|
}
|