فهرست منبع

fix: 处理空指针异常

luofeiyun 1 ماه پیش
والد
کامیت
674313eae7

+ 7 - 1
ship-module-product/ship-module-product-biz/src/main/java/com/yc/ship/module/product/service/voyagestockdistribute/VoyageStockDistributeServiceImpl.java

@@ -278,7 +278,13 @@ public class VoyageStockDistributeServiceImpl implements VoyageStockDistributeSe
         }
         List<RoomRespDTO> roomList = roomApi.getRoomList(voyage.getShipId());
         List<VoyageStockDistributeDO> list = voyageStockDistributeMapper.selectListByVoyageId(voyageId);
-        List<Integer> selectedList = list.stream().flatMap(list1 -> list1.getRoomNums().stream()).collect(Collectors.toList());
+        List<Integer> selectedList = list.stream().flatMap(list1 -> {
+            List<Integer> roomNums = list1.getRoomNums();
+            if(roomNums != null) {
+                return roomNums.stream();
+            }
+            return new ArrayList<Integer>().stream();
+        }).collect(Collectors.toList());
         roomList.stream().forEach(room -> {
             room.setIsSelected(selectedList.contains(room.getRoomNum()));
         });