AdmDictServiceImpl.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. package com.persagy.proxy.adm.service.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  5. import com.fasterxml.jackson.databind.JsonNode;
  6. import com.fasterxml.jackson.databind.node.ArrayNode;
  7. import com.fasterxml.jackson.databind.node.JsonNodeFactory;
  8. import com.fasterxml.jackson.databind.node.ObjectNode;
  9. import com.persagy.dmp.basic.model.QueryCriteria;
  10. import com.persagy.dmp.define.entity.ObjectInfoCollect;
  11. import com.persagy.dmp.define.entity.ObjectInfoDefine;
  12. import com.persagy.proxy.adm.constant.AdmDictConstant;
  13. import com.persagy.proxy.adm.constant.enums.AdmDictCategoryEnum;
  14. import com.persagy.proxy.adm.model.*;
  15. import com.persagy.proxy.adm.request.AdmCreateRequest;
  16. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  17. import com.persagy.proxy.adm.request.AdmResponse;
  18. import com.persagy.proxy.adm.service.IAdmDictService;
  19. import com.persagy.proxy.common.entity.InstanceUrlParam;
  20. import lombok.extern.slf4j.Slf4j;
  21. import org.apache.commons.lang.StringUtils;
  22. import org.springframework.context.annotation.Primary;
  23. import org.springframework.stereotype.Service;
  24. import java.util.*;
  25. import java.util.stream.Collectors;
  26. /**
  27. * @ClassName AdmDictServiceImpl
  28. * @Description: 字典查询
  29. * @Author linhuili
  30. * @Date 2021/8/31 18:21
  31. * @Version V1.0
  32. **/
  33. @Slf4j
  34. @Service
  35. public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> implements IAdmDictService<T> {
  36. /**
  37. * 字典类型查询:所有设备类型、部件类型、系统类型、专业类型
  38. * 查询类型:输入设备类型:equipment,输入部件类型:component,输入系统类型:system,输入专业类型:major,业务空间类型 space ,资产 property,
  39. * 专业和系统:majorSystem(树),设备和部件equipmentAndComponent,设备类型要以及对应的部件equipmentComponent(树),
  40. * 专业下的设备类型 majorEquipment (树),专业下的系统,系统下的设备majorSystemEquip (树),systemEquip 系统下的设备类(树)
  41. * @param request
  42. * @return
  43. * @throws Exception
  44. */
  45. @Override
  46. public AdmResponse queryCategory(InstanceUrlParam context , AdmDict request, Class<T> clazz) throws Exception {
  47. String type = request.getType();
  48. QueryCriteria criteria = new QueryCriteria();
  49. ObjectNode node = JsonNodeFactory.instance.objectNode();
  50. if(AdmDictCategoryEnum.MAJOR.getValue().equals(type)){
  51. //查询专业分类
  52. node.put("type",AdmDictCategoryEnum.MAJOR.getValue());
  53. criteria.setCriteria(node);
  54. return doQueryDictData(context, criteria, clazz);
  55. }
  56. List<String> baseCategory = getDictBaseCategory();
  57. if(baseCategory.contains(type)){
  58. //查询设备类型:equipment,部件类型:component,输入系统类型:system,输入专业类型:major,业务空间类型 space ,资产 property
  59. node.put("objType",type);
  60. criteria.setCriteria(node);
  61. return doQueryObjectType(context, criteria, clazz);
  62. }
  63. if(AdmDictCategoryEnum.EQUIPMENT_AND_COMPONENT.getValue().equals(type)){
  64. //查询设备类型:equipment,部件类型:component,输入系统类型:system,输入专业类型:major,业务空间类型 space ,资产 property
  65. ArrayNode arrayNode = node.putObject("objType").putArray("$in");
  66. arrayNode.add(AdmDictCategoryEnum.COMPONENT.getValue());
  67. arrayNode.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
  68. criteria.setCriteria(node);
  69. return doQueryObjectType(context, criteria, clazz);
  70. }
  71. List<String> dictTreeCategory = getDictTreeCategory();
  72. if(dictTreeCategory.contains(type)){
  73. //查询树形结构:专业和系统:majorSystem(树),设备类型要以及对应的部件equipmentComponent(树),专业下的设备类型 majorEquipment(树),
  74. //专业下的系统,系统下的设备majorSystemEquip (树),systemEquip 系统下的设备类(树)
  75. return queryDictObjectTypeTree(context ,type,clazz);
  76. }
  77. return null;
  78. }
  79. /**
  80. * 查询字典树
  81. * @param context
  82. * @param type
  83. * @param clazz
  84. */
  85. private AdmResponse queryDictObjectTypeTree(InstanceUrlParam context ,String type, Class<T> clazz){
  86. //查询所有的专业
  87. List<AdmObjectType> allMajor = getAllMajor(context, clazz);
  88. //查询所有的类型
  89. AdmResponse admResponse = doQueryObjectType(context, new QueryCriteria(), clazz);
  90. List<AdmObjectType> objectTypes = (List<AdmObjectType>) admResponse.getContent();
  91. Map<String, List<AdmObjectType>> objectTypeMap = objectTypes.stream().filter(k-> StringUtils.isNotEmpty(k.getObjType()))
  92. .collect(Collectors.groupingBy(AdmObjectType::getObjType));
  93. //获取专业-设备类关系
  94. List<AdmObjectType> equipments = objectTypeMap.get(AdmDictCategoryEnum.EQUIPMENT.getValue());
  95. Map<String,List<AdmObjectType>> majorEquipMap = equipments.stream().filter(k->StringUtils.isNotEmpty(k.getMajorCode()))
  96. .collect(Collectors.groupingBy(item -> item.getMajorCode()));
  97. //获取专业-系统类关系
  98. List<AdmObjectType> systems = objectTypeMap.get(AdmDictCategoryEnum.SYSTEM.getValue());
  99. Map<String, List<AdmObjectType>> majorSystemMap = systems.stream().filter(k->StringUtils.isNotEmpty(k.getMajorCode())).collect(Collectors.groupingBy(item -> item.getMajorCode()));
  100. //获取系统-设备类关系
  101. Map<String, List<AdmObjectType>> systemEquipMap = equipments.stream().filter(k->StringUtils.isNotEmpty(k.getSystemCode())).collect(Collectors.groupingBy(item -> item.getSystemCode()));
  102. //获取设备类-部件关系
  103. List<AdmObjectType> components = objectTypeMap.get(AdmDictCategoryEnum.COMPONENT.getValue());
  104. Map<String, List<AdmObjectType>> equipComponentMap = components.stream().filter(k->StringUtils.isNotEmpty(k.getEquipmentCode())).collect(Collectors.groupingBy(item -> item.getEquipmentCode()));
  105. List<AdmObjectType> content = new ArrayList<>();
  106. if(AdmDictCategoryEnum.MAJOR_SYSTEM.getValue().equals(type)){
  107. //查询专业下的系统
  108. content = buildDictTree(allMajor,majorSystemMap,null);
  109. }
  110. if(AdmDictCategoryEnum.SYSTEM_EQUIP.getValue().equals(type)){
  111. //查询系统下的设备类
  112. content = buildDictTree(systems,systemEquipMap,null);
  113. }
  114. if(AdmDictCategoryEnum.MAJOR_SYSTEM_EQUIP.getValue().equals(type)){
  115. //专业下的系统,系统下的设备
  116. content = buildDictTree(allMajor,majorSystemMap,systemEquipMap);
  117. }
  118. if(AdmDictCategoryEnum.MAJOR_EQUIPMENT.getValue().equals(type)){
  119. //查询专业下的设备类
  120. content = buildDictTree(allMajor,majorEquipMap,null);
  121. }
  122. if(AdmDictCategoryEnum.EQUIPMENT_COMPONENT.getValue().equals(type)){
  123. //查询设备类下的部件
  124. content = buildDictTree(equipments,equipComponentMap,null);
  125. }
  126. // 设置返回值
  127. AdmResponse response = AdmResponse.success(content);
  128. response.setTotal(Long.valueOf(content.size()));
  129. return response;
  130. }
  131. /**
  132. * 构建专业-系统-设备类树形结构
  133. * @param allMajor
  134. * @param majorSystemMap
  135. * @param systemEquipMap
  136. * @return
  137. */
  138. private ArrayList<AdmObjectType> buildDictTree(List<AdmObjectType> allMajor,Map<String, List<AdmObjectType>> majorSystemMap,Map<String, List<AdmObjectType>> systemEquipMap){
  139. ArrayList<AdmObjectType> result = new ArrayList<>();
  140. if(CollUtil.isEmpty(allMajor)){
  141. return result;
  142. }
  143. //构建专业-系统-设备类树形结构
  144. for (AdmObjectType major : allMajor) {
  145. //设置专业
  146. if(CollUtil.isNotEmpty(majorSystemMap)){
  147. //专业下的系统
  148. List<AdmObjectType> systemCodes = majorSystemMap.get(major.getCode());
  149. major.setChildren(systemCodes);
  150. //系统下的设备类
  151. if(CollUtil.isNotEmpty(systemEquipMap) && CollUtil.isNotEmpty(systemCodes)){
  152. for (AdmObjectType systemType : systemCodes) {
  153. systemType.setChildren(systemEquipMap.get(systemType.getCode()));
  154. }
  155. }
  156. }
  157. result.add(major);
  158. }
  159. return result;
  160. }
  161. /**
  162. * 获取所有的专业
  163. * @param context
  164. * @param clazz
  165. * @return
  166. */
  167. private List<AdmObjectType> getAllMajor(InstanceUrlParam context, Class<T> clazz){
  168. //查询专业分类
  169. QueryCriteria criteria = new QueryCriteria();
  170. ObjectNode node = JsonNodeFactory.instance.objectNode();
  171. node.put("type",AdmDictCategoryEnum.MAJOR.getValue());
  172. criteria.setCriteria(node);
  173. AdmResponse admResponse = doQueryDictData(context, criteria, clazz);
  174. List<AdmObjectType> content = (List<AdmObjectType>) admResponse.getContent();
  175. return content;
  176. }
  177. /**
  178. * 基础数据类型
  179. * @return
  180. */
  181. private List<String> getDictBaseCategory(){
  182. List<String> category = new ArrayList<>();
  183. category.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
  184. category.add(AdmDictCategoryEnum.COMPONENT.getValue());
  185. category.add(AdmDictCategoryEnum.SYSTEM.getValue());
  186. category.add(AdmDictCategoryEnum.SPACE.getValue());
  187. category.add(AdmDictCategoryEnum.PROPRTY.getValue());
  188. return category;
  189. }
  190. /**
  191. * 查询字典树形结构
  192. * @return
  193. */
  194. private List<String> getDictTreeCategory(){
  195. List<String> category = new ArrayList<>();
  196. category.add(AdmDictCategoryEnum.MAJOR_SYSTEM.getValue());
  197. category.add(AdmDictCategoryEnum.MAJOR_EQUIPMENT.getValue());
  198. category.add(AdmDictCategoryEnum.MAJOR_SYSTEM_EQUIP.getValue());
  199. category.add(AdmDictCategoryEnum.EQUIPMENT_COMPONENT.getValue());
  200. category.add(AdmDictCategoryEnum.SYSTEM_EQUIP.getValue());
  201. return category;
  202. }
  203. /**
  204. * 重置项目下的信息点
  205. * @param context
  206. * @param clazz
  207. * @return
  208. * @throws Exception
  209. */
  210. @Override
  211. public AdmResponse resetDic(InstanceUrlParam context, AdmDictQueryCriteria request, String fieldName, Class<T> clazz) throws Exception {
  212. //查询项目下点所有信息点
  213. AdmResponse admResponse = doQueryObjectInfo(context, request, fieldName, clazz);
  214. List<AdmObjectInfo> content = (List<AdmObjectInfo>) admResponse.getContent();
  215. if(CollUtil.isEmpty(content)){
  216. AdmResponse response = AdmResponse.success(new ArrayList<>());
  217. response.setTotal(Long.valueOf(0));
  218. return response;
  219. }
  220. //因BDTP根据项目查询信息点时返回的包含集团+通用信息点,需手动过滤除项目级的信息点
  221. String projectId = context.getProjectId();
  222. Iterator<AdmObjectInfo> infoIterator = content.iterator();
  223. while (infoIterator.hasNext()){
  224. String admProjectId = infoIterator.next().getProjectId();
  225. if(StringUtils.isEmpty(admProjectId) || !projectId.equals(admProjectId)){
  226. infoIterator.remove();
  227. }
  228. }
  229. //删除信息点
  230. doDeleteObjectInfo(context,(List<T>)content);
  231. // 设置返回值
  232. AdmResponse response = AdmResponse.success(content);
  233. response.setTotal(Long.valueOf(content.size()));
  234. return response;
  235. }
  236. /**
  237. * 设置-项目定制化字典
  238. * @param context
  239. * @param request
  240. * @param clazz
  241. * @return
  242. * @throws Exception
  243. */
  244. @Override
  245. public AdmResponse settingDicProject(InstanceUrlParam context, AdmCreateRequest<AdmDefFuncIdGather> request, Class<T> clazz) throws Exception {
  246. List<AdmDefFuncIdGather> content = request.getContent();
  247. if(CollUtil.isEmpty(content)){
  248. return AdmResponse.success(content);
  249. }
  250. //参数转换为中台参数
  251. List<T> list = new ArrayList<>();
  252. for (AdmDefFuncIdGather funcIdGather : content) {
  253. ObjectInfoCollect infoCollect = new ObjectInfoCollect();
  254. infoCollect.setGroupCode(funcIdGather.getGroupCode());
  255. infoCollect.setProjectId(funcIdGather.getProjectId());
  256. infoCollect.setDefineInfoId(funcIdGather.getId());
  257. infoCollect.setClassCode(funcIdGather.getClassCode());
  258. infoCollect.setCode(funcIdGather.getCode());
  259. infoCollect.setVisiable(funcIdGather.getVisible());
  260. list.add((T) infoCollect);
  261. }
  262. //设置采集信息点
  263. doSetObjectInfoCollect(context, clazz, list);
  264. return AdmResponse.success(content);
  265. }
  266. /**
  267. * 查询所有字典信息 M 和 L 类型,包括自定义信息点
  268. * @param context
  269. * @param dictTypeList
  270. * @return
  271. */
  272. @Override
  273. public AdmResponse queryMorlDict(InstanceUrlParam context, List<String> dictTypeList) {
  274. List<AdmObjectInfo> result = new ArrayList<>();
  275. for (String type : dictTypeList) {
  276. List<String> classCodes = new ArrayList<>();
  277. String name = null;
  278. //项目
  279. if(AdmDictCategoryEnum.PROJECT.getValue().equals(type)){
  280. name = AdmDictCategoryEnum.PROJECT.getDesc();
  281. classCodes.add(AdmDictCategoryEnum.PROJECT.getValue());
  282. }
  283. //建筑
  284. if(AdmDictCategoryEnum.BUILDING.getValue().equals(type)){
  285. name = AdmDictCategoryEnum.BUILDING.getDesc();
  286. classCodes.add(AdmDictCategoryEnum.BUILDING.getValue());
  287. }
  288. //楼层
  289. if(AdmDictCategoryEnum.FLOOR.getValue().equals(type)){
  290. name = AdmDictCategoryEnum.FLOOR.getDesc();
  291. classCodes.add(AdmDictCategoryEnum.FLOOR.getValue());
  292. }
  293. //设备
  294. if(AdmDictCategoryEnum.EQUIPMENT.getValue().equals(type)){
  295. name = AdmDictCategoryEnum.EQUIPMENT.getDesc();
  296. classCodes.addAll(queryDefClassType(context, AdmDictCategoryEnum.EQUIPMENT.getValue()));
  297. }
  298. //部件
  299. if(AdmDictCategoryEnum.COMPONENT.getValue().equals(type)){
  300. name = AdmDictCategoryEnum.COMPONENT.getDesc();
  301. classCodes.addAll(queryDefClassType(context, AdmDictCategoryEnum.COMPONENT.getValue()));
  302. }
  303. //系统
  304. if(AdmDictCategoryEnum.SYSTEM.getValue().equals(type)){
  305. name = AdmDictCategoryEnum.SYSTEM.getDesc();
  306. classCodes.addAll(queryDefClassType(context, AdmDictCategoryEnum.SYSTEM.getValue()));
  307. }
  308. //空间
  309. if(AdmDictCategoryEnum.SPACE.getValue().equals(type)){
  310. name = AdmDictCategoryEnum.SPACE.getDesc();
  311. classCodes.addAll(queryDefClassType(context, AdmDictCategoryEnum.SPACE.getValue()));
  312. }
  313. //查询类型下的信息点
  314. statisticObjectInfo(context,type, name, classCodes,result);
  315. }
  316. AdmResponse response = AdmResponse.success(result);
  317. response.setTotal(Long.valueOf(result.size()));
  318. return response;
  319. }
  320. /**
  321. * 查询信息点
  322. * @param context
  323. * @param request
  324. * @param fieldName
  325. * @param clazz
  326. * @return
  327. */
  328. @Override
  329. public AdmResponse query(InstanceUrlParam context, AdmDictQueryCriteria request, String fieldName, Class<T> clazz) {
  330. //查询类型下的所有信息点信息
  331. AdmResponse admResponse = doQueryObjectInfo(context, request, AdmDictConstant.CLASS_CODE, clazz);
  332. List<AdmObjectInfo> admObjectInfos = (List<AdmObjectInfo>) admResponse.getContent();
  333. //查询平台级信息点采集信息
  334. List<ObjectInfoCollect> commonObjectInfoCollect = queryObjectInfoCollect(context, "common", request.getType(), clazz);
  335. Map<String, Boolean> commonObjectInfoCollectMap = commonObjectInfoCollect.stream().filter(item -> StrUtil.isNotEmpty(item.getDefineInfoId())).collect(Collectors.toMap(ObjectInfoCollect::getDefineInfoId,ObjectInfoCollect::getVisiable));
  336. //查询项目级信息点采集信息
  337. List<ObjectInfoCollect> projectObjectInfoCollect = queryObjectInfoCollect(context, "project", request.getType(), clazz);
  338. Map<String, Boolean> projectObjectInfoCollectMap = projectObjectInfoCollect.stream().filter(item -> StrUtil.isNotEmpty(item.getDefineInfoId())).collect(Collectors.toMap(ObjectInfoCollect::getDefineInfoId,ObjectInfoCollect::getVisiable));
  339. String dictType = request.getDictType();
  340. //采集值配置查询
  341. if(StringUtils.isNotEmpty(dictType)){
  342. //查询平台级、项目级信息点采集信息
  343. if("common".equals(dictType)){
  344. setObjectInfoVisiable(admObjectInfos,commonObjectInfoCollectMap,dictType);
  345. }
  346. if("project".equals(dictType)){
  347. setObjectInfoVisiable(admObjectInfos,projectObjectInfoCollectMap,dictType);
  348. }
  349. admResponse.setContent(admObjectInfos);
  350. return admResponse;
  351. }
  352. //只查看采集值 todo
  353. if(CollUtil.isNotEmpty(projectObjectInfoCollectMap)){
  354. setOnlyQueryObjectInfoVisiable(admObjectInfos,projectObjectInfoCollectMap,dictType);
  355. }else{
  356. setOnlyQueryObjectInfoVisiable(admObjectInfos,commonObjectInfoCollectMap,dictType);
  357. }
  358. admResponse.setContent(admObjectInfos);
  359. return admResponse;
  360. }
  361. /**
  362. * 设置信息点是否可见
  363. * @param admObjectInfos
  364. * @param objectInfoCollectMap
  365. */
  366. private void setObjectInfoVisiable(List<AdmObjectInfo> admObjectInfos,Map<String, Boolean> objectInfoCollectMap,String dictType){
  367. if(CollUtil.isEmpty(admObjectInfos)){
  368. return;
  369. }
  370. for (AdmObjectInfo admObjectInfo : admObjectInfos) {
  371. Boolean visiable = null;
  372. String id = admObjectInfo.getId();
  373. if(CollUtil.isNotEmpty(objectInfoCollectMap)){
  374. visiable = objectInfoCollectMap.get(id);
  375. }
  376. if(visiable == null){
  377. if("common".equals(dictType)){
  378. if("localId".equals(admObjectInfo.getCode()) || "localName".equals(admObjectInfo.getCode())){
  379. visiable = true;
  380. }
  381. }
  382. if(visiable == null){
  383. visiable =false;
  384. }
  385. }
  386. admObjectInfo.setVisible(visiable);
  387. }
  388. }
  389. /**
  390. * 设置台账管理中只查看采集值的信息点是否可见
  391. * @param admObjectInfos
  392. * @param objectInfoCollectMap
  393. */
  394. private void setOnlyQueryObjectInfoVisiable(List<AdmObjectInfo> admObjectInfos,Map<String, Boolean> objectInfoCollectMap,String dictType){
  395. if(CollUtil.isEmpty(admObjectInfos)){
  396. return;
  397. }
  398. for (AdmObjectInfo admObjectInfo : admObjectInfos) {
  399. Boolean visiable = null;
  400. String id = admObjectInfo.getId();
  401. if(CollUtil.isNotEmpty(objectInfoCollectMap)){
  402. visiable = objectInfoCollectMap.get(id);
  403. }else {
  404. if(visiable == null && ("localId".equals(admObjectInfo.getCode()) || "localName".equals(admObjectInfo.getCode()))){
  405. visiable = true;
  406. }
  407. }
  408. if(visiable == null){
  409. visiable = false;
  410. }
  411. admObjectInfo.setVisible(visiable);
  412. }
  413. }
  414. /**
  415. * 查询信息点采集信息
  416. * @param context
  417. * @param dictType
  418. * @param classCode
  419. * @param clazz
  420. * @return
  421. */
  422. private List<ObjectInfoCollect> queryObjectInfoCollect(InstanceUrlParam context, String dictType,String classCode, Class<T> clazz){
  423. AdmQueryCriteria criteria = new AdmQueryCriteria();
  424. if("common".equals(dictType)){
  425. criteria.setFilters("groupCode = '0' and projectId = '0'");
  426. }else{
  427. criteria.setFilters("groupCode = '"+context.getGroupCode()+"' and projectId = '"+context.getProjectId()+"'");
  428. }
  429. criteria.setName(classCode);
  430. AdmResponse admResponse = doQueryObjectInfoCollect(context, criteria, "classCode", clazz);
  431. return (List<ObjectInfoCollect>) admResponse.getContent();
  432. }
  433. /**
  434. * 统计类型下的非静态信息点
  435. * @param context
  436. * @param code
  437. * @param name
  438. * @param result
  439. */
  440. private void statisticObjectInfo(InstanceUrlParam context,String code,String name,List<String> classCode,List<AdmObjectInfo> result){
  441. //根据类型查询信息点
  442. AdmQueryCriteria criteria = new AdmQueryCriteria();
  443. StringBuilder stringBuilder = new StringBuilder();
  444. classCode.stream().forEach(item -> {
  445. stringBuilder.append("'").append(item).append("'").append(",");
  446. });
  447. String filters = StrUtil.sub(stringBuilder.toString(),0, -1);
  448. criteria.setFilters("classCode in ["+filters+"]");
  449. AdmResponse response = doQueryObjectInfo(context, criteria, AdmDictConstant.CLASS_CODE, (Class<T>) AdmObjectInfo.class);
  450. List<AdmObjectInfo> content = (List<AdmObjectInfo>) response.getContent();
  451. if(CollUtil.isEmpty(content)){
  452. return ;
  453. }
  454. //过滤不需要的信息点
  455. Iterator<AdmObjectInfo> iterator = content.iterator();
  456. while (iterator.hasNext()){
  457. AdmObjectInfo objectInfo = iterator.next();
  458. if(StringUtils.isNotEmpty(objectInfo.getCategory()) && "STATIC".equals(objectInfo.getCategory())){
  459. iterator.remove();
  460. }
  461. }
  462. //返回结果拼装
  463. AdmObjectInfo admObjectInfo = new AdmObjectInfo();
  464. admObjectInfo.setCode(code);
  465. admObjectInfo.setName(name);
  466. admObjectInfo.setContent(content);
  467. result.add(admObjectInfo);
  468. }
  469. /**
  470. * 查询对象类型
  471. * @param context
  472. * @param code
  473. * @return
  474. */
  475. private List<String> queryDefClassType(InstanceUrlParam context,String code){
  476. QueryCriteria criteria = new QueryCriteria();
  477. ObjectNode node = JsonNodeFactory.instance.objectNode();
  478. node.put("parentCode",code);
  479. criteria.setCriteria(node);
  480. AdmResponse response = doQueryObjectType(context, criteria, (Class<T>) AdmObjectType.class);
  481. List<AdmObjectType> content = (List<AdmObjectType>) response.getContent();
  482. if(CollUtil.isEmpty(content)){
  483. return new ArrayList<>();
  484. }
  485. return content.stream().map(AdmObjectType::getCode).collect(Collectors.toList());
  486. }
  487. /**
  488. * 信息点转换为中台格式
  489. * @param content
  490. * @param dmpObjectInfos
  491. */
  492. private void objectInfosTransforDmp(List<AdmObjectInfo> content,List<AdmObjectInfo> dmpObjectInfos,String projectId){
  493. if(CollUtil.isEmpty(content)){
  494. return;
  495. }
  496. for (AdmObjectInfo admObjectInfo : content) {
  497. admObjectInfo.setProjectId(projectId);
  498. if(admObjectInfo.getMultiple() != null){
  499. admObjectInfo.setIsMultiple(admObjectInfo.getMultiple());
  500. }
  501. if(admObjectInfo.getIsRegion() != null){
  502. admObjectInfo.setIsRegion(admObjectInfo.getRegion());
  503. }
  504. if(StringUtils.isNotEmpty(admObjectInfo.getFirstName())){
  505. admObjectInfo.setFirstTag(admObjectInfo.getFirstName());
  506. }
  507. if(StringUtils.isNotEmpty(admObjectInfo.getSecondName())){
  508. admObjectInfo.setSecondTag(admObjectInfo.getSecondName());
  509. }
  510. admObjectInfo.setType(null);
  511. dmpObjectInfos.add(admObjectInfo);
  512. //处理子级
  513. List<AdmObjectInfo> sencondContent = admObjectInfo.getContent();
  514. if(CollUtil.isNotEmpty(sencondContent)){
  515. objectInfosTransforDmp(sencondContent,dmpObjectInfos,projectId);
  516. }
  517. }
  518. }
  519. }