liurunyu
2024-07-22 f4921197a4d6d5c58da855fb58870cb6668d7851
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java
@@ -178,8 +178,9 @@
        com.type = commandTypeOuter;
        com.rtuResultSendWebUrl = rtuResultSendWebUrl;
        com.param = param;
        if(param != null) {
            com.param = param;
        }
        return com;
    }
@@ -190,7 +191,7 @@
     * @return
     */
    protected BaseResponse<Data> dealWithCallBack(Long comId, Command com) {
        CompletableFuture<Data> feature = new CompletableFuture<>();
        CompletableFuture<JSONObject> feature = new CompletableFuture<>();
        features.put(comId, feature);
        try {
            // 发送命令
@@ -202,9 +203,10 @@
                return BaseResponseUtils.buildErrorMsg(job_param.getString("message"));
            }
            Data resultData = feature.get(180, TimeUnit.SECONDS);
            JSONObject resultData = feature.get(180, TimeUnit.SECONDS);
            features.remove(comId);
            Long commandId = Long.parseLong(resultData.getCommandId());
            Long commandId = resultData.getLong("commandId");
            if (commandId.equals(comId)) {
                return BaseResponseUtils.buildSuccess(resultData);
            } else {
@@ -283,7 +285,8 @@
            rmCommandHistory.setComId(comId);
            rmCommandHistory.setResult((byte) 0);
            rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory);
            return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
            //return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
            return BaseResponseUtils.buildErrorMsg(response_CallBack.getMsg());
        }
        // 回调超时
@@ -301,27 +304,7 @@
            return BaseResponseUtils.buildErrorMsg(CommandResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage());
        }
        // 回调成功,再判断执行是否成功
        JSONObject job_content = (JSONObject) JSON.toJSON(response_CallBack.getContent());
        JSONObject job_subData = (JSONObject) job_content.getJSONObject("subData").getJSONObject("subData");
        Boolean dealResult = job_subData.getBoolean("success");
        if (!dealResult) {
            /**
             * 执行失败
             * 更新执行结果、返回结果时间、结果内容
             */
            rmCommandHistory = new RmCommandHistory();
            rmCommandHistory.setComId(comId);
            rmCommandHistory.setResult((byte) 0);
            rmCommandHistory.setResultTime(new Date());
            //rmCommandHistory.setResultText((JSONObject)JSON.toJSON(response_CallBack.getContent()));
            rmCommandHistory.setResultText(response_CallBack.getContent().toString());
            rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory);
            return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
        }
        /**
         * 执行成功
         * 如果是开关阀:更改虚拟卡状态:是否使用中、最后操作、最后操作时间
         * 更新执行结果、返回结果时间、结果内容
         * 返回回调内容
@@ -340,8 +323,7 @@
        }
        // 回调返回的内容,回调结果写入命令日志表的任务由中间件完成
        Data myData = (Data) response_CallBack.getContent();
        return BaseResponseUtils.buildSuccess(myData);
        return response_CallBack;
    }
}