自动化立体仓库 - WCS系统
#
Junjie
2023-08-02 88a1fbd68cfb38c921fbf83c92d17b38a4a5975a
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", navigateNodeToNyPointNode(start));//起点
        body.put("target", navigateNodeToNyPointNode(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", navigateNodeToNyPointNode(start));//起点
        body.put("target", navigateNodeToNyPointNode(target));//终点
        request.setBody(body);
        httpStandard.setRequest(request);
@@ -273,22 +275,35 @@
        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;
    }
    //地图节点转换牛眼节点
    public static NyShuttleProtocol.NyShuttlePointClass navigateNodeToNyPointNode(NavigateNode node) {
        int[] NyPosition = NavigatePositionConvert.WCSXyzToNyXyz(node.getX(), node.getY(), node.getZ());//WCS系统坐标转牛眼坐标
        NyShuttleProtocol.NyShuttlePointClass point = new NyShuttleProtocol.NyShuttlePointClass();
        point.setX(NyPosition[0]);
        point.setY(NyPosition[1]);
        point.setZ(NyPosition[2]);
        return point;
    }
}