pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandResultCtrl.java
@@ -1,8 +1,10 @@
package com.dy.pipIrrRemote.common;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.mw.protocol.Data;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.command.ComResultWait;
import com.dy.pipIrrGlobal.command.ComSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
@@ -24,15 +26,20 @@
@RequestMapping(path="comRes")
public class CommandResultCtrl extends ComSupport {
    @PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE)
    public BaseResponse<String> receive(@RequestBody Data data) {
        String comId = "0";
        if(data.getCommandId() != null) {
            comId = data.getCommandId();
        }
        CompletableFuture<Data> feature = (CompletableFuture<Data>) features.get(comId);
    public void receive(@RequestBody Data data) {
        JSONObject protocolData = data == null ? null : (JSONObject)data.subData ; //协议数据
        JSONObject codeData = protocolData == null ? null : (protocolData.getJSONObject("subData")) ; //协议功能码数据
        JSONObject job_response = new JSONObject();
        job_response.put("data", codeData==null?protocolData:codeData);
        job_response.put("commandCode", data.code);
        job_response.put("commandId", data.commandId);
        CompletableFuture<JSONObject> feature = (CompletableFuture<JSONObject>) ComResultWait.get(Long.parseLong(data.commandId));
        if(feature != null) {
            feature.complete(data);
            feature.complete(job_response);
        }else{
            //超时,feature被清除了
        }
        return BaseResponseUtils.buildSuccess("ok");
    }
}