From d60979e98c6492b562e38bfe6f7925a3809892fe Mon Sep 17 00:00:00 2001
From: whycxzp <glperry@163.com>
Date: 星期二, 18 三月 2025 15:19:27 +0800
Subject: [PATCH] Wms仓库相关代码

---
 src/main/java/com/whyc/dto/WmsPalletDto.java                  |   27 +++
 src/main/java/com/whyc/util/HttpUtil.java                     |   53 ------
 src/main/java/com/whyc/service/WmsService.java                |   68 +++++++++
 src/main/java/com/whyc/controller/InterfaceWmsController.java |   57 ++++++++
 src/main/java/com/whyc/dto/WmsMaterialDto.java                |   86 ++++++++++++
 src/main/java/com/whyc/util/JsonUtil.java                     |   14 ++
 src/main/java/com/whyc/service/VideoService.java              |    5 
 src/main/java/com/whyc/dto/WmsLocationDto.java                |   74 ++++++++++
 8 files changed, 334 insertions(+), 50 deletions(-)

diff --git a/src/main/java/com/whyc/controller/InterfaceWmsController.java b/src/main/java/com/whyc/controller/InterfaceWmsController.java
new file mode 100644
index 0000000..1c45208
--- /dev/null
+++ b/src/main/java/com/whyc/controller/InterfaceWmsController.java
@@ -0,0 +1,57 @@
+package com.whyc.controller;
+
+import com.whyc.dto.Response;
+import com.whyc.dto.WmsPalletDto;
+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 = "WMS鎺ュ彛")
+@RequestMapping("wms")
+public class InterfaceWmsController {
+
+    @Autowired
+    private WmsService service;
+
+    /**
+     * 鑾峰彇鎵�鏈夊簱浣嶆暟鎹�
+     * API:/api/Wms_material/get_all
+     * @return
+     */
+    @GetMapping("getMaterialList")
+    public Response getMaterialList(){
+
+        return service.getMaterialList();
+    }
+
+    /**
+     * 涓嬪彂浠诲姟
+     * API:/api/Wms_pallet/WmsOutTask
+     * TODO 鐤戦棶鐐�: 浠诲姟濡傛灉鏄嚭搴�, 閭d箞鍑哄簱鐨勫簱浣嶆槸鍝釜? 鎺ュ彛鍙傛暟閮芥病鏈夋寚鏄�
+     */
+    @PostMapping("sendTask")
+    public Response sendTask(@RequestBody WmsPalletDto palletDto){
+
+        return service.sendTask(palletDto);
+    }
+
+    /**
+     * 浠诲姟鐘舵�佷笂鎶ユ帴鍙�
+     * TODO 寰呯幇鍦虹‘璁ゅ惈涔� API鍚嶇О	涓婂眰绯荤粺鎻愪緵
+     */
+
+
+    /**
+     * 鑾峰彇鎵�鏈夊簱浣嶆暟鎹�
+     * API:/api/wms_location/get_all
+     */
+    @GetMapping("getLocationList")
+    public Response getLocationList(){
+
+        return service.getLocationList();
+    }
+
+
+}
diff --git a/src/main/java/com/whyc/dto/WmsLocationDto.java b/src/main/java/com/whyc/dto/WmsLocationDto.java
new file mode 100644
index 0000000..d8f9202
--- /dev/null
+++ b/src/main/java/com/whyc/dto/WmsLocationDto.java
@@ -0,0 +1,74 @@
+package com.whyc.dto;
+
+/**
+ * 搴撲綅鏁版嵁
+ * 鍙傛暟璇存槑	瀛楁鍚嶇О	鍙傛暟绫诲瀷	瀛楁鎻忚堪
+ * 	location_ID	Int	搴撲綅ID
+ * 	locationCode	String	搴撲綅缂栫爜
+ * 	locationType	Int	搴撲綅绫诲瀷 1=涓�妤煎叆搴撶紦瀛樹綅銆�2=涓�妤煎嚭搴撶紦瀛樹綅銆�3=娲诲寲浠撱��4=浜屾ゼ璧板粖宸ヤ綅銆�5=瀛樻斁搴撳尯
+ * 	a1	Int	鎺�
+ * 	a2	Int	鍒�
+ * 	status	Int	鐘舵�� 0=鏃犺揣銆�1=鏈夎揣銆�4=閿佸畾涓�
+ */
+public class WmsLocationDto {
+    /** 搴撲綅ID */
+    private Integer locationId;
+    /** 搴撲綅缂栫爜 */
+    private String locationCode;
+    /** 搴撲綅绫诲瀷 1=涓�妤煎叆搴撶紦瀛樹綅銆�2=涓�妤煎嚭搴撶紦瀛樹綅銆�3=娲诲寲浠撱��4=浜屾ゼ璧板粖宸ヤ綅銆�5=瀛樻斁搴撳尯 */
+    private Integer locationType;
+    /** 鎺� */
+    private Integer a1;
+    /** 鍒� */
+    private Integer a2;
+    /** 鐘舵�� 0=鏃犺揣銆�1=鏈夎揣銆�4=閿佸畾涓� */
+    private Integer status;
+
+    public Integer getLocationId() {
+        return locationId;
+    }
+
+    public void setLocationId(Integer locationId) {
+        this.locationId = locationId;
+    }
+
+    public String getLocationCode() {
+        return locationCode;
+    }
+
+    public void setLocationCode(String locationCode) {
+        this.locationCode = locationCode;
+    }
+
+    public Integer getLocationType() {
+        return locationType;
+    }
+
+    public void setLocationType(Integer locationType) {
+        this.locationType = locationType;
+    }
+
+    public Integer getA1() {
+        return a1;
+    }
+
+    public void setA1(Integer a1) {
+        this.a1 = a1;
+    }
+
+    public Integer getA2() {
+        return a2;
+    }
+
+    public void setA2(Integer a2) {
+        this.a2 = a2;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+}
diff --git a/src/main/java/com/whyc/dto/WmsMaterialDto.java b/src/main/java/com/whyc/dto/WmsMaterialDto.java
new file mode 100644
index 0000000..a23198f
--- /dev/null
+++ b/src/main/java/com/whyc/dto/WmsMaterialDto.java
@@ -0,0 +1,86 @@
+package com.whyc.dto;
+
+/**
+ * 浠撳偍绯荤粺-鐗╂枡淇℃伅
+ */
+public class WmsMaterialDto {
+
+    private Integer materialId;
+
+    private String materialCode;
+    private String materialName;
+    /**鐗╂枡绫诲瀷 1=杞藉叿,2=鐢垫睜*/
+    private Integer materialType;
+    /**鐗╂枡瑙勬牸*/
+    private Integer modelType;
+    /**鏍囩О瀹归噺*/
+    private String specification;
+    /**鏍囩О鐢靛帇*/
+    private String unit;
+    /**鍝佺墝*/
+    private String supplier;
+
+    public Integer getMaterialId() {
+        return materialId;
+    }
+
+    public void setMaterialId(Integer materialId) {
+        this.materialId = materialId;
+    }
+
+    public String getMaterialCode() {
+        return materialCode;
+    }
+
+    public void setMaterialCode(String materialCode) {
+        this.materialCode = materialCode;
+    }
+
+    public String getMaterialName() {
+        return materialName;
+    }
+
+    public void setMaterialName(String materialName) {
+        this.materialName = materialName;
+    }
+
+    public Integer getMaterialType() {
+        return materialType;
+    }
+
+    public void setMaterialType(Integer materialType) {
+        this.materialType = materialType;
+    }
+
+    public Integer getModelType() {
+        return modelType;
+    }
+
+    public void setModelType(Integer modelType) {
+        this.modelType = modelType;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+
+    public String getSupplier() {
+        return supplier;
+    }
+
+    public void setSupplier(String supplier) {
+        this.supplier = supplier;
+    }
+}
diff --git a/src/main/java/com/whyc/dto/WmsPalletDto.java b/src/main/java/com/whyc/dto/WmsPalletDto.java
new file mode 100644
index 0000000..ef666f1
--- /dev/null
+++ b/src/main/java/com/whyc/dto/WmsPalletDto.java
@@ -0,0 +1,27 @@
+package com.whyc.dto;
+
+import java.util.List;
+
+/**
+ * 涓嬪彂浠诲姟璇锋眰鍙傛暟
+ */
+public class WmsPalletDto {
+    private Integer des;
+    private List<String> pallets;
+
+    public Integer getDes() {
+        return des;
+    }
+
+    public void setDes(Integer des) {
+        this.des = des;
+    }
+
+    public List<String> getPallets() {
+        return pallets;
+    }
+
+    public void setPallets(List<String> pallets) {
+        this.pallets = pallets;
+    }
+}
diff --git a/src/main/java/com/whyc/service/VideoService.java b/src/main/java/com/whyc/service/VideoService.java
index ea306b4..74b62c1 100644
--- a/src/main/java/com/whyc/service/VideoService.java
+++ b/src/main/java/com/whyc/service/VideoService.java
@@ -5,6 +5,7 @@
 import com.whyc.dto.Response;
 import com.whyc.dto.Response4Http;
 import com.whyc.util.HttpUtil;
+import com.whyc.util.JsonUtil;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -36,7 +37,7 @@
         Integer httpResponseCode = response.getCode();
         String responseJson = (String) response.getData();
         if(httpResponseCode == 1) { //璇锋眰鎴愬姛
-            Response4Http responseHttp = HttpUtil.getGson().fromJson(responseJson, Response4Http.class);
+            Response4Http responseHttp = JsonUtil.getGson().fromJson(responseJson, Response4Http.class);
             if(responseHttp.getCode() == 0 ) { //鎺ュ彛杩斿洖鐘舵�佺爜涓烘垚鍔�
                 if(responseHttp.getData()!=null) {
                     List<LinkedTreeMap<String, Object>> list = (List) responseHttp.getData();
@@ -118,7 +119,7 @@
         //      "rootPath" : "/www/record/live/ss/"
         //   }
         String dataStr = (String) response4Http.getData2();
-        Mp4FileDTO mp4FileDTO = HttpUtil.getGson().fromJson(dataStr, Mp4FileDTO.class);
+        Mp4FileDTO mp4FileDTO = JsonUtil.getGson().fromJson(dataStr, Mp4FileDTO.class);
         response4Http.setData2(mp4FileDTO);
         return response4Http;
 
diff --git a/src/main/java/com/whyc/service/WmsService.java b/src/main/java/com/whyc/service/WmsService.java
new file mode 100644
index 0000000..0493644
--- /dev/null
+++ b/src/main/java/com/whyc/service/WmsService.java
@@ -0,0 +1,68 @@
+package com.whyc.service;
+
+import com.whyc.dto.Response;
+import com.whyc.dto.WmsLocationDto;
+import com.whyc.dto.WmsMaterialDto;
+import com.whyc.dto.WmsPalletDto;
+import com.whyc.util.HttpUtil;
+import com.whyc.util.JsonUtil;
+import org.springframework.stereotype.Service;
+
+@Service
+public class WmsService {
+
+    /**
+     * TODO ip鍜岀鍙e緟纭畾璋冩暣
+     * @return
+     */
+    public Response getMaterialList() {
+        String httpUrl = "http://192.168.1.100:8080"+"/api/Wms_material/get_all";
+        Response response = HttpUtil.doGet(httpUrl, (String) null);
+        //瀵圭粨鏋滆繘琛屽鐞�
+        if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹�
+            String dataStr = (String) response.getData();
+            WmsMaterialDto wmsMaterialDto = JsonUtil.getGson().fromJson(dataStr, WmsMaterialDto.class);
+            response.set(1,wmsMaterialDto);
+        }
+        return response;
+    }
+
+    /**
+     *
+     * @param palletDto
+     * @return
+     * 鍝嶅簲鎶ユ枃
+     * 瀹炰緥	{
+     *   "code": 0,
+     *   "message": "string"
+     * }
+     * 鍙傛暟璇存槑	瀛楁鍚嶇О	鍙傛暟绫诲瀷	瀛楁鎻忚堪
+     * 	code	Int	鎺ュ彛閫氫俊杩斿洖缂栫爜璇︾粏淇℃伅, 0:鎴愬姛
+     * 	message	String	璇︾粏淇℃伅
+     * 浼氳嚜鍔ㄦ牴鎹繑鍥炵紪鐮丆ode鍦ㄤ俊鎭墠澧炲姞Code璇︽儏
+     */
+
+    public Response sendTask(WmsPalletDto palletDto) {
+        String httpUrl = "http://192.168.1.100:8080"+"/api/Wms_pallet/WmsOutTask";
+        Response response = HttpUtil.doPost(httpUrl, JsonUtil.getGson().toJson(palletDto));
+        //瀵圭粨鏋滆繘琛屽鐞�
+        if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹�
+            String dataStr = (String) response.getData();
+            Response responseInside = JsonUtil.getGson().fromJson(dataStr, Response.class);
+            response.set(1,responseInside);
+        }
+        return response;
+    }
+
+    public Response getLocationList() {
+        String httpUrl = "http://192.168.1.100:8080"+"/api/wms_location/get_all";
+        Response response = HttpUtil.doGet(httpUrl, (String) null);
+        //瀵圭粨鏋滆繘琛屽鐞�
+        if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹�
+            String dataStr = (String) response.getData();
+            WmsLocationDto wmsLocationDto = JsonUtil.getGson().fromJson(dataStr, WmsLocationDto.class);
+            response.set(1,wmsLocationDto);
+        }
+        return response;
+    }
+}
diff --git a/src/main/java/com/whyc/util/HttpUtil.java b/src/main/java/com/whyc/util/HttpUtil.java
index d3c6e54..2c8ebab 100644
--- a/src/main/java/com/whyc/util/HttpUtil.java
+++ b/src/main/java/com/whyc/util/HttpUtil.java
@@ -57,51 +57,6 @@
 		return getSession().getServletContext();
 	}
 
-	/*
-	 * 鑾峰彇灏嗗璞¤浆鎹㈡垚json鏍煎紡
-	 */
-	public static String toJson(Object obj){
-		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
-		return gson.toJson(obj);
-	}
-	
-	public static String chageDateToString(Date time,String type){
-		String msg = "";
-		SimpleDateFormat sdf = new SimpleDateFormat(type);
-		msg = sdf.format(time);
-		return msg;
-	}
-
-	
-	/**
-	 * 
-	 * @param datetype	闇�瑕佽В鏋愮殑鏃ユ湡鐨勬牸寮忓锛�"yyyy-MM-dd HH:mm:ss"
-	 * @return	寰楀埌瀵瑰簲鐨刧son瀵硅薄
-	 */
-	public static Gson getGson(String datetype){
-		return new  GsonBuilder().setDateFormat(datetype).create();
-	}
-	
-	/**
-	 * 鑾峰彇榛樿鐨刧son瀵硅薄
-	 * @return
-	 */
-	public static Gson getGson(){
-		return new Gson();
-	}
-	
-	
-	public static <T> T getObject(String jsonstring,Type listtype){
-		Gson gson=new Gson();
-		T t=null;
-		try {
-			t=gson.fromJson(jsonstring, listtype);
-		} catch (JsonSyntaxException e) {
-			e.printStackTrace();
-		}
-		return t;
-	}
-
 	/**
 	 * get鏂瑰紡鐨刪ttp璇锋眰
 	 *
@@ -145,7 +100,7 @@
 		} catch (IOException e) {
 			response.set(0);
 			String message = e.getMessage();
-			response.setData(message);
+			response.setMsg(message);
 		} finally {
 			// 鍏抽棴璧勬簮
 			if (null != bufferedReader) {
@@ -216,7 +171,7 @@
 		} catch (IOException e) {
 			String message = e.getMessage();
 			response.set(0);
-			response.setData(message);
+			response.setMsg(message);
 		} finally {
 			// 鍏抽棴璧勬簮
 			if (null != bufferedReader) {
@@ -268,7 +223,9 @@
 	}
 
 	/**
+	 * 鐢ㄤ簬Video 鐨凥ttp鎺ュ彛璇锋眰
 	 * 鎵цGET璇锋眰,浼犲叆Map鍙傛暟鍜孶rl,鑾峰彇鍝嶅簲
+	 * 杩欎釜瀵瑰師濮嬬殑doGet鏂规硶杩涜浜嗚皟鐢�,瀵圭粨鏋滆繘琛屽悗缁�昏緫鍐嶅鐞�,灞炰簬瀹氬埗鍖栫殑鎺ュ彛浜�.
 	 */
 	public static Response4Http doGet(String httpUrl, Map<String, ?> params) {
 		Response4Http responseResult = new Response4Http<>();
@@ -278,7 +235,7 @@
 		Integer httpResponseCode = response.getCode();
 		String responseJson = (String) response.getData();
 		if(httpResponseCode == 1) { //璇锋眰鎴愬姛
-			Response4Http responseHttp = HttpUtil.getGson().fromJson(responseJson, Response4Http.class);
+			Response4Http responseHttp = JsonUtil.getGson().fromJson(responseJson, Response4Http.class);
 			if(responseHttp.getCode() == 0 ) { //鎺ュ彛杩斿洖鐘舵�佺爜涓烘垚鍔�
 				//杩斿洖淇℃伅鏈� data灞炴��
 				if(responseHttp.getData()!=null) {
diff --git a/src/main/java/com/whyc/util/JsonUtil.java b/src/main/java/com/whyc/util/JsonUtil.java
index 855b566..c5b0719 100644
--- a/src/main/java/com/whyc/util/JsonUtil.java
+++ b/src/main/java/com/whyc/util/JsonUtil.java
@@ -2,6 +2,9 @@
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
+import com.google.gson.JsonSyntaxException;
+
+import java.lang.reflect.Type;
 
 public class JsonUtil {
 
@@ -22,4 +25,15 @@
         return new Gson();
     }
 
+    public static <T> T getObject(String jsonstring, Type listtype){
+        Gson gson=new Gson();
+        T t=null;
+        try {
+            t=gson.fromJson(jsonstring, listtype);
+        } catch (JsonSyntaxException e) {
+            e.printStackTrace();
+        }
+        return t;
+    }
+
 }

--
Gitblit v1.9.1