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 7650ad46..58f7a66c 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 @@ -3,6 +3,7 @@ package com.nflg.wms.admin.controller; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.nflg.wms.admin.util.HtmlToImageUtil; import com.nflg.wms.admin.util.PdfGeneratorUtil; import com.nflg.wms.admin.util.QRCodeUtil; @@ -18,6 +19,7 @@ import com.nflg.wms.common.pojo.vo.QrCodeItemVO; import com.nflg.wms.common.pojo.vo.QrCodeVO; import com.nflg.wms.common.pojo.vo.StrappingVO; import com.nflg.wms.common.util.NumberUtil; +import com.nflg.wms.common.util.StringUtil; import com.nflg.wms.common.util.UserUtil; import com.nflg.wms.common.util.VUtil; import com.nflg.wms.repository.entity.WmsQrCodeMaster; @@ -43,10 +45,7 @@ import java.io.ByteArrayOutputStream; import java.math.BigDecimal; import java.net.URL; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -160,7 +159,7 @@ public class QrCodeMasterController extends BaseController { } /** - * 包装 + * 装箱绑码 * * @param request * @return @@ -169,7 +168,7 @@ public class QrCodeMasterController extends BaseController { @PostMapping("pda/strapping") @ApiMark(moduleName = "装箱", apiName = "装箱(小码放在大码中)") public ApiResult strappingContents(@Valid @RequestBody StrappingAddQO request) { -//首先要判断当前中码的状态 + //首先要判断当前中码的状态 WmsQrCodeMaster qrCodeMaster = qrCodeMasterService.lambdaQuery() .eq(WmsQrCodeMaster::getBarcodeCode, request.getBarcodeCode()) .one(); @@ -180,7 +179,19 @@ public class QrCodeMasterController extends BaseController { List smallQrCodeMasters = qrCodeMasterService.lambdaQuery() .in(WmsQrCodeMaster::getBarcodeCode, request.getItems()) .list(); -// 判断箱子的物料信息是否OK + //校验批次号是否一致 + String masterBatchNo = qrCodeMaster.getBatchNo(); + Set differentBatchNos = new HashSet<>(); + for (WmsQrCodeMaster smallCode : smallQrCodeMasters) { + String smallBatchNo = smallCode.getBatchNo(); + if (!Objects.equals(masterBatchNo, smallBatchNo)) { + differentBatchNos.add(smallCode.getBarcodeCode()); + } + } + VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(differentBatchNos)) + .throwMessage("批次号不一致,不一致的物料条码号为:" + differentBatchNos); + + // 判断箱子的物料信息是否OK smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.Packaged); // 修改小码的所属关系 for (WmsQrCodeMaster smallQrCodeMaster : smallQrCodeMasters) { @@ -232,7 +243,7 @@ public class QrCodeMasterController extends BaseController { } /** - * 拆箱修改 + * 换箱 * 针对仓库内的物料箱合并,修改物料的箱属性和库存 * @param request * @return @@ -257,15 +268,27 @@ public class QrCodeMasterController extends BaseController { List smallQrCodeMasters = qrCodeMasterService.lambdaQuery() .in(WmsQrCodeMaster::getBarcodeCode, request.getItems()) .list(); -// 判断箱子的物料信息是否OK + // 判断箱子的物料信息是否OK smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.InBound); + //校验批次号是否一致 + String masterbatchNo = qrCodeMaster.getBatchNo(); + Set differentBatchNos = new HashSet<>(); + for (WmsQrCodeMaster smallCode : smallQrCodeMasters) { + String smallBatchNo = smallCode.getBatchNo(); + if (!Objects.equals(masterbatchNo, smallBatchNo)) { + differentBatchNos.add(smallCode.getBarcodeCode()); + } + } + VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(differentBatchNos)) + .throwMessage("批次号不一致,不一致的物料条码号为:" + differentBatchNos); + // 只有同一个工厂的同一个仓库的可以进行换箱 Integer count1 = qrCodeMasterService.lambdaQuery() .eq(WmsQrCodeMaster::getFactoryCode, request.getFactoryCode()) .eq(WmsQrCodeMaster::getStorageLocation, request.getStorageLocation()) .count().intValue(); VUtil.trueThrowBusinessError(count1 > 0).throwMessage("换箱只可以在相同的仓库下进行"); -// 区分状态 + // 区分状态 // 1、新箱的状态,没有入过库;直接将明细物料退库,重新绑定 if (processStage.equals(BarCodeProcessStage.Unpackaged)) { qrCodeMaster.setFactoryCode(request.getFactoryCode());