Browse Source

fix : buildingId 信息点查询调整

lvxianyun 3 years ago
parent
commit
4e11b803d2

+ 8 - 1
src/main/java/com/persagy/proxy/object/service/IAdmShaftService.java

@@ -1,8 +1,9 @@
 package com.persagy.proxy.object.service;
 
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.proxy.adm.service.IAdmBaseService;
-import com.persagy.proxy.object.model.AdmShaft;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.object.model.AdmShaft;
 
 import java.util.List;
 
@@ -13,4 +14,10 @@ import java.util.List;
  */
 public interface IAdmShaftService extends IAdmBaseService<AdmShaft> {
     void ensureSpecialValues(InstanceUrlParam context, List<AdmShaft> vos);
+    /***
+     * Description: 子类重写,以便处理带buildingId
+     * @param dmpRequest : 中台查询参数
+     * @return : void
+     */
+    void processDmpCriteria(QueryCriteria dmpRequest);
 }

+ 8 - 1
src/main/java/com/persagy/proxy/object/service/IAdmSystemService.java

@@ -1,8 +1,9 @@
 package com.persagy.proxy.object.service;
 
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.proxy.adm.service.IAdmBaseService;
-import com.persagy.proxy.object.model.AdmSystem;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.object.model.AdmSystem;
 
 import java.util.List;
 
@@ -19,4 +20,10 @@ public interface IAdmSystemService extends IAdmBaseService<AdmSystem> {
      * @param vos
      */
     void ensureSpecialValues(InstanceUrlParam context, List<AdmSystem> vos);
+    /***
+     * Description: 子类重写,以便处理带buildingId
+     * @param dmpRequest : 中台查询参数
+     * @return : void
+     */
+    void processDmpCriteria(QueryCriteria dmpRequest);
 }

+ 4 - 5
src/main/java/com/persagy/proxy/object/service/impl/AdmEquipmentServiceImpl.java

@@ -22,7 +22,6 @@ import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
-import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.common.client.DmpRwdClient;
 import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
@@ -114,9 +113,7 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
 
     @Override
     public AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request, Class<AdmEquipment> clazz) {
-        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
-        processDmpCriteria(queryCriteria);
-        AdmResponse response = super.doQuery(context, queryCriteria, clazz);
+        AdmResponse response = super.doQuery(context, request, clazz);
         // 系统需要补充分类名称属性
         ensureSpecialValues(context, (List<AdmEquipment>) response.getContent());
         return response;
@@ -158,7 +155,7 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
      */
     @Override
     public AdmResponse query(AdmQueryCriteria admQueryCriteria) {
-        AdmResponse response = this.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmEquipment.class);
+        AdmResponse response = super.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmEquipment.class);
         // 系统需要补充分类名称属性
         ensureSpecialValues(AdmContextUtil.toDmpContext(), (List<AdmEquipment>) response.getContent());
         return response;
@@ -179,6 +176,8 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
             relationFrom.set("objTo",criteria.get("floorId"));
             criteria.set("relationFrom",relationFrom);
             criteria.remove("floorId");
+            if (criteria.has("buildingId"))
+                criteria.remove("buildingId");
             return;
         }
         if (criteria.has("buildingId")){

+ 29 - 4
src/main/java/com/persagy/proxy/object/service/impl/AdmShaftServiceImpl.java

@@ -1,16 +1,22 @@
 package com.persagy.proxy.object.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.common.helper.SpringHelper;
+import com.persagy.proxy.adm.constant.GraphCodeEnum;
+import com.persagy.proxy.adm.constant.RelCodeEnum;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.object.model.AdmEquipment;
 import com.persagy.proxy.object.model.AdmShaft;
-import com.persagy.proxy.adm.request.AdmQueryCriteria;
-import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.object.model.AdmSystem;
 import com.persagy.proxy.object.service.IAdmEquipmentService;
 import com.persagy.proxy.object.service.IAdmShaftService;
-import com.persagy.proxy.adm.utils.AdmContextUtil;
-import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.object.service.IAdmSystemService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -49,6 +55,25 @@ public class AdmShaftServiceImpl extends AbstractAdmBaseServiceImpl<AdmShaft> im
         equipmentService.ensureSpecialValues(AdmContextUtil.toDmpContext(), equipmentList);
         systemService.ensureSpecialValues(AdmContextUtil.toDmpContext(), systemList);
     }
+
+    @Override
+    public void processDmpCriteria(QueryCriteria dmpRequest) {
+        ObjectNode criteria = dmpRequest.getCriteria();
+        if (null==criteria){
+            return;
+        }
+        if (criteria.has("buildingId")){
+            // 有建筑id过滤
+            ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+            ObjectNode relationTo = objectMapper.createObjectNode();
+            relationTo.put("graphCode", GraphCodeEnum.ArchSubset.name());
+            relationTo.put("relCode", RelCodeEnum.Bd2Sh.name());
+            relationTo.set("objFrom",criteria.get("buildingId"));
+            criteria.set("relationTo",relationTo);
+            criteria.remove("buildingId");
+        }
+    }
+
     @Override
     public AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request, Class<AdmShaft> clazz) {
         AdmResponse response = super.doQuery(context, request, clazz);

+ 1 - 4
src/main/java/com/persagy/proxy/object/service/impl/AdmSpaceServiceImpl.java

@@ -29,7 +29,6 @@ import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
-import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.common.client.DmpRwdClient;
 import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
@@ -344,9 +343,7 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
     @Override
     public AdmResponse query(AdmQueryCriteria request) {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
-        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
-        processDmpCriteria(queryCriteria);
-        AdmResponse response = super.doQuery(context, queryCriteria, AdmSpace.class);
+        AdmResponse response = super.doQuery(context, request, AdmSpace.class);
         // 系统需要补充分类名称属性
         ensureSpecialValues(context, (List<AdmSpace>) response.getContent());
         return response;

+ 37 - 0
src/main/java/com/persagy/proxy/object/service/impl/AdmSystemServiceImpl.java

@@ -1,6 +1,12 @@
 package com.persagy.proxy.object.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.common.helper.SpringHelper;
+import com.persagy.proxy.adm.constant.GraphCodeEnum;
+import com.persagy.proxy.adm.constant.RelCodeEnum;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
@@ -76,4 +82,35 @@ public class AdmSystemServiceImpl extends AbstractAdmBaseServiceImpl<AdmSystem>
         // 对象扩展属性赋值
         equipmentService.ensureSpecialValues(context, equipmentList);
     }
+
+    @Override
+    public void processDmpCriteria(QueryCriteria dmpRequest) {
+        ObjectNode criteria = dmpRequest.getCriteria();
+        if (null==criteria){
+            return;
+        }
+        if (criteria.has("floorId")){
+            // 有建筑id过滤
+            ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+            ObjectNode relationFrom = objectMapper.createObjectNode();
+            relationFrom.put("graphCode", GraphCodeEnum.MechInArch.name());
+            relationFrom.put("relCode", RelCodeEnum.Sy2Fl.name());
+            relationFrom.set("objTo",criteria.get("floorId"));
+            criteria.set("relationFrom",relationFrom);
+            criteria.remove("floorId");
+            if (criteria.has("buildingId"))
+                criteria.remove("buildingId");
+            return;
+        }
+        if (criteria.has("buildingId")){
+            // 有建筑id过滤
+            ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+            ObjectNode relationFrom = objectMapper.createObjectNode();
+            relationFrom.put("graphCode", GraphCodeEnum.MechInArch.name());
+            relationFrom.put("relCode", RelCodeEnum.Sy2Bd.name());
+            relationFrom.set("objTo",criteria.get("buildingId"));
+            criteria.set("relationFrom",relationFrom);
+            criteria.remove("buildingId");
+        }
+    }
 }