From 6d910029b6c81db0a2b66caa66952781397b153a Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期六, 29 八月 2026 13:45:52 +0800
Subject: [PATCH] feat(mes): 实现H5溯源页面与二维码内容集成
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java
index 00652fd..bfe7e4d 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java
@@ -14,6 +14,7 @@
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.bagcode.MesProBagCodeDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.pallet.MesProPalletDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.batch.MesProBatchDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.batch.MesWmBatchDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO;
import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesDetailMapper;
import cn.iocoder.yudao.module.mes.service.pro.bagcode.MesProBagCodeService;
@@ -34,6 +35,7 @@
import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService;
import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeService;
import cn.iocoder.yudao.module.mes.service.pro.batch.MesProBatchService;
+import cn.iocoder.yudao.module.mes.service.wm.batch.MesWmBatchService;
import cn.iocoder.yudao.module.mes.service.wm.stockreserve.MesWmStockReserveService;
import cn.iocoder.yudao.module.mes.service.wm.transaction.MesWmTransactionService;
import cn.iocoder.yudao.module.mes.service.wm.transaction.dto.MesWmTransactionSaveReqDTO;
@@ -75,7 +77,9 @@
@Resource
private MesProPalletService palletService;
@Resource
- private MesProBatchService wmBatchService;
+ private MesProBatchService proBatchService;
+ @Resource
+ private MesWmBatchService mesWmBatchService;
@Resource
private MesWmProductSalesLineService productSalesLineService;
@@ -241,9 +245,14 @@
.setCodeId(codeId).setScanContent(reqVO.getScanContent()).setAlreadyScanned(true)
.setDetailId(existed.getId()).setOutboundQuantity(existed.getQuantity()).setMessage("璇ョ爜宸叉壂鎻�");
}
- Long batchId = pallet != null ? pallet.getBatchId() : bag.getBatchId();
- MesProBatchDO batch = wmBatchService.getBatch(batchId);
+ Long proBatchId = pallet != null ? pallet.getBatchId() : bag.getBatchId();
+ MesProBatchDO batch = proBatchService.getBatch(proBatchId);
if (batch == null) {
+ throw exception(WM_TRANSACTION_BATCH_NOT_EXISTS);
+ }
+ // 鐢熶骇鎵规妗ユ帴浠撳簱鎵规锛氭壂鐮佸叆搴撳啓鍏ョ殑鏄粨搴撴壒娆★紙mes_wm_batch锛夛紝姝ゅ蹇呴』鐢ㄤ粨搴撴壒娆� id 鏌ュ簱瀛�
+ MesWmBatchDO wmBatch = mesWmBatchService.getOrCreateByProBatch(batch);
+ if (wmBatch == null) {
throw exception(WM_TRANSACTION_BATCH_NOT_EXISTS);
}
List<MesWmProductSalesLineDO> lines = productSalesLineService.getProductSalesLineListBySalesId(reqVO.getSalesId());
@@ -255,7 +264,7 @@
if (quantity == null) {
quantity = line.getQuantity();
}
- List<MesWmMaterialStockDO> stocks = materialStockService.getMaterialStockListByItemAndBatch(batch.getItemId(), batchId);
+ List<MesWmMaterialStockDO> stocks = materialStockService.getMaterialStockListByItemAndBatch(batch.getItemId(), wmBatch.getId());
BigDecimal outboundQuantity = quantity;
MesWmMaterialStockDO stock = stocks.stream().filter(item -> item.getQuantity().compareTo(outboundQuantity) >= 0).findFirst().orElse(null);
if (stock == null) {
@@ -268,13 +277,13 @@
}
MesWmProductSalesDetailDO detail = new MesWmProductSalesDetailDO().setLineId(line.getId())
.setSalesId(reqVO.getSalesId()).setItemId(batch.getItemId()).setQuantity(quantity)
- .setMaterialStockId(stock.getId()).setBatchId(batchId).setBatchCode(batch.getCode())
+ .setMaterialStockId(stock.getId()).setBatchId(wmBatch.getId()).setBatchCode(wmBatch.getCode())
.setWarehouseId(stock.getWarehouseId()).setLocationId(stock.getLocationId()).setAreaId(stock.getAreaId())
.setBagCodeId(pallet == null ? codeId : null).setPalletCodeId(pallet != null ? codeId : null);
productSalesDetailMapper.insert(detail);
return new MesWmProductSalesScanRespVO().setScanType(pallet != null ? "PALLET" : "BAG")
.setCodeId(codeId).setScanContent(reqVO.getScanContent()).setItemId(batch.getItemId())
- .setBatchId(batchId).setBatchCode(batch.getCode()).setMaterialStockId(stock.getId())
+ .setBatchId(wmBatch.getId()).setBatchCode(wmBatch.getCode()).setMaterialStockId(stock.getId())
.setAvailableQuantity(stock.getQuantity()).setScanQuantity(quantity).setOutboundQuantity(quantity)
.setAlreadyScanned(false).setDetailId(detail.getId()).setWarehouseId(stock.getWarehouseId())
.setLocationId(stock.getLocationId()).setAreaId(stock.getAreaId()).setMessage("鎵爜鎴愬姛");
--
Gitblit v1.9.3