src/main/java/com/whyc/controller/InterfaceWmsController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/WmsLocationDto.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/WmsMaterialDto.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/WmsPalletDto.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/VideoService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/WmsService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/util/HttpUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/util/JsonUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/InterfaceWmsController.java
New file @@ -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 疑问点: 任务如果是出库, 那么出库的库位是哪个? 接口参数都没有指明 */ @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(); } } src/main/java/com/whyc/dto/WmsLocationDto.java
New file @@ -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; } } src/main/java/com/whyc/dto/WmsMaterialDto.java
New file @@ -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; } } src/main/java/com/whyc/dto/WmsPalletDto.java
New file @@ -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; } } 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; src/main/java/com/whyc/service/WmsService.java
New file @@ -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和端口待确定调整 * @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 详细信息 * 会自动根据返回编码Code在信息前增加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; } } 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 得到对应的gson对象 */ public static Gson getGson(String datetype){ return new GsonBuilder().setDateFormat(datetype).create(); } /** * 获取默认的gson对象 * @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方式的http请求 * @@ -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 的Http接口请求 * 执行GET请求,传入Map参数和Url,获取响应 * 这个对原始的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) { 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; } }