|
@@ -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
|