浏览代码

公共 - 级联查询

yucheng 3 年之前
父节点
当前提交
e7752f9fbb
共有 30 个文件被更改,包括 431 次插入201 次删除
  1. 25 0
      src/main/java/com/persagy/proxy/adm/annotations/CascadeColumn.java
  2. 32 0
      src/main/java/com/persagy/proxy/adm/constant/AdmObjectType.java
  3. 2 6
      src/main/java/com/persagy/proxy/adm/controller/AdmBuildingController.java
  4. 2 4
      src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java
  5. 3 9
      src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java
  6. 2 6
      src/main/java/com/persagy/proxy/adm/controller/AdmFloorController.java
  7. 2 4
      src/main/java/com/persagy/proxy/adm/controller/AdmISpaceController.java
  8. 1 2
      src/main/java/com/persagy/proxy/adm/controller/AdmProjectController.java
  9. 2 7
      src/main/java/com/persagy/proxy/adm/controller/AdmPropertyController.java
  10. 8 20
      src/main/java/com/persagy/proxy/adm/controller/AdmShaftController.java
  11. 7 16
      src/main/java/com/persagy/proxy/adm/controller/AdmSpaceController.java
  12. 9 20
      src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java
  13. 3 8
      src/main/java/com/persagy/proxy/adm/controller/AdmTenantController.java
  14. 1 1
      src/main/java/com/persagy/proxy/adm/controller/RelationEqInSpController.java
  15. 3 0
      src/main/java/com/persagy/proxy/adm/model/AdmBuilding.java
  16. 10 1
      src/main/java/com/persagy/proxy/adm/model/AdmEquipment.java
  17. 4 1
      src/main/java/com/persagy/proxy/adm/model/AdmFloor.java
  18. 6 1
      src/main/java/com/persagy/proxy/adm/model/AdmShaft.java
  19. 10 0
      src/main/java/com/persagy/proxy/adm/model/AdmSpace.java
  20. 6 2
      src/main/java/com/persagy/proxy/adm/model/AdmSystem.java
  21. 3 0
      src/main/java/com/persagy/proxy/adm/model/AdmTenant.java
  22. 0 16
      src/main/java/com/persagy/proxy/adm/request/OrderItem.java
  23. 0 59
      src/main/java/com/persagy/proxy/adm/request/QueryCriteria.java
  24. 2 3
      src/main/java/com/persagy/proxy/adm/service/IAdmBaseService.java
  25. 10 1
      src/main/java/com/persagy/proxy/adm/service/IAdmRelationService.java
  26. 257 8
      src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java
  27. 1 1
      src/main/java/com/persagy/proxy/adm/service/impl/AdmModelKeyServiceImpl.java
  28. 17 2
      src/main/java/com/persagy/proxy/adm/service/impl/AdmRelationServiceImpl.java
  29. 1 1
      src/main/java/com/persagy/proxy/adm/utils/AdmEntityTransferUtil.java
  30. 2 2
      src/main/java/com/persagy/proxy/adm/utils/AdmQueryCriteriaHelper.java

+ 25 - 0
src/main/java/com/persagy/proxy/adm/annotations/CascadeColumn.java

@@ -0,0 +1,25 @@
+package com.persagy.proxy.adm.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 扩展属性
+ * @author Charlie Yu
+ * @data 2021-08-28
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD})
+public @interface CascadeColumn {
+
+    /** 图编码 */
+    String graphCode() default "";
+    /** 边编码 */
+    String relCode() default "";
+    /** 边值 */
+    String relValue() default "";
+    /** 是否为查询to对象 */
+    boolean selectToObj() default true;
+}

+ 32 - 0
src/main/java/com/persagy/proxy/adm/constant/AdmObjectType.java

@@ -0,0 +1,32 @@
+package com.persagy.proxy.adm.constant;
+
+import lombok.Getter;
+
+/**
+ * 对象类型
+ * @author Charlie Yu
+ * @date 2021-06-25
+ */
+@Getter
+public enum AdmObjectType {
+    /** 对象类型 */
+    PROJECT("project", "项目"),
+    BUILDING("building", "楼"),
+    FLOOR("floor", "楼层"),
+    SPACE("space", "空间"),
+    SYSTEM("system", "系统"),
+    EQUIPMENT("equipment", "设备"),
+    SHAFT("shaft", "竖井"),
+    COMPONENT("component", "部件"),
+    VIRTUAL("virtual", "虚拟对象"),
+    TOOL("tool", "工具"),
+    MATERIAL("material", "耗材");
+
+    private String index;
+    private String name;
+
+    AdmObjectType(String index, String name) {
+        this.index = index;
+        this.name = name;
+    }
+}

+ 2 - 6
src/main/java/com/persagy/proxy/adm/controller/AdmBuildingController.java

@@ -1,14 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmBuilding;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmBuildingService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -105,8 +103,7 @@ public class AdmBuildingController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("building");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmBuilding.class);
+        return service.doQuery(context, request, AdmBuilding.class);
     }
 
     /**
@@ -123,7 +120,6 @@ public class AdmBuildingController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("building");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmBuilding.class);
+        return service.doQuery(context, request, AdmBuilding.class);
     }
 }

+ 2 - 4
src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java

@@ -48,8 +48,7 @@ public class AdmComponentController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("component");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmEquipment.class);
+        return service.doQuery(context, request, AdmEquipment.class);
     }
     /**
      * 创建
@@ -108,7 +107,6 @@ public class AdmComponentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("component");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmEquipment.class);
+        return service.doQuery(context, request, AdmEquipment.class);
     }
 }

+ 3 - 9
src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java

@@ -1,7 +1,6 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmEquipment;
@@ -9,7 +8,6 @@ import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmEquipmentService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -46,8 +44,7 @@ public class AdmEquipmentController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("equipment");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmEquipment.class);
+        return service.doQuery(context, request, AdmEquipment.class);
     }
 
     /**
@@ -108,8 +105,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("equipment");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmEquipment.class);
+        return service.doQuery(context, request, AdmEquipment.class);
     }
 
     /**
@@ -161,9 +157,7 @@ public class AdmEquipmentController {
         }else{
             request.setFilters("objType in ['equipment','component']");
         }
-
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmEquipment.class);
+        return service.doQuery(context, request, AdmEquipment.class);
     }
 
     /**

+ 2 - 6
src/main/java/com/persagy/proxy/adm/controller/AdmFloorController.java

@@ -1,14 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmFloor;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmFloorService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -121,8 +119,7 @@ public class AdmFloorController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("floor");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmFloor.class);
+        return service.doQuery(context, request, AdmFloor.class);
     }
 
 
@@ -139,8 +136,7 @@ public class AdmFloorController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("floor");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmFloor.class);
+        return service.doQuery(context, request, AdmFloor.class);
     }
 
 }

+ 2 - 4
src/main/java/com/persagy/proxy/adm/controller/AdmISpaceController.java

@@ -48,8 +48,7 @@ public class AdmISpaceController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmISpace.class);
+        return service.doQuery(context, request, AdmISpace.class);
     }
     /**
      * 创建
@@ -108,8 +107,7 @@ public class AdmISpaceController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmISpace.class);
+        return service.doQuery(context, request, AdmISpace.class);
     }
 
 }

+ 1 - 2
src/main/java/com/persagy/proxy/adm/controller/AdmProjectController.java

@@ -44,8 +44,7 @@ public class AdmProjectController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("project");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmProject.class);
+        return service.doQuery(context, request, AdmProject.class);
     }
 
     /**

+ 2 - 7
src/main/java/com/persagy/proxy/adm/controller/AdmPropertyController.java

@@ -1,15 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.model.AdmEquipment;
 import com.persagy.proxy.adm.model.AdmProperty;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmPropertyService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -94,8 +91,7 @@ public class AdmPropertyController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("equipment");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmProperty.class);
+        return service.doQuery(context, request, AdmProperty.class);
     }
 
 
@@ -113,7 +109,6 @@ public class AdmPropertyController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("equipment");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmEquipment.class);
+        return service.doQuery(context, request, AdmProperty.class);
     }
 }

+ 8 - 20
src/main/java/com/persagy/proxy/adm/controller/AdmShaftController.java

@@ -1,14 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmShaft;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmShaftService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -49,8 +47,7 @@ public class AdmShaftController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("shaft");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmShaft.class);
+        return service.doQuery(context, request, AdmShaft.class);
     }
 
     /**
@@ -110,8 +107,7 @@ public class AdmShaftController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("shaft");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmShaft.class);
+        return service.doQuery(context, request, AdmShaft.class);
     }
 
     /**
@@ -128,8 +124,7 @@ public class AdmShaftController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("shaft");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmShaft.class);
+        return service.doQuery(context, request, AdmShaft.class);
     }
 
     /**
@@ -146,8 +141,7 @@ public class AdmShaftController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("shaft");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmShaft.class);
+        return service.doQuery(context, request, AdmShaft.class);
     }
 
     /**
@@ -164,8 +158,7 @@ public class AdmShaftController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("shaft");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmShaft.class);
+        return service.doQuery(context, request, AdmShaft.class);
     }
 
     /**
@@ -182,8 +175,7 @@ public class AdmShaftController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("shaft");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmShaft.class);
+        return service.doQuery(context, request, AdmShaft.class);
     }
 
     /**
@@ -200,8 +192,7 @@ public class AdmShaftController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("shaft");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmShaft.class);
+        return service.doQuery(context, request, AdmShaft.class);
     }
 
     /**
@@ -218,9 +209,6 @@ public class AdmShaftController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("shaft");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmShaft.class);
+        return service.doQuery(context, request, AdmShaft.class);
     }
-
-
 }

+ 7 - 16
src/main/java/com/persagy/proxy/adm/controller/AdmSpaceController.java

@@ -1,14 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmSpace;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmSpaceService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -48,8 +46,7 @@ public class AdmSpaceController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSpace.class);
+        return service.doQuery(context, request, AdmSpace.class);
     }
     /**
      * 创建
@@ -108,8 +105,7 @@ public class AdmSpaceController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSpace.class);
+        return service.doQuery(context, request, AdmSpace.class);
     }
 
     /**
@@ -125,8 +121,7 @@ public class AdmSpaceController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSpace.class);
+        return service.doQuery(context, request, AdmSpace.class);
     }
 
     /**
@@ -173,8 +168,7 @@ public class AdmSpaceController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSpace.class);
+        return service.doQuery(context, request, AdmSpace.class);
     }
 
 
@@ -191,8 +185,7 @@ public class AdmSpaceController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSpace.class);
+        return service.doQuery(context, request, AdmSpace.class);
     }
 
     /**
@@ -208,8 +201,7 @@ public class AdmSpaceController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSpace.class);
+        return service.doQuery(context, request, AdmSpace.class);
     }
 
 
@@ -226,8 +218,7 @@ public class AdmSpaceController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("space");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSpace.class);
+        return service.doQuery(context, request, AdmSpace.class);
     }
 
 }

+ 9 - 20
src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java

@@ -1,14 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmSystem;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmSystemService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -46,8 +44,7 @@ public class AdmSystemController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 
     /**
@@ -123,8 +120,7 @@ public class AdmSystemController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 
     /**
@@ -155,8 +151,7 @@ public class AdmSystemController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 
 
@@ -174,8 +169,7 @@ public class AdmSystemController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 
 
@@ -192,8 +186,7 @@ public class AdmSystemController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 
     /**
@@ -210,8 +203,7 @@ public class AdmSystemController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 
 
@@ -229,8 +221,7 @@ public class AdmSystemController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 
 
@@ -248,8 +239,7 @@ public class AdmSystemController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 
 
@@ -267,7 +257,6 @@ public class AdmSystemController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("system");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmSystem.class);
+        return service.doQuery(context, request, AdmSystem.class);
     }
 }

+ 3 - 8
src/main/java/com/persagy/proxy/adm/controller/AdmTenantController.java

@@ -1,14 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmTenant;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmTenantService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -48,8 +46,7 @@ public class AdmTenantController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("tenant");
         request.setOnlyCount(true);
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmTenant.class);
+        return service.doQuery(context, request, AdmTenant.class);
     }
 
     /**
@@ -109,8 +106,7 @@ public class AdmTenantController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("tenant");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmTenant.class);
+        return service.doQuery(context, request, AdmTenant.class);
     }
 
     /**
@@ -127,8 +123,7 @@ public class AdmTenantController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("tenant");
-        DmpResult<JSONArray> result = service.doQuery(context, request);
-        return AdmResponse.fromDmp(request, result, AdmTenant.class);
+        return service.doQuery(context, request, AdmTenant.class);
     }
 
 }

+ 1 - 1
src/main/java/com/persagy/proxy/adm/controller/RelationEqInSpController.java

@@ -6,9 +6,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.request.AdmResponse;
-import com.persagy.proxy.adm.request.QueryCriteria;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.common.entity.RelationDTO;

+ 3 - 0
src/main/java/com/persagy/proxy/adm/model/AdmBuilding.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 
 import java.util.Date;
@@ -39,7 +40,9 @@ public class AdmBuilding {
     /** 统计信息 */
     private Map<String, Object> statistics;
     /** 级联-项目 */
+    @CascadeColumn(graphCode = "ArchSubset", relCode = "Pj2Bd", selectToObj = false)
     private AdmProject project;
     /** 级联-楼层 */
+    @CascadeColumn(graphCode = "ArchSubset", relCode = "Bd2Fl")
     private List<AdmProject> floor;
 }

+ 10 - 1
src/main/java/com/persagy/proxy/adm/model/AdmEquipment.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 
 import java.util.Date;
@@ -95,25 +96,33 @@ public class AdmEquipment {
     /** 统计信息 */
     private Map<String, Object> statistics;
     /** 资产信息实体类 */
+    @CascadeColumn
     private AdmProperty property;
     /** 建筑信息实体类 */
+    @CascadeColumn(graphCode = "MechForArch", relCode = "Eq2Bd")
     private AdmBuilding building;
     /** 楼层信息实体类 */
+    @CascadeColumn(graphCode = "MechForArch", relCode = "Eq2Fl")
     private AdmFloor floor;
     /** 项目信息实体类 */
+    @CascadeColumn(graphCode = "MechSubset", relCode = "Pj2Eq", selectToObj = false)
     private AdmProject project;
-
     /**BIM模型中坐标json,坐标x,y,z */
     private AdmBIMLocation locationJson;
     /** 级联-设备服务所在的空 */
+    @CascadeColumn(graphCode = "MechForArch", relCode = "Eq2Sp")
     private List<AdmSpace> zoneSpaceForBase;
     /** 级联-设备服务所在的空 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Eq2Sp")
     private List<AdmSpace> zoneSpaceInBase;
     /** 级联-设备所在的竖井 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Eq2Sh")
     private List<AdmShaft> shaftList;
     /** 资产列表 */
+    @CascadeColumn
     private List<AdmProperty> propertyList;
     /** 级联-部件 */
+    @CascadeColumn
     private List<AdmEquipment> component;
 
 }

+ 4 - 1
src/main/java/com/persagy/proxy/adm/model/AdmFloor.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 
 import java.util.Date;
@@ -43,11 +44,13 @@ public class AdmFloor {
     /** 信息点 */
     private Map<String, Object> infos;
     /** 级联-建筑 */
+    @CascadeColumn(graphCode = "ArchSubset", relCode = "Bd2Fl", selectToObj = false)
     private AdmBuilding building;
     /** 级联-项目 */
+    @CascadeColumn() // TODO 没有这个关系
     private AdmProject project;
-
     /** 级联-贯通关系 */
+    @CascadeColumn(graphCode = "ThroughRelationship", relCode = "Fl2Fl")
     private List<AdmFloor> floorThroughList;
 
     /** 模型文件id */

+ 6 - 1
src/main/java/com/persagy/proxy/adm/model/AdmShaft.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 
 import java.util.Date;
@@ -46,15 +47,19 @@ public class AdmShaft {
     /** 对象类型 */
     private String objectType = "shaft";
     /** 级联-竖井内的设备 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Eq2Sh", selectToObj = false)
     private List<AdmEquipment> equipmentList;
     /** 级联-竖井内的建筑 */
+    @CascadeColumn(graphCode = "ArchForArch", relCode = "Sh2Bd")
     private List<AdmBuilding> buildingList;
     /** 级联-竖井内的系统 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Sh", selectToObj = false)
     private List<AdmSystem> systemList;
     /** 贯通关系   self = true  同样的对象查询时 id可以互相调换查询   */
+    @CascadeColumn(graphCode = "ThroughRelationship", relCode = "Sh2Sh")
     private List<AdmShaft> shaftThroughList;
-
     /** 竖井内的业务空间  self = true  同样的对象查询时 id可以互相调换查询   */
+    @CascadeColumn(graphCode = "ArchSubset", relCode = "Sh2Sp")
     private List<AdmSpace> spaceList;
     /** 统计信息 */
     private Map<String, Object> statistics;

+ 10 - 0
src/main/java/com/persagy/proxy/adm/model/AdmSpace.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 
 import java.util.ArrayList;
@@ -102,25 +103,34 @@ public class AdmSpace {
     private Map<String, Object> statistics;
 
     /** 级联-设备 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Eq2Sp", selectToObj = false)
     private List<AdmEquipment> equipment;
     /** 级联-元空间 */
     //@SCascade(table="relationship.r_sp2si", idColumn="sp_id", childIdColumn="si_id")
     //private List<AdmSpace> zoneIspace;
     /** 级联-系统 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Sp", selectToObj = false)
     private List<AdmSystem> generalSystem;
     /** 级联-服务于空间的设备 */
+    @CascadeColumn(graphCode = "MechForArch", relCode = "Eq2Sp", selectToObj = false)
     private List<AdmEquipment> equipmentFor;
     /** 建筑信息实体类 */
+    @CascadeColumn(graphCode = "ArchSubset", relCode = "Bd2Sp")
     private AdmBuilding building;
     /** 楼层信息实体类 */
+    @CascadeColumn(graphCode = "ArchSubset", relCode = "Fl2Sp", selectToObj = false)
     private AdmFloor floor;
     /** 级联-建筑 */
+    @CascadeColumn(graphCode = "ArchForArch", relCode = "Sp2Bd")
     private List<AdmBuilding> buildingList;
     /** 级联-楼层 */
+    @CascadeColumn(graphCode = "ArchForArch", relCode = "Sp2Fl")
     private List<AdmFloor> floorList;
     /** 资产列表 */
+    @CascadeColumn
     private List<AdmProperty> propertyList;
     /** 级联-部件 */
+    @CascadeColumn
     private List<AdmEquipment> component;
 
     /** 空间轮廓线 */

+ 6 - 2
src/main/java/com/persagy/proxy/adm/model/AdmSystem.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 
 import java.util.Date;
@@ -57,14 +58,17 @@ public class AdmSystem {
 
 
     /** 级联-设备 */
+    @CascadeColumn(graphCode = "MechSubset", relCode = "Sy2Eq")
     private List<AdmEquipment> equipmentList;
     /** 级联-空间 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Sp")
     private List<AdmSpace> zoneSpaceBaseTableList;
-       /** 级联-楼层 */
+    /** 级联-楼层 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Fl")
     private List<AdmFloor> floorList;
     /** 级联-建筑 */
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Bd")
     private List<AdmBuilding> buildingList;
-
     /** 建筑楼层 */
     private List<AdmBuildingFloorInfo> buildingFloorInfoList;
 }

+ 3 - 0
src/main/java/com/persagy/proxy/adm/model/AdmTenant.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 
 import java.util.Date;
@@ -32,8 +33,10 @@ public class AdmTenant {
     /** 对象类型 */
     private String objectType = "tenant";
     /** 租户租赁的租户业务空间  self = true  同样的对象查询时 id可以互相调换查询   */
+    @CascadeColumn(graphCode = "TenentInArch", relCode = "Tn2Sp", relValue = "TenantZone")
     private List<AdmSpace> zoneTenantList;
     /** 租户租赁的默认业务空间  self = true  同样的对象查询时 id可以互相调换查询   */
+    @CascadeColumn(graphCode = "TenentInArch", relCode = "Tn2Sp", relValue = "GeneralZone")
     private List<AdmSpace> zoneGeneraltList;
     /** 统计信息 */
     private Map<String, Object> statistics;

+ 0 - 16
src/main/java/com/persagy/proxy/adm/request/OrderItem.java

@@ -1,16 +0,0 @@
-package com.persagy.proxy.adm.request;
-
-import lombok.Data;
-
-/**
- * 数据中台查询条件 - 排序条件
- * @author Charlie Yu
- * @date 2021-08-16
- */
-@Data
-public class OrderItem {
-    /** 排序列 */
-    private String column;
-    /** 是否升序 */
-    private boolean asc = true;
-}

+ 0 - 59
src/main/java/com/persagy/proxy/adm/request/QueryCriteria.java

@@ -1,59 +0,0 @@
-package com.persagy.proxy.adm.request;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import lombok.Data;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * 通用查询参数 - 仅用于接收参数
- * 兼容数据中台查询规则,将数据中台查询条件转换为MyBatisPlus查询条件
- * <pre>
- * {
- *     "page": 1,
- *     "size": 10,
- *     "onlyCount": false,
- *     "criteria": {
- *         "name": "zhangsan",
- *         "name": [ "zhangsan", "lisi" ],
- *         "age": {
- *             "$gt": 18,
- *             "$lt": 35
- *         },
- *         "gender": {
- *             "$null": false
- *         }
- *     },
- *     "orders": [
- *            {
- *     		 	"column": "name",
- *     		 	"asc": false
- *            }
- *     ],
- *     "withColumns": [
- *     		"name", "age"
- *     ]
- * }
- * </pre>
- * @author yaoll
- * @date 2020-09-04
- */
-@Data
-public class QueryCriteria {
-
-    /** 分页页码,从 1 开始 */
-    private Long page;
-    /** 每页行数 */
-    private Long size;
-    /** 是否只统计总数 */
-    private boolean onlyCount = false;
-    /** 是否不统计总数 */
-    private boolean withoutCount = false;
-    /** 查询条件 */
-    private ObjectNode criteria;
-    /** 排序条件 */
-    private List<OrderItem> orders;
-    /** 额外返回的扩展字段清单 */
-    private Set<String> withColumns;
-}

+ 2 - 3
src/main/java/com/persagy/proxy/adm/service/IAdmBaseService.java

@@ -1,8 +1,7 @@
 package com.persagy.proxy.adm.service;
 
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
-import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 
 import java.util.List;
@@ -19,7 +18,7 @@ public interface IAdmBaseService<T> {
      * @param request
      * @return
      */
-    DmpResult<JSONArray> doQuery(InstanceUrlParam context, AdmQueryCriteria request);
+    AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request, Class<T> clazz);
 
     /**
      * 新增

+ 10 - 1
src/main/java/com/persagy/proxy/adm/service/IAdmRelationService.java

@@ -1,6 +1,7 @@
 package com.persagy.proxy.adm.service;
 
-import com.persagy.proxy.adm.request.QueryCriteria;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.common.entity.RelationDTO;
 
@@ -26,4 +27,12 @@ public interface IAdmRelationService {
      * @param criteria
      */
     void doDelete(InstanceUrlParam param, QueryCriteria criteria);
+
+    /**
+     * 通过条件查询
+     * @param param
+     * @param criteria
+     * @return
+     */
+    List<ObjectRelation> queryByCondition(InstanceUrlParam param, QueryCriteria criteria);
 }

+ 257 - 8
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java

@@ -1,14 +1,26 @@
 package com.persagy.proxy.adm.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.ReflectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 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;
+import com.persagy.dmp.common.helper.SpringHelper;
+import com.persagy.dmp.common.model.entity.BaseEntity;
+import com.persagy.dmp.common.utils.JsonHelper;
+import com.persagy.dmp.digital.client.DigitalObjectFacade;
+import com.persagy.dmp.digital.entity.ObjectRelation;
+import com.persagy.proxy.adm.annotations.CascadeColumn;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
-import com.persagy.proxy.adm.request.QueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmBaseService;
+import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
 import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.common.client.DmpRwdClient;
@@ -17,7 +29,10 @@ import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.List;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.util.*;
 
 /**
  * ADM 抽象实现类
@@ -38,20 +53,254 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
      * @return
      */
     @Override
-    public DmpResult<JSONArray> doQuery(InstanceUrlParam context, AdmQueryCriteria request) {
+    public AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request, Class<T> clazz) {
         // 转换为数据中台查询条件
         QueryCriteria dmpRequest = AdmQueryCriteriaHelper.toDmpCriteria(request);
         // 转换参数
         JSONObject para = null;
         try {
-            String paraStr = objectMapper.writeValueAsString(dmpRequest);
-            para = JSONObject.parseObject(paraStr);
-        } catch (JsonProcessingException e) {
+            para = JsonHelper.toJSONObject(dmpRequest);
+        } catch (IOException e) {
             log.error(e.getMessage(), e);
             return null;
         }
         // 调用中台查询
-        return rwdClient.queryObject(context, para);
+        DmpResult<JSONArray> dmpResult = rwdClient.queryObject(context, para);
+        List<T> admVOs = AdmEntityTransferUtil.toAdmMultiEntity(dmpResult.getData(), request.getProjection(), clazz);
+        // 级联查询
+        processCascade(context, admVOs, request.getName(), request.getCascade());
+        // 设置返回值
+        AdmResponse response = AdmResponse.success(admVOs);
+        Long total = dmpResult.getCount() == null ? null : dmpResult.getCount().longValue();
+        response.setTotal(total);
+        response.setPageNumber(request.getPageNumber());
+        response.setPageSize(request.getPageSize());
+        return response;
+    }
+
+    /**
+     * 处理级联查询
+     * @param context
+     * @param admVOs
+     * @param name
+     * @param cascades
+     */
+    private void processCascade(InstanceUrlParam context, List admVOs, String name, List<AdmQueryCriteria> cascades) {
+        if(CollUtil.isEmpty(admVOs) || CollUtil.isEmpty(cascades)) {
+            return;
+        }
+        Map<String, Object> voMap = CollUtil.fieldValueMap(admVOs, BaseEntity.PROP_ID);
+        Object simpleVO = admVOs.get(0);
+        for(AdmQueryCriteria cascade:cascades) {
+            // 获取关联对象的Class
+            Field casField = ReflectUtil.getField(simpleVO.getClass(), cascade.getName());
+            CascadeColumn annotationInfo = casField.getAnnotation(CascadeColumn.class);
+            // 没有扩展信息不处理
+            if(annotationInfo == null) {
+                continue;
+            }
+            Class clazz = getFieldRealClass(casField);
+            // 获取关联对象的类型
+            String objectType = getObjTypeByClass(clazz);
+            if(StrUtil.isBlank(objectType)) {
+                continue;
+            }
+            cascade.setName(objectType);
+            // 转换为数据中台查询条件
+            QueryCriteria dmpRequest = AdmQueryCriteriaHelper.toDmpCriteria(cascade);
+            // 拼接关系条件,得到关系映射
+            Map<String, List<String>> idMap = ensureRelationCond(context, dmpRequest.getCriteria(), voMap.keySet(), annotationInfo);
+            if(MapUtil.isEmpty(idMap)) {
+                continue;
+            }
+            // 查询结果
+            List vos = queryByCondition(context, dmpRequest, cascade.getProjection(), clazz);
+            if(CollUtil.isEmpty(vos)) {
+                continue;
+            }
+            // 写回原对象中
+            writeToVOs(voMap, idMap, vos, casField);
+            // 递归继续处理
+            processCascade(context, vos, objectType, cascade.getCascade());
+        }
+    }
+
+    /**
+     * 拼接关系条件
+     * @param context
+     * @param node
+     * @param idList
+     * @param annotationInfo
+     * @return
+     */
+    private Map<String, List<String>> ensureRelationCond(InstanceUrlParam context, ObjectNode node, Set<String> idList, CascadeColumn annotationInfo) {
+        if(CollUtil.isEmpty(idList)) {
+            return null;
+        }
+        // 查询关系
+        List<ObjectRelation> relations = queryRelations(context, idList, annotationInfo);
+        ArrayNode array = node.putObject(BaseEntity.PROP_ID).putArray("$in");
+        // 拼接查询条件
+        if(CollUtil.isEmpty(relations)) {
+            array.add("0");
+        } else {
+            List<String> relList = CollUtil.getFieldValues(relations, "objTo", String.class);
+            relList.forEach(id -> array.add(id));
+        }
+        return groupMapList(relations, "objFrom", "objTo");
+    }
+
+    /**
+     * 将集合转换为Map
+     * @param list 集合
+     * @param keyField key属性名
+     * @param valueField value属性名
+     * @return
+     */
+    private static Map<String, List<String>> groupMapList(List<?> list, String keyField, String valueField) {
+        if(CollUtil.isEmpty(list)) {
+            return null;
+        }
+        Map<String, List<String>> groupMap = new HashMap<>();
+        for(Object vo:list) {
+            String key = (String) ReflectUtil.getFieldValue(vo, keyField);
+            String value = (String) ReflectUtil.getFieldValue(vo, valueField);
+            if(!StrUtil.isAllNotBlank(key, value)) {
+                continue;
+            }
+            List<String> valueList = groupMap.get(key);
+            if(CollUtil.isEmpty(valueList)) {
+                valueList = new ArrayList<>();
+                groupMap.put(key, valueList);
+            }
+            valueList.add(value);
+        }
+        return groupMap;
+    }
+
+    /**
+     * 查询关系
+     * @param context
+     * @param idList
+     * @param anno
+     * @return
+     */
+    private List<ObjectRelation> queryRelations(InstanceUrlParam context, Set<String>idList, CascadeColumn anno) {
+        // 如果没有任何配置,不处理
+        if(StrUtil.isBlank(anno.graphCode()) && StrUtil.isBlank(anno.relCode()) &&
+                StrUtil.isBlank(anno.relValue())) {
+            return null;
+        }
+        // 查询关系
+        QueryCriteria queryRequest = new QueryCriteria();
+        ObjectNode criteria = JsonNodeFactory.instance.objectNode();
+        queryRequest.setCriteria(criteria);
+        boolean isSelectTo = anno.selectToObj();
+        putString(criteria, "graphCode", anno.graphCode());
+        putString(criteria, "relCode", anno.relCode());
+        putString(criteria, "relValue", anno.relValue());
+        ArrayNode array = criteria.putObject(isSelectTo?"objFrom":"objTo").putArray("$in");
+        idList.forEach(id -> array.add(id));
+        return SpringHelper.getBean(IAdmRelationService.class).queryByCondition(context, queryRequest);
+    }
+
+    /**
+     * 添加字符串条件
+     * @param node
+     * @param key
+     * @param value
+     */
+    private void putString(ObjectNode node, String key, String value) {
+        if(StrUtil.isBlank(value)) {
+            return;
+        }
+        node.put(key, value);
+    }
+
+    /**
+     * 将子集写回到对象中
+     * @param voMap 原始对象Map
+     * @param idMap 主键映射<mainId, List<subId>>
+     * @param vos 子对象
+     * @param casField 子对象对应属性
+     */
+    private <V> void writeToVOs(Map<String, Object> voMap, Map<String, List<String>> idMap, List<V> vos, Field casField) {
+        if(CollUtil.isEmpty(vos) || MapUtil.isEmpty(idMap)) {
+            return;
+        }
+        // 转换为Map
+        Map<String, V> subVOMap = CollUtil.fieldValueMap(vos, BaseEntity.PROP_ID);
+        // 是否为集合
+        boolean isList = List.class.isAssignableFrom(casField.getType());
+        // 按对象循环
+        for(String id:voMap.keySet()) {
+            Object mainVO = voMap.get(id);
+            List<String> subIdList = idMap.get(id);
+            if(CollUtil.isEmpty(subIdList)) {
+                continue;
+            }
+            // 如果是集合
+            if(isList) {
+                // 取出对应的对象集合
+                Map<String, V> currVOMap = MapUtil.filter(subVOMap, subIdList.toArray(new String[0]));
+                List<V> voList = CollUtil.newArrayList(currVOMap.values());
+                ReflectUtil.setFieldValue(mainVO, casField, voList);
+            } else {
+                // 非集合取第一个即可
+                String subId = subIdList.get(0);
+                V vo = subVOMap.get(subId);
+                ReflectUtil.setFieldValue(mainVO, casField, vo);
+            }
+        }
+    }
+
+    /**
+     * 调用Client查询
+     * @param context
+     * @param criteria
+     * @param projection
+     * @param clazz
+     * @return
+     */
+    private <V> List<V> queryByCondition(InstanceUrlParam context, QueryCriteria criteria, List<String> projection, Class<V> clazz) {
+        // 转换参数
+        if(criteria == null) {
+            return null;
+        }
+        List<ObjectNode> objects = DigitalObjectFacade.query(context.getGroupCode(), context.getProjectId(),
+                context.getAppId(), null, criteria);
+        return AdmEntityTransferUtil.toAdmMultiEntity(objects, projection, clazz);
+    }
+
+    /**
+     * 获取实际的Class
+     * @param casField
+     * @return
+     */
+    private Class getFieldRealClass(Field casField) {
+        // 取到Field
+        Class clazz = casField.getType();
+        // 如果是集合,则取实际的对象
+        if(List.class.isAssignableFrom(clazz)) {
+            clazz = (Class) ((ParameterizedType) casField.getGenericType()).getActualTypeArguments()[0];
+        }
+        return clazz;
+    }
+
+    /**
+     * 通过Class获取其对象类型
+     * @param clazz
+     * @return
+     */
+    private String getObjTypeByClass(Class clazz) {
+        // 获取关联对象的类型
+        String objectType = null;
+        try {
+            objectType = (String) ReflectUtil.getFieldValue(clazz.newInstance(), "objectType");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return objectType;
     }
 
     /**

+ 1 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AdmModelKeyServiceImpl.java

@@ -5,8 +5,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
-import com.persagy.proxy.adm.request.QueryCriteria;
 import com.persagy.proxy.adm.service.IAdmModelKeyService;
 import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.common.client.DmpRwdClient;

+ 17 - 2
src/main/java/com/persagy/proxy/adm/service/impl/AdmRelationServiceImpl.java

@@ -4,7 +4,11 @@ import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.persagy.proxy.adm.request.QueryCriteria;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.basic.utils.JsonNodeUtils;
+import com.persagy.dmp.digital.client.DigitalRelationFacade;
+import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.common.client.DmpRwdClient;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
@@ -34,7 +38,9 @@ public class AdmRelationServiceImpl implements IAdmRelationService {
         if(CollUtil.isEmpty(voList)) {
             return;
         }
-        rwdClient.createRelation(param, voList);
+        List<ObjectNode> nodeList = JsonNodeUtils.toListNode(voList, null, null);
+        DigitalRelationFacade.create(param.getGroupCode(), param.getProjectId(),
+                param.getAppId(), null, nodeList);
     }
 
     @Override
@@ -54,4 +60,13 @@ public class AdmRelationServiceImpl implements IAdmRelationService {
         }
         rwdClient.deleteRelation(param, cond);
     }
+
+    @Override
+    public List<ObjectRelation> queryByCondition(InstanceUrlParam param, QueryCriteria criteria) {
+        if(criteria == null) {
+            return null;
+        }
+        return DigitalRelationFacade.query(param.getGroupCode(), param.getProjectId(),
+                param.getAppId(), null, criteria);
+    }
 }

+ 1 - 1
src/main/java/com/persagy/proxy/adm/utils/AdmEntityTransferUtil.java

@@ -43,7 +43,7 @@ public class AdmEntityTransferUtil {
      * @param <T>
      * @return
      */
-    public static <T> List<T> toAdmMultiEntity(List<Object> array, List<String> projection, Class<T> clazz) {
+    public static <T> List<T> toAdmMultiEntity(List array, List<String> projection, Class<T> clazz) {
         ArrayNode dataNode = JsonNodeUtils.toArrayNode(array, null, null);
         return toAdmMultiEntity(dataNode, projection, clazz);
     }

+ 2 - 2
src/main/java/com/persagy/proxy/adm/utils/AdmQueryCriteriaHelper.java

@@ -3,13 +3,13 @@ package com.persagy.proxy.adm.utils;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
 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;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
-import com.persagy.proxy.adm.request.OrderItem;
-import com.persagy.proxy.adm.request.QueryCriteria;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;