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/oqc/MesQcOqcServiceImpl.java | 31 ++++++++++++++++++++++---------
1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/oqc/MesQcOqcServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/oqc/MesQcOqcServiceImpl.java
index 9daa2ba..6240055 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/oqc/MesQcOqcServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/oqc/MesQcOqcServiceImpl.java
@@ -39,6 +39,7 @@
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcImportExcelVO;
import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcImportRespVO;
@@ -114,6 +115,16 @@
.setTemplateId(templateId)
.setSourceDocCode(sourceDocCode)
.setStatus(MesQcStatusEnum.DRAFT.getStatus());
+ // 妫�娴嬩汉鍛樸�佹娴嬫棩鏈熴�佸嚭璐ф棩鏈熸湭濉啓鏃朵娇鐢ㄩ粯璁ゅ�硷紝涓嶅奖鍝嶆祦绋�
+ if (oqc.getInspectorUserId() == null) {
+ oqc.setInspectorUserId(getLoginUserId());
+ }
+ if (oqc.getInspectDate() == null) {
+ oqc.setInspectDate(LocalDateTime.now());
+ }
+ if (oqc.getOutDate() == null) {
+ oqc.setOutDate(LocalDateTime.now());
+ }
oqcMapper.insert(oqc);
// 3. 浠庢ā鏉挎寚鏍囪嚜鍔ㄧ敓鎴愭楠岃
@@ -142,7 +153,10 @@
// 鏍¢獙鐗╂枡銆佹娴嬩汉鍛樺瓨鍦�
// 娉細鐗╂枡 ID 鏉ヨ嚜 MDM锛屽鎴� ID 鏉ヨ嚜 CRM
mdmItemApi.validateItemExists(reqVO.getItemId());
- adminUserApi.validateUser(reqVO.getInspectorUserId());
+ // 鏍¢獙妫�娴嬩汉鍛樺瓨鍦紙闈炲繀濉紝鏈~鍐欐椂鐢卞垱寤洪�昏緫榛樿褰撳墠鐧诲綍浜猴級
+ if (reqVO.getInspectorUserId() != null) {
+ adminUserApi.validateUser(reqVO.getInspectorUserId());
+ }
}
@Override
@@ -203,16 +217,14 @@
return;
}
if (oqc.getSourceLineId() == null) {
- throw new IllegalArgumentException(
- "OQC 鍗昜" + oqc.getId() + "] sourceDocType 闈炵┖浣� sourceLineId 涓虹┖");
+ throw exception(QC_OQC_SOURCE_LINE_REQUIRED);
}
if (Objects.equals(oqc.getSourceDocType(), MesBizTypeConstants.WM_PRODUCT_SALES)) {
productSalesLineService.updateProductSalesLineWhenOqcFinish(
oqc.getSourceLineId(), oqc.getId(), oqc.getCheckResult());
} else {
- throw new IllegalArgumentException(
- "OQC 鍗昜" + oqc.getId() + "] sourceDocType=" + oqc.getSourceDocType() + " 鏃犳硶璇嗗埆锛屾棤娉曞洖鍐欐潵婧愬崟鎹�");
+ throw exception(QC_OQC_SOURCE_DOC_TYPE_UNKNOWN, oqc.getSourceDocType());
}
}
@@ -280,7 +292,7 @@
return null;
}
// 鏈煡鏉ユ簮绫诲瀷搴旀姤閿欙紝鑰屼笉鏄潤榛樺拷鐣�
- throw exception(QC_OQC_SOURCE_DOC_TYPE_UNKNOWN);
+ throw exception(QC_OQC_SOURCE_DOC_TYPE_UNKNOWN, sourceDocType);
}
@Override
@@ -343,15 +355,16 @@
try {
templateItem = templateItemService.getRequiredTemplateByItemIdAndType(
line.getItemId(), MesQcTypeEnum.OQC.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);
+ throw exception(QC_OQC_NO_TEMPLATE_FOR_ITEM, itemInfo);
}
Long templateId = templateItem.getTemplateId();
// 2. 鐢熸垚妫�楠屽崟缂栫爜
- String code = "OQC" + System.currentTimeMillis();
+ String code = "OQC" + java.util.UUID.randomUUID().toString().replace("-", "");
// 3. 鍒涘缓 OQC 涓昏〃锛堝緟妫�楠岀姸鎬侊紝鍒濆鏁伴噺涓� 0锛�
MesQcOqcDO oqc = new MesQcOqcDO();
--
Gitblit v1.9.3