소스 검색

/equip-query/equip-components 空指针

lvxianyun 3 년 전
부모
커밋
8a5767e368
1개의 변경된 파일22개의 추가작업 그리고 18개의 파일을 삭제
  1. 22 18
      src/main/java/com/persagy/proxy/adm/controller/AdmReportEquipController.java

+ 22 - 18
src/main/java/com/persagy/proxy/adm/controller/AdmReportEquipController.java

@@ -86,25 +86,29 @@ public class AdmReportEquipController {
         request.setCascade(cascade);
         AdmResponse admResponse = equipmentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
         List<AdmEquipment> equipmentList = (List<AdmEquipment>) admResponse.getContent();
-        equipmentList.stream().forEach(equip -> {
-            if (CollUtil.isNotEmpty(equip.getComponent())) {
-                equip.setCount(equip.getComponent().size());
-                equip.setComponent(null);
-            } else {
-                equip.setCount(0);
+        if(CollUtil.isNotEmpty(equipmentList)){
+            equipmentList.stream().forEach(equip -> {
+                if (CollUtil.isNotEmpty(equip.getComponent())) {
+                    equip.setCount(equip.getComponent().size());
+                    equip.setComponent(null);
+                } else {
+                    equip.setCount(0);
+                }
+            });
+            //查询设备的类型信息,取list中的第一个数据
+            AdmEquipment admEquipment = equipmentList.get(0);
+            QueryCriteria defineCriteria = new QueryCriteria();
+            ObjectNode criteria = JsonNodeFactory.instance.objectNode();
+            criteria.put("code", admEquipment.getClassCode());
+            defineCriteria.setCriteria(criteria);
+            AdmResponse defRes = dictService.doQueryObjectType(AdmContextUtil.toDmpContext(), defineCriteria, AdmObjectType.class);
+            if (CollUtil.isNotEmpty(defRes.getContent())) {
+                List<AdmObjectType> componentCategory = (List<AdmObjectType>) defRes.getContent();
+                admEquipment.setComponentCategory(componentCategory);
+                equipmentList.set(0, admEquipment);
             }
-        });
-        //查询设备的类型信息,取list中的第一个数据
-        AdmEquipment admEquipment = equipmentList.get(0);
-        QueryCriteria defineCriteria = new QueryCriteria();
-        ObjectNode criteria = JsonNodeFactory.instance.objectNode();
-        criteria.put("code", admEquipment.getClassCode());
-        defineCriteria.setCriteria(criteria);
-        AdmResponse defRes = dictService.doQueryObjectType(AdmContextUtil.toDmpContext(), defineCriteria, AdmObjectType.class);
-        if (CollUtil.isNotEmpty(defRes.getContent())) {
-            List<AdmObjectType> componentCategory = (List<AdmObjectType>) defRes.getContent();
-            admEquipment.setComponentCategory(componentCategory);
-            equipmentList.set(0, admEquipment);
+        }else{
+            equipmentList = new ArrayList<>();
         }
         return AdmResponse.success(equipmentList);
     }