From 41ac27fbf8c61af9b9a3bdfa53a8dc9069fa317a Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 26 七月 2023 10:44:21 +0800
Subject: [PATCH] 牛眼四向穿梭车HTTP请求工具类
---
src/main/java/com/zy/common/utils/NyHttpUtils.java | 271 +++++++++++++++++++++++++++++++++++++++++++++
src/main/java/com/zy/core/model/command/NyShuttleHttpCommand.java | 40 ++++++
2 files changed, 311 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/NyHttpUtils.java b/src/main/java/com/zy/common/utils/NyHttpUtils.java
new file mode 100644
index 0000000..e34f52e
--- /dev/null
+++ b/src/main/java/com/zy/common/utils/NyHttpUtils.java
@@ -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;
+
+/**
+ * 鐗涚溂鍥涘悜绌挎杞TTP璇锋眰宸ュ叿绫�
+ */
+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;
+ }
+
+ //鑾峰彇鏇存柊灞傚潗鏍嘮(妤煎眰)鍛戒护
+ 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");//鏇存柊灞俍
+ body.put("z", z);//鍧愭爣Z
+ request.setBody(body);
+
+ httpStandard.setRequest(request);
+ return httpStandard;
+ }
+
+ //鑾峰彇璇籉AS鐘舵�佷俊鎭懡浠�
+ 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");//璇籉AS鐘舵�佷俊鎭�
+ 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();
+ }
+
+}
diff --git a/src/main/java/com/zy/core/model/command/NyShuttleHttpCommand.java b/src/main/java/com/zy/core/model/command/NyShuttleHttpCommand.java
new file mode 100644
index 0000000..172c49d
--- /dev/null
+++ b/src/main/java/com/zy/core/model/command/NyShuttleHttpCommand.java
@@ -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;
+ }
+
+ }
+
+
+}
--
Gitblit v1.9.1