AdmShaftServiceImpl.java 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package com.persagy.proxy.object.service.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.fasterxml.jackson.databind.ObjectMapper;
  4. import com.fasterxml.jackson.databind.node.ObjectNode;
  5. import com.persagy.dmp.basic.model.QueryCriteria;
  6. import com.persagy.dmp.common.helper.SpringHelper;
  7. import com.persagy.proxy.adm.constant.GraphCodeEnum;
  8. import com.persagy.proxy.adm.constant.RelCodeEnum;
  9. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  10. import com.persagy.proxy.adm.request.AdmResponse;
  11. import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
  12. import com.persagy.proxy.adm.utils.AdmContextUtil;
  13. import com.persagy.proxy.common.entity.InstanceUrlParam;
  14. import com.persagy.proxy.object.model.AdmEquipment;
  15. import com.persagy.proxy.object.model.AdmShaft;
  16. import com.persagy.proxy.object.model.AdmSystem;
  17. import com.persagy.proxy.object.service.IAdmEquipmentService;
  18. import com.persagy.proxy.object.service.IAdmShaftService;
  19. import com.persagy.proxy.object.service.IAdmSystemService;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.stereotype.Service;
  22. import java.util.ArrayList;
  23. import java.util.List;
  24. /**
  25. * ADM 竖井 实现类
  26. * @author lvxy
  27. * @date 2021/8/18
  28. */
  29. @Service
  30. public class AdmShaftServiceImpl extends AbstractAdmBaseServiceImpl<AdmShaft> implements IAdmShaftService {
  31. @Autowired
  32. private IAdmEquipmentService equipmentService;
  33. @Autowired
  34. private IAdmSystemService systemService;
  35. @Override
  36. public void ensureSpecialValues(InstanceUrlParam context, List<AdmShaft> vos) {
  37. if(CollUtil.isEmpty(vos)) {
  38. return;
  39. }
  40. //收集设备对象、系统对象
  41. List<AdmEquipment> equipmentList = new ArrayList<>();
  42. List<AdmSystem> systemList = new ArrayList<>();
  43. vos.stream().forEach(admShaft -> {
  44. if(CollUtil.isNotEmpty(admShaft.getEquipmentList())){
  45. equipmentList.addAll(admShaft.getEquipmentList());
  46. }
  47. if(CollUtil.isNotEmpty(admShaft.getSystemList())){
  48. systemList.addAll(admShaft.getSystemList());
  49. }
  50. });
  51. equipmentService.ensureSpecialValues(AdmContextUtil.toDmpContext(), equipmentList);
  52. systemService.ensureSpecialValues(AdmContextUtil.toDmpContext(), systemList);
  53. }
  54. @Override
  55. public void processDmpCriteria(QueryCriteria dmpRequest) {
  56. ObjectNode criteria = dmpRequest.getCriteria();
  57. if (null==criteria){
  58. return;
  59. }
  60. if (criteria.has("buildingId")){
  61. // 有建筑id过滤
  62. ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
  63. ObjectNode relationTo = objectMapper.createObjectNode();
  64. relationTo.put("graphCode", GraphCodeEnum.ArchSubset.name());
  65. relationTo.put("relCode", RelCodeEnum.Bd2Sh.name());
  66. if(!criteria.get("buildingId").toString().contains("$null")) {
  67. relationTo.set("objFrom",criteria.get("buildingId"));
  68. }else{
  69. relationTo.put("$bindFlag", false);
  70. }
  71. criteria.set("relationTo",relationTo);
  72. criteria.remove("buildingId");
  73. }
  74. }
  75. @Override
  76. public AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request, Class<AdmShaft> clazz) {
  77. AdmResponse response = super.doQuery(context, request, clazz);
  78. // 系统需要补充分类名称属性
  79. ensureSpecialValues(context, (List<AdmShaft>) response.getContent());
  80. return response;
  81. }
  82. }