AdmDictServiceImpl.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. revertSortField(request);
  332. //查询类型下的所有信息点信息
  333. AdmResponse admResponse = doQueryObjectInfo(context, request, AdmDictConstant.CLASS_CODE, clazz);
  334. List<AdmObjectInfo> admObjectInfos = (List<AdmObjectInfo>) admResponse.getContent();
  335. admObjectInfos = sortFuncidForEdit(admObjectInfos);
  336. //查询平台级信息点采集信息
  337. List<ObjectInfoCollect> commonObjectInfoCollect = queryObjectInfoCollect(context, "common", request.getType(), clazz);
  338. Map<String, Boolean> commonObjectInfoCollectMap = commonObjectInfoCollect.stream().filter(item -> StrUtil.isNotEmpty(item.getDefineInfoId())).collect(Collectors.toMap(ObjectInfoCollect::getDefineInfoId,ObjectInfoCollect::getVisiable));
  339. //查询项目级信息点采集信息
  340. List<ObjectInfoCollect> projectObjectInfoCollect = queryObjectInfoCollect(context, "project", request.getType(), clazz);
  341. Map<String, Boolean> projectObjectInfoCollectMap = projectObjectInfoCollect.stream().filter(item -> StrUtil.isNotEmpty(item.getDefineInfoId())).collect(Collectors.toMap(ObjectInfoCollect::getDefineInfoId,ObjectInfoCollect::getVisiable));
  342. String dictType = request.getDictType();
  343. //采集值配置查询
  344. if(StringUtils.isNotEmpty(dictType)){
  345. //查询平台级、项目级信息点采集信息
  346. if("common".equals(dictType)){
  347. setObjectInfoVisiable(admObjectInfos,commonObjectInfoCollectMap,dictType);
  348. }
  349. if("project".equals(dictType)){
  350. setObjectInfoVisiable(admObjectInfos,projectObjectInfoCollectMap,dictType);
  351. }
  352. admResponse.setContent(admObjectInfos);
  353. return admResponse;
  354. }
  355. //只查看采集值 todo
  356. if(CollUtil.isNotEmpty(projectObjectInfoCollectMap)){
  357. setOnlyQueryObjectInfoVisiable(admObjectInfos,projectObjectInfoCollectMap,dictType);
  358. }else{
  359. setOnlyQueryObjectInfoVisiable(admObjectInfos,commonObjectInfoCollectMap,dictType);
  360. }
  361. admResponse.setContent(admObjectInfos);
  362. return admResponse;
  363. }
  364. /**
  365. * 转换排序字段
  366. * @param request
  367. */
  368. private void revertSortField(AdmDictQueryCriteria request){
  369. request.setOrders("showOrder asc, name desc");
  370. }
  371. /**
  372. * 设置信息点是否可见
  373. * @param admObjectInfos
  374. * @param objectInfoCollectMap
  375. */
  376. private void setObjectInfoVisiable(List<AdmObjectInfo> admObjectInfos,Map<String, Boolean> objectInfoCollectMap,String dictType){
  377. if(CollUtil.isEmpty(admObjectInfos)){
  378. return;
  379. }
  380. for (AdmObjectInfo admObjectInfo : admObjectInfos) {
  381. Boolean visiable = null;
  382. String id = admObjectInfo.getId();
  383. if(CollUtil.isNotEmpty(objectInfoCollectMap)){
  384. visiable = objectInfoCollectMap.get(id);
  385. }
  386. if(visiable == null){
  387. if("common".equals(dictType)){
  388. if("localId".equals(admObjectInfo.getCode()) || "localName".equals(admObjectInfo.getCode())){
  389. visiable = true;
  390. }
  391. }
  392. if(visiable == null){
  393. visiable =false;
  394. }
  395. }
  396. admObjectInfo.setVisible(visiable);
  397. admObjectInfo.setEditable(true);
  398. admObjectInfo.setUnDisabled(true);
  399. }
  400. }
  401. /**
  402. * 设置台账管理中只查看采集值的信息点是否可见
  403. * @param admObjectInfos
  404. * @param objectInfoCollectMap
  405. */
  406. private void setOnlyQueryObjectInfoVisiable(List<AdmObjectInfo> admObjectInfos,Map<String, Boolean> objectInfoCollectMap,String dictType){
  407. if(CollUtil.isEmpty(admObjectInfos)){
  408. return;
  409. }
  410. for (AdmObjectInfo admObjectInfo : admObjectInfos) {
  411. Boolean visiable = null;
  412. String id = admObjectInfo.getId();
  413. //设置信息点是否可见
  414. if(CollUtil.isNotEmpty(objectInfoCollectMap)){
  415. visiable = objectInfoCollectMap.get(id);
  416. }
  417. if(visiable == null && ("localId".equals(admObjectInfo.getCode()) || "localName".equals(admObjectInfo.getCode()))){
  418. visiable = true;
  419. }
  420. if(visiable == null){
  421. visiable = false;
  422. }
  423. //信息点是否可编辑设置默认值
  424. if(admObjectInfo.getEditable() == null){
  425. List<String> unEditableList = checkoutDefInfoUnEditable();
  426. if(unEditableList.contains(admObjectInfo.getCode())){
  427. admObjectInfo.setEditable(false);
  428. }else {
  429. admObjectInfo.setEditable(true);
  430. }
  431. }
  432. //是否禁止操作设置默认值
  433. if(admObjectInfo.getUnDisabled() == null){
  434. List<String> unDisableList = checkoutDefInfoUnDisable();
  435. if(unDisableList.contains(admObjectInfo.getCode())){
  436. admObjectInfo.setUnDisabled(false);
  437. }else {
  438. admObjectInfo.setUnDisabled(true);
  439. }
  440. }
  441. admObjectInfo.setVisible(visiable);
  442. }
  443. }
  444. /**
  445. * 校验信息点是否可编辑
  446. * @return
  447. */
  448. public List<String> checkoutDefInfoUnEditable(){
  449. List<String> list = new ArrayList<>();
  450. list.add("id");
  451. list.add("name");
  452. list.add("qRCodePic");
  453. list.add("defaultQRCode");
  454. list.add("bimId");
  455. list.add("bimFamilyName");
  456. list.add("bimFamilySymbol");
  457. return list;
  458. }
  459. /**
  460. * 校验信息点是否禁止使用
  461. * @return
  462. */
  463. public List<String> checkoutDefInfoUnDisable(){
  464. List<String> list = new ArrayList<>();
  465. list.add("id");
  466. list.add("name");
  467. list.add("localId");
  468. list.add("localName");
  469. list.add("qRCodePic");
  470. list.add("defaultQRCode");
  471. list.add("bimId");
  472. list.add("bimFamilyName");
  473. list.add("bimFamilySymbol");
  474. return list;
  475. }
  476. /**
  477. * 查询信息点采集信息
  478. * @param context
  479. * @param dictType
  480. * @param classCode
  481. * @param clazz
  482. * @return
  483. */
  484. private List<ObjectInfoCollect> queryObjectInfoCollect(InstanceUrlParam context, String dictType,String classCode, Class<T> clazz){
  485. AdmQueryCriteria criteria = new AdmQueryCriteria();
  486. if("common".equals(dictType)){
  487. criteria.setFilters("groupCode = '0' and projectId = '0'");
  488. }else{
  489. criteria.setFilters("groupCode = '"+context.getGroupCode()+"' and projectId = '"+context.getProjectId()+"'");
  490. }
  491. criteria.setName(classCode);
  492. AdmResponse admResponse = doQueryObjectInfoCollect(context, criteria, "classCode", clazz);
  493. return (List<ObjectInfoCollect>) admResponse.getContent();
  494. }
  495. private List<AdmObjectInfo> sortFuncidForEdit(List<AdmObjectInfo> list) {
  496. List<AdmObjectInfo> resultOrders = new ArrayList<>();
  497. List<AdmObjectInfo> defaultOrders = new ArrayList<>();
  498. for (AdmObjectInfo admObjectInfo : list) {
  499. if(admObjectInfo.getSort()!=null){
  500. resultOrders.add(admObjectInfo);
  501. }else{
  502. defaultOrders.add(admObjectInfo);
  503. }
  504. }
  505. if(CollUtil.isNotEmpty(defaultOrders)){
  506. resultOrders.addAll(defaultOrders);
  507. }
  508. return resultOrders;
  509. }
  510. /**
  511. * 统计类型下的非静态信息点
  512. * @param context
  513. * @param code
  514. * @param name
  515. * @param result
  516. */
  517. private void statisticObjectInfo(InstanceUrlParam context,String code,String name,List<String> classCode,List<AdmObjectInfo> result){
  518. //根据类型查询信息点
  519. AdmQueryCriteria criteria = new AdmQueryCriteria();
  520. StringBuilder stringBuilder = new StringBuilder();
  521. classCode.stream().forEach(item -> {
  522. stringBuilder.append("'").append(item).append("'").append(",");
  523. });
  524. String filters = StrUtil.sub(stringBuilder.toString(),0, -1);
  525. criteria.setFilters("classCode in ["+filters+"]");
  526. AdmResponse response = doQueryObjectInfo(context, criteria, AdmDictConstant.CLASS_CODE, (Class<T>) AdmObjectInfo.class);
  527. List<AdmObjectInfo> content = (List<AdmObjectInfo>) response.getContent();
  528. if(CollUtil.isEmpty(content)){
  529. return ;
  530. }
  531. //过滤不需要的信息点
  532. Iterator<AdmObjectInfo> iterator = content.iterator();
  533. while (iterator.hasNext()){
  534. AdmObjectInfo objectInfo = iterator.next();
  535. if(StringUtils.isNotEmpty(objectInfo.getCategory()) && "STATIC".equals(objectInfo.getCategory())){
  536. iterator.remove();
  537. }
  538. }
  539. //返回结果拼装
  540. AdmObjectInfo admObjectInfo = new AdmObjectInfo();
  541. admObjectInfo.setCode(code);
  542. admObjectInfo.setName(name);
  543. admObjectInfo.setContent(content);
  544. result.add(admObjectInfo);
  545. }
  546. /**
  547. * 查询对象类型
  548. * @param context
  549. * @param code
  550. * @return
  551. */
  552. private List<String> queryDefClassType(InstanceUrlParam context,String code){
  553. QueryCriteria criteria = new QueryCriteria();
  554. ObjectNode node = JsonNodeFactory.instance.objectNode();
  555. node.put("parentCode",code);
  556. criteria.setCriteria(node);
  557. AdmResponse response = doQueryObjectType(context, criteria, (Class<T>) AdmObjectType.class);
  558. List<AdmObjectType> content = (List<AdmObjectType>) response.getContent();
  559. if(CollUtil.isEmpty(content)){
  560. return new ArrayList<>();
  561. }
  562. return content.stream().map(AdmObjectType::getCode).collect(Collectors.toList());
  563. }
  564. /**
  565. * 信息点转换为中台格式
  566. * @param content
  567. * @param dmpObjectInfos
  568. */
  569. private void objectInfosTransforDmp(List<AdmObjectInfo> content,List<AdmObjectInfo> dmpObjectInfos,String projectId){
  570. if(CollUtil.isEmpty(content)){
  571. return;
  572. }
  573. for (AdmObjectInfo admObjectInfo : content) {
  574. admObjectInfo.setProjectId(projectId);
  575. if(admObjectInfo.getMultiple() != null){
  576. admObjectInfo.setIsMultiple(admObjectInfo.getMultiple());
  577. }
  578. if(admObjectInfo.getIsRegion() != null){
  579. admObjectInfo.setIsRegion(admObjectInfo.getRegion());
  580. }
  581. if(StringUtils.isNotEmpty(admObjectInfo.getFirstName())){
  582. admObjectInfo.setFirstTag(admObjectInfo.getFirstName());
  583. }
  584. if(StringUtils.isNotEmpty(admObjectInfo.getSecondName())){
  585. admObjectInfo.setSecondTag(admObjectInfo.getSecondName());
  586. }
  587. admObjectInfo.setType(null);
  588. dmpObjectInfos.add(admObjectInfo);
  589. //处理子级
  590. List<AdmObjectInfo> sencondContent = admObjectInfo.getContent();
  591. if(CollUtil.isNotEmpty(sencondContent)){
  592. objectInfosTransforDmp(sencondContent,dmpObjectInfos,projectId);
  593. }
  594. }
  595. }
  596. }