From b6e71ba728d0a480964879a4551ea637b32a19b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Fri, 12 Dec 2025 15:52:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=96=B0=E5=A2=9E=E7=A9=BA?= =?UTF-8?q?=E6=89=98=E7=9B=98=E5=BA=93=E5=AD=98=E6=A0=A1=E9=AA=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 WcsApiService 中添加 checkEmptyPalletType 方法声明 - 实现 checkEmptyPalletType 接口逻辑,用于查询库存中是否存在指定类型的空托盘 - 增加对接口调用日志记录与异常处理机制 - 在 WcsIntegrationServiceImpl 中集成空托盘校验逻辑 - 根据托盘类型获取 WCS 托盘类型及基础托盘类型配置 - 调用新增接口完成立库空托盘库存校验功能 - 添加对托盘类型配置缺失情况的异常处理提示 --- .../modules/api/service/WcsApiService.java | 3 +- .../api/service/impl/WcsApiServiceImpl.java | 51 +++++++++++++++++++ .../impl/WcsIntegrationServiceImpl.java | 25 ++++++++- 3 files changed, 77 insertions(+), 2 deletions(-) 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();