From 303468c3060dd53003ea9e06c6f27478f8e151ba Mon Sep 17 00:00:00 2001
From: whycxzp <glperry@163.com>
Date: 星期五, 21 三月 2025 14:50:31 +0800
Subject: [PATCH] 消防机器人相关代码

---
 src/main/java/com/whyc/dto/WmsPalletDto.java                        |    6 +-
 src/main/java/com/whyc/service/FireRobotService.java                |   55 +++++++++++++++++++++++++++
 src/main/java/com/whyc/service/WmsService.java                      |    4 --
 src/main/java/com/whyc/controller/InterfaceFireRobotController.java |   46 +++++++++++++++++++++++
 4 files changed, 104 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/whyc/controller/InterfaceFireRobotController.java b/src/main/java/com/whyc/controller/InterfaceFireRobotController.java
new file mode 100644
index 0000000..ed5e418
--- /dev/null
+++ b/src/main/java/com/whyc/controller/InterfaceFireRobotController.java
@@ -0,0 +1,46 @@
+package com.whyc.controller;
+
+import com.whyc.dto.Response;
+import com.whyc.dto.WmsPalletDto;
+import com.whyc.service.FireRobotService;
+import com.whyc.service.WmsService;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@Api(tags = "娑堥槻鏈哄櫒浜烘帴鍙�")
+@RequestMapping("fireRobot")
+public class InterfaceFireRobotController {
+
+    @Autowired
+    private FireRobotService service;
+
+    /**
+     * opendoor 鎵撳紑鍗峰笜闂ㄣ�乧losedoor 鍏抽棴鍗峰笜闂紱openfire 鎵撳紑涓冩盁涓欑兎鐏伀鍣ㄣ�乧losefire 鍏抽棴涓冩盁涓欑兎鐏伀鍣紱
+     * API:http://192.168.10.45:8085/ControlInterfaceHandler?command=opendoor
+     * @return
+     */
+    @PostMapping("control")
+    public Response control(@RequestParam String command){
+
+        return service.control(command);
+    }
+
+    /**
+     * 鎸囧畾浠诲姟鐐瑰贰妫�鎺ュ彛绀轰緥
+     * API:http://192.168.10.45:8085/SpecifyTask?interval=0-1&progress=88&direction=0
+     * 璇锋眰鍙傛暟	鍙傛暟1	interval(string)锛氬贰妫�鎴块棿鍖洪棿	鏄�	ON
+     * 	鍙傛暟2	progress(int)锛氬贰妫�浣嶇疆鐧惧垎姣�	鏄�
+     * 	鍙傛暟3	direction(int)锛氬贰妫�鏂瑰悜	鏄�
+     * 	鍙傛暟绀轰緥
+     *
+     * ["interval 鏍煎紡绀轰緥锛�0-1 ; progress 蹇呴』鏄� 0-100 鐨勬暣鏁�; direction 蹇呴』鏄� 0 鎴� 1]
+     */
+    @PostMapping("specifyTask")
+    public Response specifyTask(@RequestParam String interval,@RequestParam Integer progress,@RequestParam Integer direction){
+
+        return service.specifyTask(interval,progress,direction);
+    }
+
+}
diff --git a/src/main/java/com/whyc/dto/WmsPalletDto.java b/src/main/java/com/whyc/dto/WmsPalletDto.java
index 7834ff0..94748b9 100644
--- a/src/main/java/com/whyc/dto/WmsPalletDto.java
+++ b/src/main/java/com/whyc/dto/WmsPalletDto.java
@@ -8,7 +8,7 @@
 public class WmsPalletDto {
     private Integer des;
     private List<String> pallets;
-    private List<Integer> activateParameter;
+    private List<String> activateParameter;
 
     public Integer getDes() {
         return des;
@@ -26,11 +26,11 @@
         this.pallets = pallets;
     }
 
-    public List<Integer> getActivateParameter() {
+    public List<String> getActivateParameter() {
         return activateParameter;
     }
 
-    public void setActivateParameter(List<Integer> activateParameter) {
+    public void setActivateParameter(List<String> activateParameter) {
         this.activateParameter = activateParameter;
     }
 }
diff --git a/src/main/java/com/whyc/service/FireRobotService.java b/src/main/java/com/whyc/service/FireRobotService.java
new file mode 100644
index 0000000..910b0ef
--- /dev/null
+++ b/src/main/java/com/whyc/service/FireRobotService.java
@@ -0,0 +1,55 @@
+package com.whyc.service;
+
+import com.google.gson.reflect.TypeToken;
+import com.whyc.dto.Response;
+import com.whyc.dto.WmsMaterialDto;
+import com.whyc.util.HttpUtil;
+import com.whyc.util.JsonUtil;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class FireRobotService {
+
+
+    /**
+     *
+     * @param command
+     * @return
+     */
+    public Response control(String command) {
+        String httpUrl = "http://192.168.10.45:8085"+"/ControlInterfaceHandler?command="+command;
+        Response response = HttpUtil.doPost(httpUrl, (String) null);
+        //瀵圭粨鏋滆繘琛屽鐞�
+        if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹�
+            String dataStr = (String) response.getData();
+            //鍙傛暟绀轰緥
+            //鎵ц鎴愬姛杩斿洖锛�
+            //寮�闂ㄦ垚鍔燂紒
+            //鍏抽棬鎴愬姛锛�
+            //涓冩盁涓欑兎鎵撳紑鎴愬姛锛�
+            //涓冩盁涓欑兎鍏抽棴鎴愬姛鎴愬姛锛�
+            //鎸囦护鎵ц澶辫触锛岃閲嶆柊鍙戦�侊紒
+            if(dataStr.contains("鎴愬姛")){
+                response.set(1,true,dataStr);
+            }else{
+                response.set(1,false,dataStr);
+            }
+        }
+        return response;
+    }
+
+    public Response specifyTask(String interval, Integer progress, Integer direction) {
+        String httpUrl = "http://192.168.10.45:8085"+"/SpecifyTask?interval="+interval+"&progress="+progress+"&direction="+direction;
+        Response response = HttpUtil.doPost(httpUrl, (String) null);
+        //瀵圭粨鏋滆繘琛屽鐞�
+        if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹�
+            String dataStr = (String) response.getData();
+            //浠诲姟宸茶缃�: interval=0-1, progress=88%, direction=宸�
+            response.setMsg(dataStr);
+            response.setData(null);
+        }
+        return response;
+    }
+}
diff --git a/src/main/java/com/whyc/service/WmsService.java b/src/main/java/com/whyc/service/WmsService.java
index 58fcf47..ef11d1f 100644
--- a/src/main/java/com/whyc/service/WmsService.java
+++ b/src/main/java/com/whyc/service/WmsService.java
@@ -11,10 +11,6 @@
 @Service
 public class WmsService {
 
-    /**
-     * TODO ip鍜岀鍙e緟纭畾璋冩暣
-     * @return
-     */
     public Response getMaterialList() {
         String httpUrl = "http://192.168.10.133:8051"+"/api/Wms_material/get_all";
         Response response = HttpUtil.doGet(httpUrl, (String) null);

--
Gitblit v1.9.1