Junjie
2023-07-31 21fa85b313c072db15933668fe77995b927b386c
src/main/java/com/zy/common/utils/NyHttpUtils.java
@@ -4,6 +4,8 @@
import com.alibaba.fastjson.JSONObject;
import com.zy.common.model.NavigateNode;
import com.zy.core.model.command.NyShuttleHttpCommand;
import com.zy.core.model.protocol.NyShuttleProtocol;
import java.util.*;
/**
@@ -52,8 +54,8 @@
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "move");//移动命令
        body.put("taskId", wrkNo);//任务号
        body.put("start", start);//起点
        body.put("target", target);//终点
        body.put("start", navigateNodeToPointNode(start));//起点
        body.put("target", navigateNodeToPointNode(target));//终点
        request.setBody(body);
        httpStandard.setRequest(request);
@@ -68,8 +70,8 @@
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", in ? "intoLift" : "outLift");//进出提升机
        body.put("taskId", wrkNo);//任务号
        body.put("start", start);//起点
        body.put("target", target);//终点
        body.put("start", navigateNodeToPointNode(start));//起点
        body.put("target", navigateNodeToPointNode(target));//终点
        request.setBody(body);
        httpStandard.setRequest(request);
@@ -273,22 +275,34 @@
        try {
            String response = new HttpHandler.Builder()
                    .setUri(requestUrl)
                    .setPath("/test")
                    .setPath("/static/readStatus.json")
                    .setJson(JSON.toJSONString(httpCommand))
                    .build()
                    .doPost();
                    .doGet();
            JSONObject jsonObject = JSON.parseObject(response);
            JSONObject request = jsonObject.getJSONObject("request");
            JSONObject body = request.getJSONObject("body");
            if (body.get("result").equals("success")) {
            JSONObject response2 = jsonObject.getJSONObject("response");
            JSONObject body = response2.getJSONObject("body");
            if (body.get("responseType").equals("state")) {//读取状态,不需要判断success
                return body;
            }
            if (body.get("result").equals("success")) {
                return body;
            }
        } catch (Exception e) {
            e.printStackTrace();
//            e.printStackTrace();
        }
        return null;
    }
    //地图节点转换普通节点xyz
    public static NyShuttleProtocol.NyShuttlePointClass navigateNodeToPointNode(NavigateNode node) {
        NyShuttleProtocol.NyShuttlePointClass point = new NyShuttleProtocol.NyShuttlePointClass();
        point.setX(node.getX());
        point.setY(node.getY());
        point.setZ(node.getZ());
        return point;
    }
}