|  | @@ -74,6 +74,8 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
 | 
											
												
													
														|  |      private NorthErrorService northErrorService;
 |  |      private NorthErrorService northErrorService;
 | 
											
												
													
														|  |      @Resource
 |  |      @Resource
 | 
											
												
													
														|  |      IotAlarmDefenceAreaMapper defenceAreaMapper;
 |  |      IotAlarmDefenceAreaMapper defenceAreaMapper;
 | 
											
												
													
														|  | 
 |  | +    @Resource
 | 
											
												
													
														|  | 
 |  | +    private IotAlarmSubsystemMapper subsystemMapper;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public IotAlarmSubsystem findByCodeAndOrgId(String defenceAreaCode, Long orgId) {
 |  |      public IotAlarmSubsystem findByCodeAndOrgId(String defenceAreaCode, Long orgId) {
 | 
											
										
											
												
													
														|  | @@ -283,134 +285,123 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
 | 
											
												
													
														|  |          return ReceiveErrorDto.success();
 |  |          return ReceiveErrorDto.success();
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    public ReceiveErrorDto saveAndUpdate(List<DefenceAreaDto> defenceareaList, String msgId) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public void saveAndUpdate(List<DefenceAreaDto> defenceareaList, String msgId) {
 | 
											
												
													
														|  |          if (CollectionUtils.isEmpty(defenceareaList)) {
 |  |          if (CollectionUtils.isEmpty(defenceareaList)) {
 | 
											
												
													
														|  | -            return ReceiveErrorDto.error("报警主机子系统及防区信息为空");
 |  | 
 | 
											
												
													
														|  | 
 |  | +            ReceiveErrorDto.error("报警主机子系统及防区信息为空");
 | 
											
												
													
														|  | 
 |  | +            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);
 |  | 
 | 
											
												
													
														|  | -        return ReceiveErrorDto.success();
 |  | 
 | 
											
												
													
														|  | 
 |  | +        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;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -            if (dto.getSensorArray() == null || dto.getSensorArray().size() == 0) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +            /*if (dto.getSensorArray() == null || dto.getSensorArray().size() == 0) {
 | 
											
												
													
														|  |                  error = new NorthError(msgId, "/api/data/defenceareaList"
 |  |                  error = new NorthError(msgId, "/api/data/defenceareaList"
 | 
											
												
													
														|  |                          , dto, "参数非法:未传sensorArray");
 |  |                          , dto, "参数非法:未传sensorArray");
 | 
											
												
													
														|  |                  errors.add(error);
 |  |                  errors.add(error);
 | 
											
												
													
														|  |                  //continue;
 |  |                  //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);
 |  | 
 | 
											
												
													
														|  | -                    }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -                    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);
 |  | 
 | 
											
												
													
														|  | -                    }
 |  | 
 | 
											
												
													
														|  | 
 |  | +            } else {*/
 | 
											
												
													
														|  | 
 |  | +            if (ObjectUtil.isNull(dto.getSensorArray())) {
 | 
											
												
													
														|  | 
 |  | +                dto.setSensorArray(new ArrayList<>());
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            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);
 | 
											
												
													
														|  | 
 |  | +                    continue;
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +                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());
 |  | 
 | 
											
												
													
														|  | 
 |  | +            // }
 | 
											
												
													
														|  | 
 |  | +            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"));
 |  | 
 | 
											
												
													
														|  | 
 |  | +            IotAlarmSubsystem protection = (IotAlarmSubsystem) map.get("protection");
 | 
											
												
													
														|  | 
 |  | +            if (ObjectUtil.isNotNull(protection)) {
 | 
											
												
													
														|  | 
 |  | +                protectionList.add(protection);
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  |              List<IotAlarmDefenceArea> list = (List<IotAlarmDefenceArea>) map.get("sensorList");
 |  |              List<IotAlarmDefenceArea> list = (List<IotAlarmDefenceArea>) map.get("sensorList");
 | 
											
												
													
														|  |              if (ObjectUtil.isNotEmpty(list)) {
 |  |              if (ObjectUtil.isNotEmpty(list)) {
 | 
											
												
													
														|  |                  sensorList.addAll(list);
 |  |                  sensorList.addAll(list);
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        defenceAreaMapper.delete(new LambdaQueryWrapper<>());
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          northErrorService.saveErrorData(errors);
 |  |          northErrorService.saveErrorData(errors);
 | 
											
												
													
														|  | -        baseMapper.updateAllDelete();
 |  | 
 | 
											
												
													
														|  | -        this.saveOrUpdateBatch(protectionList);
 |  | 
 | 
											
												
													
														|  | -        defenceAreService.saveOrUpdateBatch(sensorList);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        subsystemMapper.updateAllDelete();
 | 
											
												
													
														|  | 
 |  | +        if (ObjectUtil.isNotEmpty(protectionList)) {
 | 
											
												
													
														|  | 
 |  | +            this.saveOrUpdateBatch(protectionList);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        defenceAreaMapper.delete(new LambdaQueryWrapper<>());
 | 
											
												
													
														|  | 
 |  | +        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);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -436,53 +427,49 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
 | 
											
												
													
														|  |          protection.setOrgName(org.getShortName());
 |  |          protection.setOrgName(org.getShortName());
 | 
											
												
													
														|  |          protection.setOrgPath(org.getPath());
 |  |          protection.setOrgPath(org.getPath());
 | 
											
												
													
														|  |          map.put("protection", protection);
 |  |          map.put("protection", protection);
 | 
											
												
													
														|  | 
 |  | +        saveProtectionLog(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> 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);
 |  |                  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);
 | 
											
												
													
														|  |          return map;
 |  |          return map;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  }
 |  |  }
 |