From 981d1f4a962b9b688b7ba9ca8258f75f024d62de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Wed, 1 Apr 2026 20:58:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(qrcodemaster):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=A3=85=E7=AE=B1=E7=AE=A1=E7=90=86=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=A3=85=E7=AE=B1=E6=8B=86=E7=AE=B1=E6=8D=A2?= =?UTF-8?q?=E7=AE=B1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 QrCodeMasterController 控制器提供装箱管理相关接口 - 实现装箱绑码功能支持小码放入大码中 - 实现拆箱删除功能支持从箱中移除物料二维码 - 实现换箱功能支持库存地点内物料箱合并 - 添加扫码接口获取二维码详细信息 - 实现标签导出功能支持ZIP和PDF格式 - 提供包装箱和箱内物料信息查询接口 - 添加批次号一致性校验防止混批操作 - 实现物料匹配验证确保装箱准确性 - 完善状态流转控制防止非法操作 - 添加防重复装箱和跨工厂仓库限制 - 优化库存管理实现出入库自动处理 --- .../controller/QrCodeMasterController.java | 73 +++++++++++++------ .../impl/WmsQrCodeMasterServiceImpl.java | 41 +++++------ 2 files changed, 68 insertions(+), 46 deletions(-) diff --git a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/QrCodeMasterController.java b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/QrCodeMasterController.java index 83e77da9..c06c6867 100644 --- a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/QrCodeMasterController.java +++ b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/QrCodeMasterController.java @@ -54,6 +54,7 @@ import java.util.zip.ZipOutputStream; /** * 装箱管理 + * * @author: nflg * @date: 2022/3/17 * @description: @@ -133,16 +134,18 @@ public class QrCodeMasterController extends BaseController { @ApiMark(moduleName = "包装箱编码获取获取包装箱信息", apiName = "包装箱编码获取获取包装箱信息") public ApiResult> getPackageInfos(@Valid @RequestBody PackageQO request) { List wmsPackageItems = wmsPackageItemService.lambdaQuery() - .eq(WmsPackageItem::getPackageId,request.getPackageId()) + .eq(WmsPackageItem::getPackageId, request.getPackageId()) .list(); + if (CollectionUtil.isEmpty(wmsPackageItems)) { + return ApiResult.success(Collections.emptyList()); + } List barcodeCodes = wmsPackageItems.stream() .map(WmsPackageItem::getBarcodeCode) - .filter(Objects::nonNull) .toList(); List qrCodeMasterList = qrCodeMasterService.lambdaQuery() .in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes) .list(); - List packageInfoVOS = Convert.toList(PackageInfoVO.class,qrCodeMasterList); + List packageInfoVOS = Convert.toList(PackageInfoVO.class, qrCodeMasterList); packageInfoVOS.forEach(vo -> { WmsPackageItem item = wmsPackageItems.stream() .filter(p -> StrUtil.equals(p.getBarcodeCode(), vo.getBarcodeCode())) @@ -164,7 +167,8 @@ public class QrCodeMasterController extends BaseController { */ private void smallBarcodeValidation(WmsQrCodeMaster qrCodeMaster, List smallQrCodeMasters, - BarCodeProcessStage processStage) { + BarCodeProcessStage processStage, + boolean equals) { boolean hasDuplicates = smallQrCodeMasters.stream() .map(WmsQrCodeMaster::getBarcodeCode) .collect(Collectors.toSet()) @@ -182,16 +186,25 @@ public class QrCodeMasterController extends BaseController { VUtil.trueThrowBusinessError(materialCodes.size() > 1).throwMessage("此箱码中包含多中物料"); VUtil.trueThrowBusinessError(!materialCodes.get(0).equals(qrCodeMaster.getMaterialCode())).throwMessage("物料不匹配"); //判断小码中是否又被使用过了 - Integer count = qrCodeMasterService.lambdaQuery() - .in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes) - .eq(WmsQrCodeMaster::getProcessStage, processStage.getState()) - .count().intValue(); - VUtil.trueThrowBusinessError(count > 0).throwMessage("此箱码中包含已使用的物料二维码"); - Integer count1 = qrCodeMasterService.lambdaQuery() + if (equals) { + VUtil.trueThrowBusinessError( + qrCodeMasterService.lambdaQuery() + .in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes) + .ne(WmsQrCodeMaster::getProcessStage, processStage.getState()) + .exists() + ).throwMessage("此箱码中包含非【" + processStage.getDescription() + "】的物料二维码"); + } else { + VUtil.trueThrowBusinessError( + qrCodeMasterService.lambdaQuery() + .in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes) + .eq(WmsQrCodeMaster::getProcessStage, processStage.getState()) + .exists() + ).throwMessage("此箱码中包含【" + processStage.getDescription() + "】的物料二维码"); + } + VUtil.trueThrowBusinessError(qrCodeMasterService.lambdaQuery() .eq(WmsQrCodeMaster::getPackagingType, 1) - .in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes) - .count().intValue(); - VUtil.trueThrowBusinessError(count1 > 0).throwMessage("存在箱子码(中码)"); + .in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes).exists() + ).throwMessage("存在箱子码(中码)"); } /** @@ -225,10 +238,10 @@ public class QrCodeMasterController extends BaseController { } } VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(differentBatchNos)) - .throwMessage("批次号不一致,不一致的物料条码号为:" + StrUtil.join(",",differentBatchNos)); + .throwMessage("批次号不一致,不一致的物料条码号为:" + StrUtil.join(",", differentBatchNos)); // 判断箱子的物料信息是否OK - smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.Packaged); + smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.Packaged, false); // 修改小码的所属关系 for (WmsQrCodeMaster smallQrCodeMaster : smallQrCodeMasters) { smallQrCodeMaster.setParentBarcodeId(qrCodeMaster.getId()); @@ -281,6 +294,7 @@ public class QrCodeMasterController extends BaseController { /** * 换箱 * 针对库存地点内的物料箱合并,修改物料的箱属性和库存 + * * @param request * @return */ @@ -305,7 +319,7 @@ public class QrCodeMasterController extends BaseController { .in(WmsQrCodeMaster::getBarcodeCode, request.getItems()) .list(); // 判断箱子的物料信息是否OK - smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.InBound); + smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.InBound, true); //校验批次号是否一致 String masterbatchNo = qrCodeMaster.getBatchNo(); Set differentBatchNos = new HashSet<>(); @@ -319,11 +333,18 @@ public class QrCodeMasterController extends BaseController { .throwMessage("批次号不一致,不一致的物料条码号为:" + differentBatchNos); // 只有同一个工厂的同一个库存地点的可以进行换箱 - Integer count1 = qrCodeMasterService.lambdaQuery() - .eq(WmsQrCodeMaster::getFactoryCode, request.getFactoryCode()) - .eq(WmsQrCodeMaster::getStorageLocation, request.getStorageLocation()) - .count().intValue(); - VUtil.trueThrowBusinessError(count1 > 0).throwMessage("换箱只可以在相同的库存地点下进行"); +// Integer count1 = qrCodeMasterService.lambdaQuery() +// .eq(WmsQrCodeMaster::getFactoryCode, request.getFactoryCode()) +// .eq(WmsQrCodeMaster::getStorageLocation, request.getStorageLocation()) +// .count().intValue(); +// VUtil.trueThrowBusinessError(count1 > 0).throwMessage("换箱只可以在相同的库存地点下进行"); + Set factory = smallQrCodeMasters.stream().map(WmsQrCodeMaster::getFactoryCode).collect(Collectors.toSet()); + VUtil.trueThrowBusinessError(factory.size() > 1).throwMessage("换箱只可以在同一个工厂的库存地点下进行"); + Set warehouse = smallQrCodeMasters.stream().map(WmsQrCodeMaster::getStorageLocation).collect(Collectors.toSet()); + VUtil.trueThrowBusinessError(warehouse.size() > 1).throwMessage("换箱只可以在同一个库存地点下进行"); + VUtil.trueThrowBusinessError(!StrUtil.equals(factory.iterator().next(), request.getFactoryCode()) + || !StrUtil.equals(warehouse.iterator().next(), request.getStorageLocation()) + ).throwMessage("物料所在仓库地点与选择的仓库地点不一致"); // 区分状态 // 1、新箱的状态,没有入过库;直接将明细物料退库,重新绑定 if (processStage.equals(BarCodeProcessStage.Unpackaged)) { @@ -381,6 +402,7 @@ public class QrCodeMasterController extends BaseController { /** * 物料出入库统一扫码接口 + * * @param request * @return * @author @@ -417,9 +439,10 @@ public class QrCodeMasterController extends BaseController { * 换箱扫码接口 * * @param request - * @return - * @author - * */ + * @return + * @author + * + */ @PostMapping("pda/changeScan") @ApiMark(moduleName = "换箱扫码", apiName = "扫码换箱箱子扫码信息") public ApiResult changeScan(@Valid @RequestBody QRCodeSearchQO request) { @@ -446,6 +469,7 @@ public class QrCodeMasterController extends BaseController { /** * 导出标签图片为ZIP + * * @param datas 二维码列表 */ @PostMapping(value = "exportToZip", produces = "application/zip") @@ -475,6 +499,7 @@ public class QrCodeMasterController extends BaseController { /** * 导出标签图片为PDF + * * @param datas 二维码列表 */ @PostMapping("exportToPdf") diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/WmsQrCodeMasterServiceImpl.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/WmsQrCodeMasterServiceImpl.java index f4adb7da..5843ff8d 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/WmsQrCodeMasterServiceImpl.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/WmsQrCodeMasterServiceImpl.java @@ -3,20 +3,18 @@ package com.nflg.wms.repository.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.nflg.wms.common.constant.BarCodeProcessStage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.nflg.wms.common.exception.NflgException; import com.nflg.wms.common.pojo.dto.InventoryInDTO; import com.nflg.wms.common.pojo.dto.InventoryOutDTO; import com.nflg.wms.common.pojo.qo.FilterIdSearchQO; import com.nflg.wms.common.pojo.qo.QrCodeItemSearchQO; import com.nflg.wms.common.pojo.vo.QrCodeItemVO; -import com.nflg.wms.common.util.UserUtil; import com.nflg.wms.repository.entity.WmsQrCodeMaster; import com.nflg.wms.repository.entity.WmsTransferOrders; import com.nflg.wms.repository.mapper.WmsQrCodeMasterMapper; import com.nflg.wms.repository.service.IWmsInventoryService; import com.nflg.wms.repository.service.IWmsQrCodeMasterService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.nflg.wms.repository.service.IWmsTransferOrdersService; import jakarta.annotation.Resource; import org.springframework.retry.annotation.Backoff; @@ -24,7 +22,6 @@ import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; import java.util.List; /** @@ -100,24 +97,24 @@ public class WmsQrCodeMasterServiceImpl extends ServiceImpl { - WmsQrCodeMaster qrCodeMaster = lambdaQuery() - .eq(WmsQrCodeMaster::getId, code) - .one(); - - if (qrCodeMaster != null) { - List smallQcodeMasters = lambdaQuery() - .eq(WmsQrCodeMaster::getParentBarcodeId, code) - .ne(WmsQrCodeMaster::getProcessStage, BarCodeProcessStage.InBound.getState()) - .list(); - if (CollectionUtil.isEmpty(smallQcodeMasters)) { - qrCodeMaster.setProcessStage(BarCodeProcessStage.OutBound.getState()); - smallQrCodeMasters.add(qrCodeMaster); - } - } - }); - } +// if (CollectionUtil.isNotEmpty(changeBeforeParentBarcodeCodes)) { +// changeBeforeParentBarcodeCodes.forEach(code -> { +// WmsQrCodeMaster qrCodeMaster = lambdaQuery() +// .eq(WmsQrCodeMaster::getId, code) +// .one(); +// +// if (qrCodeMaster != null) { +// List smallQcodeMasters = lambdaQuery() +// .eq(WmsQrCodeMaster::getParentBarcodeId, code) +// .ne(WmsQrCodeMaster::getProcessStage, BarCodeProcessStage.InBound.getState()) +// .list(); +// if (CollectionUtil.isEmpty(smallQcodeMasters)) { +// qrCodeMaster.setProcessStage(BarCodeProcessStage.OutBound.getState()); +// smallQrCodeMasters.add(qrCodeMaster); +// } +// } +// }); +// } //修改状态 updateBarCode(smallQrCodeMasters); }