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.10.133:8051"+"/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.10.133:8051"+"/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.10.133:8051"+"/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; } }