zhubaomin
2025-04-15 70b2c7a1f5b54cf9157d8fce4d6a9b0f2fadaebe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.dy.pipIrrWechat.command;
 
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.mw.protocol.Data;
import com.dy.pipIrrGlobal.command.ComSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.concurrent.CompletableFuture;
 
/**
 * @author ZhuBaoMin
 * @date 2024-05-30 16:07
 * @LastEditTime 2024-05-30 16:07
 * @Description
 */
 
@Slf4j
@RestController
@RequestMapping(path="comRes")
public class CommandResultCtrl extends ComSupport {
    @PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE)
    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(job_response);
        }else{
            feature.complete(new JSONObject());
        }
    }
}