2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-05-16 0a0f2442eedce9879378294ca930c2f113eeddd2
操作记录
已修改1个文件
36 ■■■■ 文件已修改
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
@@ -47,6 +47,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
 * @author chenjiantian
@@ -89,19 +90,27 @@
            throw new BusinessException("保存路灯任务失败");
        }
        List<Pole> poleList = SpringContextHolder.getBean(PoleService.class).listByIds(param.getPoleIdList());
//        SpringContextHolder.getBean(LightService.class).list(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, poleList.st)param.getPoleIdList());
        //根据灯杆code查询路灯信息  路灯code与灯杆code一一对应
        List<Light> lightList = SpringContextHolder.getBean(LightService.class).list(Wrappers.lambdaQuery(Light.class).in(Light::getDeviceCode, poleList.stream().map(Pole::getDeviceCode).toArray()));
        /**
         * 新增路灯任务日志记录开始
         */
        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:" + lightTask.getTaskId()
                + ", 任务名:" + lightTask.getTaskName()
                + "},{内帧指令" + lightTask.getFramePayload()
                + ", 灯杆ID:" + param.getPoleIdList().toString()
                + ", 控制的灯头地址:" + param.getLightAddress()
                + " }";
        StoreOperationRecordsUtils.storeOperationData(null, null, "新增路灯任务", content, null);
        StoreOperationRecordsUtils.storeOperationData(poleCodeList.toString(), null, "新增路灯任务", content, poleCodeList.toString());
        /**
         * 新增路灯任务日志记录结束
         */
        List<Long> poleIdList = param.getPoleIdList();
        if (CollectionUtil.isNotEmpty(poleIdList)) {
@@ -115,6 +124,21 @@
            // 一个灯杆只能使用一个任务,新任务要覆盖旧任务
            lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIdList).ne(LightTaskPoleRelation::getTaskId, lightTask.getTaskId()));
            /**
             * 下发路灯任务日志记录开始
             */
            String content1 = "{任务ID:" + lightTask.getTaskId()
                    + ", 任务名:" + lightTask.getTaskName()
                    + "},{内帧指令" + lightTask.getFramePayload()
                    + ", 灯杆ID:" + param.getPoleIdList().toString()
                    + ", 控制的灯头地址:" + param.getLightAddress()
                    + " }";
            StoreOperationRecordsUtils.storeOperationData(poleCodeList.toString(), null, "下发路灯任务", content1, poleCodeList.toString());
            /**
             * 下发路灯任务日志记录结束
             */
        }
        return true;
    }