| | |
| | | |
| | | /** |
| | | * 新增路灯任务 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | |
| | | newLightTask.setLightAdress(param.getLightAddress()); |
| | | newLightTask.setUpdateTime(LocalDateTime.now()); |
| | | newLightTask.setFramePayload(buildControlFramePayload(param.getOpenOrder(), param.getCloseOrder(), param.getControlOrder(), week)); |
| | | |
| | | if (!save(newLightTask)) { |
| | | throw new BusinessException("保存路灯任务失败"); |
| | | } |
| | |
| | | //传入的灯杆id集合 |
| | | List<Long> poleIdList = param.getPoleIdList(); |
| | | //记录这些灯杆原先的任务 |
| | | List<LightTaskPoleRelation> oldLightTaskStatusAndPoles = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIdList)); |
| | | //记录这些灯杆原先的id |
| | | List<Long> oldList = oldLightTaskStatusAndPoles.stream().map(LightTaskPoleRelation::getPoleId).collect(Collectors.toList()); |
| | | List<LightTaskPoleRelation> oldLightTaskStatusAndPoles; |
| | | if ("FFFF".equals(param.getLightAddress())) { |
| | | oldLightTaskStatusAndPoles = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class) |
| | | .in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, "0001")); |
| | | List<LightTaskPoleRelation> list = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class) |
| | | .in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, "0002")); |
| | | oldLightTaskStatusAndPoles.addAll(list); |
| | | } else { |
| | | oldLightTaskStatusAndPoles = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, param.getLightAddress())); |
| | | } |
| | | |
| | | //判断param.getPoleIdList()中是否有旧的灯杆ID (直接下发) |
| | | List<Long> newPoleIdList = param.getPoleIdList().stream().filter(poleId -> !oldList.contains(poleId)).collect(Collectors.toList()); |
| | | //判断param.getPoleIdList()中是否有新的灯杆ID (覆盖操作) |
| | | List<Long> oldPoleIdList = param.getPoleIdList().stream().filter(poleId -> oldList.contains(poleId)).collect(Collectors.toList()); |
| | | //新增不存在关灯操作 |
| | | /** |
| | | * 重复任务的灯头 |
| | | */ |
| | | List<Long> taskIds = oldLightTaskStatusAndPoles.stream().map(LightTaskPoleRelation::getTaskId).collect(Collectors.toList()); |
| | | List<Long> poleIds = oldLightTaskStatusAndPoles.stream().map(LightTaskPoleRelation::getPoleId).collect(Collectors.toList()); |
| | | //poleIds中重复元素只保留一个 |
| | | taskIds = taskIds.stream().distinct().collect(Collectors.toList()); |
| | | poleIds = poleIds.stream().distinct().collect(Collectors.toList()); |
| | | if (!oldLightTaskStatusAndPoles.isEmpty()) { |
| | | throw new BusinessException("任务中存在已有任务的单灯," + "任务id为{" + taskIds + "}, " |
| | | + "灯杆id为{" + poleIds + "}"); |
| | | } |
| | | |
| | | |
| | | |
| | | List<LightTaskPoleRelation> newPoleMap = new ArrayList<>(); |
| | | if (!newPoleIdList.isEmpty()) { |
| | | if (!poleIdList.isEmpty()) { |
| | | //新灯杆下发新任务 |
| | | newPoleMap = sendControllerFrame(newLightTask, newPoleIdList, newLightTask.getFramePayload(), param.getLightAddress()); |
| | | newPoleMap = sendControllerFrame(newLightTask, poleIdList, newLightTask.getFramePayload(), param.getLightAddress()); |
| | | |
| | | } |
| | | |
| | | List<LightTaskPoleRelation> oldPoleFail = new ArrayList<>(); |
| | | List<LightTaskPoleRelation> oldPoleSuccess = new ArrayList<>(); |
| | | if (!oldPoleIdList.isEmpty()) { |
| | | //覆盖操作灯杆 |
| | | Map<String, List<LightTaskPoleRelation>> oldPoleMap = sendControllerFrame(oldPoleIdList, newLightTask.getFramePayload(), param.getLightAddress()); |
| | | oldPoleFail = oldPoleMap.getOrDefault("fail", new ArrayList<>()); |
| | | oldPoleSuccess = oldPoleMap.getOrDefault("success", new ArrayList<>()); |
| | | } |
| | | //覆盖成功 添加新的任务关系 |
| | | if (!oldPoleSuccess.isEmpty()) { |
| | | oldPoleSuccess.forEach( |
| | | success -> { |
| | | success.setTaskId(newLightTask.getTaskId()); |
| | | } |
| | | ); |
| | | } |
| | | |
| | | //判断旧灯杆覆盖操作是否存在失败 如果存在失败,则保存旧的任务关系 |
| | | List<LightTaskPoleRelation> failOldLightTaskStatusAndPoles = new ArrayList<>(); |
| | | if (!oldPoleFail.isEmpty()) { |
| | | //获取失败的灯杆id |
| | | List<Long> failPoleIdList = oldPoleFail.stream().map(LightTaskPoleRelation::getPoleId).collect(Collectors.toList()); |
| | | //从oldLightTaskStatusAndPoles获取失败的灯杆原先的任务绑定关系. |
| | | failOldLightTaskStatusAndPoles = oldLightTaskStatusAndPoles.stream() |
| | | .filter(lightTaskPoleRelation -> failPoleIdList.contains(lightTaskPoleRelation.getPoleId())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 下发路灯任务日志记录开始 |
| | |
| | | |
| | | List<LightTaskPoleRelation> all = new ArrayList<>(); |
| | | all.addAll(newPoleMap); |
| | | all.addAll(oldPoleSuccess); |
| | | //旧灯杆下发失败不需要保存信管系 |
| | | int num = (int) newPoleMap.stream().filter(lightTaskPoleRelation -> lightTaskPoleRelation.getIssueStatus() != 0).count(); |
| | | |
| | | //删除旧灯杆中覆盖成功的任务id |
| | | List<Long> oldSuccessPoleId = new ArrayList<>(); |
| | | for (LightTaskPoleRelation bean : oldPoleSuccess) { |
| | | oldSuccessPoleId.add(bean.getPoleId()); |
| | | } |
| | | if (!oldSuccessPoleId.isEmpty()) { |
| | | lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, oldSuccessPoleId)); |
| | | |
| | | } |
| | | |
| | | //保存新灯杆以及旧灯杆覆盖成功的任务关系 |
| | | if (!all.isEmpty()) { |
| | | lightTaskPoleRelationService.saveBatch(all); |
| | | } |
| | | |
| | | if (!param.getPoleIdList().isEmpty() && !all.isEmpty() && !oldPoleFail.isEmpty()) { |
| | | return "任务中存在下发异常,异常灯杆原任务关系保留"; |
| | | } else if (!param.getPoleIdList().isEmpty() && all.isEmpty()) { |
| | | if (!param.getPoleIdList().isEmpty() && num == newPoleMap.size()) { |
| | | //所有灯杆都下发失败 新增的任务不保留 |
| | | removeById(newLightTask); |
| | | throw new BusinessException("指令下发失败,请检查灯杆状态后重新新增任务"); |
| | |
| | | |
| | | LightTask newLightTask = new LightTask(); |
| | | newLightTask.setTaskName(param.getTaskName()); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | lightTask.setClientId(clientService.getClientId()); |
| | | lightTask.setUserId(SecurityUtils.getUserId()); |
| | | } |
| | | |
| | | newLightTask.setClientId(clientService.getClientId()); |
| | | newLightTask.setUserId(SecurityUtils.getUserId()); |
| | | |
| | | newLightTask.setWeek(week); |
| | | newLightTask.setCreateUser(SecurityUtils.getUsername()); |
| | | newLightTask.setControlOrder(param.getControlOrder()); |
| | |
| | | |
| | | //编辑后灯杆ID集合 |
| | | List<Long> poleIdList = param.getPoleIdList(); |
| | | if (poleIdList.isEmpty()) { |
| | | throw new BusinessException("编辑任务时请选择灯杆"); |
| | | } |
| | | //记录任务编辑器前灯杆ID集合 |
| | | List<LightTaskStatusAndPole> oldLightTaskStatusAndPoles = lightTaskPoleRelationService.listPoleAndStatusIdByTaskId(taskId); |
| | | List<Long> oldList = oldLightTaskStatusAndPoles.stream().map(LightTaskStatusAndPole::getId).collect(Collectors.toList()); |
| | |
| | | List<Long> oldPoleIdList = param.getPoleIdList().stream().filter(poleId -> oldList.contains(poleId)).collect(Collectors.toList()); |
| | | //oldList中有的灯杆ID,但是param.getPoleIdList()中没有 (关灯操作) |
| | | List<Long> closeLight = oldList.stream().filter(poleId -> !param.getPoleIdList().contains(poleId)).collect(Collectors.toList()); |
| | | |
| | | |
| | | //取出覆盖操作的关系信息 |
| | | //记录这些灯杆原先的任务 |
| | | List<LightTaskPoleRelation> oldRelation = new ArrayList<>(); |
| | | if ("FFFF".equals(param.getLightAddress())) { |
| | | // 灯杆中存在其他任务的灯头 |
| | | if (CollectionUtil.isNotEmpty(oldPoleIdList)) { |
| | | oldRelation = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, oldPoleIdList) |
| | | .ne(LightTaskPoleRelation::getTaskId, taskId).eq(LightTaskPoleRelation::getLightAddress, "0001")); |
| | | List<LightTaskPoleRelation> list = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, oldPoleIdList) |
| | | .ne(LightTaskPoleRelation::getTaskId, taskId).eq(LightTaskPoleRelation::getLightAddress, "0002")); |
| | | oldRelation.addAll(list); |
| | | } |
| | | } else { |
| | | if (CollectionUtil.isNotEmpty(oldPoleIdList)) { |
| | | oldRelation = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, oldPoleIdList) |
| | | .eq(LightTaskPoleRelation::getLightAddress, param.getLightAddress())); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 重复任务的灯头 |
| | | */ |
| | | if (!oldRelation.isEmpty()) { |
| | | List<Long> taskIds = oldRelation.stream().map(LightTaskPoleRelation::getTaskId).collect(Collectors.toList()); |
| | | List<Long> poleIds = oldRelation.stream().map(LightTaskPoleRelation::getPoleId).collect(Collectors.toList()); |
| | | //poleIds中重复元素只保留一个 |
| | | taskIds = taskIds.stream().distinct().collect(Collectors.toList()); |
| | | poleIds = poleIds.stream().distinct().collect(Collectors.toList()); |
| | | throw new BusinessException("任务中存在已有任务的单灯," + "任务id为{" + taskIds + "}, " |
| | | + "灯杆id为{" + poleIds + "}"); |
| | | } |
| | | |
| | | |
| | | List<LightTaskPoleRelation> newPoleAll = new ArrayList<>(); |
| | |
| | | newPoleFail = newPoleMap.getOrDefault("fail", new ArrayList<>()); |
| | | } |
| | | |
| | | List<LightTaskPoleRelation> oldPoleFail = new ArrayList<>(); |
| | | List<LightTaskPoleRelation> oldPoleSuccess = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(oldPoleIdList)) { |
| | | //覆盖操作灯杆 |
| | | Map<String, List<LightTaskPoleRelation>> oldPoleMap = sendControllerFrame(oldPoleIdList, lightTask.getFramePayload(), param.getLightAddress()); |
| | | oldPoleFail = oldPoleMap.getOrDefault("fail", new ArrayList<>()); |
| | | oldPoleSuccess = oldPoleMap.getOrDefault("success", new ArrayList<>()); |
| | | } |
| | | |
| | | List<LightTaskPoleRelation> closePoleFail = new ArrayList<>(); |
| | | List<LightTaskPoleRelation> closePoleSuccess = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(closeLight)) { |
| | | //执行关灯内帧 |
| | | //关灯内帧 |
| | | String framePayloadClose = "7f0000007f173b00"; |
| | | //覆盖操作灯杆 |
| | | Map<String, List<LightTaskPoleRelation>> closePoleMap = sendControllerFrame(closeLight, framePayloadClose, param.getLightAddress()); |
| | |
| | | } |
| | | |
| | | |
| | | if (closePoleFail.size() == 0 && oldPoleFail.size() == 0) { |
| | | if (closePoleFail.size() == 0) { |
| | | //旧任务中全部发送指令成功,更新原本任务中的数据 |
| | | newLightTask.setTaskId(lightTask.getTaskId()); |
| | | updateById(newLightTask); |
| | | } else { |
| | | if (!newPoleSuccess.isEmpty() || !oldPoleSuccess.isEmpty()) { |
| | | if (!newPoleSuccess.isEmpty()) { |
| | | //有失敗的需要保存旧的任務,新增新的任务数据进行保存 |
| | | save(newLightTask); |
| | | } |
| | |
| | | for (LightTaskPoleRelation bean : newPoleSuccess) { |
| | | bean.setTaskId(newLightTask.getTaskId()); |
| | | } |
| | | //成功用新的任务ID |
| | | for (LightTaskPoleRelation bean : oldPoleSuccess) { |
| | | bean.setTaskId(newLightTask.getTaskId()); |
| | | } |
| | | //失败用旧的任务ID |
| | | for (LightTaskPoleRelation bean : oldPoleFail) { |
| | | bean.setTaskId(lightTask.getTaskId()); |
| | | } |
| | | |
| | | //失败用旧的任务ID |
| | | for (LightTaskPoleRelation bean : closePoleFail) { |
| | |
| | | |
| | | List<LightTaskPoleRelation> all = new ArrayList<>(); |
| | | all.addAll(newPoleSuccess); |
| | | all.addAll(oldPoleSuccess); |
| | | all.addAll(oldPoleFail); |
| | | all.addAll(closePoleFail); |
| | | // all.addAll(closePoleFail); |
| | | |
| | | |
| | | List<Long> allPoleId = new ArrayList<>(); |
| | | for (LightTaskPoleRelation bean : newPoleSuccess) { |
| | | allPoleId.add(bean.getPoleId()); |
| | | } |
| | | for (LightTaskPoleRelation bean : oldPoleSuccess) { |
| | | allPoleId.add(bean.getPoleId()); |
| | | } |
| | | for (LightTaskPoleRelation bean : oldPoleFail) { |
| | | allPoleId.add(bean.getPoleId()); |
| | | } |
| | | for (LightTaskPoleRelation bean : closePoleSuccess) { |
| | |
| | | lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, allPoleId)); |
| | | |
| | | } |
| | | |
| | | if (!all.isEmpty()) { |
| | | lightTaskPoleRelationService.saveBatch(all); |
| | | } |
| | |
| | | * 下发路灯任务日志记录结束 |
| | | */ |
| | | |
| | | if (newPoleFail.isEmpty() && oldPoleFail.isEmpty() && closePoleFail.isEmpty()) { |
| | | if (newPoleFail.isEmpty() && closePoleFail.isEmpty()) { |
| | | return "编辑成功"; |
| | | } else if (newPoleSuccess.isEmpty() && oldPoleSuccess.isEmpty() && closePoleSuccess.isEmpty()) { |
| | | throw new BusinessException("编辑失败,请检查编辑的设备是否在线!"); |
| | | } else if (!closePoleFail.isEmpty() || !oldPoleFail.isEmpty()) { |
| | | } else if (newPoleSuccess.isEmpty() && closePoleSuccess.isEmpty()) { |
| | | throw new BusinessException("编辑失败,请检查原有设备和编辑后的设备是否在线!"); |
| | | } else if (!closePoleFail.isEmpty() && !newPoleSuccess.isEmpty()) { |
| | | return "原任务中存在下发异常,原任务保留,创建新任务进行保存"; |
| | | } else if (!newPoleFail.isEmpty()) { |
| | | } else if (!newPoleFail.isEmpty() && !newPoleSuccess.isEmpty()) { |
| | | return "新任务中存在下发异常,忽略异常操作的灯杆"; |
| | | } else { |
| | | return "操作异常"; |
| | |
| | | LightTaskDto lightTaskDto = new LightTaskDto(); |
| | | BeanUtils.copyProperties(lightTask, lightTaskDto); |
| | | lightTaskDto.setWeekList(TaskOrderUtil.parseLightWeek2List(lightTask.getWeek())); |
| | | |
| | | |
| | | //判断灯头是否存在任务 |
| | | List<LightTaskPoleRelation> lightTaskPoleRelationList = lightTaskPoleRelationService.list(Wrappers.<LightTaskPoleRelation>lambdaQuery().eq(LightTaskPoleRelation::getTaskId, lightTask.getTaskId())); |
| | | |
| | | //下发成功的灯杆数量 |
| | | Integer successCount = baseMapper.successCount(lightTaskDto.getTaskId()); |
| | | ///任务中总的灯杆数量 |
| | |
| | | } |
| | | |
| | | for (Pole pole : poles) { |
| | | if (pole.getDeviceCode() == null || pole.getDeviceCode().equals("")) { |
| | | removeById(lightTask.getTaskId()); |
| | | throw new BusinessException("灯杆不存在mac,不能下发任务 请检查灯杆是否存在单灯"); |
| | | } |
| | | LightTaskPoleRelation lightTaskPoleRelation = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation.setPoleId(pole.getId()); |
| | | lightTaskPoleRelation.setTaskId(lightTask.getTaskId()); |
| | | // rrpc 发生定时命令 |
| | | try { |
| | | A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame = sendTimeRRpc(framePayload, pole.getDeviceCode(), lightAddress); |
| | | if (a5LightTimerRespInnerFrame == null) { |
| | | lightTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } else { |
| | | lightTaskPoleRelation.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame.getResponseStatus())); |
| | | if ("FFFF".equals(lightAddress)) { |
| | | LightTaskPoleRelation lightTaskPoleRelation01 = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation01.setPoleId(pole.getId()); |
| | | lightTaskPoleRelation01.setTaskId(lightTask.getTaskId()); |
| | | lightTaskPoleRelation01.setLightAddress("0001"); |
| | | |
| | | LightTaskPoleRelation lightTaskPoleRelation02 = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation02.setPoleId(pole.getId()); |
| | | lightTaskPoleRelation02.setTaskId(lightTask.getTaskId()); |
| | | lightTaskPoleRelation02.setLightAddress("0002"); |
| | | |
| | | // 灯头1 rrpc 发生定时命令 |
| | | try { |
| | | A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame01 = sendTimeRRpc(framePayload, pole.getDeviceCode(), "0001"); |
| | | //灯头1 |
| | | if (a5LightTimerRespInnerFrame01 == null) { |
| | | lightTaskPoleRelation01.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } else { |
| | | lightTaskPoleRelation01.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame01.getResponseStatus())); |
| | | } |
| | | |
| | | } catch (BusinessException e) { |
| | | lightTaskPoleRelation01.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } |
| | | } catch (BusinessException e) { |
| | | lightTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | |
| | | // 灯头2 rrpc 发生定时命令 |
| | | try { |
| | | A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame02 = sendTimeRRpc(framePayload, pole.getDeviceCode(), "0002"); |
| | | //灯头2 |
| | | if (a5LightTimerRespInnerFrame02 == null) { |
| | | lightTaskPoleRelation02.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } else { |
| | | lightTaskPoleRelation02.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame02.getResponseStatus())); |
| | | } |
| | | |
| | | } catch (BusinessException e) { |
| | | lightTaskPoleRelation02.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } |
| | | |
| | | lightTaskPoleRelationList.add(lightTaskPoleRelation01); |
| | | lightTaskPoleRelationList.add(lightTaskPoleRelation02); |
| | | } else { |
| | | lightTaskPoleRelation.setLightAddress(lightAddress); |
| | | // rrpc 发生定时命令 |
| | | try { |
| | | A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame = sendTimeRRpc(framePayload, pole.getDeviceCode(), lightAddress); |
| | | if (a5LightTimerRespInnerFrame == null) { |
| | | lightTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } else { |
| | | lightTaskPoleRelation.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame.getResponseStatus())); |
| | | } |
| | | } catch (BusinessException e) { |
| | | lightTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } |
| | | lightTaskPoleRelationList.add(lightTaskPoleRelation); |
| | | } |
| | | |
| | | lightTaskPoleRelationList.add(lightTaskPoleRelation); |
| | | } |
| | | return lightTaskPoleRelationList; |
| | | } |
| | |
| | | } |
| | | |
| | | for (Pole pole : poles) { |
| | | if (pole.getDeviceCode() == null || pole.getDeviceCode().equals("")) { |
| | | throw new BusinessException("灯杆不存在mac,不能下发任务 请检查灯杆是否存在单灯"); |
| | | } |
| | | LightTaskPoleRelation lightTaskPoleRelation = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation.setPoleId(pole.getId()); |
| | | // lightTaskPoleRelation.setTaskId(lightTask.getTaskId()); |
| | | //关系表插入灯头地址 |
| | | lightTaskPoleRelation.setLightAddress(lightAddress); |
| | | |
| | | |
| | | // rrpc 发生定时命令 |
| | | try { |
| | | A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame = sendTimeRRpc(framePayload, pole.getDeviceCode(), lightAddress); |
| | | if (a5LightTimerRespInnerFrame == null) { |
| | | if ("FFFF".equals(lightAddress)) { |
| | | LightTaskPoleRelation lightTaskPoleRelation01 = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation01.setPoleId(pole.getId()); |
| | | lightTaskPoleRelation01.setLightAddress("0001"); |
| | | |
| | | LightTaskPoleRelation lightTaskPoleRelation02 = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation02.setPoleId(pole.getId()); |
| | | lightTaskPoleRelation02.setLightAddress("0002"); |
| | | |
| | | // 灯头1 rrpc 发生定时命令 |
| | | try { |
| | | A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame01 = sendTimeRRpc(framePayload, pole.getDeviceCode(), "0001"); |
| | | //灯头1 |
| | | if (a5LightTimerRespInnerFrame01 == null) { |
| | | lightTaskPoleRelation01.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(lightTaskPoleRelation01); |
| | | } else { |
| | | lightTaskPoleRelation01.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame01.getResponseStatus())); |
| | | success.add(lightTaskPoleRelation01); |
| | | } |
| | | |
| | | } catch (BusinessException e) { |
| | | lightTaskPoleRelation01.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(lightTaskPoleRelation01); |
| | | } |
| | | |
| | | // 灯头2 rrpc 发生定时命令 |
| | | try { |
| | | A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame02 = sendTimeRRpc(framePayload, pole.getDeviceCode(), "0002"); |
| | | //灯头2 |
| | | if (a5LightTimerRespInnerFrame02 == null) { |
| | | lightTaskPoleRelation02.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(lightTaskPoleRelation02); |
| | | } else { |
| | | lightTaskPoleRelation02.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame02.getResponseStatus())); |
| | | success.add(lightTaskPoleRelation02); |
| | | } |
| | | |
| | | } catch (BusinessException e) { |
| | | lightTaskPoleRelation02.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(lightTaskPoleRelation02); |
| | | } |
| | | |
| | | lightTaskPoleRelationList.add(lightTaskPoleRelation01); |
| | | lightTaskPoleRelationList.add(lightTaskPoleRelation02); |
| | | } else { |
| | | lightTaskPoleRelation.setLightAddress(lightAddress); |
| | | // rrpc 发生定时命令 |
| | | try { |
| | | A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame = sendTimeRRpc(framePayload, pole.getDeviceCode(), lightAddress); |
| | | if (a5LightTimerRespInnerFrame == null) { |
| | | lightTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(lightTaskPoleRelation); |
| | | } else { |
| | | lightTaskPoleRelation.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame.getResponseStatus())); |
| | | success.add(lightTaskPoleRelation); |
| | | } |
| | | } catch (BusinessException e) { |
| | | lightTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(lightTaskPoleRelation); |
| | | } else { |
| | | lightTaskPoleRelation.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame.getResponseStatus())); |
| | | success.add(lightTaskPoleRelation); |
| | | } |
| | | } catch (BusinessException e) { |
| | | lightTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(lightTaskPoleRelation); |
| | | lightTaskPoleRelationList.add(lightTaskPoleRelation); |
| | | } |
| | | |
| | | lightTaskPoleRelationList.add(lightTaskPoleRelation); |
| | | } |
| | | map.put("success", success); |
| | | map.put("fail", fail); |