diff --git a/src/main/java/com/gaotao/modules/api/service/WcsApiService.java b/src/main/java/com/gaotao/modules/api/service/WcsApiService.java index 72d73cd..1705593 100644 --- a/src/main/java/com/gaotao/modules/api/service/WcsApiService.java +++ b/src/main/java/com/gaotao/modules/api/service/WcsApiService.java @@ -1,5 +1,6 @@ package com.gaotao.modules.api.service; +import com.gaotao.modules.api.apiData.CheckInventoryExistsRequest; import com.gaotao.modules.api.apiData.UpdateEmptyPalletTypeData; import com.gaotao.modules.api.entity.*; import com.gaotao.modules.automatedWarehouse.entity.WmsOrderTask; @@ -17,7 +18,7 @@ public interface WcsApiService { void pushAgvFeedbackToWcs(AgvFeedBackToWcs inData); String callPallet(CallPalletRequest inData); - + String checkEmptyPalletType(CheckInventoryExistsRequest inData); String updateEmptyPalletType(UpdateEmptyPalletTypeData inData); /** * 栈板特殊操作 diff --git a/src/main/java/com/gaotao/modules/api/service/impl/WcsApiServiceImpl.java b/src/main/java/com/gaotao/modules/api/service/impl/WcsApiServiceImpl.java index 5e79385..ff6c1aa 100644 --- a/src/main/java/com/gaotao/modules/api/service/impl/WcsApiServiceImpl.java +++ b/src/main/java/com/gaotao/modules/api/service/impl/WcsApiServiceImpl.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.gaotao.common.utils.HttpUtils; import com.gaotao.common.utils.ResponseData; +import com.gaotao.modules.api.apiData.CheckInventoryExistsRequest; import com.gaotao.modules.api.apiData.UpdateEmptyPalletTypeData; import com.gaotao.modules.api.entity.*; import com.gaotao.modules.api.entity.issueAndReturnVo.InventoryPartVo; @@ -387,6 +388,56 @@ public class WcsApiServiceImpl implements WcsApiService { } + @Override + public String checkEmptyPalletType(CheckInventoryExistsRequest inData){ + // 通常这个 bean 由 Spring 管理,也可以手动创建 + ObjectMapper objectMapper2 = new ObjectMapper(); + +// 将对象直接转为 Map + Map request = objectMapper2.convertValue(inData, new TypeReference>() {}); + + + Long logId = null; + String url = wcsUrl+"check-inventory-exists"; + try { + // 记录接口调用日志 + String requestJson = JSONObject.toJSONString(request); + logId = interfaceCallLogService.logInterfaceCall( + "check-inventory-exists", + "查询是否有空托", + requestJson, + "55", + null, + "查询是否有空托" + ); + //调用wcs接口 + ObjectMapper objectMapper = new ObjectMapper(); + String jsonBody = objectMapper.writeValueAsString(request); + String ifsResponse = HttpUtils.doPost(url,jsonBody,null); + ObjectMapper mapper = new ObjectMapper(); + JsonNode jsonNode = mapper.readTree(ifsResponse); + + int code = jsonNode.get("resCode").asInt(); + String msg = jsonNode.get("resMsg").asText(); + + if(code!=200){ + throw new RuntimeException("调用WCS接口失败,错误码:"+code+",错误信息:"+msg); + } + if (logId != null) { + interfaceCallLogService.updateCallResult(logId, null, "Success", msg, null); + } + + return msg; + } catch (Exception e) { + // 更新接口日志错误信息 + if (logId != null) { + interfaceCallLogService.updateCallResult(logId, null, "FAILED", e.getMessage(), null); + } + throw new RuntimeException(e.getMessage()); + } + + } + //接口1 传栈板出库指令给WCS 后期做成只允许单独叫一个栈板 或者循环调用,但是循环调用会有问题 public void callPalletOutWcs(WmsOrderTask inData) { diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java index 0ef4602..124080c 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java @@ -1,6 +1,7 @@ package com.gaotao.modules.automatedWarehouse.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.gaotao.modules.api.apiData.CheckInventoryExistsRequest; import com.gaotao.modules.api.entity.*; import com.gaotao.modules.api.service.WcsApiService; import com.gaotao.modules.api.service.WmsMessageService; @@ -2109,8 +2110,30 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { System.out.println("站点校验通过 - rqrq,stationCode=" + stationCode + ", status_db=0"); - //调用接口校验库里有没有托盘 + // 调用接口校验库里有没有托盘 - rqrq + // 1. 通过palletType查询pallet_type表获取wcs_pallet_type和wcs_base_pallet_type - rqrq + com.gaotao.modules.base.entity.PalletType palletTypeInfo = palletMapper.getPalletTypeInfo(site, palletType); + if (palletTypeInfo == null) { + throw new RuntimeException("托盘类型不存在:" + palletType); + } + Integer wcsPalletType = palletTypeInfo.getWcsPalletType(); + Integer wcsBasePalletType = palletTypeInfo.getWcsBasePalletType(); + if (wcsPalletType == null || wcsBasePalletType == null) { + throw new RuntimeException("托盘类型【" + palletType + "】未配置WCS托盘类型或基础托盘类型"); + } + System.out.println("查询托盘类型信息 - rqrq,palletType=" + palletType + ", wcsPalletType=" + wcsPalletType + ", wcsBasePalletType=" + wcsBasePalletType); + // 2. 调用checkEmptyPalletType接口查看库内空托盘是否存在 - rqrq + CheckInventoryExistsRequest checkRequest = new CheckInventoryExistsRequest(); + checkRequest.setPalletType(wcsPalletType); + checkRequest.setBasePalletType(wcsBasePalletType); + try { + String checkResult = wcsApiService.checkEmptyPalletType(checkRequest); + System.out.println("校验库内空托盘存在 - rqrq,响应:" + checkResult); + } catch (Exception e) { + System.out.println("校验库内空托盘不存在 - rqrq,错误:" + e.getMessage()); + throw new RuntimeException("立库内该托盘类型库存不足"); + } // 构建NeedPalletTask参数 - rqrq NeedPalletTask needPalletTask = new NeedPalletTask();