From 05ab6e3f69a5e73624b2573db043f5923e8f7d8b Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 05 十一月 2026 14:17:19 +0800
Subject: [PATCH] fix 修复bug
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/safety/SafetyRefResolver.java | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/safety/SafetyRefResolver.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/safety/SafetyRefResolver.java
index 6350614..702a2ff 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/safety/SafetyRefResolver.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/safety/SafetyRefResolver.java
@@ -9,6 +9,7 @@
import org.springframework.stereotype.Component;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -65,12 +66,15 @@
* 鎵归噺鍙栧憳宸ワ紝杩斿洖 id -> 鍛樺伐 鐨� Map
*/
public Map<Long, HrmEmployeeSimpleDTO> employeeMap(Collection<Long> employeeIds) {
+ // 娉ㄦ剰锛氳繖閲屽繀椤昏繑鍥炲彲鎺ュ彈 null key 鐨勭┖ Map銆�
+ // 璋冪敤鏂逛細鐩存帴 map.get(璁板綍閲岀殑 xxxId)锛岃�� xxxId 鍏佽涓� null锛堜緥濡傜粍缁囨湭璁捐礋璐d汉銆�
+ // 璇佷欢鏈叧鑱旀寔璇佷汉锛夛紝Map.of() 鐨� get(null) 浼氭姏 NPE锛屽鑷村垪琛ㄦ帴鍙� 500銆�
if (CollUtil.isEmpty(employeeIds)) {
- return Map.of();
+ return new HashMap<>();
}
List<Long> ids = employeeIds.stream().filter(Objects::nonNull).distinct().toList();
if (ids.isEmpty()) {
- return Map.of();
+ return new HashMap<>();
}
return hrmEmployeeApi.getEmployeeList(ids).stream()
.collect(Collectors.toMap(HrmEmployeeSimpleDTO::getId, e -> e, (a, b) -> a));
@@ -103,12 +107,13 @@
* 鎵归噺鍙栬溅闂达紝杩斿洖 id -> 杞﹂棿 鐨� Map
*/
public Map<Long, MesMdWorkshopDO> workshopMap(Collection<Long> workshopIds) {
+ // 鍚屼笂锛氳溅闂寸紪鍙峰厑璁镐负 null锛岀┖闆嗗悎蹇呴』杩斿洖鍙帴鍙� null key 鐨� Map
if (CollUtil.isEmpty(workshopIds)) {
- return Map.of();
+ return new HashMap<>();
}
List<Long> ids = workshopIds.stream().filter(Objects::nonNull).distinct().toList();
if (ids.isEmpty()) {
- return Map.of();
+ return new HashMap<>();
}
return workshopMapper.selectBatchIds(ids).stream()
.collect(Collectors.toMap(MesMdWorkshopDO::getId, w -> w, (a, b) -> a));
--
Gitblit v1.9.3