| | |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | | import com.sandu.ximon.admin.utils.TaskOrderUtil; |
| | | import com.sandu.ximon.dao.bo.LightTaskStatusAndPole; |
| | | import com.sandu.ximon.dao.domain.Light; |
| | | import com.sandu.ximon.dao.domain.LightTask; |
| | | import com.sandu.ximon.dao.domain.LightTaskPoleRelation; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | |
| | | lightTask.setOpenOrder(param.getOpenOrder()); |
| | | lightTask.setControlOrder(param.getControlOrder()); |
| | | lightTask.setCreateUser(SecurityUtils.getUsername()); |
| | | String framePayload = buildControlFramePayload(param.getOpenOrder(), param.getCloseOrder(), param.getControlOrder(), week); |
| | | lightTask.setFramePayload(framePayload); |
| | | lightTask.setFramePayload(buildControlFramePayload(param.getOpenOrder(), param.getCloseOrder(), param.getControlOrder(), week)); |
| | | if (!save(lightTask)) { |
| | | throw new BusinessException("保存路灯任务失败"); |
| | | } |
| | |
| | | + ", 灯杆ID:" + param.getPoleIdList().toString() |
| | | + ", 控制的灯头地址:" + param.getLightAddress() |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList.toString(), null, "新增路灯任务", content, poleCodeList.toString()); |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "新增路灯任务", content); |
| | | /** |
| | | * 新增路灯任务日志记录结束 |
| | | */ |
| | |
| | | |
| | | String content1 = "{任务ID:" + lightTask.getTaskId() |
| | | + ", 任务名:" + lightTask.getTaskName() |
| | | + "},{内帧指令" + lightTask.getFramePayload() |
| | | + ", 灯杆ID:" + param.getPoleIdList().toString() |
| | | + ", 控制的灯头地址:" + param.getLightAddress() |
| | | + "}," + " 灯杆ID:" + param.getPoleIdList().toString() |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList.toString(), null, "下发路灯任务", content1, poleCodeList.toString()); |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "下发路灯任务", content1); |
| | | /** |
| | | * 下发路灯任务日志记录结束 |
| | | */ |
| | |
| | | throw new BusinessException("编辑任务失败"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑路灯任务日志记录开始 |
| | | */ |
| | | List<String> poleCodeList = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(param.getPoleIdList())) { |
| | | List<Pole> poleList = SpringContextHolder.getBean(PoleService.class).listByIds(param.getPoleIdList()); |
| | | if (CollectionUtil.isNotEmpty(poleList)) { |
| | | poleCodeList = poleList.stream().map(Pole::getDeviceCode).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | String content = "{任务ID:" + taskId |
| | | + ", 任务名:" + lightTask.getTaskName() |
| | | + "},{内帧指令" + lightTask.getFramePayload() |
| | | + ", 灯杆ID:" + param.getPoleIdList().toString() |
| | | + ", 控制的灯头地址:" + param.getLightAddress() |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "编辑路灯任务", content); |
| | | /** |
| | | * 编辑路灯任务日志记录结束 |
| | | */ |
| | | |
| | | List<Long> poleIdList = param.getPoleIdList(); |
| | | if (CollectionUtil.isNotEmpty(poleIdList)) { |
| | | |
| | |
| | | |
| | | // 一个灯杆只能使用一个任务,新任务要覆盖旧任务 |
| | | lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIdList).ne(LightTaskPoleRelation::getTaskId, lightTask.getTaskId())); |
| | | |
| | | /** |
| | | * 下发路灯任务日志记录开始 |
| | | */ |
| | | |
| | | String content1 = "{任务ID:" + lightTask.getTaskId() |
| | | + ", 任务名:" + lightTask.getTaskName() |
| | | + "}," + " 灯杆ID:" + param.getPoleIdList().toString() |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "下发路灯任务", content1); |
| | | /** |
| | | * 下发路灯任务日志记录结束 |
| | | */ |
| | | } |
| | | |
| | | return true; |
| | |
| | | } |
| | | String framePayload = buildControlFramePayload(lightTask.getOpenOrder(), lightTask.getCloseOrder(), lightTask.getControlOrder(), lightTask.getWeek()); |
| | | List<LightTaskPoleRelation> lightTaskPoleRelationList = sendControllerFrame(lightTask, ListUtil.toList(param.getPoleId()), framePayload, lightTask.getLightAdress()); |
| | | |
| | | /** |
| | | * 下发路灯任务日志记录开始 |
| | | */ |
| | | List<String> poleCodeList = new ArrayList<>(); |
| | | List<Pole> list = SpringContextHolder.getBean(PoleService.class).list(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, param.getPoleId())); |
| | | if (CollectionUtil.isNotEmpty(list)) { |
| | | poleCodeList = list.stream().map(Pole::getDeviceCode).collect(Collectors.toList()); |
| | | } |
| | | String content = "{任务ID:" + lightTask.getTaskId() |
| | | + ", 任务名:" + lightTask.getTaskName() |
| | | + "}," + " 灯杆ID:" + param.getPoleId() |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "下发路灯任务", content); |
| | | /** |
| | | * 下发路灯任务日志记录结束 |
| | | */ |
| | | |
| | | |
| | | if (CollectionUtil.isNotEmpty(lightTaskPoleRelationList)) { |
| | | return lightTaskPoleRelationService.update(lightTaskPoleRelationList.get(0), |
| | | Wrappers.lambdaUpdate(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getPoleId, param.getPoleId()) |
| | | .eq(LightTaskPoleRelation::getTaskId, param.getTaskId())); |
| | | } |
| | | |
| | | |
| | | return true; |
| | | } |
| | | } |