From defe1e1c3ade87de0a7990f565f08f93aeb2decc Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 08 十一月 2026 19:31:46 +0800
Subject: [PATCH] fix(bpm): 统一审批标题单号并收紧各模块提交校验
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java | 74 ++++++++++++++++++++----------------
1 files changed, 41 insertions(+), 33 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 92444cb..14fc6b1 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
@@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.mes.service.wm.productsales;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.module.erp.api.sale.ErpSaleOrderApi;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ObjUtil;
@@ -60,6 +61,8 @@
@Resource
@Lazy
private MesQcOqcService oqcService;
+ @Resource
+ private ErpSaleOrderApi saleOrderApi;
@Override
public Long createProductSalesLine(MesWmProductSalesLineSaveReqVO createReqVO) {
@@ -71,8 +74,31 @@
if (noticeLine != null) {
line.setSaleOrderItemId(noticeLine.getSaleOrderItemId());
}
+ fillProductSalesLinePrice(line);
productSalesLineMapper.insert(line);
return line.getId();
+ }
+
+ /**
+ * 鎸夐攢鍞鍗曡鍗曚环鍥炲~鍑哄簱琛岄噾棰濓紝渚涘紑绁�/瀵硅处浣跨敤
+ */
+ private void fillProductSalesLinePrice(MesWmProductSalesLineDO line) {
+ if (line.getSaleOrderItemId() == null) {
+ return;
+ }
+ try {
+ var item = saleOrderApi.getSaleOrderItem(line.getSaleOrderItemId()).getData();
+ if (item == null || item.getProductPrice() == null) {
+ return;
+ }
+ line.setPrice(item.getProductPrice());
+ if (line.getQuantity() != null) {
+ line.setTotalPrice(item.getProductPrice().multiply(line.getQuantity()));
+ }
+ } catch (Exception ex) {
+ // 浠锋牸鍙槸蹇収锛岃鍗曡鍙栦笉鍒版椂涓嶉樆鏂紑鍗�
+ log.warn("[fillProductSalesLinePrice][閿�鍞鍗曡({}) 浠锋牸蹇収澶辫触]", line.getSaleOrderItemId(), ex);
+ }
}
@Override
@@ -88,37 +114,10 @@
if (noticeLine != null) {
updateObj.setSaleOrderItemId(noticeLine.getSaleOrderItemId());
}
+ fillProductSalesLinePrice(updateObj);
productSalesLineMapper.updateById(updateObj);
- // 妫�鏌ユ槸鍚﹂渶瑕佸垱寤� OQC 妫�楠屽崟锛氫粠涓嶉渶瑕佹楠屽彉涓洪渶瑕佹楠�
- if (Boolean.TRUE.equals(updateReqVO.getOqcCheckFlag())
- && !Boolean.TRUE.equals(oldLine.getOqcCheckFlag())) {
- // 鑾峰彇鍑哄簱鍗曚俊鎭�
- MesWmProductSalesDO sales = productSalesService.getProductSales(updateReqVO.getSalesId());
- if (sales == null) {
- log.warn("[updateProductSalesLine] 鍑哄簱鍗曚笉瀛樺湪锛宻alesId={}", updateReqVO.getSalesId());
- return;
- }
-
- // 鏋勫缓鍑哄簱鏄庣粏 DO
- MesWmProductSalesLineDO line = new MesWmProductSalesLineDO();
- line.setId(updateReqVO.getId());
- line.setItemId(updateReqVO.getItemId());
- line.setSaleOrderItemId(updateObj.getSaleOrderItemId() != null
- ? updateObj.getSaleOrderItemId() : oldLine.getSaleOrderItemId());
- line.setBatchCode(updateReqVO.getBatchCode());
- line.setQuantity(updateReqVO.getQuantity());
-
- // 鍒涘缓 OQC 妫�楠屽崟锛岃寮傚父鎶涘嚭
- Long oqcId = oqcService.createOqcFromProductSales(
- sales.getId(), line, sales.getCode(), sales.getClientId());
-
- // 鏇存柊鍑哄簱鏄庣粏鐨� oqcId 鍜岃川閲忕姸鎬�
- productSalesLineMapper.updateById(new MesWmProductSalesLineDO()
- .setId(updateReqVO.getId())
- .setOqcId(oqcId)
- .setQualityStatus(MesWmQualityStatusEnum.PENDING.getStatus()));
- }
+ // 鎻愪氦鍑哄簱鍗曞悗鐢辫川妫�浜哄憳閫夋嫨宸插畬鎴愮殑鍑哄巶妫�楠屽崟銆�
}
@Override
@@ -196,6 +195,16 @@
mdmItemService.validateItemExistsAndEnable(reqVO.getItemId());
// 鏍¢獙鍏宠仈鍙戣揣閫氱煡鍗曡锛堝瓨鍦ㄦ�� + 褰掑睘 + 瀛楁涓�鑷存�э級
MesWmSalesNoticeLineDO noticeLine = validateSalesNoticeLine(sales, reqVO);
+ if (noticeLine == null && sales.getSaleOrderId() != null) {
+ if (reqVO.getSaleOrderItemId() == null) {
+ throw exception(WM_SALES_NOTICE_SALE_ORDER_ITEM_EMPTY);
+ }
+ var item = saleOrderApi.getSaleOrderItem(reqVO.getSaleOrderItemId()).getCheckedData();
+ if (item == null || !Objects.equals(item.getOrderId(), sales.getSaleOrderId())
+ || !Objects.equals(item.getProductId(), reqVO.getItemId())) {
+ throw exception(WM_SALES_NOTICE_LINE_SALE_ITEM_MISMATCH);
+ }
+ }
// 鏍规嵁 batchCode 瑙f瀽 batchId
fillBatchId(reqVO);
return noticeLine;
@@ -256,19 +265,18 @@
Long salesId = currentLine.getSalesId();
List<MesWmProductSalesLineDO> allLines = productSalesLineMapper.selectListBySalesId(salesId);
- // 2.1 妫�鏌ユ槸鍚︽湁涓嶅悎鏍艰 鈫� 鍙栨秷鍑哄簱鍗�
+ // 涓嶅悎鏍艰鐣欏緟鍚庣画澶勭疆锛屼笉鑳藉洜涓烘楠岀粨鏋滆嚜鍔ㄥ彇娑堟暣寮犲嚭搴撳崟銆�
boolean hasNg = CollectionUtils.anyMatch(allLines,
line -> Boolean.TRUE.equals(line.getOqcCheckFlag())
&& Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus()));
if (hasNg) {
- log.info("[updateProductSalesLineWhenOqcFinish][閿�鍞嚭搴撳崟({}) 瀛樺湪璐ㄦ涓嶅悎鏍艰锛屽彇娑堝嚭搴撳崟]", salesId);
- productSalesService.cancelProductSales(salesId);
+ log.info("[updateProductSalesLineWhenOqcFinish][閿�鍞嚭搴撳崟({}) 瀛樺湪璐ㄦ涓嶅悎鏍艰锛岀瓑寰呭悗缁缃甝", salesId);
return;
}
// 2.2 妫�鏌ユ槸鍚︽墍鏈� OQC 琛岄兘宸插畬鎴愶紝鑷姩娴佽浆 CONFIRMED 鈫� APPROVING
boolean hasUnchecked = CollectionUtils.anyMatch(allLines,
- line -> Boolean.TRUE.equals(line.getOqcCheckFlag()) && line.getOqcId() == null);
+ line -> Boolean.TRUE.equals(line.getOqcCheckFlag()) && !Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.PASS.getStatus()));
if (!hasUnchecked) {
log.info("[updateProductSalesLineWhenOqcFinish][閿�鍞嚭搴撳崟({}) 鎵�鏈� OQC 琛屾楠屽畬鎴愶紝娴佽浆鍒板緟鎷h揣]", salesId);
productSalesService.confirmProductSales(salesId);
--
Gitblit v1.9.3