2021与蓝度共同重构项目,服务端
liuhaonan
2022-08-15 5c3a5b7bf75718a003de4b167cf9fc81a27f06ee
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
@@ -235,7 +235,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)
@@ -265,15 +265,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 +282,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 +291,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<>());
@@ -407,10 +404,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 +611,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 +705,7 @@
        map.put("success", success);
        map.put("fail", fail);
        map.put("all", lightTaskPoleRelationList);
        log.error("发送控制器帧结果:{}", map);
        return map;
    }