|  |  |  | 
|---|
|  |  |  | 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.ComSupport; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.http.MediaType; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | 
|---|
|  |  |  | @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 job_data = (JSONObject) JSON.toJSON(data); | 
|---|
|  |  |  | String job_dataS = job_data.toJSONString(); | 
|---|
|  |  |  | JSONObject job_subData = job_data.getJSONObject("subData").getJSONObject("subData"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JSONObject job_response = new JSONObject(); | 
|---|
|  |  |  | job_response.put("data", job_subData); | 
|---|
|  |  |  | job_response.put("commandCode", job_data.getString("code")); | 
|---|
|  |  |  | job_response.put("commandId", job_data.getString("commandId")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CompletableFuture<JSONObject> feature = (CompletableFuture<JSONObject>) features.get(job_data.getLong("commandId")); | 
|---|
|  |  |  | if(feature != null) { | 
|---|
|  |  |  | feature.complete(data); | 
|---|
|  |  |  | feature.complete(job_response); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | feature.complete(new JSONObject()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess("ok"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|