|  | @@ -288,57 +288,45 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
 | 
											
												
													
														|  |              ReceiveErrorDto.error("报警主机子系统及防区信息为空");
 |  |              ReceiveErrorDto.error("报警主机子系统及防区信息为空");
 | 
											
												
													
														|  |              return;
 |  |              return;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        List<NorthError> errors = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  | -        List<IotAlarmSubsystem> protectionList = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  | -        List<IotAlarmDefenceArea> sensorList = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  | -        List<IotAlarmSubsystem> deviceList = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  | -        //获取机构列表
 |  | 
 | 
											
												
													
														|  | -        final List<SysOrgVO> orgList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
 |  | 
 | 
											
												
													
														|  | -        //获取category列表
 |  | 
 | 
											
												
													
														|  | -        List<MediatorCategory> categorys = categoryService.list();
 |  | 
 | 
											
												
													
														|  |          //查询报警主机主机设备列表
 |  |          //查询报警主机主机设备列表
 | 
											
												
													
														|  |          List<IotDevice> devices = iotDeviceService.findByCategory(CategoryDataEnum.ALARM_HOST_DEVICE.getId());
 |  |          List<IotDevice> devices = iotDeviceService.findByCategory(CategoryDataEnum.ALARM_HOST_DEVICE.getId());
 | 
											
												
													
														|  | -        checkParam(defenceareaList, msgId, errors, orgList, categorys, devices, deviceList, protectionList, sensorList);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        checkParam(defenceareaList, msgId, devices);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    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) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private void checkParam(List<DefenceAreaDto> defenceareaList, String msgId, List<IotDevice> devices) {
 | 
											
												
													
														|  | 
 |  | +        //获取category列表
 | 
											
												
													
														|  | 
 |  | +        List<MediatorCategory> categorys = categoryService.list();
 | 
											
												
													
														|  | 
 |  | +        final List<SysOrgVO> orgList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
 | 
											
												
													
														|  | 
 |  | +        List<NorthError> errors = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +        List<IotAlarmDefenceArea> sensorList = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +        List<IotAlarmSubsystem> protectionList = new ArrayList<>();
 | 
											
												
													
														|  |          NorthError error = null;
 |  |          NorthError error = null;
 | 
											
												
													
														|  |          for (DefenceAreaDto dto : defenceareaList) {
 |  |          for (DefenceAreaDto dto : defenceareaList) {
 | 
											
												
													
														|  | -            SysOrgVO org = null;
 |  | 
 | 
											
												
													
														|  | 
 |  | +            SysOrgVO org;
 | 
											
												
													
														|  |              if (StringUtils.isEmpty(dto.getOrganizationGuid())) {
 |  |              if (StringUtils.isEmpty(dto.getOrganizationGuid())) {
 | 
											
												
													
														|  | -                error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                        , dto, "参数非法:未传organizationGuid");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传organizationGuid");
 | 
											
												
													
														|  |                  errors.add(error);
 |  |                  errors.add(error);
 | 
											
												
													
														|  |                  continue;
 |  |                  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, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                            , dto, "orgGUID:" + dto.getOrganizationGuid() + "不正确");
 |  | 
 | 
											
												
													
														|  | -                    errors.add(error);
 |  | 
 | 
											
												
													
														|  | -                    continue;
 |  | 
 | 
											
												
													
														|  | -                } else {
 |  | 
 | 
											
												
													
														|  | -                    org = orgs.get(0);
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +            final Optional<SysOrgVO> optional = orgList.stream().filter(r -> r.getGuid().equals(dto.getOrganizationGuid())).findFirst();//orgDao.findByGuid(dto.getOrganizationGuid());
 | 
											
												
													
														|  | 
 |  | +            if (!optional.isPresent()) {
 | 
											
												
													
														|  | 
 |  | +                error = new NorthError(msgId, "/api/data/defenceareaList", dto, "orgGUID:" + dto.getOrganizationGuid() + "不正确");
 | 
											
												
													
														|  | 
 |  | +                errors.add(error);
 | 
											
												
													
														|  | 
 |  | +                continue;
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            org = optional.get();
 | 
											
												
													
														|  |              if (StringUtils.isEmpty(dto.getDefenceareaCode())) {
 |  |              if (StringUtils.isEmpty(dto.getDefenceareaCode())) {
 | 
											
												
													
														|  | -                error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                        , dto, "参数非法:未传defenceareaCode");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传defenceareaCode");
 | 
											
												
													
														|  |                  errors.add(error);
 |  |                  errors.add(error);
 | 
											
												
													
														|  |                  continue;
 |  |                  continue;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |              if (StringUtils.isEmpty(dto.getDefenceareaName())) {
 |  |              if (StringUtils.isEmpty(dto.getDefenceareaName())) {
 | 
											
												
													
														|  | -                error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                        , dto, "参数非法:未传defenceareaName");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传defenceareaName");
 | 
											
												
													
														|  |                  errors.add(error);
 |  |                  errors.add(error);
 | 
											
												
													
														|  |                  continue;
 |  |                  continue;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |              if (StringUtils.isEmpty(dto.getAlarmHostCode())) {
 |  |              if (StringUtils.isEmpty(dto.getAlarmHostCode())) {
 | 
											
												
													
														|  | -                error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                        , dto, "参数非法:未传alarmHostCode");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传alarmHostCode");
 | 
											
												
													
														|  |                  errors.add(error);
 |  |                  errors.add(error);
 | 
											
												
													
														|  |                  continue;
 |  |                  continue;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
										
											
												
													
														|  | @@ -351,65 +339,56 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
 | 
											
												
													
														|  |              } else {*/
 |  |              } else {*/
 | 
											
												
													
														|  |              for (SensorDto sensorDto : dto.getSensorArray()) {
 |  |              for (SensorDto sensorDto : dto.getSensorArray()) {
 | 
											
												
													
														|  |                  if (StringUtils.isEmpty(sensorDto.getInputName())) {
 |  |                  if (StringUtils.isEmpty(sensorDto.getInputName())) {
 | 
											
												
													
														|  | -                    error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                            , dto, "参数非法:未传InputName");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传InputName");
 | 
											
												
													
														|  |                      errors.add(error);
 |  |                      errors.add(error);
 | 
											
												
													
														|  |                      continue;
 |  |                      continue;
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                  if (sensorDto.getInputIndex() == null) {
 |  |                  if (sensorDto.getInputIndex() == null) {
 | 
											
												
													
														|  | -                    error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                            , dto, "参数非法:未传InputIndex");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传InputIndex");
 | 
											
												
													
														|  |                      errors.add(error);
 |  |                      errors.add(error);
 | 
											
												
													
														|  |                      continue;
 |  |                      continue;
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                  if (StringUtils.isEmpty(sensorDto.getModuleAddress())) {
 |  |                  if (StringUtils.isEmpty(sensorDto.getModuleAddress())) {
 | 
											
												
													
														|  | -                    error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                            , dto, "参数非法:未传ModuleAddress");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传ModuleAddress");
 | 
											
												
													
														|  |                      errors.add(error);
 |  |                      errors.add(error);
 | 
											
												
													
														|  |                      continue;
 |  |                      continue;
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                  if (StringUtils.isEmpty(sensorDto.getSensorType())) {
 |  |                  if (StringUtils.isEmpty(sensorDto.getSensorType())) {
 | 
											
												
													
														|  | -                    error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                            , dto, "参数非法:未传SensorType");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传SensorType");
 | 
											
												
													
														|  |                      errors.add(error);
 |  |                      errors.add(error);
 | 
											
												
													
														|  |                      continue;
 |  |                      continue;
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                  if (StringUtils.isEmpty(sensorDto.getSensorTypeName())) {
 |  |                  if (StringUtils.isEmpty(sensorDto.getSensorTypeName())) {
 | 
											
												
													
														|  | -                    error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                            , dto, "参数非法:未传SensorTypeName");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:未传SensorTypeName");
 | 
											
												
													
														|  |                      errors.add(error);
 |  |                      errors.add(error);
 | 
											
												
													
														|  | 
 |  | +                    continue;
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |                  List<MediatorCategory> categorysa = categorys.stream().filter(r -> r.getName().equals(sensorDto.getSensorTypeName())).collect(Collectors.toList());//categoryDao.getOne(qw);
 |  |                  List<MediatorCategory> categorysa = categorys.stream().filter(r -> r.getName().equals(sensorDto.getSensorTypeName())).collect(Collectors.toList());//categoryDao.getOne(qw);
 | 
											
												
													
														|  |                  if (categorysa.size() == 0) {
 |  |                  if (categorysa.size() == 0) {
 | 
											
												
													
														|  | -                    error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                            , dto, "参数非法:没有找到设备类型,默认归到其他类型中");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:没有找到设备类型,默认归到其他类型中");
 | 
											
												
													
														|  |                      errors.add(error);
 |  |                      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());
 |  | 
 | 
											
												
													
														|  | 
 |  | +            List<IotDevice> devicesa = devices.stream().filter(r -> r.getEquipmentCode().equals(dto.getAlarmHostCode()) && r.getOrgId().equals(org.getId())).collect(Collectors.toList());
 | 
											
												
													
														|  |              if (devicesa.size() == 0) {
 |  |              if (devicesa.size() == 0) {
 | 
											
												
													
														|  | -                error = new NorthError(msgId, "/api/data/defenceareaList"
 |  | 
 | 
											
												
													
														|  | -                        , dto, "参数非法:没有找到报警主机");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                error = new NorthError(msgId, "/api/data/defenceareaList", dto, "参数非法:没有找到报警主机");
 | 
											
												
													
														|  |                  errors.add(error);
 |  |                  errors.add(error);
 | 
											
												
													
														|  |                  continue;
 |  |                  continue;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              Map<String, Object> map = this.protectionBuild(dto, org);
 |  |              Map<String, Object> map = this.protectionBuild(dto, org);
 | 
											
												
													
														|  |              protectionList.add((IotAlarmSubsystem) map.get("protection"));
 |  |              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);
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +            sensorList.addAll(list);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          northErrorService.saveErrorData(errors);
 |  |          northErrorService.saveErrorData(errors);
 | 
											
												
													
														|  |          baseMapper.updateAllDelete();
 |  |          baseMapper.updateAllDelete();
 | 
											
												
													
														|  |          this.saveOrUpdateBatch(protectionList);
 |  |          this.saveOrUpdateBatch(protectionList);
 | 
											
												
													
														|  |          defenceAreaMapper.delete(new LambdaQueryWrapper<>());
 |  |          defenceAreaMapper.delete(new LambdaQueryWrapper<>());
 | 
											
												
													
														|  | -        defenceAreService.saveOrUpdateBatch(sensorList);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (ObjectUtil.isNotEmpty(sensorList)) {
 | 
											
												
													
														|  | 
 |  | +            defenceAreService.saveOrUpdateBatch(sensorList);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |          this.northStatisticsSyncService.saveOrUpdateBaseCountByDataType(DataType.protectionCount.getIndex(), defenceareaList.size(), true);
 |  |          this.northStatisticsSyncService.saveOrUpdateBaseCountByDataType(DataType.protectionCount.getIndex(), defenceareaList.size(), true);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -441,7 +420,6 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
 | 
											
												
													
														|  |              return map;
 |  |              return map;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          List<IotAlarmDefenceArea> list = new ArrayList<>();
 |  |          List<IotAlarmDefenceArea> list = new ArrayList<>();
 | 
											
												
													
														|  | -        List<IotAlarmDefenceArea> list1 = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  |          List<IotAlarmDefenceArea> sensorList = defenceAreService.findBySubSystemCode(dto.getDefenceareaCode());
 |  |          List<IotAlarmDefenceArea> sensorList = defenceAreService.findBySubSystemCode(dto.getDefenceareaCode());
 | 
											
												
													
														|  |          for (SensorDto sensorDto : dto.getSensorArray()) {
 |  |          for (SensorDto sensorDto : dto.getSensorArray()) {
 | 
											
												
													
														|  |              IotAlarmDefenceArea sensor = new IotAlarmDefenceArea();
 |  |              IotAlarmDefenceArea sensor = new IotAlarmDefenceArea();
 | 
											
										
											
												
													
														|  | @@ -479,7 +457,6 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          map.put("sensorList", list);
 |  |          map.put("sensorList", list);
 | 
											
												
													
														|  | -        map.put("deviceList", list1);
 |  | 
 | 
											
												
													
														|  |          return map;
 |  |          return map;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  }
 |  |  }
 |