From eee03bbfea8b15d1a56ab63bd09a35c6c861c4cb Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 09 十一月 2026 13:01:08 +0800
Subject: [PATCH] feat(mes): 不合格品处置联动入库与生产订单

---
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerProgressServiceImpl.java |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerProgressServiceImpl.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerProgressServiceImpl.java
index 603630f..bb80d59 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerProgressServiceImpl.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerProgressServiceImpl.java
@@ -1,14 +1,18 @@
 package cn.iocoder.yudao.module.crm.service.customer;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.progress.CrmCustomerProgressSaveReqVO;
+import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerProgressDO;
 import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerProgressMapper;
 import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
 import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
 import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
+import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
 import jakarta.annotation.Resource;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -39,6 +43,9 @@
     @Resource
     @Lazy
     private CrmPermissionService permissionService;
+
+    @Resource
+    private CrmCustomerService customerService;
 
     @Override
     @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#createReqVO.customerId",
@@ -92,6 +99,19 @@
         return result;
     }
 
+    /**
+     * 寮傚父鎻愮ず閲岀敤鐨勫鎴峰悕绉帮細瑙f瀽澶辫触鏃跺洖閫�涓� ID锛岄伩鍏嶅紓甯稿垎鏀啀鎶涗簩娆″紓甯�
+     */
+    private String getCustomerDisplayName(Long customerId) {
+        try {
+            CrmCustomerDO customer = customerService.getCustomer(customerId);
+            return customer != null && StrUtil.isNotBlank(customer.getName())
+                    ? customer.getName() : "ID=" + customerId;
+        } catch (Exception ex) {
+            return "ID=" + customerId;
+        }
+    }
+
     private CrmCustomerProgressDO validateProgressExists(Long id) {
         CrmCustomerProgressDO progress = customerProgressMapper.selectById(id);
         if (progress == null) {
@@ -101,9 +121,16 @@
     }
 
     private void validateCustomerWritePermission(Long customerId) {
+        // 瓒呯 / CRM 绠$悊鍛樹笌 @CrmPermission 鍒囬潰淇濇寔涓�鑷达紝鐩存帴鏀捐
+        if (CrmPermissionUtils.isCrmAdmin()) {
+            return;
+        }
         if (!permissionService.hasPermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customerId,
                 getLoginUserId(), CrmPermissionLevelEnum.WRITE)) {
-            throw exception(CRM_PERMISSION_DENIED, "瀹㈡埛娲借皥杩涘害");
+            throw new ServiceException(CRM_PERMISSION_DENIED.getCode(),
+                    "娌℃湁鏉冮檺淇敼/鍒犻櫎瀹㈡埛[" + getCustomerDisplayName(customerId)
+                            + "]鐨勬唇璋堣繘搴︼細鎮ㄤ笉鏄瀹㈡埛鐨勮礋璐d汉鎴栧洟闃熸垚鍛樸�傝璁╁鎴疯礋璐d汉鍦ㄥ鎴疯鎯呫�屽洟闃熸垚鍛樸�嶄腑鎶婃偍鍔犲叆锛�"
+                            + "鎴栧垏鎹㈠埌璇ュ鎴疯礋璐d汉璐﹀彿鍚庨噸璇曘��");
         }
     }
 

--
Gitblit v1.9.3