From ac2e2b5af3726ee64dc37c3ebf26989a0346f22a Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期六, 07 十一月 2026 19:16:05 +0800
Subject: [PATCH] feat(feedback): 优化报工审批流程并增加报工人校验

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcServiceImpl.java |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcServiceImpl.java
index dab5ea9..a493534 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcServiceImpl.java
@@ -40,6 +40,7 @@
 import java.util.*;
 
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
@@ -112,6 +113,16 @@
                 .setCheckQuantity(createReqVO.getQualifiedQuantity().add(createReqVO.getUnqualifiedQuantity()))
                 .setSourceDocCode(sourceDocCode)
                 .setStatus(MesQcStatusEnum.DRAFT.getStatus());
+        // 妫�娴嬩汉鍛樸�佹娴嬫棩鏈熴�佹潵鏂欐棩鏈熸湭濉啓鏃朵娇鐢ㄩ粯璁ゅ�硷紝涓嶅奖鍝嶆祦绋�
+        if (iqc.getInspectorUserId() == null) {
+            iqc.setInspectorUserId(getLoginUserId());
+        }
+        if (iqc.getInspectDate() == null) {
+            iqc.setInspectDate(LocalDateTime.now());
+        }
+        if (iqc.getReceiveDate() == null) {
+            iqc.setReceiveDate(LocalDateTime.now());
+        }
         iqcMapper.insert(iqc);
 
         // 3. 浠庢ā鏉挎寚鏍囪嚜鍔ㄧ敓鎴愭楠岃
@@ -146,8 +157,10 @@
         if (reqVO.getItemId() != null) {
             mdmItemApi.getItem(reqVO.getItemId()).getCheckedData();
         }
-        // 鏍¢獙妫�娴嬩汉鍛樺瓨鍦�
-        adminUserApi.validateUser(reqVO.getInspectorUserId());
+        // 鏍¢獙妫�娴嬩汉鍛樺瓨鍦紙闈炲繀濉紝鏈~鍐欐椂鐢卞垱寤洪�昏緫榛樿褰撳墠鐧诲綍浜猴級
+        if (reqVO.getInspectorUserId() != null) {
+            adminUserApi.validateUser(reqVO.getInspectorUserId());
+        }
     }
 
     @Override
@@ -204,8 +217,7 @@
             return;
         }
         if (ObjectUtil.hasNull(iqc.getSourceLineId(), iqc.getSourceDocId())) {
-            throw new IllegalArgumentException(
-                    "IQC 鍗昜" + iqc.getId() + "] sourceDocType 闈炵┖浣� sourceLineId 鎴� sourceDocId 涓虹┖");
+            throw exception(QC_IQC_SOURCE_DOC_PARAMS_MISSING);
         }
 
         // 鏍规嵁涓嶅悓鐨勬潵婧愬崟鎹被鍨嬶紝鍥炲啓涓嶅悓鐨勫崟鎹�
@@ -216,8 +228,7 @@
             outsourceReceiptService.updateOutsourceReceiptWhenIqcFinish(iqc.getSourceDocId(), iqc.getSourceLineId(),
                     iqc.getId(), iqc.getQualifiedQuantity(), iqc.getUnqualifiedQuantity());
         } else {
-            throw new IllegalArgumentException(
-                    "IQC 鍗昜" + iqc.getId() + "] sourceDocType=" + iqc.getSourceDocType() + " 鏃犳硶璇嗗埆锛屾棤娉曞洖鍐欐潵婧愬崟鎹�");
+            throw exception(QC_IQC_SOURCE_DOC_TYPE_UNKNOWN, iqc.getSourceDocType());
         }
     }
 
@@ -367,7 +378,8 @@
         try {
             templateItem = templateItemService.getRequiredTemplateByItemIdAndType(
                     line.getItemId(), MesQcTypeEnum.IQC.getType());
-        } catch (Exception e) {
+        } catch (cn.iocoder.yudao.framework.common.exception.ServiceException e) {
+            if (!java.util.Objects.equals(e.getCode(), QC_NO_TEMPLATE.getCode())) throw e;
             // 鑾峰彇鐗╂枡淇℃伅锛屾彁渚涙洿鏄庣‘鐨勯敊璇彁绀�
             String itemInfo = getItemInfo(line.getItemId());
             throw exception(QC_NO_TEMPLATE_FOR_ITEM, itemInfo);
@@ -375,7 +387,7 @@
         Long templateId = templateItem.getTemplateId();
 
         // 2. 鐢熸垚妫�楠屽崟缂栫爜
-        String code = "IQC" + System.currentTimeMillis();
+        String code = "IQC" + UUID.randomUUID().toString().replace("-", "");
 
         // 3. 鍒涘缓 IQC 涓昏〃锛堝緟妫�楠岀姸鎬侊紝鍒濆鍚堟牸鏁伴噺涓� 0锛�
         MesQcIqcDO iqc = new MesQcIqcDO();

--
Gitblit v1.9.3