| | |
| | | if (!"0001".equals(param.getLightAddress()) && !"0002".equals(param.getLightAddress())) { |
| | | throw new BusinessException("灯头地址格式不正确"); |
| | | } |
| | | // LightTask lightTask = getById(null); |
| | | |
| | | |
| | | int week = 0; |
| | |
| | | newPoleMap.forEach( |
| | | commend -> { |
| | | //开关灯时间 |
| | | // String s = newLightTask.getOpenOrder() + newLightTask.getCloseOrder(); |
| | | // if (newLightTask.getControlOrder() != null) { |
| | | // //控灯时间 |
| | | // s = s + newLightTask.getControlOrder(); |
| | | // } |
| | | // // 更新系统定时 |
| | | commend.setSysScheduled(JSON.toJSONString(newLightTask)); |
| | | System.out.println(commend.getIssueStatus() + "状态"); |
| | | if (commend.getIssueStatus() == 0) { |
| | |
| | | if (StrUtil.length(param.getControlOrder()) % LightTaskParam.REQUEST_ORDER_LENGTH != 0) { |
| | | throw new BusinessException("灯控命令格式不正确"); |
| | | } |
| | | if (!"0001".equals(param.getLightAddress()) && !"0002".equals(param.getLightAddress())) { |
| | | throw new BusinessException("灯头地址格式不正确"); |
| | | } |
| | | LightTask newLightTask = getById(taskId); |
| | | if (newLightTask == null) { |
| | | throw new BusinessException("找不到路灯任务"); |
| | |
| | | week |= w; |
| | | } |
| | | |
| | | // LightTask newLightTask = new LightTask(); |
| | | newLightTask.setTaskName(param.getTaskName()); |
| | | |
| | | newLightTask.setClientId(clientService.getClientId(SecurityUtils.getUserId())); |
| | |
| | | all.addAll(newPoleFail); |
| | | all.addAll(oldPoleSuccess); |
| | | all.addAll(oldPoleFail); |
| | | all.addAll(closePoleSuccess); |
| | | all.addAll(closePoleFail); |
| | | |
| | | |
| | | if (closePoleFail.size() != 0) { |
| | | List<LightTaskPoleRelation> colesFail = new ArrayList<>(); |
| | | //原来任务中本身就下发失败的任务 即硬件定时为空 编辑后进行关灯操作 可直接剔除任务关系 |
| | | closePoleFail.forEach( |
| | | close -> { |
| | | relations.forEach( |
| | | task -> { |
| | | System.out.println(task.getLightAddress().equals(close.getLightAddress()) + " addressResult"); |
| | | System.out.println(close.getLightAddress() + " close.getLightAddress()"); |
| | | if (task.getLightAddress().equals(close.getLightAddress()) && task.getDeviceCode().equals(close.getDeviceCode()) |
| | | && task.getDeviceScheduled() != null && !task.getDeviceScheduled().isEmpty()) { |
| | | colesFail.add(close); |
| | | } |
| | | } |
| | | ); |
| | | all.addAll(colesFail); |
| | | } |
| | | ); |
| | | |
| | | } |
| | | |
| | | |
| | | if (!all.isEmpty()) { |
| | | List<LightTaskPoleRelation> finalOldRelation = relations; |
| | |
| | | //下发成功 更新系统定时和硬件定时 |
| | | commend.setDeviceScheduled(JSON.toJSONString(newLightTask)); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | //编辑前后所有的灯杆ID集合 |
| | | poleIdList.addAll(oldList); |
| | | List<Long> longs = new ArrayList<>(); |
| | | //去重 |
| | | List<Long> collect = poleIdList.stream().distinct().collect(Collectors.toList()); |
| | | // for (Long item : poleIdList) { |
| | | // if (!poleIdList.contains(item)) { |
| | | // longs.add(item); |
| | | // } |
| | | // } |
| | | if (!collect.isEmpty()) { |
| | | lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class) |
| | | .in(LightTaskPoleRelation::getPoleId, collect).eq(LightTaskPoleRelation::getLightAddress, newLightTask.getLightAdress())); |
| | | |
| | | } |
| | | |
| | | |
| | | if (!all.isEmpty()) { |
| | | b = lightTaskPoleRelationService.saveBatch(all); |
| | |
| | | lightTaskRelationVO.setLightAddress(relation.getLightAddress()); |
| | | lightTaskRelationVO.setIssueStatus(relation.getIssueStatus()); |
| | | lightTaskRelationVO.setPoleId(relation.getPoleId()); |
| | | Pole byId = poleService.getById(relation.getPoleId()); |
| | | if (byId != null) { |
| | | lightTaskRelationVO.setPoleName(byId.getPoleName()); |
| | | } |
| | | |
| | | LightTaskVO sys = JSONObject.parseObject(relation.getSysScheduled(), LightTaskVO.class); |
| | | sys.setWeekList(TaskOrderUtil.parseLightWeek2List(sys.getWeek())); |
| | |
| | | * 下发单个灯杆的任务 |
| | | */ |
| | | public boolean issueLightTask(LightTaskIssueParam param) { |
| | | LightTask lightTask = getById(param.getTaskId()); |
| | | |
| | | LightTaskPoleRelation relation = lightTaskPoleRelationService.getOne(Wrappers.lambdaQuery(LightTaskPoleRelation.class) |
| | | .eq(LightTaskPoleRelation::getPoleId, param.getPoleId()).eq(LightTaskPoleRelation::getTaskId, param.getTaskId())); |
| | | |
| | | if (relation == null) { |
| | | throw new BusinessException("找不到任务关系,无法补发"); |
| | | } |
| | | LightTask lightTask = JSONObject.parseObject(relation.getSysScheduled(), LightTask.class); |
| | | // LightTask lightTask = getById(param.getTaskId()); |
| | | if (lightTask == null) { |
| | | throw new BusinessException("找不到任务"); |
| | | } |
| | | //转换帧指令 |
| | | String framePayload = buildControlFramePayload(lightTask.getOpenOrder(), lightTask.getCloseOrder(), lightTask.getControlOrder(), lightTask.getWeek()); |
| | | //发送rrpc 得到发送结果 |
| | | List<LightTaskPoleRelation> lightTaskPoleRelationList = sendControllerFrame(lightTask, ListUtil.toList(param.getPoleId()), framePayload, lightTask.getLightAdress()); |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | if (CollectionUtil.isNotEmpty(lightTaskPoleRelationList)) { |
| | | return lightTaskPoleRelationService.update(lightTaskPoleRelationList.get(0), Wrappers.lambdaUpdate(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getPoleId, param.getPoleId()).eq(LightTaskPoleRelation::getTaskId, param.getTaskId())); |
| | | } |
| | | |
| | | |
| | | LightTaskPoleRelation lightTaskPoleRelation = lightTaskPoleRelationList.get(0); |
| | | if (lightTaskPoleRelation.getIssueStatus() == 0) { |
| | | //下发成功 更新硬件定时 返回成功 |
| | | relation.setDeviceScheduled(JSON.toJSONString(lightTaskPoleRelation)); |
| | | lightTaskPoleRelationService.updateById(relation); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |