|
|
@@ -2,8 +2,6 @@ package com.xunmei.mediator.api.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-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;
|
|
|
@@ -18,6 +16,7 @@ import com.xunmei.common.core.enums.CategoryDataEnum;
|
|
|
import com.xunmei.common.core.util.BeanHelper;
|
|
|
import com.xunmei.common.core.utils.IDHelper;
|
|
|
import com.xunmei.common.redis.utils.RedisUtils;
|
|
|
+import com.xunmei.mediator.api.mapper.IotAlarmDefenceAreaMapper;
|
|
|
import com.xunmei.mediator.api.mapper.IotAlarmSubsystemMapper;
|
|
|
import com.xunmei.mediator.api.mapper.ProtectionLogMapper;
|
|
|
import com.xunmei.mediator.api.service.*;
|
|
|
@@ -29,8 +28,6 @@ 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.AlarmRuleExpressOperateEnum;
|
|
|
import com.xunmei.system.api.enums.DataType;
|
|
|
import com.xunmei.system.api.enums.ProtectionStatus;
|
|
|
import com.xunmei.system.api.util.LogUtils;
|
|
|
@@ -43,7 +40,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -74,6 +70,8 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
private IotAlarmDefenceAreaService defenceAreService;
|
|
|
@Resource
|
|
|
private NorthErrorService northErrorService;
|
|
|
+ @Resource
|
|
|
+ IotAlarmDefenceAreaMapper defenceAreaMapper;
|
|
|
|
|
|
@Override
|
|
|
public IotAlarmSubsystem findByCodeAndOrgId(String defenceAreaCode, Long orgId) {
|
|
|
@@ -84,7 +82,7 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ReceiveErrorDto saveData(ProtectionEditDto protectionEditDto, String msgId, String branchId) {
|
|
|
+ public ReceiveErrorDto saveData(ProtectionEditDto protectionEditDto, String msgId) {
|
|
|
|
|
|
ReceiveErrorDto result = new ReceiveErrorDto();
|
|
|
String organizationGuid = protectionEditDto.getOrganizationGuid();
|
|
|
@@ -125,7 +123,7 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
|
|
|
SysOrg org = orgService.findByCode(organizationGuid, SecurityConstants.INNER);
|
|
|
if (org == null) {
|
|
|
- NorthError error = new NorthError(msgId, branchId, "/status/defencearea"
|
|
|
+ NorthError error = new NorthError(msgId, "/status/defencearea"
|
|
|
, protectionEditDto, "orgGUID:" + organizationGuid + "不正确");
|
|
|
northErrorService.saveError(error);
|
|
|
return result;
|
|
|
@@ -197,6 +195,8 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
protection.setOrgName(org.getShortName());
|
|
|
protection.setOrgPath(org.getPath());
|
|
|
protection.setAlarmHostCode(protectionEditDto.getAlarmHostCode());
|
|
|
+ protection.setStatusUpdatorId(null);
|
|
|
+ protection.setStatusUpdatorName(null);
|
|
|
this.saveOrUpdate(protection);
|
|
|
this.northStatisticsSyncService.saveOrUpdateBusinessCountByDateAndDataType(DateUtil.today(), DataType.protectionStatusCount.getIndex(), 1L);
|
|
|
this.saveProtectionLog(protection);
|
|
|
@@ -255,7 +255,7 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ReceiveErrorDto defenceAreaList(DataPageDto<DefenceAreaDto> request, String branchId, String msgId) {
|
|
|
+ public ReceiveErrorDto defenceAreaList(DataPageDto<DefenceAreaDto> request, String msgId) {
|
|
|
String packageGuid = request.getPackageGuid();
|
|
|
if (StringUtils.isEmpty(packageGuid)) {
|
|
|
return ReceiveErrorDto.error("packageGuid参数非法");
|
|
|
@@ -268,7 +268,7 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
if (CollectionUtils.isEmpty(request.getData())) {
|
|
|
return ReceiveErrorDto.error("报警主机子系统及防区信息为空");
|
|
|
}
|
|
|
- final List<DefenceAreaDto> defenceareaList = RedisCheckRepeatDataUtil.isCompleted(request,DefenceAreaDto.class);
|
|
|
+ final List<DefenceAreaDto> defenceareaList = RedisCheckRepeatDataUtil.isCompleted(request, DefenceAreaDto.class);
|
|
|
LogUtils.BASE_INFO_DEFENCEAREA.info("判断是否获取全部报警主机子系统及防区信息分页数据:{}", defenceareaList.size() > 0);
|
|
|
if (ObjectUtil.isEmpty(defenceareaList)) {
|
|
|
return ReceiveErrorDto.error("尚未获取全部报警主机子系统及防区信息分页数据,暂不处理!");
|
|
|
@@ -276,14 +276,15 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
LogUtils.BASE_INFO_DEFENCEAREA.info("获取全部的报警主机子系统及防区信息,开始数据处理界面!");
|
|
|
this.northStatisticsSyncService.saveOrUpdateBaseCountByDataType(DataType.protectionCount.getIndex(), defenceareaList.size(), false);
|
|
|
new Thread(() -> {
|
|
|
- this.saveAndUpdate(defenceareaList, branchId, msgId);
|
|
|
+ this.saveAndUpdate(defenceareaList, msgId);
|
|
|
}).start();
|
|
|
return ReceiveErrorDto.success();
|
|
|
}
|
|
|
|
|
|
- public ReceiveErrorDto saveAndUpdate(List<DefenceAreaDto> defenceareaList, String branchId, String msgId) {
|
|
|
+ public void saveAndUpdate(List<DefenceAreaDto> defenceareaList, String msgId) {
|
|
|
if (CollectionUtils.isEmpty(defenceareaList)) {
|
|
|
- return ReceiveErrorDto.error("报警主机子系统及防区信息为空");
|
|
|
+ ReceiveErrorDto.error("报警主机子系统及防区信息为空");
|
|
|
+ return;
|
|
|
}
|
|
|
List<NorthError> errors = new ArrayList<>();
|
|
|
List<IotAlarmSubsystem> protectionList = new ArrayList<>();
|
|
|
@@ -295,23 +296,22 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
List<MediatorCategory> categorys = categoryService.list();
|
|
|
//查询报警主机主机设备列表
|
|
|
List<IotDevice> devices = iotDeviceService.findByCategory(CategoryDataEnum.ALARM_HOST_DEVICE.getId());
|
|
|
- checkParam(defenceareaList, branchId, msgId, errors, orgList, categorys, devices, deviceList, protectionList, sensorList);
|
|
|
- return ReceiveErrorDto.success();
|
|
|
+ checkParam(defenceareaList, msgId, errors, orgList, categorys, devices, deviceList, protectionList, sensorList);
|
|
|
}
|
|
|
|
|
|
- private void checkParam(List<DefenceAreaDto> defenceareaList, String branchId, String msgId, List<NorthError> errors, List<SysOrgVO> orgList, List<MediatorCategory> categorys, List<IotDevice> devices, List<IotAlarmSubsystem> deviceList, List<IotAlarmSubsystem> protectionList, List<IotAlarmDefenceArea> sensorList) {
|
|
|
+ private void checkParam(List<DefenceAreaDto> defenceareaList, String msgId, List<NorthError> errors, List<SysOrgVO> orgList, List<MediatorCategory> categorys, List<IotDevice> devices, List<IotAlarmSubsystem> deviceList, List<IotAlarmSubsystem> protectionList, List<IotAlarmDefenceArea> sensorList) {
|
|
|
NorthError error = null;
|
|
|
for (DefenceAreaDto dto : defenceareaList) {
|
|
|
SysOrgVO org = null;
|
|
|
if (StringUtils.isEmpty(dto.getOrganizationGuid())) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传organizationGuid");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
} else {
|
|
|
List<SysOrgVO> orgs = orgList.stream().filter(r -> r.getGuid().equals(dto.getOrganizationGuid())).collect(Collectors.toList()); //orgDao.findByGuid(dto.getOrganizationGuid());
|
|
|
if (orgs.size() == 0) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "orgGUID:" + dto.getOrganizationGuid() + "不正确");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
@@ -321,28 +321,28 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(dto.getDefenceareaCode())) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传defenceareaCode");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(dto.getDefenceareaName())) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传defenceareaName");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(dto.getAlarmHostCode())) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传alarmHostCode");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (dto.getSensorArray() == null || dto.getSensorArray().size() == 0) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ /*if (dto.getSensorArray() == null || dto.getSensorArray().size() == 0) {
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传sensorArray");
|
|
|
errors.add(error);
|
|
|
//continue;
|
|
|
@@ -351,64 +351,65 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
|
|
|
for (SensorDto sensorDto : sensorArray) {
|
|
|
if (StringUtils.isEmpty(sensorDto.getInputName())) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传InputName");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
if (sensorDto.getInputIndex() == null) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传InputIndex");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
if (StringUtils.isEmpty(sensorDto.getModuleAddress())) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传ModuleAddress");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
if (StringUtils.isEmpty(sensorDto.getSensorType())) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:未传SensorType");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
if (StringUtils.isEmpty(sensorDto.getSensorTypeName())) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ 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, branchId, "/api/data/defenceareaList"
|
|
|
+ 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) {
|
|
|
- error = new NorthError(msgId, branchId, "/api/data/defenceareaList"
|
|
|
+ error = new NorthError(msgId, "/api/data/defenceareaList"
|
|
|
, dto, "参数非法:没有找到报警主机");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
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);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
}
|
|
|
- defenceAreService.remove(new LambdaQueryWrapper<>());
|
|
|
+
|
|
|
northErrorService.saveErrorData(errors);
|
|
|
baseMapper.updateAllDelete();
|
|
|
this.saveOrUpdateBatch(protectionList);
|
|
|
- defenceAreService.saveOrUpdateBatch(sensorList);
|
|
|
+ /*defenceAreaMapper.delete(new LambdaQueryWrapper<>());
|
|
|
+ defenceAreService.saveOrUpdateBatch(sensorList);*/
|
|
|
this.northStatisticsSyncService.saveOrUpdateBaseCountByDataType(DataType.protectionCount.getIndex(), defenceareaList.size(), true);
|
|
|
}
|
|
|
|
|
|
@@ -436,7 +437,7 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
map.put("protection", protection);
|
|
|
|
|
|
|
|
|
- List<SensorDto> sensorArray = dto.getSensorArray();
|
|
|
+ /* List<SensorDto> sensorArray = dto.getSensorArray();
|
|
|
if (sensorArray != null && sensorArray.size() > 0) {
|
|
|
List<IotAlarmDefenceArea> list = new ArrayList<>();
|
|
|
List<IotAlarmDefenceArea> list1 = new ArrayList<>();
|
|
|
@@ -479,7 +480,7 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
|
|
|
map.put("sensorList", list);
|
|
|
map.put("deviceList", list1);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
return map;
|
|
|
}
|