自动化立体仓库 - WCS系统
Junjie
2023-07-26 41ac27fbf8c61af9b9a3bdfa53a8dc9069fa317a
牛眼四向穿梭车HTTP请求工具类
2个文件已添加
311 ■■■■■ 已修改文件
src/main/java/com/zy/common/utils/NyHttpUtils.java 271 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/command/NyShuttleHttpCommand.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NyHttpUtils.java
New file
@@ -0,0 +1,271 @@
package com.zy.common.utils;
import com.zy.common.model.NavigateNode;
import com.zy.core.model.command.NyShuttleHttpCommand;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
 * 牛眼四向穿梭车HTTP请求工具类
 */
public class NyHttpUtils {
    //获取HTTP请求标准结构体
    public static NyShuttleHttpCommand getHttpStandard(Integer shuttleNo) {
        NyShuttleHttpCommand httpStandard = new NyShuttleHttpCommand();
        httpStandard.setMsgType("requestMsg");//请求消息
        httpStandard.setRobotId(shuttleNo);//车辆编号
        //设置请求消息
        NyShuttleHttpCommand.NyRequest request = new NyShuttleHttpCommand.NyRequest();
        NyShuttleHttpCommand.NyRequest.NyHeader header = new NyShuttleHttpCommand.NyRequest.NyHeader();
        header.setVersion("1.0");//版本号
        header.setRequestId(getRequestId());//消息编号
        //设置请求头
        request.setHeader(header);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取FAS 手动/自动切换
    public static NyShuttleHttpCommand getFASSwitchCommand(Integer shuttleNo, boolean auto) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", auto ? "switchAuto" : "switchManual");
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取移动请求
    public static NyShuttleHttpCommand getMoveCommand(Integer shuttleNo, Integer wrkNo, NavigateNode start, NavigateNode target) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "move");//移动命令
        body.put("taskId", wrkNo);//任务号
        body.put("start", start);//起点
        body.put("target", target);//终点
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取进出提升机请求
    public static NyShuttleHttpCommand getInOutLiftCommand(Integer shuttleNo, Integer wrkNo, NavigateNode start, NavigateNode target, boolean in) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", in ? "intoLift" : "outLift");//进出提升机
        body.put("taskId", wrkNo);//任务号
        body.put("start", start);//起点
        body.put("target", target);//终点
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取顶升命令
    public static NyShuttleHttpCommand getPalletLiftCommand(Integer shuttleNo, Integer wrkNo, boolean lift) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", lift ? "liftUp" : "liftDown");//顶升或下降命令
        body.put("taskId", wrkNo);//任务号
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取充电命令
    public static NyShuttleHttpCommand getChargeCommand(Integer shuttleNo, Integer wrkNo, boolean charge) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", charge ? "charge" : "stopCharge");//充电或停止充电
        body.put("taskId", wrkNo);//任务号
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取管制命令
    public static NyShuttleHttpCommand getSuspendCommand(Integer shuttleNo, Integer wrkNo, boolean suspend) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", suspend ? "stop" : "resume");//管制或取消管制
        body.put("taskId", wrkNo);//任务号
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取更新层坐标Z(楼层)命令
    public static NyShuttleHttpCommand getUpdateZCommand(Integer shuttleNo, Integer z) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "updateFloor");//更新层Z
        body.put("z", z);//坐标Z
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取读FAS状态信息命令
    public static NyShuttleHttpCommand getReadStatusCommand(Integer shuttleNo) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "readState");//读FAS状态信息
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取更新FAS基准地图命令
    public static NyShuttleHttpCommand getUpdateFASBaseMapCommand(Integer shuttleNo, Integer xBase, Integer yBase, Integer zBase, Integer xEnd, Integer yEnd, Integer zEnd, Integer xBaseCoord, Integer yBaseCoord, Integer xDefaultSpace, Integer yDefaultSpace) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "updateMapStandard");//更新FAS基准地图
        HashMap<String, Object> standard = new HashMap<>();
        standard.put("xBase", xBase);//库位X向基点
        standard.put("yBase", yBase);//库位Y向基点
        standard.put("zBase", zBase);//库位Z向基点
        standard.put("xEnd", xEnd);//库位X向终点
        standard.put("yEnd", yEnd);//库位Y向终点
        standard.put("zEnd", zEnd);//库位Z向终点
        standard.put("xBaseCoord", xBaseCoord);//库位X向基点坐标 单位mm
        standard.put("yBaseCoord", yBaseCoord);//库位Y向基点坐标 单位mm
        standard.put("xDefaultSpace", xDefaultSpace);//库位X向标准间距 单位mm
        standard.put("yDefaultSpace", yDefaultSpace);//库位Y向标准间距 单位mm
        body.put("standard", standard);
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取更新FAS特殊X轴地图命令
    public static NyShuttleHttpCommand getUpdateMapSpecialXAxisCommand(Integer shuttleNo, List<Map<String, Object>> list) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "updateMapSpecialXAxis");//更新FAS特殊X轴地图
        body.put("specialXAxis", list);
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取更新FAS特殊Y轴地图命令
    public static NyShuttleHttpCommand getUpdateMapSpecialYAxisCommand(Integer shuttleNo, List<Map<String, Object>> list) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "updateMapSpecialYAxis");//更新FAS特殊Y轴地图
        body.put("specialYAxis", list);
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取更新FAS特殊库位点地图命令
    public static NyShuttleHttpCommand getUpdateMapSpecialPointCommand(Integer shuttleNo, List<Map<String, Object>> list) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "updateMapSpecialPoint");//更新FAS特殊库位点地图
        body.put("specialPoint", list);
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取更新FAS提升机点位地图命令
    public static NyShuttleHttpCommand getUpdateMapDevicePointCommand(Integer shuttleNo, List<Map<String, Object>> list) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "updateMapDevicePoint");//更新FAS提升机点位地图
        body.put("devicePoint", list);
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取单个RFID录写命令
    public static NyShuttleHttpCommand getWriteSingleRFIDCommand(Integer shuttleNo, Integer xPoint, Integer yPoint, Integer zPoint) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "WriteSingleRFID");//单个RFID录写
        body.put("xPoint", xPoint);//X 点位
        body.put("yPoint", yPoint);//Y 点位
        body.put("zPoint", zPoint);//Z 点位
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取自动录写RFID命令
    public static NyShuttleHttpCommand getAutoWriteRFIDCommand(Integer shuttleNo, Integer dir, Integer xBase, Integer yBase, Integer zBase, Integer pointEnd, List<Integer> specialPoint) {
        NyShuttleHttpCommand httpStandard = getHttpStandard(shuttleNo);
        NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
        HashMap<String, Object> body = new HashMap<>();
        body.put("requestType", "AutoWriteRFID");//自动录写RFID
        body.put("requestCode", dir);//方向xDir/yDir
        body.put("xBase", xBase);//X 起始点位
        body.put("yBase", yBase);//Y 起始点位
        body.put("zBase", zBase);//Z 起始点位
        body.put("pointEnd", pointEnd);//终点坐标 根据requestCode来决定终点坐标的方向
        body.put("specialPoint", specialPoint);//特殊点位过程中不需要录制的RFID点位
        request.setBody(body);
        httpStandard.setRequest(request);
        return httpStandard;
    }
    //获取请求编号
    public static Integer getRequestId() {
        Random random = new Random();
        return random.nextInt();
    }
}
src/main/java/com/zy/core/model/command/NyShuttleHttpCommand.java
New file
@@ -0,0 +1,40 @@
package com.zy.core.model.command;
import lombok.Data;
import java.util.Map;
@Data
public class NyShuttleHttpCommand {
    //消息类型
    private String msgType;
    //车辆编号
    private Integer robotId;
    //请求消息
    private NyRequest request;
    @Data
    public static class NyRequest {
        //消息头
        private NyHeader header;
        //消息体
        private Map<String, Object> body;
        //HTTP请求头
        @Data
        public static class NyHeader {
            //请求编号,唯一编号
            private Integer requestId;
            //版本号
            private String version;
        }
    }
}