2021与蓝度共同重构项目,服务端
liuhaonan
2022-08-16 fd24c689e120d4a4dbd163ee78bc54e44adf949f
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
@@ -126,7 +126,8 @@
                    .in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, "0002"));
            oldLightTaskStatusAndPoles.addAll(list);
        } else {
            oldLightTaskStatusAndPoles = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, param.getLightAddress()));
            oldLightTaskStatusAndPoles = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class)
                    .in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, param.getLightAddress()));
        }
        /**
@@ -235,7 +236,7 @@
        //取出覆盖操作的关系信息
        //记录这些灯杆原先的任务
        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)
@@ -247,7 +248,7 @@
        } else {
            if (CollectionUtil.isNotEmpty(oldPoleIdList)) {
                oldRelation = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, oldPoleIdList)
                        .eq(LightTaskPoleRelation::getLightAddress, param.getLightAddress()));
                        .ne(LightTaskPoleRelation::getTaskId, taskId).eq(LightTaskPoleRelation::getLightAddress, param.getLightAddress()));
            }
        }
@@ -265,15 +266,12 @@
        }
        List<LightTaskPoleRelation> newPoleAll = new ArrayList<>();
        List<LightTaskPoleRelation> newPoleSuccess = new ArrayList<>();
        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<>());
@@ -285,7 +283,7 @@
        List<LightTaskPoleRelation> oldPoleSuccess = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(oldPoleIdList)) {
            //覆盖操作灯杆
            Map<String, List<LightTaskPoleRelation>> oldPoleMap = sendControllerFrame(oldPoleIdList, lightTask.getFramePayload(), param.getLightAddress());
            Map<String, List<LightTaskPoleRelation>> oldPoleMap = sendControllerFrame(oldPoleIdList, newLightTask.getFramePayload(), param.getLightAddress());
            oldPoleFail = oldPoleMap.getOrDefault("fail", new ArrayList<>());
            oldPoleSuccess = oldPoleMap.getOrDefault("success", new ArrayList<>());
        }
@@ -294,9 +292,9 @@
        List<LightTaskPoleRelation> closePoleFail = new ArrayList<>();
        List<LightTaskPoleRelation> closePoleSuccess = new ArrayList<>();
        System.out.println(closeLight + "closeLight");
        if (CollectionUtil.isNotEmpty(closeLight) && closeLight != null&& closeLight.get(0) != null) {
        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<>());
@@ -384,11 +382,11 @@
         * 下发路灯任务日志记录结束
         */
        if (newPoleFail.isEmpty() && closePoleFail.isEmpty()) {
        if (newPoleFail.isEmpty() && closePoleFail.isEmpty() && oldPoleFail.isEmpty()) {
            return "编辑成功";
        } else if (newPoleSuccess.isEmpty() && closePoleSuccess.isEmpty()) {
        } else if (newPoleSuccess.isEmpty() && closePoleSuccess.isEmpty() && oldPoleSuccess.isEmpty()) {
            throw new BusinessException("编辑失败,请检查原有设备和编辑后的设备是否在线!");
        } else if (!closePoleFail.isEmpty() && !newPoleSuccess.isEmpty()) {
        } else if (!closePoleFail.isEmpty() && !newPoleSuccess.isEmpty() && !oldPoleFail.isEmpty()) {
            return "原任务中存在下发异常,原任务保留,创建新任务进行保存";
        } else if (!newPoleFail.isEmpty() && !newPoleSuccess.isEmpty()) {
            return "新任务中存在下发异常,忽略异常操作的灯杆";
@@ -407,10 +405,11 @@
     */
    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);
    }
@@ -613,6 +612,8 @@
     * @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<>();
@@ -705,6 +706,7 @@
        map.put("success", success);
        map.put("fail", fail);
        map.put("all", lightTaskPoleRelationList);
        log.error("发送控制器帧结果:{}", map);
        return map;
    }