| | |
| | | throw new BusinessException("任务中存在已有任务的单灯," + "任务id为{" + taskIds + "}, " |
| | | + "灯杆id为{" + poleIds + "}"); |
| | | } |
| | | // //记录这些灯杆原先的id |
| | | // List<Long> oldList = oldLightTaskStatusAndPoles.stream().map(LightTaskPoleRelation::getPoleId).collect(Collectors.toList()); |
| | | |
| | | //判断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<LightTaskPoleRelation> newPoleMap = new ArrayList<>(); |
| | |
| | | |
| | | } |
| | | |
| | | // 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()); |
| | | // } |
| | | |
| | | /** |
| | | * 下发路灯任务日志记录开始 |
| | |
| | | all.addAll(newPoleMap); |
| | | int num = (int) newPoleMap.stream().filter(lightTaskPoleRelation -> lightTaskPoleRelation.getIssueStatus() != 0).count(); |
| | | |
| | | // all.addAll(oldPoleSuccess) |
| | | //旧灯杆下发失败不需要保存信管系 |
| | | |
| | | // //删除旧灯杆中覆盖成功的任务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).eq(LightTaskPoleRelation::getLightAddress, "0001")); |
| | | //// lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, oldSuccessPoleId).eq(LightTaskPoleRelation::getLightAddress, "0002")); |
| | | //// } |
| | | |
| | | //保存新灯杆以及旧灯杆覆盖成功的任务关系 |
| | | if (!all.isEmpty()) { |
| | |
| | | //取出覆盖操作的关系信息 |
| | | //记录这些灯杆原先的任务 |
| | | List<LightTaskPoleRelation> oldRelation = new ArrayList<>(); |
| | | if ("FFFF".equals(param.getLightAddress())) { |
| | | if ("FFFF".equals(param.getLightAddress())) { //todo |
| | | // 灯杆中存在其他任务的灯头 |
| | | if (CollectionUtil.isNotEmpty(oldPoleIdList)) { |
| | | oldRelation = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, oldPoleIdList) |
| | |
| | | List<LightTaskPoleRelation> newPoleFail = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(newPoleIdList)) { |
| | | //新灯杆下发新任务 |
| | | Map<String, List<LightTaskPoleRelation>> newPoleMap = sendControllerFrame(newPoleIdList, lightTask.getFramePayload(), param.getLightAddress()); |
| | | Map<String, List<LightTaskPoleRelation>> newPoleMap = sendControllerFrame(newPoleIdList, newLightTask.getFramePayload(), param.getLightAddress()); |
| | | |
| | | //newPoleAll集合后面用于存储关系表 |
| | | newPoleAll = newPoleMap.getOrDefault("all", 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> oldPoleFail = new ArrayList<>(); |
| | | List<LightTaskPoleRelation> oldPoleSuccess = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(oldPoleIdList)) { |
| | | //覆盖操作灯杆 |
| | | Map<String, List<LightTaskPoleRelation>> oldPoleMap = sendControllerFrame(oldPoleIdList, newLightTask.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)) { |
| | | System.out.println(closeLight + "closeLight"); |
| | | if (CollectionUtil.isNotEmpty(closeLight) && closeLight != null && closeLight.get(0) != null) { |
| | | //关灯内帧 |
| | | String framePayloadClose = "7f0000007f173b00"; |
| | | //覆盖操作灯杆 |
| | | String framePayloadClose = "7F0000007F173B00"; |
| | | //关灯操作灯杆 |
| | | Map<String, List<LightTaskPoleRelation>> closePoleMap = sendControllerFrame(closeLight, framePayloadClose, param.getLightAddress()); |
| | | closePoleFail = closePoleMap.getOrDefault("fail", new ArrayList<>()); |
| | | closePoleSuccess = closePoleMap.getOrDefault("success", new ArrayList<>()); |
| | |
| | | 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(oldPoleFail); |
| | | // all.addAll(closePoleFail); |
| | | |
| | | |
| | |
| | | allPoleId.add(bean.getPoleId()); |
| | | } |
| | | for (LightTaskPoleRelation bean : closePoleSuccess) { |
| | | allPoleId.add(bean.getPoleId()); |
| | | } |
| | | for (LightTaskPoleRelation bean : oldPoleSuccess) { |
| | | allPoleId.add(bean.getPoleId()); |
| | | } |
| | | |
| | |
| | | */ |
| | | public A5LightTimerRespInnerFrame sendTimeRRpc(String framePayload, String deviceCode, String lightAddress) { |
| | | IRequestFrame requestFrame = FrameBuilder.builderA5().innerFrame(new A5LightTimerReqInnerFrame(framePayload, lightAddress)).orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).build(); |
| | | System.out.println(requestFrame + " --------requestFrame"); |
| | | |
| | | WrapResponseCommonFrame<A5LightTimerRespInnerFrame> responseCommonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceCode, requestFrame, A5LightTimerRespInnerFrame.class); |
| | | |
| | | System.out.println(responseCommonFrame + " -----------responseCommonFrame"); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceCode, "单灯帧-控灯", requestFrame, responseCommonFrame); |
| | | |
| | | return Optional.ofNullable(responseCommonFrame).map(WrapResponseCommonFrame::getResponseInnerFrame).orElse(null); |
| | | } |
| | | |
| | |
| | | for (Pole pole : poles) { |
| | | if (pole.getDeviceCode() == null || pole.getDeviceCode().equals("")) { |
| | | removeById(lightTask.getTaskId()); |
| | | throw new BusinessException("灯杆不存在mac,不能下发任务 请检查灯杆是否存在单灯"); |
| | | throw new BusinessException("编辑的灯杆或原有任务的灯杆不存在mac,不能下发任务 请检查灯杆是否存在单灯"); |
| | | } |
| | | LightTaskPoleRelation lightTaskPoleRelation = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation.setPoleId(pole.getId()); |
| | |
| | | * @return |
| | | */ |
| | | private Map<String, List<LightTaskPoleRelation>> sendControllerFrame(List<Long> poleIdList, String framePayload, String lightAddress) { |
| | | |
| | | System.out.println("framePayload:" + framePayload); |
| | | List<LightTaskPoleRelation> lightTaskPoleRelationList = new ArrayList<>(); |
| | | //成功 |
| | | List<LightTaskPoleRelation> success = new ArrayList<>(); |
| | |
| | | |
| | | for (Pole pole : poles) { |
| | | if (pole.getDeviceCode() == null || pole.getDeviceCode().equals("")) { |
| | | throw new BusinessException("灯杆不存在mac,不能下发任务 请检查灯杆是否存在单灯"); |
| | | throw new BusinessException("编辑的灯杆或原有任务的灯杆不存在mac,不能下发任务 请检查灯杆是否存在单灯"); |
| | | } |
| | | LightTaskPoleRelation lightTaskPoleRelation = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation.setPoleId(pole.getId()); |
| | |
| | | map.put("success", success); |
| | | map.put("fail", fail); |
| | | map.put("all", lightTaskPoleRelationList); |
| | | log.error("发送控制器帧结果:{}", map); |
| | | return map; |
| | | } |
| | | |