From 25bdb3fa20edd3b09611ccd5d19244d4e7264ab0 Mon Sep 17 00:00:00 2001
From: lead <lead@local>
Date: 星期二, 03 十一月 2026 10:09:31 +0800
Subject: [PATCH] fix(kyzn): 物料新增 500 —— 修复 MES 物料分类编码重复导致 selectOne 抛 TooManyResultsException

---
 yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java
index cfbc790..325d8b5 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java
@@ -152,6 +152,11 @@
         String itemTypeCode = null;
         if (reqVO.getCategoryId() != null) {
             CommonResult<MesMdItemTypeRespDTO> itemType = mesMdItemTypeApi.getItemType(reqVO.getCategoryId());
+            // 鍒嗙被鍦� MES 渚т笉瀛樺湪鏃讹紙濡傚巻鍙叉暟鎹腑 MDM 鍒嗙被涓� MES 鍒嗙被涓嶅悓姝ワ級锛�
+            // 缁欏嚭鏄庣‘鐨勪笟鍔℃彁绀猴紝鑰屼笉鏄姏 NullPointerException 鍙樻垚 500
+            if (itemType == null || itemType.getData() == null) {
+                throw exception(MDM_ITEM_CATEGORY_NOT_SYNC_MES, reqVO.getCategoryId());
+            }
             itemTypeCode = itemType.getData().getCode();
         }
         // 缁勮鍚屾 DTO

--
Gitblit v1.9.3