Browse Source

bug修复

linhuili 3 years ago
parent
commit
30a8e24422

+ 3 - 0
src/main/java/com/persagy/proxy/adm/constant/enums/AdmDictCategoryEnum.java

@@ -11,6 +11,9 @@ import java.util.List;
  * @Version V1.0
  **/
 public enum AdmDictCategoryEnum {
+    PROJECT("project", "项目"),
+    BUILDING("building", "建筑"),
+    FLOOR("floor", "楼层"),
     EQUIPMENT("equipment", "设备"),
     COMPONENT("component", "组件"),
     SYSTEM("system", "系统"),

+ 2 - 2
src/main/java/com/persagy/proxy/adm/model/AdmObjectInfo.java

@@ -119,8 +119,8 @@ public class AdmObjectInfo {
 
     /**路径 :
      * 若firstName == "基本信息"|| firstName.isNullOrEmpty()||firstName == "基本参数 path为code编码,否则,path为infos.$code */
-    private String path;
+   private String path;
 
     /** 字典内容 */
-    private List<AdmObjectInfo> content;
+   private List<AdmObjectInfo> content;
 }

+ 6 - 2
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java

@@ -390,9 +390,13 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
         }
         // 调用中台查询
         DmpResult<JSONArray> dmpResult = rwdClient.queryObject(context, para);
-       // List<T> admVOs = AdmEntityTransferUtil.toAdmMultiEntity(dmpResult.getData(), null, clazz);
+        JSONArray data = dmpResult.getData();
+        List<T> admVOs = new ArrayList<>();
+        if(CollUtil.isNotEmpty(data)){
+            admVOs = data.toJavaList(clazz);
+        }
         // 设置返回值
-        AdmResponse response = AdmResponse.success((List<T>)dmpResult.getData());
+        AdmResponse response = AdmResponse.success(admVOs);
         Long total = dmpResult.getCount() == null ? null : dmpResult.getCount().longValue();
         response.setTotal(total);
         return response;

+ 7 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmDictBaseServiceImpl.java

@@ -96,7 +96,10 @@ public class AbstractAdmDictBaseServiceImpl<T> implements IAdmDictBaseService<T>
         // 调用中台查询
         DmpResult<JSONArray> dmpResult = rwdClient.queryObjectType(context, para);
         JSONArray data = dmpResult.getData();
-        List<T> admVOs = data.toJavaList(clazz);
+        List<T> admVOs = new ArrayList<>();
+        if(CollUtil.isNotEmpty(data)){
+            admVOs = data.toJavaList(clazz);
+        }
         // 设置返回值
         AdmResponse response = AdmResponse.success(admVOs);
         Long total = dmpResult.getCount() == null ? null : dmpResult.getCount().longValue();
@@ -181,6 +184,9 @@ public class AbstractAdmDictBaseServiceImpl<T> implements IAdmDictBaseService<T>
      * @param admVOs
      */
     private void handleObjectInfoResult(List<AdmObjectInfo> admVOs){
+        if(CollUtil.isEmpty(admVOs)){
+            return;
+        }
         for (AdmObjectInfo admVO : admVOs) {
             admVO.setFirstName(admVO.getFirstTag());
             admVO.setSecondName(admVO.getSecondTag());

+ 115 - 12
src/main/java/com/persagy/proxy/adm/service/impl/AdmDictServiceImpl.java

@@ -2,6 +2,9 @@ package com.persagy.proxy.adm.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
@@ -63,10 +66,9 @@ public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> imp
 
         if(AdmDictCategoryEnum.EQUIPMENT_AND_COMPONENT.getValue().equals(type)){
             //查询设备类型:equipment,部件类型:component,输入系统类型:system,输入专业类型:major,业务空间类型 space ,资产 property
-            List<String> objTypes = new ArrayList<>();
-            objTypes.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
-            objTypes.add(AdmDictCategoryEnum.COMPONENT.getValue());
-            node.put("objType",objTypes.toString());
+            ArrayNode arrayNode = node.putObject("objType").putArray("$in");
+            arrayNode.add(AdmDictCategoryEnum.COMPONENT.getValue());
+            arrayNode.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
             criteria.setCriteria(node);
             return doQueryObjectType(context, criteria, clazz);
         }
@@ -97,18 +99,20 @@ public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> imp
                                                          .collect(Collectors.groupingBy(AdmObjectType::getObjType));
         //获取专业-设备类关系
         List<AdmObjectType> equipments = objectTypeMap.get(AdmDictCategoryEnum.EQUIPMENT.getValue());
-        Map<String,List<AdmObjectType>> majorEquipMap = equipments.stream().collect(Collectors.groupingBy(item -> item.getMajorCode()));
+        Map<String,List<AdmObjectType>> majorEquipMap = equipments.stream().filter(k->StringUtils.isNotEmpty(k.getMajorCode()))
+                                                         .collect(Collectors.groupingBy(item -> item.getMajorCode()));
 
         //获取专业-系统类关系
         List<AdmObjectType> systems = objectTypeMap.get(AdmDictCategoryEnum.SYSTEM.getValue());
-        Map<String, List<AdmObjectType>> majorSystemMap = systems.stream().collect(Collectors.groupingBy(item -> item.getMajorCode()));
+        log.info("aaa");
+        Map<String, List<AdmObjectType>> majorSystemMap = systems.stream().filter(k->StringUtils.isNotEmpty(k.getMajorCode())).collect(Collectors.groupingBy(item -> item.getMajorCode()));
 
         //获取系统-设备类关系
-        Map<String, List<AdmObjectType>> systemEquipMap = equipments.stream().collect(Collectors.groupingBy(item -> item.getSystemCode()));
+        Map<String, List<AdmObjectType>> systemEquipMap = equipments.stream().filter(k->StringUtils.isNotEmpty(k.getSystemCode())).collect(Collectors.groupingBy(item -> item.getSystemCode()));
 
         //获取设备类-部件关系
         List<AdmObjectType> components = objectTypeMap.get(AdmDictCategoryEnum.COMPONENT.getValue());
-        Map<String, List<AdmObjectType>> equipComponentMap = components.stream().collect(Collectors.groupingBy(item -> item.getEquipmentCode()));
+        Map<String, List<AdmObjectType>> equipComponentMap = components.stream().filter(k->StringUtils.isNotEmpty(k.getEquipmentCode())).collect(Collectors.groupingBy(item -> item.getEquipmentCode()));
 
         List<AdmObjectType> content = new ArrayList<>();
         if(AdmDictCategoryEnum.MAJOR_SYSTEM.getValue().equals(type)){
@@ -279,14 +283,113 @@ public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> imp
     @Override
     public AdmResponse queryMorlDict(InstanceUrlParam context, List<String> dictTypeList) {
 
+        List<AdmObjectInfo> result = new ArrayList<>();
+        for (String type : dictTypeList) {
+            List<String> classCodes = new ArrayList<>();
+            String name = null;
+            //项目
+            if(AdmDictCategoryEnum.PROJECT.getValue().equals(type)){
+               name = AdmDictCategoryEnum.PROJECT.getDesc();
+               classCodes.add(AdmDictCategoryEnum.PROJECT.getValue());
+            }
+            //建筑
+            if(AdmDictCategoryEnum.BUILDING.getValue().equals(type)){
+                name = AdmDictCategoryEnum.BUILDING.getDesc();
+                classCodes.add(AdmDictCategoryEnum.BUILDING.getValue());
+            }
+            //楼层
+            if(AdmDictCategoryEnum.FLOOR.getValue().equals(type)){
+                name = AdmDictCategoryEnum.FLOOR.getDesc();
+                classCodes.add(AdmDictCategoryEnum.FLOOR.getValue());
+            }
+            //设备
+            if(AdmDictCategoryEnum.EQUIPMENT.getValue().equals(type)){
+                name = AdmDictCategoryEnum.EQUIPMENT.getDesc();
+                classCodes.addAll(queryDefClassType(context, AdmDictCategoryEnum.EQUIPMENT.getValue()));
+            }
+            //部件
+            if(AdmDictCategoryEnum.COMPONENT.getValue().equals(type)){
+                name = AdmDictCategoryEnum.COMPONENT.getDesc();
+                classCodes.addAll(queryDefClassType(context, AdmDictCategoryEnum.COMPONENT.getValue()));
+            }
+            //系统
+            if(AdmDictCategoryEnum.SYSTEM.getValue().equals(type)){
+                name = AdmDictCategoryEnum.SYSTEM.getDesc();
+                classCodes.addAll(queryDefClassType(context, AdmDictCategoryEnum.SYSTEM.getValue()));
+            }
+            //空间
+            if(AdmDictCategoryEnum.SPACE.getValue().equals(type)){
+                name = AdmDictCategoryEnum.SPACE.getDesc();
+                classCodes.addAll(queryDefClassType(context, AdmDictCategoryEnum.SPACE.getValue()));
+            }
+            //查询类型下的信息点
+            statisticObjectInfo(context,type, name, classCodes,result);
+        }
+        AdmResponse response = AdmResponse.success(result);
+        response.setTotal(Long.valueOf(result.size()));
+        return response;
+    }
+
+
+    /**
+     * 统计类型下的非静态信息点
+     * @param context
+     * @param code
+     * @param name
+     * @param result
+     */
+    private void statisticObjectInfo(InstanceUrlParam context,String code,String name,List<String> classCode,List<AdmObjectInfo> result){
+        //根据类型查询信息点
         AdmQueryCriteria criteria = new AdmQueryCriteria();
+        StringBuilder stringBuilder = new StringBuilder();
+        classCode.stream().forEach(item -> {
+            stringBuilder.append("'").append(item).append("'").append(",");
+        });
+        String filters = StrUtil.sub(stringBuilder.toString(),0, -1);
+        criteria.setFilters("classCode in ["+filters+"]");
+        AdmResponse response = doQueryObjectInfo(context, criteria, AdmDictConstant.CLASS_CODE, (Class<T>) AdmObjectInfo.class);
+        List<AdmObjectInfo> content = (List<AdmObjectInfo>) response.getContent();
+        if(CollUtil.isEmpty(content)){
+            return ;
+        }
+        //过滤不需要的信息点
+        Iterator<AdmObjectInfo> iterator = content.iterator();
+        while (iterator.hasNext()){
+            AdmObjectInfo objectInfo = iterator.next();
+            if(StringUtils.isNotEmpty(objectInfo.getCategory()) && "STATIC".equals(objectInfo.getCategory())){
+                iterator.remove();
+            }
+        }
+        //返回结果拼装
+        AdmObjectInfo admObjectInfo = new AdmObjectInfo();
+        admObjectInfo.setCode(code);
+        admObjectInfo.setName(name);
+        admObjectInfo.setContent(content);
+        result.add(admObjectInfo);
+    }
+
+
+    /**
+     * 查询对象类型
+     * @param context
+     * @param code
+     * @return
+     */
+    private List<String> queryDefClassType(InstanceUrlParam context,String code){
+        QueryCriteria criteria = new QueryCriteria();
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put("parentCode",code);
+        criteria.setCriteria(node);
 
-        StringBuilder filters = new StringBuilder();
-        filters.append("objType in "+ dictTypeList);
-        criteria.setFilters(filters.toString());
-        return doQueryObjectInfo(context, criteria, AdmDictConstant.CLASS_CODE, (Class<T>) AdmObjectInfo.class);
+        AdmResponse response = doQueryObjectType(context, criteria, (Class<T>) AdmObjectType.class);
+        List<AdmObjectType> content = (List<AdmObjectType>) response.getContent();
+        if(CollUtil.isEmpty(content)){
+            return new ArrayList<>();
+        }
+        return content.stream().map(AdmObjectType::getCode).collect(Collectors.toList());
     }
 
+
     /**
      * 信息点转换为中台格式
      * @param content

+ 5 - 4
src/main/java/com/persagy/proxy/adm/service/impl/AdmLabslServiceImpl.java

@@ -2,6 +2,7 @@ package com.persagy.proxy.adm.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
@@ -59,10 +60,10 @@ public class AdmLabslServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> im
         }
 
         //查询所有的系统,设备类
-        List<String> objTypes = new ArrayList<>();
-        objTypes.add(AdmDictCategoryEnum.SYSTEM.getValue());
-        objTypes.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
-        node.put("objType",objTypes.toString());
+        ArrayNode arrayNode = node.putObject("objType").putArray("$in");
+        arrayNode.add(AdmDictCategoryEnum.SYSTEM.getValue());
+        arrayNode.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
+
         criteria.setCriteria(node);
         AdmResponse equipResponse = doQueryObjectType(context, criteria, clazz);