自动化立体仓库 - WCS系统
Junjie
2023-07-26 41ac27fbf8c61af9b9a3bdfa53a8dc9069fa317a
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
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();
    }
 
}