From bc9d77f6061a5c7f7deceaabc7c5ed6c17ad8c2f Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 12 十月 2026 14:19:37 +0800
Subject: [PATCH] fix(wm/productissue): 修复物料匹配校验逻辑并迁移至 MDM 物料服务
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
index 590df99..373e12f 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
@@ -18,6 +18,7 @@
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO;
import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeLineService;
import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcService;
+import cn.iocoder.yudao.module.mes.service.wm.unitconvert.MesWmItemUnitConvertService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
@@ -25,6 +26,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
+import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
@@ -35,7 +37,7 @@
/**
* MES 閿�鍞嚭搴撳崟琛� Service 瀹炵幇绫�
*
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
*/
@Service
@Validated
@@ -60,9 +62,13 @@
@Resource
@Lazy
private MesQcOqcService oqcService;
+ @Resource
+ private MesWmItemUnitConvertService itemUnitConvertService;
@Override
public Long createProductSalesLine(MesWmProductSalesLineSaveReqVO createReqVO) {
+ // 鍙屽崟浣嶆崲绠楋細鎸夊綍鍏ュ崟浣嶆崲绠椾负鐗╂枡涓诲崟浣嶆暟閲忥紙蹇呴』鍏堟崲绠楋紝鍐嶆牎楠屼笌鍙戣揣閫氱煡鍗曡鐨勬暟閲忎竴鑷存�э級
+ fillPrimaryQuantity(createReqVO);
// 鏍¢獙鏁版嵁
validateLineSaveData(createReqVO);
@@ -76,8 +82,10 @@
public void updateProductSalesLine(MesWmProductSalesLineSaveReqVO updateReqVO) {
// 鏍¢獙瀛樺湪
MesWmProductSalesLineDO oldLine = validateProductSalesLineExists(updateReqVO.getId());
- // 鏍¢獙鏁版嵁
updateReqVO.setSalesId(oldLine.getSalesId());
+ // 鍙屽崟浣嶆崲绠楋細鎸夊綍鍏ュ崟浣嶆崲绠椾负鐗╂枡涓诲崟浣嶆暟閲忥紙蹇呴』鍏堟崲绠楋紝鍐嶆牎楠屼笌鍙戣揣閫氱煡鍗曡鐨勬暟閲忎竴鑷存�э級
+ fillPrimaryQuantity(updateReqVO);
+ // 鏍¢獙鏁版嵁
validateLineSaveData(updateReqVO);
// 鏇存柊
@@ -167,6 +175,25 @@
}
/**
+ * 鍙屽崟浣嶆崲绠楋細閫夋嫨浜嗗綍鍏ュ崟浣嶆椂锛屾寜銆屽綍鍏ユ暟閲� 脳 鎹㈢畻姣旂巼銆嶅緱鍒扮墿鏂欎富鍗曚綅鍙e緞鐨勫嚭搴撴暟閲�
+ *
+ * 鏈寜杈呭崟浣嶅綍鍏ユ椂蹇呴』鐩存帴濉啓鍑哄簱鏁伴噺
+ */
+ private void fillPrimaryQuantity(MesWmProductSalesLineSaveReqVO reqVO) {
+ if (reqVO.getEnterUnitMeasureId() != null) {
+ BigDecimal primaryQuantity = itemUnitConvertService.convertToPrimaryUnit(
+ reqVO.getItemId(), reqVO.getItemModelId(),
+ reqVO.getEnterUnitMeasureId(), reqVO.getEnterQuantity());
+ if (primaryQuantity != null) {
+ reqVO.setQuantity(primaryQuantity);
+ }
+ }
+ if (reqVO.getQuantity() == null) {
+ throw exception(WM_PRODUCT_SALES_LINE_QUANTITY_REQUIRED);
+ }
+ }
+
+ /**
* 鏍规嵁 batchCode 瑙f瀽 batchId
*/
private void fillBatchId(MesWmProductSalesLineSaveReqVO reqVO) {
--
Gitblit v1.9.3