From 061a64ae34ef5e6980fbadf0f1e896552116b757 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: Thu, 16 Oct 2025 16:57:34 +0800 Subject: [PATCH] =?UTF-8?q?wcs=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WcsIntegrationController.java | 52 ++++- .../entity/CheckPalletResult.java | 60 +++++ .../mapper/WcsIntegrationMapper.java | 26 ++- .../service/WcsIntegrationService.java | 36 ++- .../impl/WcsIntegrationServiceImpl.java | 214 ++++++++++++++++-- .../WcsIntegrationMapper.xml | 51 ++++- 6 files changed, 414 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/gaotao/modules/automatedWarehouse/entity/CheckPalletResult.java diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java index 46e94ed..2bcc523 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java @@ -6,6 +6,7 @@ import com.gaotao.modules.api.service.IfsApiService; import com.gaotao.modules.automatedWarehouse.entity.*; import com.gaotao.modules.automatedWarehouse.service.WcsIntegrationService; import com.gaotao.modules.automatedWarehouse.service.PalletChangeStationService; +import com.gaotao.modules.base.entity.PalletType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -379,7 +380,7 @@ public class WcsIntegrationController { @PostMapping(value="/checkPalletForChangeStation") @ResponseBody public R checkPalletForChangeStation(@RequestBody Map params) { - Map row = wcsIntegrationService.checkPalletForChangeStation(params); + CheckPalletResult row = wcsIntegrationService.checkPalletForChangeStation(params); return R.ok().put("row", row); } @@ -441,7 +442,7 @@ public class WcsIntegrationController { @PostMapping(value="/checkPalletForManualMove") @ResponseBody public R checkPalletForManualMove(@RequestBody Map params) { - Map row = wcsIntegrationService.checkPalletForManualMove(params); + CheckPalletResult row = wcsIntegrationService.checkPalletForManualMove(params); return R.ok().put("row", row); } @@ -504,4 +505,51 @@ public class WcsIntegrationController { wcsIntegrationService.bindPalletToStation(params); return R.ok(); } + + // ==================== 空托盘组盘相关方法 - rqrq ==================== + + /** + * @Description 检查托盘是否为空托盘 - rqrq + * @Title checkEmptyPallet + * @param params {site, palletId} + * @return R + * @author rqrq + * @date 2025/10/16 + */ + @PostMapping(value="/checkEmptyPallet") + @ResponseBody + public R checkEmptyPallet(@RequestBody Map params) { + CheckPalletResult row = wcsIntegrationService.checkEmptyPallet(params); + return R.ok().put("row", row); + } + + /** + * @Description 获取托盘类型列表(根据pallet_family过滤)- rqrq + * @Title getPalletTypes + * @param params {site, palletFamily} + * @return R + * @author rqrq + * @date 2025/10/16 + */ + @PostMapping(value="/getPalletTypes") + @ResponseBody + public R getPalletTypes(@RequestBody Map params) { + List rows = wcsIntegrationService.getPalletTypes(params); + return R.ok().put("rows", rows); + } + + /** + * @Description 空托盘通知入库 - rqrq + * @Title notifyEmptyPalletInbound + * @param params {site, palletId, transportFlag} + * @return R + * @author rqrq + * @date 2025/10/16 + */ + @PostMapping(value="/notifyEmptyPalletInbound") + @ResponseBody + public R notifyEmptyPalletInbound(@RequestBody Map params) { + wcsIntegrationService.notifyEmptyPalletInbound(params); + return R.ok(); + } } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/entity/CheckPalletResult.java b/src/main/java/com/gaotao/modules/automatedWarehouse/entity/CheckPalletResult.java new file mode 100644 index 0000000..5415fe8 --- /dev/null +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/entity/CheckPalletResult.java @@ -0,0 +1,60 @@ +package com.gaotao.modules.automatedWarehouse.entity; + +import lombok.Data; +import org.apache.ibatis.type.Alias; + +/** + * @Description 检查托盘结果实体类 - rqrq + * @Author rqrq + * @Date 2025/10/16 + */ +@Data +@Alias("CheckPalletResult") +public class CheckPalletResult { + + /** + * 托盘编码 + */ + private String palletId; + + /** + * 托盘类型 + */ + private String palletType; + + /** + * 托盘族(用于过滤托盘类型) + */ + private String palletFamily; + + /** + * 调用标志(Y-被调用,N-未被调用) + */ + private String callingFlag; + + /** + * 当前站点编码 + */ + private String currentStationCode; + + /** + * 当前站点ID + */ + private String currentStationId; + + /** + * 站点类型 + */ + private String stationType; + + /** + * 是否可操作(Y-可操作,N-不可操作) + */ + private String canOperate; + + /** + * 是否为空托盘(Y-是,N-否) + */ + private String isEmpty; +} + diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java index 7c0c0f6..518d053 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java @@ -400,7 +400,7 @@ public interface WcsIntegrationMapper { * @author rqrq * @date 2025/10/16 */ - Map checkPalletForChangeStation(@Param("site") String site, @Param("palletId") String palletId); + CheckPalletResult checkPalletForChangeStation(@Param("site") String site, @Param("palletId") String palletId); /** * @Description 获取可选择的区域列表(choose_able为Y) - rqrq @@ -438,7 +438,7 @@ public interface WcsIntegrationMapper { * @author rqrq * @date 2025/10/16 */ - Map checkPalletForManualMove(@Param("site") String site, @Param("palletId") String palletId); + CheckPalletResult checkPalletForManualMove(@Param("site") String site, @Param("palletId") String palletId); /** * @Description 更新托盘location_code为null(移出站点)- rqrq @@ -474,4 +474,26 @@ public interface WcsIntegrationMapper { * @date 2025/10/16 */ void updateStationToOccupied(@Param("stationCode") String stationCode); + + // ==================== 空托盘组盘相关方法 - rqrq ==================== + + /** + * @Description 检查托盘是否为空托盘(pallet_detail表无数据)- rqrq + * @param site 工厂编码 + * @param palletId 托盘编码 + * @return 托盘信息(包含当前站点ID、站点编码、托盘类型) + * @author rqrq + * @date 2025/10/16 + */ + CheckPalletResult checkEmptyPallet(@Param("site") String site, @Param("palletId") String palletId); + + /** + * @Description 获取托盘类型列表(根据pallet_family过滤)- rqrq + * @param site 工厂编码 + * @param palletFamily 托盘族(可为空) + * @return 托盘类型列表 + * @author rqrq + * @date 2025/10/16 + */ + List getPalletTypes(@Param("site") String site, @Param("palletFamily") String palletFamily); } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java index 7e2ddcb..3525d82 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java @@ -1,6 +1,7 @@ package com.gaotao.modules.automatedWarehouse.service; import com.gaotao.modules.automatedWarehouse.entity.*; +import com.gaotao.modules.base.entity.PalletType; import java.util.List; import java.util.Map; @@ -168,7 +169,7 @@ public interface WcsIntegrationService { * @author rqrq * @date 2025/10/16 */ - Map checkPalletForChangeStation(Map params); + CheckPalletResult checkPalletForChangeStation(Map params); /** * @Description 获取可选择的区域列表(choose_able为Y)- rqrq @@ -200,7 +201,7 @@ public interface WcsIntegrationService { * @author rqrq * @date 2025/10/16 */ - Map checkPalletForManualMove(Map params); + CheckPalletResult checkPalletForManualMove(Map params); /** * @Description 移出站点(更新托盘location_code为null,更新站点状态为空闲)- rqrq @@ -220,4 +221,35 @@ public interface WcsIntegrationService { */ void bindPalletToStation(Map params); + // ==================== 空托盘组盘相关方法 - rqrq ==================== + + /** + * @Description 检查托盘是否为空托盘 - rqrq + * @Title checkEmptyPallet + * @param params {site, palletId} + * @return 托盘信息(包含当前站点ID、站点编码、托盘类型、是否为空托盘) + * @author rqrq + * @date 2025/10/16 + */ + CheckPalletResult checkEmptyPallet(Map params); + + /** + * @Description 获取托盘类型列表(根据pallet_family过滤)- rqrq + * @Title getPalletTypes + * @param params {site, palletFamily} + * @return 托盘类型列表 + * @author rqrq + * @date 2025/10/16 + */ + List getPalletTypes(Map params); + + /** + * @Description 空托盘通知入库 - rqrq + * @Title notifyEmptyPalletInbound + * @param params {site, palletId, transportFlag} + * @author rqrq + * @date 2025/10/16 + */ + void notifyEmptyPalletInbound(Map params); + } 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 8f40b4f..e405962 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 @@ -1523,7 +1523,7 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { // ==================== 栈板换站相关方法实现 - rqrq ==================== @Override - public Map checkPalletForChangeStation(Map params) { + public CheckPalletResult checkPalletForChangeStation(Map params) { System.out.println("开始检查栈板换站条件 - rqrq"); String site = (String) params.get("site"); @@ -1538,13 +1538,13 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { } // 查询栈板信息 - rqrq - Map palletInfo = wcsIntegrationMapper.checkPalletForChangeStation(site, palletId); + CheckPalletResult palletInfo = wcsIntegrationMapper.checkPalletForChangeStation(site, palletId); - if (palletInfo == null || palletInfo.isEmpty()) { + if (palletInfo == null) { throw new RuntimeException("栈板不存在:" + palletId); } - System.out.println("检查栈板换站条件完成 - rqrq,callingFlag=" + palletInfo.get("callingFlag")); + System.out.println("检查栈板换站条件完成 - rqrq,callingFlag=" + palletInfo.getCallingFlag()); return palletInfo; } @@ -1578,7 +1578,7 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { // ==================== 手工移动托盘相关方法实现 - rqrq ==================== @Override - public Map checkPalletForManualMove(Map params) { + public CheckPalletResult checkPalletForManualMove(Map params) { System.out.println("开始检查托盘是否可以手工移动 - rqrq"); String site = (String) params.get("site"); @@ -1593,7 +1593,7 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { } // 查询托盘信息 - rqrq - Map palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId); + CheckPalletResult palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId); if (palletInfo == null) { throw new RuntimeException("托盘不存在"); } @@ -1623,20 +1623,18 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { } // 检查托盘是否存在 - rqrq - Map palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId); + CheckPalletResult palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId); if (palletInfo == null) { throw new RuntimeException("托盘不存在"); } // 检查托盘是否被调用 - rqrq - String callingFlag = (String) palletInfo.get("callingFlag"); - if ("Y".equals(callingFlag)) { + if ("Y".equals(palletInfo.getCallingFlag())) { throw new RuntimeException("托盘正在被调用中,无法移出站点"); } // 检查是否可操作(必须是正式站点)- rqrq - String canOperate = (String) palletInfo.get("canOperate"); - if (!"Y".equals(canOperate)) { + if (!"Y".equals(palletInfo.getCanOperate())) { throw new RuntimeException("当前站点位置不可变更"); } @@ -1670,21 +1668,19 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { } // 检查托盘是否存在 - rqrq - Map palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId); + CheckPalletResult palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId); if (palletInfo == null) { throw new RuntimeException("托盘不存在"); } // 检查托盘是否被调用 - rqrq - String callingFlag = (String) palletInfo.get("callingFlag"); - if ("Y".equals(callingFlag)) { + if ("Y".equals(palletInfo.getCallingFlag())) { throw new RuntimeException("托盘正在被调用中,无法绑定站点"); } // 检查托盘当前是否已有站点 - rqrq - String currentStationCode = (String) palletInfo.get("currentStationCode"); - if (StringUtils.hasText(currentStationCode)) { - throw new RuntimeException("托盘已绑定站点【" + currentStationCode + "】,请先移出站点"); + if (StringUtils.hasText(palletInfo.getCurrentStationCode())) { + throw new RuntimeException("托盘已绑定站点【" + palletInfo.getCurrentStationCode() + "】,请先移出站点"); } // 检查站点是否存在且可用 - rqrq @@ -1719,4 +1715,188 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { System.out.println("绑定托盘到站点完成 - rqrq"); } + // ==================== 空托盘组盘相关方法实现 - rqrq ==================== + + @Override + public CheckPalletResult checkEmptyPallet(Map params) { + System.out.println("开始检查空托盘 - rqrq"); + + String site = (String) params.get("site"); + String palletId = (String) params.get("palletId"); + + // 参数校验 - rqrq + if (!StringUtils.hasText(site)) { + throw new RuntimeException("站点不能为空"); + } + if (!StringUtils.hasText(palletId)) { + throw new RuntimeException("托盘编码不能为空"); + } + + // 查询托盘信息 - rqrq + CheckPalletResult palletInfo = wcsIntegrationMapper.checkEmptyPallet(site, palletId); + if (palletInfo == null) { + throw new RuntimeException("托盘不存在"); + } + + // 判断是否为空托盘 - rqrq + if (!"Y".equals(palletInfo.getIsEmpty())) { + throw new RuntimeException("该托盘不是空托盘,无法进行空托盘组盘操作"); + } + + System.out.println("检查空托盘完成 - rqrq,托盘信息:" + palletInfo); + return palletInfo; + } + + @Override + public List getPalletTypes(Map params) { + System.out.println("开始获取托盘类型列表 - rqrq"); + + String site = (String) params.get("site"); + String palletFamily = (String) params.get("palletFamily"); + + // 参数校验 - rqrq + if (!StringUtils.hasText(site)) { + throw new RuntimeException("站点不能为空"); + } + + // 查询托盘类型列表(根据pallet_family过滤)- rqrq + List list = wcsIntegrationMapper.getPalletTypes(site, palletFamily); + + System.out.println("获取托盘类型列表完成,共" + list.size() + "条记录 - rqrq,palletFamily=" + palletFamily); + return list; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void notifyEmptyPalletInbound(Map params) { + System.out.println("开始空托盘通知入库 - rqrq"); + + SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); + + String site = (String) params.get("site"); + String palletId = (String) params.get("palletId"); + String transportFlag = (String) params.get("transportFlag"); + + // 参数校验 - rqrq + if (!StringUtils.hasText(site)) { + throw new RuntimeException("工厂编码不能为空"); + } + if (!StringUtils.hasText(palletId)) { + throw new RuntimeException("栈板编码不能为空"); + } + + // 校验栈板是否存在 - rqrq + Map palletInfo = wcsIntegrationMapper.getPalletInfo(site, palletId); + if (palletInfo == null) { + throw new RuntimeException("栈板不存在"); + } + + // 生成入库任务编号 - rqrq + TransNoControl transData = transNoService.getTransNo(site, "WOT", 10); + Date currentTime = new Date(); + + // 创建入库任务记录 - rqrq + WmsOrderTask orderTask = new WmsOrderTask(); + orderTask.setSite(site); + orderTask.setTaskNo(transData.getNewTransNo()); + orderTask.setItemNo(1); + orderTask.setSourceType("空托盘入库"); // 设置为空托盘入库 - rqrq + orderTask.setSourceBillNo(""); + orderTask.setSourceLineId(0L); + orderTask.setPartNo(""); + orderTask.setQty(BigDecimal.ZERO); + orderTask.setBatchNo(""); + orderTask.setSerialNo(""); + orderTask.setFromLocation("无"); + orderTask.setToLocation("无"); + orderTask.setPalletId(palletId); + orderTask.setAgvCode(""); + orderTask.setPriority(1); + orderTask.setStatus("已创建"); + orderTask.setWmsSendTime(currentTime); + orderTask.setCreatedBy(currentUser.getUsername()); + orderTask.setCreatedTime(currentTime); + orderTask.setUpdatedTime(currentTime); + orderTask.setFinishQty(BigDecimal.ZERO); + + // 保存任务记录 - rqrq + wcsIntegrationMapper.insertOrderTask(orderTask); + + System.out.println("空托盘入库任务已创建 - rqrq,taskNo=" + orderTask.getTaskNo()); + + // 调用空托盘推送方法(只推送托盘数据,cargoInfos为null)- rqrq + pushEmptyPalletDetail(site, palletId, orderTask.getTaskNo(), orderTask.getItemNo()); + + // 如果是入库并运输,在这里新增逻辑(暂时留空)- rqrq + if ("Y".equals(transportFlag)) { + System.out.println("入库并运输标志为Y,后续将在此处新增运输逻辑 - rqrq"); + // TODO: 新增运输相关逻辑 - rqrq + } + + System.out.println("空托盘通知入库完成 - rqrq"); + } + + /** + * @Description 推送空托盘数据到WCS(只传托盘数据,cargoInfos为null)- rqrq + * @param site 工厂编码 + * @param palletId 托盘编码 + * @param taskNo 任务编号 + * @param itemNo 项次 + * @author rqrq + * @date 2025/10/16 + */ + private void pushEmptyPalletDetail(String site, String palletId, String taskNo, Integer itemNo) { + System.out.println("开始推送空托盘数据到WCS - rqrq,palletId=" + palletId + ", taskNo=" + taskNo); + + // 获取栈板信息(包含pallet_type表关联数据)- rqrq + com.gaotao.modules.warehouse.entity.PalletData palletInfo = wcsIntegrationMapper.getPalletInfoWithTypeDetails(site, palletId); + String locationCode = palletInfo.getLocationCode(); + + // 从pallet表关联pallet_type获取WCS相关字段 - rqrq + Integer wcsPalletType = palletInfo.getWcsPalletType() != null ? palletInfo.getWcsPalletType() : 1; + Integer wcsBasePalletType = palletInfo.getWcsBasePalletType() != null ? palletInfo.getWcsBasePalletType() : 1; + Integer soreType = palletInfo.getWcsSoreType(); + if (palletInfo.getSoreType() != null) { + soreType = palletInfo.getSoreType(); + } + String autoSort = palletInfo.getAutoSort(); + boolean isAutoSort = "Y".equals(autoSort); + + // 更新栈板calling_flag为Y - rqrq + String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + wcsIntegrationMapper.updatePalletCallingFlag(site, palletId, "Y", username); + + // 构建推送数据 - rqrq + PushPalletDetailDto inData = new PushPalletDetailDto(); + + // 设置物料类型 - rqrq + if ("A01".equals(palletInfo.getPalletFamily())) { + inData.setPartType(PartTypeEnum.fromCode(2)); + } else if ("A02".equals(palletInfo.getPalletFamily())) { + inData.setPartType(PartTypeEnum.fromCode(1)); + } else if ("A03".equals(palletInfo.getPalletFamily())) { + inData.setPartType(PartTypeEnum.fromCode(0)); + } else { + inData.setPartType(PartTypeEnum.fromCode(3)); + } + + inData.setSite(site); + inData.setTaskNo(taskNo); + inData.setItemNo(itemNo); + inData.setPalletBarcode(palletId); + inData.setPalletType(wcsPalletType); + inData.setBasePalletType(wcsBasePalletType); + inData.setCommonUsed(false); // 空托盘没有常用料标记 - rqrq + inData.setAutoSort(isAutoSort); + inData.setSoreType(soreType); + inData.setAssemblyPosition(locationCode); + inData.setEndFlag(true); // 空托盘直接结束组盘 - rqrq + inData.setCargoInfos(null); // 空托盘没有货物信息,传null - rqrq + + // 调用WCS推送接口(不修改此方法)- rqrq + wcsApiService.pushZuPanApi(inData); + + System.out.println("推送空托盘数据到WCS完成 - rqrq"); + } + } diff --git a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml index f32032b..3358b2b 100644 --- a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml +++ b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml @@ -845,7 +845,7 @@ - SELECT p.calling_flag AS callingFlag, s.station_id AS currentStationId, @@ -900,7 +900,7 @@ - SELECT p.calling_flag AS callingFlag, p.location_code AS currentStationCode, @@ -954,4 +954,51 @@ WHERE station_code = #{stationCode} + + + + + + + + \ No newline at end of file