| | |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.dto.LightTaskDto; |
| | | import com.sandu.ximon.admin.dto.SingleLightOrderDto; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A5Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightTimerReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.A5LightTimerRespInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.WrapResponseCommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateLightTask(Long taskId, LightTaskParam param) { |
| | | public int updateLightTask(Long taskId, LightTaskParam param) { |
| | | if (StrUtil.length(param.getControlOrder()) % LightTaskParam.REQUEST_ORDER_LENGTH != 0) { |
| | | throw new BusinessException("灯控命令格式不正确"); |
| | | } |
| | |
| | | |
| | | |
| | | List<LightTaskPoleRelation> newPoleAll = new ArrayList<>(); |
| | | List<LightTaskPoleRelation> newPoleSuccess = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(newPoleIdList)) { |
| | | //新灯杆下发新任务 |
| | | Map<String, List<LightTaskPoleRelation>> newPoleMap = sendControllerFrame(newPoleIdList, lightTask.getFramePayload(), param.getLightAddress()); |
| | | |
| | | //newPoleAll集合后面用于存储关系表 |
| | | newPoleAll = newPoleMap.getOrDefault("all", new ArrayList<>()); |
| | | newPoleSuccess = newPoleMap.getOrDefault("success", new ArrayList<>()); |
| | | } |
| | | |
| | | List<LightTaskPoleRelation> oldPoleFail = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | List<LightTaskPoleRelation> closePoleFail = new ArrayList<>(); |
| | | List<LightTaskPoleRelation> closeSuccess = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(closeLight)) { |
| | | //执行关灯内帧 |
| | | String framePayloadClose = "7f0000007f173b00"; |
| | | //覆盖操作灯杆 |
| | | Map<String, List<LightTaskPoleRelation>> closePoleMap = sendControllerFrame(closeLight, framePayloadClose, param.getLightAddress()); |
| | | closePoleFail = closePoleMap.getOrDefault("fail", new ArrayList<>()); |
| | | closeSuccess = closePoleMap.getOrDefault("success", new ArrayList<>()); |
| | | } |
| | | |
| | | //有失敗的需要保存旧的任務 |
| | |
| | | all.addAll(closePoleFail); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | List<Long> allPoleId = new ArrayList<>(); |
| | | allPoleId.addAll(poleIdList); |
| | | allPoleId.addAll(oldList); |
| | |
| | | * 下发路灯任务日志记录结束 |
| | | */ |
| | | |
| | | return true; |
| | | if(oldPoleFail.isEmpty()&&closePoleFail.isEmpty()){ |
| | | //全部成功 |
| | | return 0; |
| | | }else if(!closeLight.isEmpty()||!oldPoleFail.isEmpty()){ |
| | | //关灯失败 或者覆盖任务失败 |
| | | return 1; |
| | | }else if(newPoleSuccess.isEmpty()&&oldPoleSuccess.isEmpty()&&closeSuccess.isEmpty()){ |
| | | //编辑全部失败 |
| | | return 2; |
| | | }else { |
| | | //其他情况 |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | |