Browse Source

Merge branch 'develop' of http://39.106.8.246:3003/BDTP/adm-middleware.git into develop

zhangqiankun 3 years ago
parent
commit
6256559247
34 changed files with 560 additions and 722 deletions
  1. 12 26
      src/main/java/com/persagy/proxy/adm/controller/AdmBuildingController.java
  2. 11 26
      src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java
  3. 10 12
      src/main/java/com/persagy/proxy/adm/controller/AdmDictController.java
  4. 3 5
      src/main/java/com/persagy/proxy/adm/controller/AdmEquipFloorController.java
  5. 24 46
      src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java
  6. 22 39
      src/main/java/com/persagy/proxy/adm/controller/AdmFloorController.java
  7. 13 30
      src/main/java/com/persagy/proxy/adm/controller/AdmISpaceController.java
  8. 6 5
      src/main/java/com/persagy/proxy/adm/controller/AdmLabslController.java
  9. 7 6
      src/main/java/com/persagy/proxy/adm/controller/AdmLocationPointController.java
  10. 3 2
      src/main/java/com/persagy/proxy/adm/controller/AdmPlanarController.java
  11. 9 7
      src/main/java/com/persagy/proxy/adm/controller/AdmProjectController.java
  12. 13 28
      src/main/java/com/persagy/proxy/adm/controller/AdmPropertyController.java
  13. 75 69
      src/main/java/com/persagy/proxy/adm/controller/AdmRelCalController.java
  14. 2 1
      src/main/java/com/persagy/proxy/adm/controller/AdmRelationController.java
  15. 3 2
      src/main/java/com/persagy/proxy/adm/controller/AdmRelationObjectController.java
  16. 60 78
      src/main/java/com/persagy/proxy/adm/controller/AdmReportEquipController.java
  17. 40 71
      src/main/java/com/persagy/proxy/adm/controller/AdmShaftController.java
  18. 37 71
      src/main/java/com/persagy/proxy/adm/controller/AdmSpaceController.java
  19. 48 92
      src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java
  20. 14 34
      src/main/java/com/persagy/proxy/adm/controller/AdmTenantController.java
  21. 6 5
      src/main/java/com/persagy/proxy/adm/controller/AdmVirtualWallController.java
  22. 6 5
      src/main/java/com/persagy/proxy/adm/controller/AdmWindowController.java
  23. 3 3
      src/main/java/com/persagy/proxy/adm/controller/RelationShInBdController.java
  24. 22 19
      src/main/java/com/persagy/proxy/adm/controller/RelationSyEqController.java
  25. 16 15
      src/main/java/com/persagy/proxy/adm/controller/RelationSyInBdController.java
  26. 14 13
      src/main/java/com/persagy/proxy/adm/controller/RelationSyInFlController.java
  27. 1 1
      src/main/java/com/persagy/proxy/adm/model/AdmBuilding.java
  28. 1 1
      src/main/java/com/persagy/proxy/adm/model/AdmFloor.java
  29. 1 1
      src/main/java/com/persagy/proxy/adm/model/AdmProperty.java
  30. 2 0
      src/main/java/com/persagy/proxy/adm/model/AdmSBaseEntity.java
  31. 6 5
      src/main/java/com/persagy/proxy/adm/request/AdmResponse.java
  32. 4 0
      src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java
  33. 62 0
      src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmDictBaseServiceImpl.java
  34. 4 4
      src/main/java/com/persagy/proxy/common/handler/AdmContextHandler.java

+ 12 - 26
src/main/java/com/persagy/proxy/adm/controller/AdmBuildingController.java

@@ -3,17 +3,15 @@ package com.persagy.proxy.adm.controller;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.persagy.dmp.common.model.entity.BaseEntity;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.*;
 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.*;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
 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;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -42,8 +40,6 @@ public class AdmBuildingController {
     private IAdmISpaceService iAdmISpaceService;
     @Autowired
     private IAdmSpaceService spaceService;
-    @Value("${middleware.group.code}")
-    private String groupCode;
 
     /**
      * 创建
@@ -52,16 +48,14 @@ public class AdmBuildingController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmBuilding> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmBuilding> createRequest) throws Exception {
         List<AdmBuilding> vos = CollUtil.newArrayList(createRequest.getContent());
         vos.stream().forEach(admBuilding -> {
             if (StrUtil.isEmpty(admBuilding.getName())){
                 admBuilding.setName(ObjectNameUtil.objectName("建筑-"));
             }
         });
-        vos = service.doInsert(context, AdmBuilding.class, vos);
+        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmBuilding.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -73,8 +67,6 @@ public class AdmBuildingController {
      */
     @PostMapping("/delete")
     public AdmResponse delete(@RequestBody List<AdmBuilding> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, null, AdmCommonConstant.APP_ID);
         if(CollUtil.isEmpty(vos)){
             return AdmResponse.failure("参数不能为空");
         }
@@ -93,27 +85,27 @@ public class AdmBuildingController {
 
         admQueryCriteria.setFilters(filters);
         admQueryCriteria.setName(AdmFloor.OBJ_TYPE);
-        AdmResponse admResponseF = floorService.doQuery(context, admQueryCriteria, AdmFloor.class);
+        AdmResponse admResponseF = floorService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmFloor.class);
         if(DmpResult.SUCCESS.equals(admResponseF.getResult()) && CollUtil.isNotEmpty(admResponseF.getContent())){
             return AdmResponse.failure(msg);
         }
         admQueryCriteria.setName(AdmSpace.OBJ_TYPE);
-        AdmResponse admResponseSpace = spaceService.doQuery(context, admQueryCriteria, AdmSpace.class);
+        AdmResponse admResponseSpace = spaceService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmSpace.class);
         if(admResponseSpace.getResult().equals(DmpResult.SUCCESS) && CollUtil.isNotEmpty(admResponseSpace.getContent())){
             return AdmResponse.failure(msg);
         }
         admQueryCriteria.setName(AdmISpace.OBJ_TYPE);
-        AdmResponse admResponseISpace = iAdmISpaceService.doQuery(context, admQueryCriteria, AdmISpace.class);
+        AdmResponse admResponseISpace = iAdmISpaceService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmISpace.class);
         if(admResponseISpace.getResult().equals(DmpResult.SUCCESS) && CollUtil.isNotEmpty(admResponseISpace.getContent())){
             return AdmResponse.failure(msg);
         }
 
         admQueryCriteria.setName(AdmEquipment.OBJ_TYPE);
-        AdmResponse admResponseEuip = equipmentService.doQuery(context, admQueryCriteria, AdmEquipment.class);
+        AdmResponse admResponseEuip = equipmentService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmEquipment.class);
         if(admResponseEuip.getResult().equals(DmpResult.SUCCESS) && CollUtil.isNotEmpty(admResponseEuip.getContent())){
             return AdmResponse.failure(msg);
         }
-        service.doDelete(context, vos);
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -136,16 +128,14 @@ public class AdmBuildingController {
      * @throws Exception
      */
     @PostMapping("/update")
-    public AdmResponse update(@RequestBody AdmCreateRequest<AdmBuilding> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmBuilding> createRequest) throws Exception {
         List<AdmBuilding> vos = CollUtil.newArrayList(createRequest.getContent());
         vos.forEach(admBuilding -> {
             if(StrUtil.isEmpty(admBuilding.getName())){
                 admBuilding.setName(ObjectNameUtil.objectName("建筑-"));
             }
         });
-        vos = service.doUpdate(context, AdmBuilding.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmBuilding.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -159,10 +149,8 @@ public class AdmBuildingController {
     @PostMapping("/query")
     public AdmResponse query(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName(AdmBuilding.OBJ_TYPE);
-        return service.doQuery(context, request, AdmBuilding.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmBuilding.class);
     }
 
     /**
@@ -175,10 +163,8 @@ public class AdmBuildingController {
     @PostMapping("/count")
     public AdmResponse count(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName(AdmBuilding.OBJ_TYPE);
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmBuilding.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmBuilding.class);
     }
 }

+ 11 - 26
src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java

@@ -1,15 +1,13 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmComponent;
 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.IAdmComponentService;
-import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -29,24 +27,20 @@ import java.util.List;
 public class AdmComponentController {
     @Autowired
     private IAdmComponentService service;
-    @Value("${middleware.group.code}")
-    private String groupCode;
 
     /**
      * 统计
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId,
+    public AdmResponse count(
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName(AdmComponent.OBJ_TYPE);
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmComponent.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmComponent.class);
     }
     /**
      * 创建
@@ -56,10 +50,8 @@ public class AdmComponentController {
      */
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmComponent> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmComponent> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsertExt(context, AdmComponent.class, vos);
+        vos = service.doInsertExt(AdmContextUtil.toDmpContext(), AdmComponent.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -70,10 +62,8 @@ public class AdmComponentController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmComponent> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        service.doDelete(context, vos);
+    public AdmResponse delete( @RequestBody List<AdmComponent> vos) throws Exception {
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -85,26 +75,21 @@ public class AdmComponentController {
      */
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmComponent> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmComponent> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmComponent.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmComponent.class, vos);
         return AdmResponse.success(vos);
     }
 
     /**
      * 查询
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmComponent.OBJ_TYPE);
-        return service.doQuery(context, request, AdmComponent.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmComponent.class);
     }
 }

+ 10 - 12
src/main/java/com/persagy/proxy/adm/controller/AdmDictController.java

@@ -9,6 +9,7 @@ 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.IAdmDictService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -35,9 +36,6 @@ import java.util.List;
 @Slf4j
 public class AdmDictController {
 
-    @Value("${middleware.group.code}")
-    private String groupCode;
-
     @Autowired
     private IAdmDictService service;
 
@@ -52,7 +50,7 @@ public class AdmDictController {
     public AdmResponse queryCategory(@QueryParam("projectId") String projectId,
                                      @RequestBody AdmDict request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         if(StringUtils.isEmpty(request.getType())){
             throw new Exception("type不能为空");
         }
@@ -71,7 +69,7 @@ public class AdmDictController {
     public AdmResponse dictBatch(@QueryParam("projectId") String projectId,
                                      @RequestBody AdmCreateRequest<AdmDictBatch> request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         //方案设定:方案id :全新设定(schemeZero)、方案1(schemeOne)、方案2(schemeTwo),
         //"注意SchemeId为必填字段 ,优先级在列表中[R,S,M] ,一级标签[技术参数,基本参数] 列表为String类型
         return AdmResponse.success(new ArrayList<>());
@@ -88,7 +86,7 @@ public class AdmDictController {
     public AdmResponse query(@QueryParam("projectId") String projectId,
                              @RequestBody AdmDictQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setName(request.getType());
         return service.doQueryObjectInfo(context, request, AdmDictConstant.CLASS_CODE, AdmObjectInfo.class);
     }
@@ -105,7 +103,7 @@ public class AdmDictController {
     public AdmResponse familyQuery(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return AdmResponse.success(new ArrayList<>());
     }
 
@@ -120,7 +118,7 @@ public class AdmDictController {
     public AdmResponse resetDic(@QueryParam("projectId") String projectId,
                                    @RequestBody AdmDictQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.resetDic(context,request,null,AdmObjectInfo.class);
     }
 
@@ -136,7 +134,7 @@ public class AdmDictController {
     public AdmResponse resetType(@QueryParam("projectId") String projectId,
                                 @RequestBody AdmDictQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         if(StringUtils.isEmpty(request.getType())){
             throw new Exception("type不能为空");
         }
@@ -155,7 +153,7 @@ public class AdmDictController {
     public AdmResponse settingDicProject(@QueryParam("projectId") String projectId,
                                  @RequestBody AdmCreateRequest<AdmObjectInfo> request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.settingDicProject(context,request,AdmObjectInfo.class);
     }
 
@@ -171,7 +169,7 @@ public class AdmDictController {
     public AdmResponse querySystemEquipCategory(@QueryParam("projectId") String projectId,
                                  @RequestBody AdmDict request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setType(AdmDictCategoryEnum.SYSTEM_EQUIP.getValue());
         return service.queryCategory(context,request,AdmObjectType.class);
     }
@@ -188,7 +186,7 @@ public class AdmDictController {
     public AdmResponse queryMorlDict(@QueryParam("projectId") String projectId,
                                                 @RequestBody List<String> dictTypeList) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         if(CollUtil.isEmpty(dictTypeList)){
             return AdmResponse.success(new ArrayList<>());
         }

+ 3 - 5
src/main/java/com/persagy/proxy/adm/controller/AdmEquipFloorController.java

@@ -1,17 +1,15 @@
 package com.persagy.proxy.adm.controller;
 
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmFloor;
 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.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
-import javax.ws.rs.QueryParam;
-
 /**
  * @author zhangwencheng
  * 楼层相关接口
@@ -32,8 +30,8 @@ public class AdmEquipFloorController {
      *级联对象:建筑(building)、项目(project)、楼层贯通关系(floorThroughList)
      */
     @PostMapping("/query")
-    public AdmResponse query(@RequestBody AdmQueryCriteria criteria,  @RequestParam("projectId") String projectId) {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@RequestBody AdmQueryCriteria criteria) {
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         criteria.setName(AdmFloor.OBJ_TYPE);
         return service.doQuery(context, criteria, AdmFloor.class);
     }

+ 24 - 46
src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java

@@ -2,18 +2,15 @@ package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmEquipment;
 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.InstanceUrlParam;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
-import javax.ws.rs.QueryParam;
 import java.util.List;
 
 /**
@@ -27,24 +24,20 @@ import java.util.List;
 public class AdmEquipmentController {
     @Autowired
     private IAdmEquipmentService service;
-    @Value("${middleware.group.code}")
-    private String groupCode;
 
     /**
      * 统计
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId,
+    public AdmResponse count(
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName(AdmEquipment.OBJ_TYPE);
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmEquipment.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
     }
 
     /**
@@ -54,11 +47,9 @@ public class AdmEquipmentController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsertEuip(context, AdmEquipment.class, vos);
+        vos = service.doInsertEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -69,10 +60,9 @@ public class AdmEquipmentController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmEquipment> vos) throws Exception {
+    public AdmResponse delete( @RequestBody List<AdmEquipment> vos) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        service.doDelete(context, vos);
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -84,29 +74,25 @@ public class AdmEquipmentController {
      * @throws Exception
      */
     @PostMapping("/update")
-    public AdmResponse update(@RequestBody AdmCreateRequest<AdmEquipment> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        //vos = service.doUpdateEuip(context, AdmEquipment.class, vos);
-        vos = service.doUpdate(context, AdmEquipment.class, vos);
+        //vos = service.doUpdateEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 
     /**
      * 查询
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
+    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName(AdmEquipment.OBJ_TYPE);
-        return service.doQuery(context, request, AdmEquipment.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
     }
 
     /**
@@ -116,11 +102,9 @@ public class AdmEquipmentController {
      * @throws Exception
      */
     @GetMapping("/export")
-    public AdmResponse exportInfos(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse exportInfos(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
         List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
-        vos = service.doUpdate(context, AdmEquipment.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -132,33 +116,29 @@ public class AdmEquipmentController {
      * @throws Exception
      */
     @PostMapping("/import")
-    public AdmResponse importInfos(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse importInfos(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
         List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
-        vos = service.doUpdate(context, AdmEquipment.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 
     /**
      * 根据项目id查询所有的设备和部件
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @GetMapping("/query-equip")
-    public AdmResponse queryEquip(@QueryParam("projectId") String projectId,
+    public AdmResponse queryEquip(
                                   @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         //request.setName("equipment");
         if(StrUtil.isNotEmpty(request.getFilters())){
             request.setFilters(String.join(";",request.getFilters(),"objType in ['equipment','component']"));
         }else{
             request.setFilters("objType in ['equipment','component']");
         }
-        return service.doQuery(context, request, AdmEquipment.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
     }
 
     /**
@@ -167,12 +147,10 @@ public class AdmEquipmentController {
      * @return
      * @throws Exception
      */
-    @PostMapping("/create-equip-pro")
-    public AdmResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    @PostMapping("/creat-equip-pro")
+    public AdmResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
         List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
-        vos = service.doInsertExt(context, AdmEquipment.class, vos);
+        vos = service.doInsertExt(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 

+ 22 - 39
src/main/java/com/persagy/proxy/adm/controller/AdmFloorController.java

@@ -3,7 +3,6 @@ package com.persagy.proxy.adm.controller;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.persagy.dmp.common.model.entity.BaseEntity;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmEquipment;
 import com.persagy.proxy.adm.model.AdmFloor;
 import com.persagy.proxy.adm.model.AdmISpace;
@@ -15,17 +14,15 @@ import com.persagy.proxy.adm.service.IAdmEquipmentService;
 import com.persagy.proxy.adm.service.IAdmFloorService;
 import com.persagy.proxy.adm.service.IAdmISpaceService;
 import com.persagy.proxy.adm.service.IAdmSpaceService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
 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;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.ws.rs.QueryParam;
 import java.util.List;
 import java.util.Map;
 
@@ -46,8 +43,6 @@ public class AdmFloorController {
     private IAdmISpaceService iAdmISpaceService;
     @Autowired
     private IAdmSpaceService spaceService;
-    @Value("${middleware.group.code}")
-    private String groupCode;
 
     /**
      * 创建
@@ -56,9 +51,7 @@ public class AdmFloorController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmFloor> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmFloor> createRequest) throws Exception {
         List<AdmFloor> vos = createRequest.getContent();
         for(AdmFloor floor : vos){
             if(StrUtil.isEmpty(floor.getName())){
@@ -80,7 +73,7 @@ public class AdmFloorController {
             filters+= "]";
             admQueryCriteria.setFilters(filters);
             admQueryCriteria.setName("floor");
-            AdmResponse admResponseF = service.doQuery(context, admQueryCriteria, AdmFloor.class);
+            AdmResponse admResponseF = service.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmFloor.class);
             if(DmpResult.SUCCESS.equals(admResponseF.getResult()) && admResponseF.getTotal() > 0){
                 List<AdmFloor> vosOld = (List<AdmFloor>) admResponseF.getContent();
                 for(AdmFloor admFloorOld : vosOld){
@@ -94,7 +87,7 @@ public class AdmFloorController {
                 }
             }
         }
-        List<AdmFloor> admFloors = service.doInsert(context, AdmFloor.class, createRequest.getContent());
+        List<AdmFloor> admFloors = service.doInsert(AdmContextUtil.toDmpContext(), AdmFloor.class, createRequest.getContent());
         return AdmResponse.success(admFloors);
     }
 
@@ -105,9 +98,7 @@ public class AdmFloorController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmFloor> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse delete( @RequestBody List<AdmFloor> vos) throws Exception {
         String msg = "楼层下包含其他对象实例,请解除关系后删除";
         Map<String, AdmFloor> admFloorMap = CollUtil.fieldValueMap(vos, BaseEntity.PROP_ID);
 
@@ -124,21 +115,21 @@ public class AdmFloorController {
         admQueryCriteria.setOnlyCount(true);
 
         admQueryCriteria.setName(AdmSpace.OBJ_TYPE);
-        AdmResponse admResponseSpace = spaceService.doQuery(context, admQueryCriteria, AdmSpace.class);
+        AdmResponse admResponseSpace = spaceService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmSpace.class);
         if(admResponseSpace.getResult().equals(DmpResult.SUCCESS) && CollUtil.isNotEmpty(admResponseSpace.getContent())){
             return AdmResponse.failure(msg);
         }
         admQueryCriteria.setName(AdmISpace.OBJ_TYPE);
-        AdmResponse admResponseISpace = iAdmISpaceService.doQuery(context, admQueryCriteria, AdmISpace.class);
+        AdmResponse admResponseISpace = iAdmISpaceService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmISpace.class);
         if(admResponseISpace.getResult().equals(DmpResult.SUCCESS) && CollUtil.isNotEmpty(admResponseISpace.getContent())){
             return AdmResponse.failure(msg);
         }
         admQueryCriteria.setName(AdmEquipment.OBJ_TYPE);
-        AdmResponse admResponseEuip = equipmentService.doQuery(context, admQueryCriteria, AdmEquipment.class);
+        AdmResponse admResponseEuip = equipmentService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmEquipment.class);
         if(admResponseEuip.getResult().equals(DmpResult.SUCCESS) && CollUtil.isNotEmpty(admResponseEuip.getContent())){
             return AdmResponse.failure(msg);
         }
-        service.doDelete(context, vos);
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -149,8 +140,8 @@ public class AdmFloorController {
      * @throws Exception
      */
     @PostMapping("/single/delete")
-    public AdmResponse deleteSingle(@QueryParam("projectId") String projectId, @RequestBody List<AdmFloor> vos) throws Exception {
-       delete(projectId,vos);
+    public AdmResponse deleteSingle( @RequestBody List<AdmFloor> vos) throws Exception {
+       delete(vos);
        return AdmResponse.success();
     }
 
@@ -161,9 +152,7 @@ public class AdmFloorController {
      * @throws Exception
      */
     @PostMapping("/update")
-    public AdmResponse update(@RequestBody AdmCreateRequest<AdmFloor> admFloor, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmFloor> admFloor) throws Exception {
         List<AdmFloor> vos = CollUtil.newArrayList(admFloor.getContent());
         /** 遍历楼层列表 */
         Map<String, AdmFloor> admFloorBdMap = CollUtil.fieldValueMap(vos, "buildingId");
@@ -178,7 +167,7 @@ public class AdmFloorController {
             filters+= "]";
             admQueryCriteria.setFilters(filters);
             admQueryCriteria.setName("floor");
-            AdmResponse admResponseF = service.doQuery(context, admQueryCriteria, AdmFloor.class);
+            AdmResponse admResponseF = service.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmFloor.class);
             if(DmpResult.SUCCESS.equals(admResponseF.getResult()) && admResponseF.getTotal() > 0 && CollUtil.isNotEmpty(admResponseF.getContent())){
                 List<AdmFloor> vosOld = (List<AdmFloor>) admResponseF.getContent();
                 for(AdmFloor admFloorOld : vosOld){
@@ -192,7 +181,7 @@ public class AdmFloorController {
                 }
             }
         }
-        vos = service.doUpdate(context, AdmFloor.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmFloor.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -204,9 +193,9 @@ public class AdmFloorController {
      * @throws Exception
      */
     @PostMapping("/update-outline")
-    public AdmResponse updateOutline(@RequestBody AdmCreateRequest<AdmFloor> admFloor, @QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse updateOutline(@RequestBody AdmCreateRequest<AdmFloor> admFloor) throws Exception {
         // 组装上下文条件
-        AdmResponse admResponse = update(admFloor,projectId);
+        AdmResponse admResponse = update(admFloor);
         //TODO 处理关系
         /** 处理关系标记 */
        /* val listtype = ArrayList<String>()
@@ -231,35 +220,29 @@ public class AdmFloorController {
 
     /**
      * 查询
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmFloor.OBJ_TYPE);
-        return service.doQuery(context, request, AdmFloor.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmFloor.class);
     }
 
 
     /**
      * 查询
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query-outline")
-    public AdmResponse queryOutline(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse queryOutline(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmFloor.OBJ_TYPE);
-        return service.doQueryOutLine(context, request, AdmFloor.class);
+        return service.doQueryOutLine(AdmContextUtil.toDmpContext(), request, AdmFloor.class);
     }
 
 }

+ 13 - 30
src/main/java/com/persagy/proxy/adm/controller/AdmISpaceController.java

@@ -1,21 +1,18 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmISpace;
 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.IAdmISpaceService;
-import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.ws.rs.QueryParam;
 import java.util.List;
 
 /**
@@ -29,24 +26,19 @@ import java.util.List;
 public class AdmISpaceController {
     @Autowired
     private IAdmISpaceService service;
-    @Value("${middleware.group.code}")
-    private String groupCode;
 
     /**
      * 统计
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmISpace.OBJ_TYPE);
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmISpace.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmISpace.class);
     }
     /**
      * 创建
@@ -55,11 +47,9 @@ public class AdmISpaceController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmISpace> AdmISpace, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmISpace> AdmISpace) throws Exception {
         List<AdmISpace> vos = CollUtil.newArrayList(AdmISpace.getContent());
-        vos = service.doInsert(context, AdmISpace.class, vos);
+        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmISpace.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -70,10 +60,8 @@ public class AdmISpaceController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmISpace> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        service.doDelete(context, vos);
+    public AdmResponse delete( @RequestBody List<AdmISpace> vos) throws Exception {
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -84,28 +72,23 @@ public class AdmISpaceController {
      * @throws Exception
      */
     @PostMapping("/update")
-    public AdmResponse update(@RequestBody AdmCreateRequest<AdmISpace> AdmISpace, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmISpace> AdmISpace) throws Exception {
         List<AdmISpace> vos = CollUtil.newArrayList(AdmISpace.getContent());
-        vos = service.doUpdate(context, AdmISpace.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmISpace.class, vos);
         return AdmResponse.success(vos);
     }
 
     /**
      * 查询
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmISpace.OBJ_TYPE);
-        return service.doQuery(context, request, AdmISpace.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmISpace.class);
     }
 
 }

+ 6 - 5
src/main/java/com/persagy/proxy/adm/controller/AdmLabslController.java

@@ -5,6 +5,7 @@ import com.persagy.proxy.adm.model.AdmObjectInfo;
 import com.persagy.proxy.adm.model.AdmObjectType;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmLabslService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,7 +44,7 @@ public class AdmLabslController {
      */
     @PostMapping("/category")
     public AdmResponse queryCategory() throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, AdmCommonConstant.PROJECTID, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.queryCategory(context, AdmObjectInfo.class);
     }
 
@@ -55,7 +56,7 @@ public class AdmLabslController {
      */
     @PostMapping("/zone/type")
     public AdmResponse queryZoneType() throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, AdmCommonConstant.PROJECTID, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.queryZoneType(context, AdmObjectInfo.class);
     }
 
@@ -66,7 +67,7 @@ public class AdmLabslController {
      */
     @PostMapping("/building/floor")
     public AdmResponse queryBuildFloor(@QueryParam("projectId") String projectId) throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.queryBuildFloor(context, AdmObjectInfo.class);
     }
 
@@ -78,7 +79,7 @@ public class AdmLabslController {
      */
     @PostMapping("/query/equip")
     public AdmResponse queryEquipType(@QueryParam("projectId") String projectId) throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.queryBuildFloor(context, AdmObjectInfo.class);
     }
 
@@ -91,7 +92,7 @@ public class AdmLabslController {
     @PostMapping("/major/category")
     public AdmResponse queryMajorCategory(@QueryParam("projectId") String projectId,
                                           @RequestBody List<String> ids) throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.queryMajorCategory(context, ids , AdmObjectType.class);
     }
 

+ 7 - 6
src/main/java/com/persagy/proxy/adm/controller/AdmLocationPointController.java

@@ -9,6 +9,7 @@ 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.IAdmLocationPointService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
@@ -52,7 +53,7 @@ public class AdmLocationPointController {
     public AdmResponse count(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setName("point");
         request.setOnlyCount(true);
         return service.doQuery(context, request, AdmLocationPoint.class);
@@ -69,7 +70,7 @@ public class AdmLocationPointController {
     public AdmResponse query(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setName("point");
         // 查询信息点标签
         AdmResponse admResponse = service.doQuery(context, request, AdmLocationPoint.class);
@@ -87,7 +88,7 @@ public class AdmLocationPointController {
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmLocationPoint> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         List<AdmLocationPoint> vos = CollUtil.newArrayList(createRequest.getContent());
         log.info("创建条件"+vos.toString());
         vos = service.doInsert(context, AdmLocationPoint.class, vos);
@@ -104,7 +105,7 @@ public class AdmLocationPointController {
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmLocationPoint> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         List<AdmLocationPoint> vos = CollUtil.newArrayList(createRequest.getContent());
         vos = service.doUpdate(context, AdmLocationPoint.class, vos);
         return AdmResponse.success(vos);
@@ -120,7 +121,7 @@ public class AdmLocationPointController {
     @PostMapping("/delete")
     public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmLocationPoint> vos) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doDelete(context, vos);
         return AdmResponse.success();
     }
@@ -134,7 +135,7 @@ public class AdmLocationPointController {
     @PostMapping("/delete-image")
     public AdmResponse deleteImage(@QueryParam("projectId") String projectId, @RequestBody List<AdmPointImage> vos) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         // 删除图片参数转换
         List<AdmLocationPoint> points = deleteImageParamRevert(vos);
         service.doUpdate(context,AdmLocationPoint.class, points);

+ 3 - 2
src/main/java/com/persagy/proxy/adm/controller/AdmPlanarController.java

@@ -5,6 +5,7 @@ import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.*;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmPlanarService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,7 +45,7 @@ public class AdmPlanarController {
     @PostMapping("/equip")
     public AdmResponse queryPlanarEquip(@QueryParam("projectId") String projectId,
                                           @RequestBody AdmPlanarEquipRequests requests) throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         if(requests == null){
             throw new Exception("请求参数不能为空");
         }
@@ -59,7 +60,7 @@ public class AdmPlanarController {
     @PostMapping("/space")
     public AdmResponse queryPlanarSpace(@QueryParam("projectId") String projectId,
                                   @RequestBody AdmPlanarEquipRequests requests) throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         if(requests == null){
             throw new Exception("请求参数不能为空");
         }

+ 9 - 7
src/main/java/com/persagy/proxy/adm/controller/AdmProjectController.java

@@ -1,6 +1,7 @@
 package com.persagy.proxy.adm.controller;
 
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import cn.hutool.core.util.StrUtil;
+import com.persagy.dmp.common.context.AppContext;
 import com.persagy.proxy.adm.model.AdmProject;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
@@ -26,23 +27,24 @@ public class AdmProjectController {
 
     @Autowired
     private IAdmProjectService service;
+
     @Value("${middleware.group.code}")
     private String groupCode;
 
     /**
      * 查询项目信息
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@QueryParam("projectId") String projectId, @RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmProject.OBJ_TYPE);
-        return service.doQuery(context, request, AdmProject.class);
+        String group = (StrUtil.isBlank(AppContext.getContext().getGroupCode()) || AppContext.getContext().getGroupCode().equals("null") ) ? groupCode:AppContext.getContext().getGroupCode();
+        InstanceUrlParam param = InstanceUrlParam.builder().groupCode(group)
+                .projectId(projectId).userId(AppContext.getContext().getAccountId())
+                .appId(AppContext.getContext().getAppId()).build();
+        return service.doQuery(param, request, AdmProject.class);
     }
 
     /**

+ 13 - 28
src/main/java/com/persagy/proxy/adm/controller/AdmPropertyController.java

@@ -1,15 +1,13 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 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.InstanceUrlParam;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -29,8 +27,6 @@ import java.util.List;
 public class AdmPropertyController {
     @Autowired
     private IAdmPropertyService service;
-    @Value("${middleware.group.code}")
-    private String groupCode;
 
     /**
      * 创建
@@ -39,11 +35,9 @@ public class AdmPropertyController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmProperty> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmProperty> createRequest) throws Exception {
         List<AdmProperty> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsert(context, AdmProperty.class, vos);
+        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmProperty.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -54,10 +48,8 @@ public class AdmPropertyController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmProperty> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        service.doDelete(context, vos);
+    public AdmResponse delete( @RequestBody List<AdmProperty> vos) throws Exception {
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -70,45 +62,38 @@ public class AdmPropertyController {
      */
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmProperty> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        
         List<AdmProperty> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmProperty.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmProperty.class, vos);
         return AdmResponse.success(vos);
     }
 
 
     /**
      * 查询
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName("equipment");
-        return service.doQuery(context, request, AdmProperty.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmProperty.class);
     }
 
 
     /**
      * 统计 已经关联岗位的资产数量("Filters": " not EquipId isNull"),未关联岗位的资产数量("Filters": " EquipId isNull")
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName("equipment");
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmProperty.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmProperty.class);
     }
 }

+ 75 - 69
src/main/java/com/persagy/proxy/adm/controller/AdmRelCalController.java

@@ -47,12 +47,17 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"bd2sp","fl2sp","sh2bd"})
-    public AdmResponse archSubsetCalcRelation(@QueryParam("projectId") String projectId,
-                                              @QueryParam("objectTypes") String objectTypeStr,
-                                              @QueryParam("relationType") String relationTypeStr,
+    public AdmResponse archSubsetCalcRelation(@RequestParam("projectId") String projectId,
+                                              @RequestParam("groupCode") String groupCode,
+                                              @RequestParam("appId") String appId,
+                                              @RequestParam("userId") String userId,
+                                              @RequestParam("objectTypes") String objectTypeStr,
+                                              @RequestParam("relationType") String relationTypeStr,
                                               HttpServletRequest request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
         admRelCalService.calcRelation(context,CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
         return AdmResponse.success(new ArrayList<>());
     }
@@ -76,19 +81,23 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"eq2bd","eq2fl","eq2sh","eq2sp_in","sy2bd","sy2fl","sy2sh","sy2sp"})
-    public AdmResponse mechInArchCalcRelation(@QueryParam("projectId") String projectId,
-                                              @QueryParam("objectTypes") String objectTypeStr,
-                                              @QueryParam("relationType") String relationTypeStr,
+    public AdmResponse mechInArchCalcRelation(@RequestParam("projectId") String projectId,
+                                              @RequestParam("groupCode") String groupCode,
+                                              @RequestParam("appId") String appId,
+                                              @RequestParam("userId") String userId,
+                                              @RequestParam("objectTypes") String objectTypeStr,
+                                              @RequestParam("relationType") String relationTypeStr,
                                               HttpServletRequest request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
         admRelCalService.calcRelation(context, CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
         return AdmResponse.success(new ArrayList<>());
     }
 
     /***
      * Description: 添加关系(图类型关系为PropertyInArch)
-     * @param relType : 关系类型
      * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
      *                      DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
      *                      FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
@@ -102,19 +111,22 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"pe2bd","pe2fl","pe2sh","pe2sp"})
-    public AdmResponse propertyInArchCalcRelation( @PathVariable("relType") String relType,
-                                     @QueryParam("projectId") String projectId,
-                                     @QueryParam("objectTypes") String objectTypeStr,
-                                     @QueryParam("relationType") String relationTypeStr) throws Exception {
+    public AdmResponse propertyInArchCalcRelation(@RequestParam("projectId") String projectId,
+                                                  @RequestParam("groupCode") String groupCode,
+                                                  @RequestParam("appId") String appId,
+                                                  @RequestParam("userId") String userId,
+                                                  @RequestParam("objectTypes") String objectTypeStr,
+                                                  @RequestParam("relationType") String relationTypeStr) throws Exception {
         // 资产暂时未引入,直接返回成功
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
         // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
         return AdmResponse.success(new ArrayList<>());
     }
     /***
      * Description: 添加关系(图类型关系为MechForArch)
-     * @param relType : 关系类型
      * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
      *                      DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
      *                      FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
@@ -125,13 +137,17 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"eq2sp_for"})
-    public AdmResponse mechForArchCalcRelation( @PathVariable("relType") String relType,
-                                     @QueryParam("projectId") String projectId,
-                                     @QueryParam("objectTypes") String objectTypeStr,
-                                     @QueryParam("relationType") String relationTypeStr) throws Exception {
+    public AdmResponse mechForArchCalcRelation(@RequestParam("projectId") String projectId,
+                                               @RequestParam("groupCode") String groupCode,
+                                               @RequestParam("appId") String appId,
+                                               @RequestParam("userId") String userId,
+                                               @RequestParam("objectTypes") String objectTypeStr,
+                                               @RequestParam("relationType") String relationTypeStr) throws Exception {
         // 资产暂时未引入,直接返回成功
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
         // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
         return AdmResponse.success(new ArrayList<>());
     }
@@ -189,10 +205,6 @@ public class AdmRelCalController {
     }
     /***
      * Description: 添加关系(图类型关系为ConvectionNetwork)
-     * @param relType : 关系类型
-     * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
-     *                      DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
-     *                      FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
      * sp2sp_ConvectionNetwork_1:Natural-空气自然对流
      * @return : com.persagy.proxy.adm.request.AdmCreateResponse
      * @author : lijie
@@ -200,22 +212,20 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"sp2sp_ConvectionNetwork_1"})
-    public AdmResponse convectionNetworkCalcRelation( @PathVariable("relType") String relType,
-                                     @QueryParam("projectId") String projectId,
-                                     @QueryParam("objectTypes") String objectTypeStr,
-                                     @QueryParam("relationType") String relationTypeStr) throws Exception {
+    public AdmResponse convectionNetworkCalcRelation(@RequestParam("projectId") String projectId,
+                                                     @RequestParam("groupCode") String groupCode,
+                                                     @RequestParam("appId") String appId,
+                                                     @RequestParam("userId") String userId) throws Exception {
         // 资产暂时未引入,直接返回成功
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
+        admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_CONVECTIONNETWORK_1),null);
         return AdmResponse.success(new ArrayList<>());
     }
     /***
      * Description: 添加关系(图类型关系为RadiationNetwork)
-     * @param relType : 关系类型
-     * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
-     *                      DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
-     *                      FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
      * sp2sp_RadiationNetwork_1:光照辐射网络-Connect-光照连通
      * @return : com.persagy.proxy.adm.request.AdmCreateResponse
      * @author : lijie
@@ -223,22 +233,20 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"sp2sp_RadiationNetwork_1"})
-    public AdmResponse radiationNetworkCalcRelation( @PathVariable("relType") String relType,
-                                     @QueryParam("projectId") String projectId,
-                                     @QueryParam("objectTypes") String objectTypeStr,
-                                     @QueryParam("relationType") String relationTypeStr) throws Exception {
+    public AdmResponse radiationNetworkCalcRelation(@RequestParam("projectId") String projectId,
+                                                    @RequestParam("groupCode") String groupCode,
+                                                    @RequestParam("appId") String appId,
+                                                    @RequestParam("userId") String userId) throws Exception {
         // 资产暂时未引入,直接返回成功
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
+        admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_RADIATIONNETWORK_1),null);
         return AdmResponse.success(new ArrayList<>());
     }
     /***
      * Description: 添加关系(图类型关系为SpaceNeighborhood)
-     * @param relType : 关系类型
-     * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
-     *                      DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
-     *                      FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
      * sp2sp_SpaceNeighborhood_5:业务空间(同类)邻接关系-Connect-空间连通
      * @return : com.persagy.proxy.adm.request.AdmCreateResponse
      * @author : lijie
@@ -246,22 +254,20 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"sp2sp_SpaceNeighborhood_5"})
-    public AdmResponse spaceNeighborhoodCalcRelation( @PathVariable("relType") String relType,
-                                     @QueryParam("projectId") String projectId,
-                                     @QueryParam("objectTypes") String objectTypeStr,
-                                     @QueryParam("relationType") String relationTypeStr) throws Exception {
+    public AdmResponse spaceNeighborhoodCalcRelation(@RequestParam("projectId") String projectId,
+                                                     @RequestParam("groupCode") String groupCode,
+                                                     @RequestParam("appId") String appId,
+                                                     @RequestParam("userId") String userId) throws Exception {
         // 资产暂时未引入,直接返回成功
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
+        admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_SPACENEIGHBORHOOD_5),null);
         return AdmResponse.success(new ArrayList<>());
     }
     /***
      * Description: 添加关系(计算设备所在建筑,系统所在建筑,图类型关系为MechInArch)
-     * @param relType : 关系类型
-     * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
-     *                      DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
-     *                      FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
      * syeq2bd:建筑下的系统设备部件,计算设备所在建筑(eq2bd),系统所在建筑(sy2bd)
      * @return : com.persagy.proxy.adm.request.AdmCreateResponse
      * @author : lijie
@@ -269,13 +275,15 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"syeq2bd"})
-    public AdmResponse syeq2bdCalcRelation( @PathVariable("relType") String relType,
-                                     @QueryParam("projectId") String projectId,
-                                     @QueryParam("objectTypes") String objectTypeStr,
-                                     @QueryParam("relationType") String relationTypeStr) throws Exception {
+    public AdmResponse syeq2bdCalcRelation(@RequestParam("projectId") String projectId,
+                                           @RequestParam("groupCode") String groupCode,
+                                           @RequestParam("appId") String appId,
+                                           @RequestParam("userId") String userId) throws Exception {
         // 资产暂时未引入,直接返回成功
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
         Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
         if (!relationTypeMap.containsKey("eq2bd") || !relationTypeMap.containsKey("sy2bd")){
             throw new BusinessException(BusinessErrorRwdCode.A7201.getCode(),BusinessErrorRwdCode.A7201.getDesc());
@@ -287,10 +295,6 @@ public class AdmRelCalController {
     }
     /***
      * Description: 添加关系(图类型关系为TrafficNetwork)
-     * @param relType : 关系类型
-     * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
-     *                      DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
-     *                      FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
      * sp2sp_TrafficNetwork_1:建筑交通网络(同类)-Normal-普通交通
      * @return : com.persagy.proxy.adm.request.AdmCreateResponse
      * @author : lijie
@@ -298,14 +302,16 @@ public class AdmRelCalController {
      * Update By lijie 2021/8/31 12:10
      */
     @PostMapping(value = {"sp2sp_TrafficNetwork_1"})
-    public AdmResponse trafficNetworkCalcRelation( @PathVariable("relType") String relType,
-                                     @QueryParam("projectId") String projectId,
-                                     @QueryParam("objectTypes") String objectTypeStr,
-                                     @QueryParam("relationType") String relationTypeStr) throws Exception {
+    public AdmResponse trafficNetworkCalcRelation(@RequestParam("projectId") String projectId,
+                                                  @RequestParam("groupCode") String groupCode,
+                                                  @RequestParam("appId") String appId,
+                                                  @RequestParam("userId") String userId) throws Exception {
         // 资产暂时未引入,直接返回成功
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
+        InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
+                null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
+                StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
+        admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_TRAFFICNETWORK_1),null);
         return AdmResponse.success(new ArrayList<>());
     }
     /***

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

@@ -19,6 +19,7 @@ import com.persagy.proxy.adm.service.IAdmGraphicTypeService;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.service.IAdmRelationTypeService;
 import com.persagy.proxy.adm.service.IAdmWindowService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -57,7 +58,7 @@ public class AdmRelationController {
     @PostMapping("/equip/category")
     public AdmResponse equipRel(@QueryParam("projectId") String projectId) {
         //组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         AdmResponse res = service.query(context);
         return res;
     }

+ 3 - 2
src/main/java/com/persagy/proxy/adm/controller/AdmRelationObjectController.java

@@ -7,6 +7,7 @@ import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmDtRelationService;
 import com.persagy.proxy.adm.service.IAdmGraphicTypeService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -40,9 +41,9 @@ public class AdmRelationObjectController {
     @PostMapping("/equip/query")
     public AdmResponse equipRel(@QueryParam("projectId") String projectId) {
         //组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         AdmQueryCriteria criteria = new AdmQueryCriteria();
-        criteria.setFilters("projectId = "+projectId);
+        criteria.setFilters("projectId = "+context.getProjectId());
         AdmResponse admResponse = service.doQuery(context, criteria, AdmDtRelation.class);
         return admResponse;
     }

+ 60 - 78
src/main/java/com/persagy/proxy/adm/controller/AdmReportEquipController.java

@@ -29,9 +29,9 @@ import com.persagy.proxy.adm.service.IAdmComponentService;
 import com.persagy.proxy.adm.service.IAdmDictService;
 import com.persagy.proxy.adm.service.IAdmEquipmentService;
 import com.persagy.proxy.adm.service.IAdmSystemService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 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;
 import org.springframework.web.bind.annotation.*;
@@ -65,16 +65,13 @@ public class AdmReportEquipController {
      * 查询设备信息 关联的部件 资产信息
      * 查询设备关联资产部件数量
      *
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/equip-components")
-    public AdmResponse getEquipAssetComponents(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse getEquipAssetComponents(@RequestBody AdmQueryCriteria request) throws Exception {
         //查询设备
         request.setName(AdmEquipment.OBJ_TYPE);
         List<AdmQueryCriteria> cascade = new ArrayList<>();
@@ -88,7 +85,7 @@ public class AdmReportEquipController {
         cascade.add(cascadeSys);
         request.setCascade(cascade);
         QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
-        List<ObjectNode> equips = DigitalObjectFacade.query(context.getGroupCode(), context.getProjectId(), context.getAppId(), null, queryCriteria);
+        List<ObjectNode> equips = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteria);
         if (CollUtil.isEmpty(equips)) {
             return AdmResponse.success();
         }
@@ -107,7 +104,7 @@ public class AdmReportEquipController {
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
         criteria.put("code", admEquipment.getClassCode());
         defineCriteria.setCriteria(criteria);
-        AdmResponse defRes = dictService.doQueryObjectType(context, queryCriteria, AdmObjectType.class);
+        AdmResponse defRes = dictService.doQueryObjectType(AdmContextUtil.toDmpContext(), defineCriteria, AdmObjectType.class);
         if (CollUtil.isNotEmpty(defRes.getContent())) {
             List<AdmObjectType> componentCategory = (List<AdmObjectType>) defRes.getContent();
             admEquipment.setComponentCategory(componentCategory);
@@ -123,10 +120,7 @@ public class AdmReportEquipController {
      * @return 查询结果
      */
     @PostMapping("/components-count")
-    public AdmResponse getEquipComponentsCount(@QueryParam("projectId") String projectId,
-                                               @RequestBody AdmQueryCriteria request){
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse getEquipComponentsCount(@RequestBody AdmQueryCriteria request){
         QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
         ObjectNode criteria = queryCriteria.getCriteria();
         if(JSONUtil.isNull(criteria)){
@@ -135,7 +129,7 @@ public class AdmReportEquipController {
         JsonNode euipId = criteria.get("id");
         RequestData requestData = new RequestData();
         requestData.setEquipmentId(String.valueOf(euipId));
-        List result = DigitalObjectSimpleFacade.queryComponentsCountByEquipId(context.getGroupCode(), context.getProjectId(), context.getAppId(),null,requestData);
+        List result = DigitalObjectSimpleFacade.queryComponentsCountByEquipId(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(),null,requestData);
         if(CollUtil.isNotEmpty(result)){
             return AdmResponse.success(result);
         }else{
@@ -152,12 +146,9 @@ public class AdmReportEquipController {
      * @return              查询结果
      */
     @PostMapping("/components-property")
-    public AdmResponse getComponentProperty(@QueryParam("projectId") String projectId,
-                                             @RequestBody AdmQueryCriteria request){
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse getComponentProperty(@RequestBody AdmQueryCriteria request){
         request.setName(AdmComponent.OBJ_TYPE);
-        return componentService.doQuery(context, request, AdmComponent.class);
+        return componentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmComponent.class);
     }
 
     /**
@@ -167,10 +158,8 @@ public class AdmReportEquipController {
      * @param   category    分类
      */
     @GetMapping("/equip-compon")
-    public AdmResponse getEquipCompon(@QueryParam("projectId") String projectId, @QueryParam("id") String id, @QueryParam("category") String category){
-        //return  rEquipComponService.getEquipCompon(id,category)
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse getEquipCompon(@QueryParam("id") String id, @QueryParam("category") String category){
+        //return  rEquipComponService.getEquipCompon(id,category)        
         RequestData requestData = new RequestData();
         if(StrUtil.isNotEmpty(id)){
             requestData.setEquipmentId(id);
@@ -178,7 +167,7 @@ public class AdmReportEquipController {
         if(StrUtil.isNotEmpty(category)){
             requestData.setClassCode(category);
         }
-        List result = DigitalObjectSimpleFacade.queryEquipComponentsByProjectId(context.getGroupCode(), context.getProjectId(), context.getAppId(),null, requestData);
+        List result = DigitalObjectSimpleFacade.queryEquipComponentsByProjectId(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(),null, requestData);
         if(CollUtil.isNotEmpty(result)){
             return AdmResponse.success(result);
         }else{
@@ -204,7 +193,7 @@ public class AdmReportEquipController {
      *      "根据设备类型和建筑楼层查询(\"Filters\": \"category ='FASE';buildingId = '建筑id';floorId = '楼层id'\")"
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId, @RequestBody AdmQueryCriteria request) {
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) {
         QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
         if(StrUtil.isNotEmpty(request.getFilters()) && request.getFilters().contains("category")){
@@ -213,7 +202,7 @@ public class AdmReportEquipController {
         }
         queryCriteria.setCriteria(criteria);
         queryCriteria.setOnlyCount(true);
-        List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null, queryCriteria);
+        List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteria);
         if(CollUtil.isNotEmpty(euipCom)){
             return AdmResponse.success(euipCom);
         }else{
@@ -229,7 +218,7 @@ public class AdmReportEquipController {
      *             "根据设备类型和建筑楼层查询(\"Filters\": \"category ='FASE';buildingId = '建筑id';floorId = '楼层id'\")"
      */
     @PostMapping("/pagequery")
-    public AdmResponse pageQuery(@QueryParam("projectId") String projectId, @RequestBody AdmQueryCriteria request) {
+    public AdmResponse pageQuery(@RequestBody AdmQueryCriteria request) {
         QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
         queryCriteria.setCriteria(criteria);
@@ -237,7 +226,7 @@ public class AdmReportEquipController {
             criteria.put("classCode", criteria.get("category").textValue());
             criteria.remove("category");
         }
-        List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null, queryCriteria);
+        List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteria);
         if(CollUtil.isNotEmpty(euipCom)){
             return AdmResponse.success(euipCom);
         }else{
@@ -257,10 +246,10 @@ public class AdmReportEquipController {
      *             "如果是查询不属于任何业务空间的对象, 设置notInZone = true"
      */
     @PostMapping("/zone-query")
-    public AdmResponse zoneQuery(@QueryParam("projectId") String projectId, @RequestBody AdmZoneEquipQueryRequest request) {
+    public AdmResponse zoneQuery(@RequestBody AdmZoneEquipQueryRequest request) {
         request.setName(AdmEquipment.OBJ_TYPE);
         if(StrUtil.isAllEmpty(request.getZoneType(),request.getZoneId())){
-            return pageQuery(projectId, request);
+            return pageQuery(request);
         }else{
 
         }
@@ -278,10 +267,10 @@ public class AdmReportEquipController {
      *             "如果是查询不属于任何业务空间的对象, 设置notInZone = true"
      */
     @PostMapping("/zone-component-query")
-    public AdmResponse zoneComponentQuery(@QueryParam("projectId") String projectId,@RequestBody AdmZoneEquipQueryRequest request) {
+    public AdmResponse zoneComponentQuery(@RequestBody AdmZoneEquipQueryRequest request) {
         if(StrUtil.isAllEmpty(request.getZoneType(),request.getZoneId())){
             request.setName(AdmComponent.OBJ_TYPE);
-            return pageQuery(projectId, request);
+            return pageQuery(request);
         }
        return null;
     }
@@ -291,12 +280,10 @@ public class AdmReportEquipController {
      *
      */
     @PostMapping("/creat-equip-pro")
-    public AdmResponse create(@QueryParam("projectId") String projectId,@RequestBody AdmCreateRequest<AdmEquipment> createRequest){
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest){
         //return EquipmentProSyService.createList(request)
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = equipmentService.doInsertEuip(context, AdmEquipment.class, vos);
+        vos = equipmentService.doInsertEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -304,7 +291,7 @@ public class AdmReportEquipController {
      * 查询不在当前系统下的设备
      */
     @PostMapping("/equip-sys")
-    public AdmResponse pageQueryEquipSys(@QueryParam("projectId") String projectId, @RequestBody AdmQueryCriteria request,@QueryParam("sysId") String sysId){
+    public AdmResponse pageQueryEquipSys(@RequestBody AdmQueryCriteria request,@QueryParam("sysId") String sysId){
         //return EquipmentService.queryBeforeEquipSy(sysId,request)
         QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
         ObjectNode criteriaEquip = JsonNodeFactory.instance.objectNode();
@@ -317,7 +304,7 @@ public class AdmReportEquipController {
         relationTo.put("objFrom", objFrom);
         criteriaEquip.putPOJO("relationTo",relationTo);
         queryCriteria.setCriteria(criteriaEquip);
-        List<ObjectNode> equips = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null,queryCriteria);
+        List<ObjectNode> equips = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteria);
         if (CollUtil.isEmpty(equips))
             return AdmResponse.success();
         else
@@ -330,12 +317,12 @@ public class AdmReportEquipController {
      * datacenter 查询目标是SysEquip 没先查询系统,根据系统id查询系统和设备的关系,根据关系查询设备,拼接数据
      */
     @PostMapping("/sys-equip")
-    public AdmResponse pageQuerySysEquip(@QueryParam("projectId") String projectId, @RequestBody AdmQueryCriteria request){
-        //return SysEquipService.pageQuery(request, arrayListOf(SFilter.eq("projectId", SPageContext.getHeader("projectId").toString())))
+    public AdmResponse pageQuerySysEquip(@RequestBody AdmQueryCriteria request){
+        //return SysEquipService.pageQuery(request, arrayListOf(SFilter.eq("projectId", SPageAdmContextUtil.toDmpContext().getHeader("projectId").toString())))
         request.setName(AdmSystem.OBJ_TYPE);
         QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
         queryCriteria.setSize(500l);
-        List<ObjectNode> objectNodeList = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null,queryCriteria);
+        List<ObjectNode> objectNodeList = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteria);
         if(CollUtil.isEmpty(objectNodeList)){
             return AdmResponse.success();
         }
@@ -352,7 +339,7 @@ public class AdmReportEquipController {
         admSystemMap.keySet().stream().forEach(id -> arrayNode.add(id));
         queryCriteriaRelation.setCriteria(criteria);
 
-        List<ObjectRelation> relations = DigitalRelationFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null,queryCriteriaRelation);
+        List<ObjectRelation> relations = DigitalRelationFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteriaRelation);
         if(CollUtil.isEmpty(relations)){
             AdmResponse.success();
         }
@@ -365,7 +352,7 @@ public class AdmReportEquipController {
         ArrayNode array = criteriaEquip.putObject("id").putArray("$in");
         relationMap.keySet().stream().forEach(id -> array.add(id));
         queryCriteriaEqu.setCriteria(criteriaEquip);
-        List<ObjectNode> equips = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null,queryCriteriaEqu);
+        List<ObjectNode> equips = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteriaEqu);
         List<AdmEquipment> equipsList = JSONUtil.toList(equips.toString(), AdmEquipment.class);
         Map<String, AdmEquipment> admEquipmentMap = CollUtil.fieldValueMap(equipsList, BaseEntity.PROP_ID);
 
@@ -392,14 +379,12 @@ public class AdmReportEquipController {
     @GetMapping("/equip-compon-category")
     public AdmResponse equipORComponCategory(@QueryParam("projectId") String projectId){
         //return EquipORComponCategoryService.getEquipORComponCategory()
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         RequestData requestData = new RequestData();
         if(StrUtil.isNotEmpty(projectId)){
             requestData.setProjectId(projectId);
         }
         requestData.setObjTypes(CollUtil.newHashSet(AdmEquipment.OBJ_TYPE, AdmComponent.OBJ_TYPE));
-        List<Map<String, Object>> result = DigitalObjectSimpleFacade.queryDefineInfoByObjType(context.getGroupCode(),projectId,context.getAppId(),null,requestData);
+        List<Map<String, Object>> result = DigitalObjectSimpleFacade.queryDefineInfoByObjType(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(),null,requestData);
         if(CollUtil.isNotEmpty(result)){
             return AdmResponse.success(result);
         }else{
@@ -436,12 +421,12 @@ public class AdmReportEquipController {
      * }
      */
     @PostMapping("/update")
-    public AdmResponse equipUpDateEnclosure(@QueryParam("projectId") String projectId,@RequestBody ObjectNode equipUpDateEnclosureRequest) {
+    public AdmResponse equipUpDateEnclosure(@RequestBody ObjectNode equipUpDateEnclosureRequest) {
         //return EquipmentService.equipUpDateEnclosurs(equipUpDateEnclosureRequest)
         if(JSONUtil.isNull(equipUpDateEnclosureRequest)){
             return AdmResponse.failure(ResponseCode.A0400.getDesc()+",不能为空");
         }
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        
         List<EquipUpDateEnclosure> equipUpDateEnclosure = JSONUtil.toList(equipUpDateEnclosureRequest.get("content").toString(), EquipUpDateEnclosure.class);
         if(CollUtil.isNotEmpty(equipUpDateEnclosure)){
             Map<String, EquipUpDateEnclosure> equipUpDateEnclosureMap = CollUtil.fieldValueMap(equipUpDateEnclosure, BaseEntity.PROP_ID);
@@ -455,7 +440,7 @@ public class AdmReportEquipController {
             ArrayNode arrayNode = criteria.putObject("id").putArray("$in");
             equipUpDateEnclosureMap.keySet().stream().forEach(equipId -> arrayNode.add(equipId));
             queryCriteria.setCriteria(criteria);
-            AdmResponse equips = equipmentService.doQuery(context, queryCriteria, AdmEquipment.class);
+            AdmResponse equips = equipmentService.doQuery(AdmContextUtil.toDmpContext(), queryCriteria, AdmEquipment.class);
             if(CollUtil.isEmpty(equips.getContent())){
                 return AdmResponse.failure(ResponseCode.A0400.getDesc());
             }
@@ -473,7 +458,7 @@ public class AdmReportEquipController {
                     }
                 });
             });
-            List<AdmEquipment> vos = equipmentService.doUpdate(context, AdmEquipment.class, equipmentList);
+            List<AdmEquipment> vos = equipmentService.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, equipmentList);
             return AdmResponse.success(vos);
         }else{
             return AdmResponse.failure(ResponseCode.A0400.getDesc());
@@ -488,7 +473,7 @@ public class AdmReportEquipController {
      * }]
      */
     @PostMapping("/equip-del-com")
-    public AdmResponse equipComDel(@QueryParam("projectId") String projectId,@RequestBody List<ObjectNode> equipComDelList){
+    public AdmResponse equipComDel(@RequestBody List<ObjectNode> equipComDelList){
         //return EquipmentService.equipComDels(equipComDelList)
         if(CollUtil.isEmpty(equipComDelList)){
             return AdmResponse.failure(ResponseCode.A0400.getCode());
@@ -504,7 +489,7 @@ public class AdmReportEquipController {
             }
         });
         queryCriteriaEuip.setCriteria(criteriaEquip);
-        List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
+        List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
         if(CollUtil.isEmpty(equipList)){
             return AdmResponse.success(equipComDelList);
         }
@@ -532,9 +517,9 @@ public class AdmReportEquipController {
      * }]
      */
     @PostMapping("/equip-supply")
-    public AdmResponse equipPropertySupply(@QueryParam("projectId") String projectId,@RequestBody List<ObjectNode> equipComDelList){
+    public AdmResponse equipPropertySupply(@RequestBody List<ObjectNode> equipComDelList){
         //return EquipmentService.equipPropertySupplys(equipComDelList)
-        //InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        //
         if(CollUtil.isEmpty(equipComDelList)){
             return AdmResponse.failure(ResponseCode.A0400.getCode());
         }
@@ -547,7 +532,7 @@ public class AdmReportEquipController {
             arrayNode.add(node.get("modelId").textValue());
         });
         queryCriteria.setCriteria(criteria);
-        List<ObjectNode> floorList = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null,queryCriteria);
+        List<ObjectNode> floorList = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteria);
         if(CollUtil.isEmpty(floorList)){
             return AdmResponse.success();
         }
@@ -573,7 +558,7 @@ public class AdmReportEquipController {
         criteriaEquip.putPOJO("modelId", modelId);
 
         queryCriteriaEuip.setCriteria(criteriaEquip);
-        List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
+        List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
         if(CollUtil.isEmpty(equipList)){
             return AdmResponse.success(equipComDelList);
         }
@@ -606,8 +591,7 @@ public class AdmReportEquipController {
      * 级联-任务(scanTaskBase)、资产(property)、设备类型(equipCategory),级联任务的时候需要设置条件(TaskState = 0 添加时间降序  取第一个值 )
      */
     @PostMapping("/equip-comm-del")
-    public AdmResponse equipCommDel(@QueryParam("projectId") String projectId,@RequestBody AdmQueryCriteria request){
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse equipCommDel(@RequestBody AdmQueryCriteria request){
         //return EquipDelService.pageQuery(sQueryRequest,withFilterList)
         //e.task_state = '-1'::integer
         //AND NOT e.model_id IS NULL
@@ -621,7 +605,7 @@ public class AdmReportEquipController {
         criteria.put("taskState","-1");
         queryCriteria.setCriteria(criteria);
 
-        AdmResponse equipRes = equipmentService.doQuery(context, queryCriteria, AdmEquipment.class);
+        AdmResponse equipRes = equipmentService.doQuery(AdmContextUtil.toDmpContext(), queryCriteria, AdmEquipment.class);
         return equipRes;
     }
 
@@ -630,8 +614,8 @@ public class AdmReportEquipController {
      * 级联-设备类型(equipFamily)
      */
     @PostMapping("/property-equip-supp")
-    public AdmResponse propertyEquip(@QueryParam("projectId") String projectId,@RequestBody AdmQueryCriteria request){
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse propertyEquip(@RequestBody AdmQueryCriteria request){
+        
         //return EquipmentService.equipPropertySupp(sQueryRequest)
         //equipment.bim_id IS NULL
         //  AND equipment.model_id IS NULL
@@ -652,7 +636,7 @@ public class AdmReportEquipController {
         criteria.putPOJO("bimLocation", bimLocation);
         queryCriteria.setCriteria(criteria);
 
-        AdmResponse equipRes = equipmentService.doQuery(context, queryCriteria, AdmEquipment.class);
+        AdmResponse equipRes = equipmentService.doQuery(AdmContextUtil.toDmpContext(), queryCriteria, AdmEquipment.class);
         if(CollUtil.isNotEmpty(equipRes.getContent())){
             List<AdmEquipment> admEquipments = JSONUtil.toList(equipRes.getContent().toString(), AdmEquipment.class);
             Map<String, AdmEquipment> admEquipmentMap = CollUtil.fieldValueMap(admEquipments, BaseEntity.PROP_ID);
@@ -676,7 +660,7 @@ public class AdmReportEquipController {
             filter =  filter + ";id in "+arrayNode.toString();
             request.setFilters(filter);
 
-           AdmResponse admResponse = equipmentService.doQuery(context, request, AdmEquipment.class);
+           AdmResponse admResponse = equipmentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
            if(CollUtil.isNotEmpty(admResponse.getContent())){
                //处理数据
                List<ObjectNode> objectNodeList = (List<ObjectNode>) admResponse.getContent();
@@ -753,8 +737,8 @@ public class AdmReportEquipController {
     @PostMapping("/info-point")
     public AdmResponse infoPoint(@QueryParam("projectId") String projectId) {
         //return customSqlService.infoPoints()
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        JSONObject gatherInfoPoint = calInfoPointByObjType(AdmEquipment.OBJ_TYPE, context, false, false);
+        
+        JSONObject gatherInfoPoint = calInfoPointByObjType(AdmEquipment.OBJ_TYPE, false, false);
         JSONObject infoPoint = new JSONObject();
         infoPoint.put("dynamicInfoPoint",gatherInfoPoint.getString("gatherDynamicInfoPointCounts"));
         infoPoint.put("staticInfoPoint",gatherInfoPoint.getString("gatherStaticInfoPointCounts"));
@@ -771,8 +755,8 @@ public class AdmReportEquipController {
         if(StrUtil.isEmpty(projectId)){
             return AdmResponse.failure(ResponseCode.A0400.getCode());
         }
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        JSONObject gatherInfoPoint = calInfoPointByObjType(AdmEquipment.OBJ_TYPE, context, true, true);
+        
+        JSONObject gatherInfoPoint = calInfoPointByObjType(AdmEquipment.OBJ_TYPE, true, true);
         return AdmResponse.success(CollUtil.newArrayList(gatherInfoPoint));
     }
 
@@ -785,8 +769,8 @@ public class AdmReportEquipController {
         if(StrUtil.isEmpty(projectId)){
             return AdmResponse.failure(ResponseCode.A0400.getCode());
         }
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        JSONObject gatherInfoPoint = calInfoPointByObjType(AdmSystem.OBJ_TYPE, context, true, true);
+        
+        JSONObject gatherInfoPoint = calInfoPointByObjType(AdmSystem.OBJ_TYPE,true, true);
         return AdmResponse.success(CollUtil.newArrayList(gatherInfoPoint));
     }
 
@@ -802,7 +786,7 @@ public class AdmReportEquipController {
         criteria.put("objType","['equipment','component']");
         queryCriteria.setCriteria(criteria);
         queryCriteria.setOnlyCount(true);
-        List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,projectId,AdmCommonConstant.APP_ID,null, queryCriteria);
+        List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteria);
         if(CollUtil.isNotEmpty(euipCom)){
            return AdmResponse.success(euipCom);
         }else{
@@ -817,14 +801,12 @@ public class AdmReportEquipController {
      */
     @PostMapping("/type")
     public AdmResponse equipType(@QueryParam("projectId") String projectId){
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         RequestData requestData = new RequestData();
         if(StrUtil.isNotEmpty(projectId)){
             requestData.setProjectId(projectId);
         }
         requestData.setObjType(AdmEquipment.OBJ_TYPE);
-        List<Map<String, Object>> result = DigitalObjectSimpleFacade.queryDefineInfoByObjType(context.getGroupCode(),projectId,context.getAppId(),null,requestData);
+        List<Map<String, Object>> result = DigitalObjectSimpleFacade.queryDefineInfoByObjType(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(),null,requestData);
         if(CollUtil.isNotEmpty(result)){
             return AdmResponse.success(result);
         }else{
@@ -936,7 +918,7 @@ public class AdmReportEquipController {
         return hashMap;
     }
 
-    private JSONObject calInfoPointByObjType(String objType, InstanceUrlParam context, Boolean visible, Boolean getInfoCounts){
+    private JSONObject calInfoPointByObjType(String objType, Boolean visible, Boolean getInfoCounts){
         //1 查询项目下所有现有的系统
         AdmQueryCriteria admQueryCriteriaObj =  new AdmQueryCriteria();
         if(objType.equals(AdmEquipment.OBJ_TYPE)){
@@ -946,7 +928,7 @@ public class AdmReportEquipController {
         }
         admQueryCriteriaObj.setName(objType);
         QueryCriteria queryCriteriaSys = AdmQueryCriteriaHelper.toDmpCriteria(admQueryCriteriaObj);
-        List<ObjectNode> admObjList = DigitalObjectFacade.query(groupCode, context.getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteriaSys);
+        List<ObjectNode> admObjList = DigitalObjectFacade.query(groupCode, AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteriaSys);
 
         //2 获取动态 静态 信息点
         // 2.1 根据objType获取定义
@@ -956,7 +938,7 @@ public class AdmReportEquipController {
             ObjectNode criteria = JsonNodeFactory.instance.objectNode();
             criteria.put("objType", objType);
             queryCriteriaType.setCriteria(criteria);
-            AdmResponse admResponseType = dictService.doQueryObjectType(context, queryCriteriaType, AdmObjectType.class);
+            AdmResponse admResponseType = dictService.doQueryObjectType(AdmContextUtil.toDmpContext(), queryCriteriaType, AdmObjectType.class);
             if(CollUtil.isEmpty(admResponseType.getContent())){
                 return null;
             }
@@ -989,7 +971,7 @@ public class AdmReportEquipController {
                 criteria.put("valid","['0','1']");
                 queryCriteria.setCriteria(criteria);
                 queryCriteria.setOnlyCount(true);
-                List<ObjectInfoDefine> totalInfo = DigitalObjectInfoFacade.query(groupCode, context.getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
+                List<ObjectInfoDefine> totalInfo = DigitalObjectInfoFacade.query(groupCode, AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
                 controlInfoCounts = totalInfo.size();
                 criteria.remove("valid");
             }
@@ -1001,7 +983,7 @@ public class AdmReportEquipController {
                 criteria.put("valid","['0','1']");
             }
             queryCriteria.setCriteria(criteria);
-            List<ObjectInfoDefine> staticInfoCode = DigitalObjectInfoFacade.query(groupCode, context.getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
+            List<ObjectInfoDefine> staticInfoCode = DigitalObjectInfoFacade.query(groupCode, AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
             criteria.remove("category");
 
             //动态信息点
@@ -1009,7 +991,7 @@ public class AdmReportEquipController {
             category.put("$ne","STATIC");
             criteria.putPOJO("category", category);
             queryCriteria.setCriteria(criteria);
-            List<ObjectInfoDefine> dynamicInfoCode = DigitalObjectInfoFacade.query(groupCode, context.getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
+            List<ObjectInfoDefine> dynamicInfoCode = DigitalObjectInfoFacade.query(groupCode, AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
             //4 计算已采集的和需要采集的信息点占比
             //return customSqlService.systemInfoPoins()
             Map<String, Integer> hashMap = calculate(dynamicInfoCode, staticInfoCode, admObjList, 1);

+ 40 - 71
src/main/java/com/persagy/proxy/adm/controller/AdmShaftController.java

@@ -16,7 +16,6 @@ import com.persagy.dmp.define.entity.ObjectInfoDefine;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
 import com.persagy.dmp.digital.client.DigitalRelationFacade;
 import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.*;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
@@ -24,12 +23,11 @@ import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmBuildingService;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.service.IAdmShaftService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
-import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.common.entity.RelationDTO;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import javax.ws.rs.QueryParam;
@@ -51,25 +49,19 @@ public class AdmShaftController {
     private IAdmRelationService relationService;
     @Autowired
     private IAdmBuildingService buildingService;
-    @Value("${middleware.group.code}")
-    private String groupCode;
-
 
     /**
      * 统计
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName("shaft");
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmShaft.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmShaft.class);
     }
 
     /**
@@ -79,16 +71,14 @@ public class AdmShaftController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmShaft> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmShaft> createRequest, @QueryParam("projectId") String projectId) throws Exception {       
         List<AdmShaft> vos = CollUtil.newArrayList(createRequest.getContent());
         vos.stream().forEach(admShaft -> {
             if (StrUtil.isEmpty(admShaft.getName())) {
                 admShaft.setName(ObjectNameUtil.objectName("竖井-"));
             }
         });
-        vos = service.doInsert(context, AdmShaft.class, vos);
+        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmShaft.class, vos);
 
         //TODO 创建竖井和建筑的关系
         /*if (!entity.buildingList.isNullOrEmpty()){
@@ -125,10 +115,8 @@ public class AdmShaftController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmShaft> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        service.doDelete(context, vos);
+    public AdmResponse delete( @RequestBody List<AdmShaft> vos) throws Exception {       
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -139,28 +127,23 @@ public class AdmShaftController {
      * @throws Exception
      */
     @PostMapping("/update")
-    public AdmResponse update(@RequestBody AdmCreateRequest<AdmShaft> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmShaft> createRequest, @QueryParam("projectId") String projectId) throws Exception {        
         List<AdmShaft> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmShaft.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmShaft.class, vos);
         return AdmResponse.success(vos);
     }
 
     /**
      * 查询
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {      
         request.setName("shaft");
-        return service.doQuery(context, request, AdmShaft.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmShaft.class);
     }
 
     /**
@@ -168,33 +151,27 @@ public class AdmShaftController {
      * 此方法可能会弃用
      *
      * 暂不实现
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query-with-count")
-    public AdmResponse queryWithCount(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse queryWithCount(@RequestBody AdmQueryCriteria request) throws Exception {       
         request.setName("shaft");
-        return service.doQuery(context, request, AdmShaft.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmShaft.class);
     }
 
     /**
      * 查询关联元空间
      * 可能移至关系
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/relate-space")
-    public AdmResponse queryRelateSp(@QueryParam("projectId") String projectId,
-                             @RequestBody JSONObject request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse queryRelateSp(@RequestBody JSONObject request) throws Exception {      
         //Sh2Sp
         // 先取消后重新建立
         if(JSONUtil.isNull(request)){
@@ -212,10 +189,10 @@ public class AdmShaftController {
         node.put("relCode", "Sh2Sp");
         node.put("objFrom", shaftId);
         criteria.setCriteria(node);
-        relationService.doDelete(context, criteria);
+        relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
 
         List<String> spaceIds = Arrays.asList(spaceId.split(","));
-        Set<String> existsIds = spaceExists(context, spaceIds);
+        Set<String> existsIds = spaceExists(spaceIds);
         List<String> failureList = null;
         if(CollUtil.isNotEmpty(existsIds)){
             failureList = spaceIds.stream().filter(isId -> !existsIds.contains(isId)).collect(Collectors.toList());
@@ -229,7 +206,7 @@ public class AdmShaftController {
                 relationDTOS.add(relationDTO);
             });
             List<ObjectNode> nodeList = JsonNodeUtils.toListNode(relationDTOS, null, null);
-            DigitalRelationFacade.create(context.getGroupCode(), context.getProjectId(),context.getAppId(), null, nodeList);
+            DigitalRelationFacade.create(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(), null, nodeList);
         }else{
             failureList = spaceIds;
         }
@@ -247,14 +224,12 @@ public class AdmShaftController {
      *     "id":"shaftFuncType",
      *     "name":"竖井功能"
      * }
-     * @param projectId
+     * 
      * @return
      * @throws Exception
      */
     @PostMapping("/query-shaft-functype")
-    public AdmResponse queryShFuncType(@QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse queryShFuncType(@QueryParam("projectId") String projectId) throws Exception {       
         if(StrUtil.isNotEmpty(projectId)){
             AdmResponse admResponse = AdmResponse.success();
             //查询参数请求查询的类型是否存在
@@ -264,14 +239,14 @@ public class AdmShaftController {
             filters.append(" classCode ='").append("shaft").append(" '");
             admQueryCriteria.setFilters(filters.toString());
             QueryCriteria dmpRequest = AdmQueryCriteriaHelper.toDmpCriteria(admQueryCriteria);
-            List<ObjectInfoDefine> defineList = DigitalObjectInfoFacade.query(context.getGroupCode(),context.getProjectId(),context.getAppId(),null,dmpRequest);
+            List<ObjectInfoDefine> defineList = DigitalObjectInfoFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(),null,dmpRequest);
             //是否有该类型的竖井信息
             if(CollUtil.isNotEmpty(defineList)){
                 //查询中台项目实际使用该信息点的竖井
                 RequestData requestData = new RequestData();
                 requestData.setObjType(AdmShaft.OBJ_TYPE);
                 requestData.setGroups(Arrays.asList("shaftFuncType"));
-                List<Map<String, Object>> listInfos = DigitalObjectSimpleFacade.queryObjectCountByObjInfos(context.getGroupCode(),context.getAppId(),null, requestData);
+                List<Map<String, Object>> listInfos = DigitalObjectSimpleFacade.queryObjectCountByObjInfos(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getAppId(),null, requestData);
 
                 if(CollUtil.isNotEmpty(listInfos)){
                     ArrayNode datasource = defineList.get(0).getDataSource();
@@ -300,19 +275,17 @@ public class AdmShaftController {
     /**
      * 查询和当前竖井有关联的业务空间
      * shaftId 为竖井id
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/shaft-zoneSpaceBaseTable")
-    public AdmResponse queryZoneSp(@QueryParam("projectId") String projectId, @RequestParam String shaftId,
+    public AdmResponse queryZoneSp(@RequestParam String shaftId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         // 组装条件
         QueryCriteria queryCriteria = new QueryCriteria();
-        if(!StrUtil.isAllNotEmpty(shaftId,projectId)) {
+        if(!StrUtil.isAllNotEmpty(shaftId,AdmContextUtil.toDmpContext().getProjectId())) {
             return AdmResponse.failure("必填项:shaftId(竖井id)、projectId(项目id)");
         }
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
@@ -323,7 +296,7 @@ public class AdmShaftController {
         criteria.put("objType", AdmSpace.OBJ_TYPE);
         queryCriteria.setCriteria(relationTO);
 
-        List<ObjectNode> spaceList = DigitalObjectFacade.query(context.getGroupCode(), context.getProjectId(), context.getAppId(), null, queryCriteria);
+        List<ObjectNode> spaceList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteria);
         if(CollUtil.isNotEmpty(spaceList)){
             List<AdmSpace> vos = JSONUtil.toList(spaceList.toString(), AdmSpace.class);
             return AdmResponse.success(spaceList);
@@ -335,18 +308,16 @@ public class AdmShaftController {
     /**
      * 查询和当前竖井有关联的业务空间所在建筑及楼层信息
      * shaftId 为竖井id
-     * @param projectId
+     * 
      * @return
      * @throws Exception
      */
     @PostMapping("/shaft-zoneSpaceBaseTable-building")
-    public AdmResponse queryZoneSpBd(@QueryParam("projectId") String projectId, @RequestParam String shaftId,
+    public AdmResponse queryZoneSpBd( @RequestParam String shaftId,
              @RequestParam String objectType) throws Exception {
-        if(!StrUtil.isAllNotEmpty(shaftId,projectId)) {
+        if(!StrUtil.isAllNotEmpty(shaftId,AdmContextUtil.toDmpContext().getProjectId())) {
             return AdmResponse.failure("必填项:shaftId(竖井id)、projectId(项目id)");
         }
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         // 组装条件 查询竖井下的空间
         AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
         admQueryCriteria.setName(AdmSpace.OBJ_TYPE);
@@ -364,7 +335,7 @@ public class AdmShaftController {
         criteria.put("objType", AdmSpace.OBJ_TYPE);
         queryCriteria.setCriteria(criteria);
 
-        List<ObjectNode> spaceList = DigitalObjectFacade.query(context.getGroupCode(), context.getProjectId(), context.getAppId(), null, queryCriteria);
+        List<ObjectNode> spaceList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteria);
         if(CollUtil.isNotEmpty(spaceList)){
             AdmQueryCriteria queryCriteriaBd = new AdmQueryCriteria();
             queryCriteriaBd.setName(AdmBuilding.OBJ_TYPE);
@@ -384,7 +355,7 @@ public class AdmShaftController {
             admSpaceMap.keySet().stream().forEach(spaceId -> filter.append(spaceId).append("','"));
             String filters = StrUtil.sub(filter.toString(), 0,-2)+"]";
             queryCriteriaBd.setFilters(filters);
-            AdmResponse response =  buildingService.doQuery(context, queryCriteriaBd, AdmBuilding.class);
+            AdmResponse response =  buildingService.doQuery(AdmContextUtil.toDmpContext(), queryCriteriaBd, AdmBuilding.class);
             return response;
         }else{
             return AdmResponse.success();
@@ -394,19 +365,17 @@ public class AdmShaftController {
     /**
      * 查询和当前竖井没有关联的业务空间
      * shaftId 为竖井id
-     * @param projectId
+     * 
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/un-shaft-zoneSpaceBaseTable")
-    public AdmResponse queryUnZoneSp(@QueryParam("projectId") String projectId, @RequestParam String shaftId,
+    public AdmResponse queryUnZoneSp( @RequestParam String shaftId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         // 组装条件
         QueryCriteria queryCriteria = new QueryCriteria();
-        if(!StrUtil.isAllNotEmpty(shaftId,projectId)) {
+        if(!StrUtil.isAllNotEmpty(shaftId,AdmContextUtil.toDmpContext().getProjectId())) {
             return AdmResponse.failure("必填项:shaftId(竖井id)、projectId(项目id)");
         }
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
@@ -418,7 +387,7 @@ public class AdmShaftController {
 
         criteria.put("objType", "space");
         queryCriteria.setCriteria(relationTO);
-        List<ObjectNode> spaceList = DigitalObjectFacade.query(context.getGroupCode(), context.getProjectId(), context.getAppId(), null, queryCriteria);
+        List<ObjectNode> spaceList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteria);
         if(CollUtil.isNotEmpty(spaceList)){
             List<AdmSpace> vos = JSONUtil.toList(spaceList.toString(), AdmSpace.class);
             return AdmResponse.success(spaceList);
@@ -433,14 +402,14 @@ public class AdmShaftController {
      * @param       spaceIds       failureList
      * @return      是否存在
      */
-    private Set<String> spaceExists(InstanceUrlParam context, List<String> spaceIds) {
+    private Set<String> spaceExists(List<String> spaceIds) {
         QueryCriteria queryCriteria = new QueryCriteria();
         ObjectNode node = JsonNodeFactory.instance.objectNode();
         ArrayNode arrayNode = node.putObject("id").putArray("$in");
         spaceIds.stream().forEach(spaceId -> arrayNode.add(spaceId));
         node.put("objType","ispace");
         queryCriteria.setCriteria(node);
-        List<ObjectNode> ispaces = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(),context.getAppId(),context.getAppId(),queryCriteria);
+        List<ObjectNode> ispaces = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(),AdmContextUtil.toDmpContext().getAppId(),queryCriteria);
         if(CollUtil.isNotEmpty(ispaces)){
             List<AdmISpace> iSpaceList = JSONUtil.toList(JSONUtil.parseArray(ispaces.toString()), AdmISpace.class);
             Map<String, AdmISpace> admISpaceMap = CollUtil.fieldValueMap(iSpaceList, BaseEntity.PROP_ID);

+ 37 - 71
src/main/java/com/persagy/proxy/adm/controller/AdmSpaceController.java

@@ -7,7 +7,6 @@ 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.model.*;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
@@ -16,10 +15,9 @@ import com.persagy.proxy.adm.service.IAdmBuildingService;
 import com.persagy.proxy.adm.service.IAdmFloorService;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.service.IAdmSpaceService;
-import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.RelationDTO;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -46,24 +44,19 @@ public class AdmSpaceController {
     private IAdmRelationService relationService;
     @Autowired
     private IAdmFloorService floorService;
-    @Value("${middleware.group.code}")
-    private String groupCode;
 
     /**
      * 统计
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName("space");
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmSpace.class);
+        return service.doQuery( AdmContextUtil.toDmpContext(), request, AdmSpace.class);
     }
     /**
      * 创建
@@ -73,8 +66,6 @@ public class AdmSpaceController {
      */
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmSpace> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmSpace> vos = CollUtil.newArrayList(createRequest.getContent());
         String msg = null;
         for (AdmSpace admSpace : vos) {
@@ -84,7 +75,7 @@ public class AdmSpaceController {
             }
         }
         if(StrUtil.isNotEmpty(msg)){
-            vos = service.doInsertExt(context, AdmSpace.class, vos);
+            vos = service.doInsertExt( AdmContextUtil.toDmpContext(), AdmSpace.class, vos);
             return AdmResponse.success(vos);
         }else{
             return AdmResponse.failure(msg);
@@ -99,15 +90,13 @@ public class AdmSpaceController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmSpace> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        service.doDelete(context, vos);
+    public AdmResponse delete( @RequestBody List<AdmSpace> vos) throws Exception {
+        service.doDelete( AdmContextUtil.toDmpContext(), vos);
         QueryCriteria queryCriteria = new QueryCriteria();
         vos.forEach(vo -> {
             /** 清除空间和建筑楼层的的数据 */
-            dealRelation(vo.getId(),context,queryCriteria,"Bd2Sp");
-            dealRelation(vo.getId(),context,queryCriteria,"Fl2Sp");
+            dealRelation(vo.getId(), queryCriteria,"Bd2Sp");
+            dealRelation(vo.getId(), queryCriteria,"Fl2Sp");
         });
         return AdmResponse.success();
     }
@@ -120,41 +109,33 @@ public class AdmSpaceController {
      */
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmSpace> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmSpace> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmSpace.class, vos);
+        vos = service.doUpdate( AdmContextUtil.toDmpContext(), AdmSpace.class, vos);
         return AdmResponse.success(vos);
     }
 
     /**
      * 查询
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmDCSQueryRequest request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        return service.doQuerySpaces(context, request);
+    public AdmResponse query(@RequestBody AdmDCSQueryRequest request) throws Exception {
+        return service.doQuerySpaces( AdmContextUtil.toDmpContext(), request);
     }
 
     /**
      * 查询业务空间的建筑楼层,包含受影响的空间数量
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/building-floor")
-    public AdmResponse queryBuildingFloor(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        request.setName("building");
+    public AdmResponse queryBuildingFloor(@RequestBody AdmQueryCriteria request) throws Exception {
+        request.setName(AdmBuilding.OBJ_TYPE);
         AdmQueryCriteria criteriaFloor = new AdmQueryCriteria();
         criteriaFloor.setName(AdmFloor.OBJ_TYPE);
 
@@ -164,7 +145,7 @@ public class AdmSpaceController {
 
         criteriaFloor.setCascade(CollUtil.newArrayList(criteriaSpace));
         request.setCascade(CollUtil.newArrayList(criteriaFloor));
-        AdmResponse response = buildingService.doQueryBuildingFloor(context, request);
+        AdmResponse response = buildingService.doQueryBuildingFloor( AdmContextUtil.toDmpContext(), request);
         List<AdmBuilding> buildings = (List<AdmBuilding>) response.getContent();
         buildings.stream().forEach(building -> {
             if(CollUtil.isNotEmpty(building.getFloor())){
@@ -195,8 +176,6 @@ public class AdmSpaceController {
         if(CollUtil.isEmpty(voList)){
             return AdmResponse.failure("不可以传入空数据");
         }
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         //TODO 循环删除 需要改为 批量删除
         List<RelationDTO> RSpInBd_up = new ArrayList<>();
         List<RelationDTO> RSpInFl_up = new ArrayList<>();
@@ -208,14 +187,14 @@ public class AdmSpaceController {
             String type = requestData.getType();//classCode
 
             /** 清除空间和建筑楼层的的数据 */
-            dealRelation(spaceId,context,queryCriteria,"Bd2Sp");
-            dealRelation(spaceId,context,queryCriteria,"Fl2Sp");
+            dealRelation(spaceId, queryCriteria,"Bd2Sp");
+            dealRelation(spaceId, queryCriteria,"Fl2Sp");
 
             if(StrUtil.isNotEmpty(id)){
                 if(id.startsWith("Fl") && StrUtil.isNotEmpty(spaceId)){
                     AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
                     admQueryCriteria.setName(AdmFloor.OBJ_TYPE);
-                    AdmResponse admResponseFl = floorService.doQuery(context, admQueryCriteria, AdmFloor.class);
+                    AdmResponse admResponseFl = floorService.doQuery( AdmContextUtil.toDmpContext(), admQueryCriteria, AdmFloor.class);
                     if(CollUtil.isNotEmpty(admResponseFl.getContent())){
                         AdmFloor floor = JSONUtil.toBean(admResponseFl.getContent().get(0).toString(), AdmFloor.class);
                         if (floor!=null){
@@ -263,9 +242,9 @@ public class AdmSpaceController {
                 }
             }
         });
-        service.doUpdate(context, AdmSpace.class, space_up);
-        relationService.doSave(context, RSpInBd_up);
-        relationService.doSave(context, RSpInFl_up);
+        service.doUpdate( AdmContextUtil.toDmpContext(), AdmSpace.class, space_up);
+        relationService.doSave( AdmContextUtil.toDmpContext(), RSpInBd_up);
+        relationService.doSave( AdmContextUtil.toDmpContext(), RSpInFl_up);
          return AdmResponse.success(space_up);
     }
 
@@ -277,26 +256,21 @@ public class AdmSpaceController {
      */
     @PostMapping("/update-outline")
     public AdmResponse updateOutLine(@RequestBody AdmCreateRequest<AdmSpace> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmSpace> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmSpace.class, vos);
+        vos = service.doUpdate( AdmContextUtil.toDmpContext(), AdmSpace.class, vos);
         //TODO 更新计算关系ZoneSpaceBaseService.upDateOutline
         return AdmResponse.success(vos);
     }
 
     /**
      * 查询空间信息-outline 级联查询:建筑(building),楼层(floor),空间类型(objectType)
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query-outline")
-    public AdmResponse queryOutline(@QueryParam("projectId") String projectId,
-                                      @RequestBody AdmDCSQueryRequest request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse queryOutline(@RequestBody AdmDCSQueryRequest request) throws Exception {
         request.setName(AdmSpace.OBJ_TYPE);
         request.setProjection(null);
         List<String> list = new ArrayList<>();
@@ -310,61 +284,53 @@ public class AdmSpaceController {
         list.add("infos");
         list.add("properties");
         request.setProjection(list);
-        return service.doQuerySpaces(context, request);
+        return service.doQuerySpaces( AdmContextUtil.toDmpContext(), request);
     }
 
 
     /**
      * 获取项目下已有的空间类型
-     * @param projectId
+     *
      * @return
      * @throws Exception
      */
     @PostMapping("/space-type")
     public List<JSONObject> querySpaceType(@QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        return service.doQuerySpaceTypes(context);
+        return service.doQuerySpaceTypes( AdmContextUtil.toDmpContext());
     }
 
     /**
      * 查询业务空间所有类型
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/type")
-    public AdmResponse queryType(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmDCSQueryRequest request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        return service.doQueryType(context, request);
+    public AdmResponse queryType(@RequestBody AdmDCSQueryRequest request) throws Exception {
+        return service.doQueryType( AdmContextUtil.toDmpContext(), request);
     }
 
 
     /**
      * 上传EXCEL 识别镜头信息点
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/import")
-    public AdmResponse importExcel(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse importExcel(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmSpace.OBJ_TYPE);
-        return service.doQuery(context, request, AdmSpace.class);
+        return service.doQuery( AdmContextUtil.toDmpContext(), request, AdmSpace.class);
     }
 
 
-    private void dealRelation(String spaceId, InstanceUrlParam context, QueryCriteria queryCriteria, String relCode){
+    private void dealRelation(String spaceId, QueryCriteria queryCriteria, String relCode){
         ObjectNode rBd = JsonNodeFactory.instance.objectNode();
         rBd.put("objTo",spaceId);
         rBd.put("relCode",relCode);
         queryCriteria.setCriteria(rBd);
-        relationService.doDelete(context, queryCriteria);
+        relationService.doDelete( AdmContextUtil.toDmpContext(), queryCriteria);
     }
 }

+ 48 - 92
src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java

@@ -16,7 +16,6 @@ import com.persagy.dmp.digital.client.DigitalObjectFacade;
 import com.persagy.dmp.digital.client.DigitalRelationFacade;
 import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.*;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
@@ -25,12 +24,11 @@ import com.persagy.proxy.adm.service.IAdmBuildingService;
 import com.persagy.proxy.adm.service.IAdmDictService;
 import com.persagy.proxy.adm.service.IAdmFloorService;
 import com.persagy.proxy.adm.service.IAdmSystemService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
 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;
 import org.springframework.web.bind.annotation.*;
 
 import javax.json.JsonObject;
@@ -57,24 +55,19 @@ public class AdmSystemController {
     private IAdmFloorService floorService;
     @Autowired
     private IAdmDictService dictService;
-    @Value("${middleware.group.code}")
-    private String groupCode;
 
     /**
      * 统计
-     * @param projectId
+
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmSystem.OBJ_TYPE);
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmSystem.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
     }
 
     /**
@@ -85,10 +78,8 @@ public class AdmSystemController {
      */
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsert(context, AdmSystem.class, vos);
+        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmSystem.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -100,8 +91,6 @@ public class AdmSystemController {
      */
     @PostMapping("/create-bd-fl")
     public AdmResponse createBdFl(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
 
         Map<String, AdmSystem> admSystemMap = CollUtil.fieldValueMap(vos, "classCode");
@@ -111,7 +100,7 @@ public class AdmSystemController {
         ArrayNode array = criteria.putObject("code").putArray("$in");
         admSystemMap.keySet().stream().forEach(classCode -> array.add(classCode));
         defineCriteria.setCriteria(criteria);
-        List<ObjectTypeDefine> defineList = DigitalDefineFacade.queryObjectType(context.getGroupCode(),context.getProjectId(),context.getAppId(),null,defineCriteria);
+        List<ObjectTypeDefine> defineList = DigitalDefineFacade.queryObjectType(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(),null,defineCriteria);
         Map<String, ObjectTypeDefine> defineMap = CollUtil.fieldValueMap(defineList, "code");
         vos.stream().forEach(admSystem -> {
             if(StrUtil.isEmpty(admSystem.getName())){
@@ -122,7 +111,7 @@ public class AdmSystemController {
                 }
             }
         });
-        vos = service.doInsert(context, AdmSystem.class, vos);
+        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmSystem.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -133,10 +122,8 @@ public class AdmSystemController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmSystem> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        service.doDelete(context, vos);
+    public AdmResponse delete( @RequestBody List<AdmSystem> vos) throws Exception {
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -148,28 +135,24 @@ public class AdmSystemController {
      */
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmSystem.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmSystem.class, vos);
         return AdmResponse.success(vos);
     }
 
     /**
      * 系统绑定的动态信息点或静态信息点
      * type: static(静态),iot (动态)
-     * @param projectId
+
      * @param request
      * @return
      * @throws Exception
      */
     @GetMapping("/export")
-    public AdmResponse exportInfos(@QueryParam("projectId") String projectId,
+    public AdmResponse exportInfos(
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName(AdmSystem.OBJ_TYPE);
-        return service.doQuery(context, request, AdmSystem.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
     }
 
     /**
@@ -180,8 +163,6 @@ public class AdmSystemController {
      */
     @PostMapping("/link-equip")
     public AdmResponse createRelateEquip(@RequestBody JsonObject createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         String sysId = createRequest.get("sysId").toString();
         List<String> equipIdList = (List<String>)createRequest.get("equipIdList");
         List<ObjectNode> relations = new ArrayList<>(equipIdList.size());
@@ -192,29 +173,26 @@ public class AdmSystemController {
             objectNode.put("objFrom", sysId);
             objectNode.put("objTo", euipId);
         });
-        List<ObjectRelation> list = DigitalRelationFacade.create(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, relations);
+        List<ObjectRelation> list = DigitalRelationFacade.create(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, relations);
         return AdmResponse.success(list);
     }
 
     /**
      * 查询
-     * @param projectId
+
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmSystem.OBJ_TYPE);
-        AdmResponse admResponse = service.doQuery(context, request, AdmSystem.class);
+        AdmResponse admResponse = service.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
         List<AdmSystem> systemList = (List<AdmSystem>) admResponse.getContent();
         if(CollUtil.isNotEmpty(systemList)){
             AdmDict admDict = new AdmDict();
             admDict.setType(AdmSystem.OBJ_TYPE);
-            AdmResponse admResponseDic = dictService.queryCategory(context, admDict, AdmObjectType.class);
+            AdmResponse admResponseDic = dictService.queryCategory(AdmContextUtil.toDmpContext(), admDict, AdmObjectType.class);
             if(CollUtil.isNotEmpty(admResponseDic.getContent())){
                 List<AdmObjectType> admDictList = (List<AdmObjectType>) admResponseDic.getContent();
                 Map<String, AdmObjectType> admDictMap = CollUtil.fieldValueMap(admDictList, "code");
@@ -239,7 +217,6 @@ public class AdmSystemController {
      * 未明确建筑/未明确楼层 中台定制接口
      *
      * 这个参见中心代码,
-     * @param projectId
      * @param buildingId buildingId=1,未明确建筑
      * @param floorId   floorId=1,未明确楼层
      * @param request
@@ -247,15 +224,9 @@ public class AdmSystemController {
      * @throws Exception
      */
     @PostMapping("/query-new")
-    public AdmResponse queryNew(@QueryParam("projectId") String projectId, @QueryParam("buildingId") String buildingId,
+    public AdmResponse queryNew(@QueryParam("buildingId") String buildingId,
                                 @QueryParam("floorId") String floorId, @RequestBody AdmQueryCriteria request) throws Exception {
-        if (StrUtil.isEmpty(projectId)) {
-            return AdmResponse.failure("项目id为空");
-        }
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         AdmResponse syses = new AdmResponse();
-
         if(StrUtil.isAllEmpty(buildingId,floorId)){
             //case one 查询全部系统,级联建筑,建筑级联楼层
             AdmQueryCriteria admQueryCriteriaBd = new AdmQueryCriteria();
@@ -269,7 +240,7 @@ public class AdmSystemController {
             List<AdmQueryCriteria> cascade = new ArrayList<>(1);
             cascade.add(admQueryCriteriaBd);
             request.setCascade(cascade);
-            syses = service.doQuery(context,request,AdmSystem.class);
+            syses = service.doQuery(AdmContextUtil.toDmpContext(),request,AdmSystem.class);
             //处理数据 BuildingFloorInfo
             if(CollUtil.isNotEmpty(syses.getContent())){
                 List<AdmSystem> admSystemList = (List<AdmSystem>) syses.getContent();
@@ -320,20 +291,20 @@ public class AdmSystemController {
                     relationFrom.put("objTo", floorId);
                     criteria.putPOJO("relationFrom",relationFrom);
                     rwdQueryCriteria.setCriteria(criteria);
-                    syses = service.doQuery(context, rwdQueryCriteria, AdmSystem.class);
+                    syses = service.doQuery(AdmContextUtil.toDmpContext(), rwdQueryCriteria, AdmSystem.class);
                     if (CollUtil.isNotEmpty(syses.getContent())) {
                         admSystemList = (List<AdmSystem>) syses.getContent();
                     }
 
                 }else if("1".equals(floorId)){
                     //case three 明确建筑 不明确楼层
-                    admSystemList = queryNotSureObj(buildingId, rwdQueryCriteria, context);
+                    admSystemList = queryNotSureObj(buildingId, rwdQueryCriteria);
                     //处理通用返回结果
                     dealRespose(syses, request);
                 }
                 if(CollUtil.isNotEmpty(admSystemList)){
                     //处理数据 BuildingFloorInfo
-                    admSystemList = dealBdFlInfo(floorId,buildingId,admSystemList,context);
+                    admSystemList = dealBdFlInfo(floorId,buildingId,admSystemList);
                     syses.setContent(admSystemList);
                 }
             }else{
@@ -341,10 +312,10 @@ public class AdmSystemController {
                 dealRespose(syses, request);
                 if(StrUtil.isNotEmpty(buildingId) && buildingId.equals("1")){
                     //case four 未明确建筑
-                    admSystemList = queryNotSureObj(null, rwdQueryCriteria, context);
+                    admSystemList = queryNotSureObj(null, rwdQueryCriteria);
                     if(CollUtil.isNotEmpty(admSystemList)){
                         //处理数据 BuildingFloorInfo
-                        admSystemList = dealBdFlInfo(null,null, admSystemList, context);
+                        admSystemList = dealBdFlInfo(null,null, admSystemList);
                         syses.setContent(admSystemList);
                     }
                 }
@@ -366,10 +337,9 @@ public class AdmSystemController {
      * 查询不确定建筑/楼层的系统
      * @param buildingId
      * @param rwdQueryCriteria
-     * @param context
      * @return
      */
-    private List<AdmSystem> queryNotSureObj(String buildingId, QueryCriteria rwdQueryCriteria, InstanceUrlParam context){
+    private List<AdmSystem> queryNotSureObj(String buildingId, QueryCriteria rwdQueryCriteria){
         RequestData requestData = new RequestData();
         String classCode = rwdQueryCriteria.getCriteria().get("classCode").textValue();
         if(StrUtil.isNotEmpty(classCode)){
@@ -381,7 +351,7 @@ public class AdmSystemController {
         requestData.setObjType(AdmSystem.OBJ_TYPE);
         requestData.setPage(rwdQueryCriteria.getPage());
         requestData.setSize(rwdQueryCriteria.getSize());
-        List result = DigitalObjectSimpleFacade.queryNotSureSystem(context.getGroupCode(), context.getProjectId(), context.getAppId(),null, requestData);
+        List result = DigitalObjectSimpleFacade.queryNotSureSystem(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(),null, requestData);
         if(CollUtil.isNotEmpty(result)){
            List<AdmSystem> admSystemList = JSONUtil.toList(result.toString(), AdmSystem.class);
            return admSystemList;
@@ -395,10 +365,9 @@ public class AdmSystemController {
      * @param floorId
      * @param buildingId
      * @param admSystemList
-     * @param context
      * @return
      */
-    private List<AdmSystem> dealBdFlInfo(String floorId, String buildingId, List<AdmSystem> admSystemList, InstanceUrlParam context){
+    private List<AdmSystem> dealBdFlInfo(String floorId, String buildingId, List<AdmSystem> admSystemList){
         if(CollUtil.isEmpty(admSystemList)){
             return null;
         }
@@ -412,12 +381,12 @@ public class AdmSystemController {
         AdmResponse buildings = null;
         if(StrUtil.isNotEmpty(buildingId)){
             AdmQueryCriteria admQueryCriteria = getAdmQueryCriteria(AdmBuilding.OBJ_TYPE, buildingId);
-            buildings = buildingService.doQuery(context, admQueryCriteria, AdmBuilding.class);
+            buildings = buildingService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmBuilding.class);
         }
         AdmResponse floors = null;
         if(StrUtil.isNotEmpty(floorId)){
             AdmQueryCriteria admQueryCriteria = getAdmQueryCriteria(AdmFloor.OBJ_TYPE, floorId);
-            floors = floorService.doQuery(context, admQueryCriteria, AdmFloor.class);
+            floors = floorService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmFloor.class);
         }
         AdmBuildingFloorInfo buildingFloorInfo = new AdmBuildingFloorInfo();
         if (CollUtil.isNotEmpty(buildings.getContent())) {
@@ -445,34 +414,29 @@ public class AdmSystemController {
 
     /**
      * 查询系统信息-试图级联建筑楼层 暂未使用
-     * @param projectId
+
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query-bdfl")
-    public AdmResponse queryUnBdFl(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse queryUnBdFl(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmSystem.OBJ_TYPE);
-        return service.doQuery(context, request, AdmSystem.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
     }
 
     /**
      * 查询没有和当前系统关联的设备
      * id 为系统id
-     * @param projectId
+
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/un-sys-equip")
-    public AdmResponse queryUnEquip(@QueryParam("projectId") String projectId, @NotNull @QueryParam("sysId") String sysId,
+    public AdmResponse queryUnEquip( @NotNull @QueryParam("sysId") String sysId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Eq","MechSubset", AdmEquipment.OBJ_TYPE);
+        AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Eq","MechSubset", AdmEquipment.OBJ_TYPE);
         return admResponse;
     }
 
@@ -480,17 +444,15 @@ public class AdmSystemController {
     /**
      * 查询没有和当前系统关联的竖井
      *  id 为系统id
-     * @param projectId
+
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/un-sys-shaft")
-    public AdmResponse queryUnSh(@QueryParam("projectId") String projectId, @NotNull @QueryParam("sysId") String sysId,
+    public AdmResponse queryUnSh( @NotNull @QueryParam("sysId") String sysId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Sh",null, AdmShaft.OBJ_TYPE);
+        AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Sh",null, AdmShaft.OBJ_TYPE);
         return admResponse;
     }
 
@@ -498,17 +460,14 @@ public class AdmSystemController {
     /**
      * 查询没有和当前系统关联的业务空间
      * id 为系统id
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/un-sys-zoneSpaceBaseTable")
-    public AdmResponse queryUnZoneSp(@QueryParam("projectId") String projectId,@NotNull @QueryParam("sysId") String sysId,
+    public AdmResponse queryUnZoneSp(@NotNull @QueryParam("sysId") String sysId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Sp",null, AdmSpace.OBJ_TYPE);
+        AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Sp",null, AdmSpace.OBJ_TYPE);
         return admResponse;
     }
 
@@ -516,18 +475,15 @@ public class AdmSystemController {
     /**
      * 查询没有和当前空间绑定的系统
      * 例如:prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 spaceId 为当前空间id type为当前空间类型
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/unspace-sys")
-    public AdmResponse queryUnSpSy(@QueryParam("projectId") String projectId,  @QueryParam("type") String type, @QueryParam("spaceId") String spaceId,
+    public AdmResponse queryUnSpSy(  @QueryParam("type") String type, @QueryParam("spaceId") String spaceId,
                                      @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         if(StrUtil.isNotEmpty(spaceId)){
-            AdmResponse admResponse = queryObjectByType(context, spaceId, request,"Sy2Sp",null, AdmSystem.OBJ_TYPE);
+            AdmResponse admResponse = queryObjectByType(spaceId, request,"Sy2Sp",null, AdmSystem.OBJ_TYPE);
             return admResponse;
         }else{
             if(StrUtil.isNotEmpty(type)){
@@ -535,7 +491,7 @@ public class AdmSystemController {
                 ObjectNode criteriaObj = JsonNodeFactory.instance.objectNode();
                 criteriaObj.put("objType", AdmSpace.OBJ_TYPE);
                 queryCriteriaObj.setCriteria(criteriaObj);
-                List<ObjectNode> objs = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObj);
+                List<ObjectNode> objs = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObj);
 
                 QueryCriteria queryCriteriaObjSys = AdmQueryCriteriaHelper.toDmpCriteria(request);
                 ObjectNode criteriaSys = JsonNodeFactory.instance.objectNode();
@@ -547,7 +503,7 @@ public class AdmSystemController {
                     }
                 }
                 queryCriteriaObj.setCriteria(criteriaObj);
-                List<ObjectNode> syses = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObjSys);
+                List<ObjectNode> syses = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObjSys);
                 return AdmResponse.success(syses);
             }
             return AdmResponse.success();
@@ -555,7 +511,7 @@ public class AdmSystemController {
     }
 
 
-    private AdmResponse queryObjectByType(InstanceUrlParam context, String sysId, AdmQueryCriteria request, String relCode, String graphCode, String objType){
+    private AdmResponse queryObjectByType(String sysId, AdmQueryCriteria request, String relCode, String graphCode, String objType){
         QueryCriteria queryCriteria = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
         criteria.put("objFrom", sysId);
@@ -566,7 +522,7 @@ public class AdmSystemController {
         queryCriteria.setCriteria(criteria);
         queryCriteria.setSize(request.getPageSize()*1L);
         queryCriteria.setPage(request.getPageNumber()*1L);
-        List<ObjectRelation> relations = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria);
+        List<ObjectRelation> relations = DigitalRelationFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteria);
 
         QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
         ObjectNode criteriaObj = JsonNodeFactory.instance.objectNode();
@@ -577,7 +533,7 @@ public class AdmSystemController {
             objectRelationMap.keySet().stream().forEach(id -> arrayNode.add(id));
         }
         queryCriteriaObj.setCriteria(criteriaObj);
-        List<ObjectNode> obj = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObj);
+        List<ObjectNode> obj = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObj);
         return AdmResponse.success(obj);
     }
 }

+ 14 - 34
src/main/java/com/persagy/proxy/adm/controller/AdmTenantController.java

@@ -2,16 +2,14 @@ package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
-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.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
-import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -31,24 +29,18 @@ import java.util.List;
 public class AdmTenantController {
     @Autowired
     private IAdmTenantService service;
-    @Value("${middleware.group.code}")
-    private String groupCode;
-
     /**
      * 统计
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmTenant.OBJ_TYPE);
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmTenant.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmTenant.class);
     }
 
     /**
@@ -59,15 +51,13 @@ public class AdmTenantController {
      */
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmTenant> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmTenant> vos = CollUtil.newArrayList(createRequest.getContent());
         vos.stream().forEach(admTenant -> {
             if (StrUtil.isEmpty(admTenant.getName())){
                 admTenant.setName(ObjectNameUtil.objectName("租户-"));
             }
         });
-        vos = service.doInsert(context, AdmTenant.class, vos);
+        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmTenant.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -78,10 +68,8 @@ public class AdmTenantController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmTenant> vos) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        service.doDelete(context, vos);
+    public AdmResponse delete( @RequestBody List<AdmTenant> vos) throws Exception {
+        service.doDelete(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success();
     }
 
@@ -93,44 +81,36 @@ public class AdmTenantController {
      */
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmTenant> createRequest, @QueryParam("projectId") String projectId) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmTenant> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmTenant.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmTenant.class, vos);
         return AdmResponse.success(vos);
     }
 
     /**
      * 查询
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmTenant.OBJ_TYPE);
-        return service.doQuery(context, request, AdmTenant.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmTenant.class);
     }
 
     /**
      * 查询租户-包含统计信息
      * 此方法可能会被废弃
-     * @param projectId
+     *
      * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/query-with-count")
-    public AdmResponse queryWithCount(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
-        // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+    public AdmResponse queryWithCount(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmTenant.OBJ_TYPE);
-        return service.doQuery(context, request, AdmTenant.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmTenant.class);
     }
 
 }

+ 6 - 5
src/main/java/com/persagy/proxy/adm/controller/AdmVirtualWallController.java

@@ -7,6 +7,7 @@ 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.IAdmVirtualWallService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -41,7 +42,7 @@ public class AdmVirtualWallController {
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmVirtualWall> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         List<AdmVirtualWall> vos = CollUtil.newArrayList(createRequest.getContent());
         vos = service.doInsert(context, AdmVirtualWall.class, vos);
         return AdmResponse.success(vos);
@@ -56,7 +57,7 @@ public class AdmVirtualWallController {
     @PostMapping("/create_ignore")
     public AdmResponse createIgnore(@RequestBody AdmCreateRequest<AdmVirtualWall> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         createRequest.getContent().forEach(it->{
             //TODO
         });
@@ -86,7 +87,7 @@ public class AdmVirtualWallController {
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmVirtualWall> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         List<AdmVirtualWall> vos = CollUtil.newArrayList(createRequest.getContent());
         vos = service.doUpdate(context, AdmVirtualWall.class, vos);
         return AdmResponse.success(vos);
@@ -103,7 +104,7 @@ public class AdmVirtualWallController {
     public AdmResponse query(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setName("equipment");
         request.setFilters("classCode = 'VIRTUALWALL'");
         return service.doQuery(context, request, AdmVirtualWall.class);
@@ -120,7 +121,7 @@ public class AdmVirtualWallController {
     public AdmResponse count(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setName("equipment");
         request.setOnlyCount(true);
         return service.doQuery(context, request, AdmVirtualWall.class);

+ 6 - 5
src/main/java/com/persagy/proxy/adm/controller/AdmWindowController.java

@@ -7,6 +7,7 @@ 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.IAdmWindowService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -41,7 +42,7 @@ public class AdmWindowController {
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmWindow> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         List<AdmWindow> vos = CollUtil.newArrayList(createRequest.getContent());
         vos = service.doInsert(context, AdmWindow.class, vos);
         return AdmResponse.success(vos);
@@ -56,7 +57,7 @@ public class AdmWindowController {
     @PostMapping("/create_ignore")
     public AdmResponse createIgnore(@RequestBody AdmCreateRequest<AdmWindow> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         createRequest.getContent().forEach(request->{
             //TODO
         });
@@ -86,7 +87,7 @@ public class AdmWindowController {
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmWindow> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         List<AdmWindow> vos = CollUtil.newArrayList(createRequest.getContent());
         vos = service.doUpdate(context, AdmWindow.class, vos);
         return AdmResponse.success(vos);
@@ -103,7 +104,7 @@ public class AdmWindowController {
     public AdmResponse query(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setName("equipment");
         request.setFilters("classCode = 'CFBEWN'");
         return service.doQuery(context, request, AdmWindow.class);
@@ -120,7 +121,7 @@ public class AdmWindowController {
     public AdmResponse count(@QueryParam("projectId") String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setName("equipment");
         request.setOnlyCount(true);
         return service.doQuery(context, request, AdmWindow.class);

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

@@ -1,10 +1,10 @@
 package com.persagy.proxy.adm.controller;
 
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.adm.model.relation.ShInBdList;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmRelationService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.common.entity.RelationDTO;
 import lombok.extern.slf4j.Slf4j;
@@ -38,7 +38,7 @@ public class RelationShInBdController {
      */
 
     @PostMapping("link-bd")
-    public AdmResponse createBd(@RequestBody ShInBdList shInBdList, @RequestParam("projectId") String projectId){
+    public AdmResponse createBd(@RequestBody ShInBdList shInBdList){
         log.info("创建系统所在建筑关系link-bd");
         List<String> buildingIdList = shInBdList.getBuildingIdList();
         String shaftId = shInBdList.getShaftId();
@@ -55,7 +55,7 @@ public class RelationShInBdController {
             RelationDTO relation = new RelationDTO(null, graphCode, relCode, "", shaftId,buildingId);
             voList.add(relation);
         }
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         return AdmResponse.success();
     }

+ 22 - 19
src/main/java/com/persagy/proxy/adm/controller/RelationSyEqController.java

@@ -10,8 +10,10 @@ 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.service.IAdmRelationService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.common.entity.RelationDTO;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
@@ -42,18 +44,20 @@ public class RelationSyEqController {
      * @throws Exception
      */
     @PostMapping(value = {"/link-sy-eq","/link"})
-    public AdmResponse create(@RequestParam("projectId") String projectId,
-                                @RequestBody JSONObject param) throws Exception {
-        String equipId = param.getString("equipId");
+    public AdmResponse create(@RequestBody JSONObject param) throws Exception {
+        //String equipId = param.getString("equipId");
+        JSONArray equipIdList = param.getJSONArray("equipIdList");
         String sysID = param.getString("sysId");
-        if(!StrUtil.isAllNotEmpty(equipId,sysID)) {
-            return AdmResponse.failure("必填项:EquipID(设备id)、SysID(系统id)");
+        if(StringUtils.isEmpty(sysID) || CollUtil.isEmpty(equipIdList)) {
+            return AdmResponse.failure("必填项:EquipIdList(设备id列表)、SysID(系统id)");
         }
         // 创建关系对象
         List<RelationDTO> voList = new ArrayList<>();
-        voList.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null, sysID , equipId));
+        equipIdList.forEach(item->{
+            voList.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null, sysID , item.toString()));
+        });
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         return AdmResponse.success();
     }
@@ -66,13 +70,12 @@ public class RelationSyEqController {
      */
 
     @PostMapping("/unlink")
-    public AdmResponse delete(@RequestParam String projectId,
-                              @RequestBody JSONObject param) throws Exception {
+    public AdmResponse delete(@RequestBody JSONObject param) throws Exception {
         if(CollUtil.isEmpty(param)) {
             return AdmResponse.success();
         }
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         // 组装条件
         QueryCriteria criteria = new QueryCriteria();
         String equipId = param.getString("equipId");
@@ -97,14 +100,13 @@ public class RelationSyEqController {
      * @return                  创建结果信息
      */
     @PostMapping("/link-eq")
-    public AdmResponse createBatchWithDeleteOldsysIdRelation(@RequestParam("projectId") String projectId,
-                              @RequestBody JSONObject syEqList) throws Exception {
+    public AdmResponse createBatchWithDeleteOldsysIdRelation(@RequestBody JSONObject syEqList) throws Exception {
         JSONArray equipIdList = syEqList.getJSONArray("equipIdList");
         String sysId = syEqList.getString("sysId");
         if(StrUtil.isBlank(sysId) || CollUtil.isEmpty(equipIdList)) {
             return AdmResponse.failure("必填项:EquipIdList(设备id列表)、SysID(系统id)");
         }
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context =AdmContextUtil.toDmpContext();
         QueryCriteria queryRequest = new QueryCriteria();
         ObjectNode node = JsonNodeFactory.instance.objectNode();
         node.put("graphCode", "MechSubset");
@@ -129,14 +131,13 @@ public class RelationSyEqController {
      * @return                  创建结果信息
      */
     @PostMapping("/link-sy")
-    public AdmResponse createDistinctEq(@RequestParam("projectId") String projectId,
-                              @RequestBody JSONObject param) throws Exception {
+    public AdmResponse createDistinctEq(@RequestBody JSONObject param) throws Exception {
         String equipId = param.getString("equipId");
-        String sysID = param.getString("sysId");
-        if(!StrUtil.isAllNotEmpty(equipId,sysID)) {
+        JSONArray sysIdList = param.getJSONArray("sysIdList");
+        if(StringUtils.isEmpty(equipId) || CollUtil.isEmpty(sysIdList)) {
             return AdmResponse.failure("必填项:EquipId(设备id)、sysIdList(系统id列表)");
         }
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         QueryCriteria queryRequest = new QueryCriteria();
         ObjectNode node = JsonNodeFactory.instance.objectNode();
         node.put("graphCode", "MechSubset");
@@ -146,7 +147,9 @@ public class RelationSyEqController {
         service.doDelete(context,queryRequest);
         // 创建关系对象
         List<RelationDTO> voList = new ArrayList<>();
-        voList.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null, sysID , equipId));
+        sysIdList.forEach(item->{
+            voList.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null, item.toString() , equipId));
+        });
         // 组装上下文条件
         service.doSave(context, voList);
         return AdmResponse.success();

+ 16 - 15
src/main/java/com/persagy/proxy/adm/controller/RelationSyInBdController.java

@@ -9,6 +9,7 @@ import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.adm.model.relation.*;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmRelationService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.common.entity.RelationDTO;
 import lombok.extern.slf4j.Slf4j;
@@ -45,8 +46,8 @@ public class RelationSyInBdController {
      * @throws Exception
      */
     @PostMapping("/link")
-    public AdmResponse create(@RequestBody SyInBd syInBd, @RequestParam("projectId") String projectId) throws Exception {
-        log.info("创建系统所在建筑关系create方法开始参数projectId为{}", projectId);
+    public AdmResponse create(@RequestBody SyInBd syInBd) throws Exception {
+        log.info("创建系统所在建筑关系create方法开始参数projectId为{}", AdmContextUtil.toDmpContext().getProjectId());
         //系统Id
         String sysID = syInBd.getSysId();
         //建筑Id
@@ -61,7 +62,7 @@ public class RelationSyInBdController {
         RelationDTO relation = new RelationDTO(null, graphCode, relCode, null, sysID, buildingId);
         voList.add(relation);
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         log.info("创建系统所在建筑create方法结束");
         return AdmResponse.success();
@@ -107,8 +108,8 @@ public class RelationSyInBdController {
      * @throws Exception
      */
     @PostMapping("/link-bd")
-    public AdmResponse createBd(@RequestBody SyInBdList syInFlList, @RequestParam("projectId") String projectId) throws Exception {
-        log.info("创建系统所在建筑关系createBD方法开始参数projectId为{}", projectId);
+    public AdmResponse createBd(@RequestBody SyInBdList syInFlList) throws Exception {
+        log.info("创建系统所在建筑关系createBD方法开始参数projectId为{}", AdmContextUtil.toDmpContext().getProjectId());
         //系统Id
         String sysID = syInFlList.getSysId();
         //楼层
@@ -125,7 +126,7 @@ public class RelationSyInBdController {
             voList.add(relation);
         }
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         log.info("创建系统所在建筑关系createBD方法结束");
         return AdmResponse.success();
@@ -140,8 +141,8 @@ public class RelationSyInBdController {
      * @throws Exception
      */
     @PostMapping("/link-bd-sy")
-    public AdmResponse createSyBd(@RequestBody SyInBdList syInFlList, @RequestParam("projectId") String projectId) throws Exception {
-        log.info("创建系统所在建筑关系createSyBd方法开始参数projectId为{}", projectId);
+    public AdmResponse createSyBd(@RequestBody SyInBdList syInFlList) throws Exception {
+        log.info("创建系统所在建筑关系createSyBd方法开始参数projectId为{}", AdmContextUtil.toDmpContext().getProjectId());
         //系统Id
         String sysID = syInFlList.getSysId();
         //楼层
@@ -158,7 +159,7 @@ public class RelationSyInBdController {
             voList.add(relation);
         }
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         log.info("创建系统所在建筑关系createSyBd方法结束");
         return AdmResponse.success();
@@ -173,8 +174,8 @@ public class RelationSyInBdController {
      * @throws Exception
      */
     @PostMapping("/link-sy")
-    public AdmResponse createSyBd(@RequestBody BdInSyList bdInSyList, @RequestParam("projectId") String projectId) throws Exception {
-        log.info("创建系统所在建筑关系createSyBd方法开始参数projectId为{}", projectId);
+    public AdmResponse createSyBd(@RequestBody BdInSyList bdInSyList) throws Exception {
+        log.info("创建系统所在建筑关系createSyBd方法开始参数projectId为{}", AdmContextUtil.toDmpContext().getProjectId());
         //建筑Id
         String buildingId = bdInSyList.getBuildingId();
         //系统
@@ -191,7 +192,7 @@ public class RelationSyInBdController {
             voList.add(relation);
         }
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         log.info("创建系统所在建筑关系createSyBd方法结束");
         return AdmResponse.success();
@@ -207,8 +208,8 @@ public class RelationSyInBdController {
      * @throws Exception
      */
     @PostMapping("/unlink")
-    public AdmResponse delete(@RequestBody SyInBd syInBd, @RequestParam("projectId") String projectId) throws Exception {
-        log.info("创建系统所在建筑关系delete方法开始参数projectId为{}", projectId);
+    public AdmResponse delete(@RequestBody SyInBd syInBd) throws Exception {
+        log.info("创建系统所在建筑关系delete方法开始参数projectId为{}", AdmContextUtil.toDmpContext().getProjectId());
         //系统Id
         String sysID = syInBd.getSysId();
         //建筑Id
@@ -230,7 +231,7 @@ public class RelationSyInBdController {
         node.put("objTo", buildingId);
         criteria.setCriteria(node);
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doDelete(context,criteria);
         log.info("创建系统服务于业务空间关系delete方法结束");
         return AdmResponse.success();

+ 14 - 13
src/main/java/com/persagy/proxy/adm/controller/RelationSyInFlController.java

@@ -12,6 +12,7 @@ import com.persagy.proxy.adm.model.relation.SyInFl;
 import com.persagy.proxy.adm.model.relation.SyInFlList;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmRelationService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.common.entity.RelationDTO;
 import lombok.extern.slf4j.Slf4j;
@@ -47,7 +48,7 @@ public class RelationSyInFlController {
      * @throws Exception
      */
     @PostMapping("/link")
-    public AdmResponse create(@RequestBody SyInFl syInFl, @RequestParam("projectId") String projectId) throws Exception {
+    public AdmResponse create(@RequestBody SyInFl syInFl) throws Exception {
         //系统Id
         String sysID = syInFl.getSysId();
         //楼层Id
@@ -64,7 +65,7 @@ public class RelationSyInFlController {
         RelationDTO relation = new RelationDTO(null, graphCode, relCode, type, sysID, floorId);
         voList.add(relation);
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         return AdmResponse.success();
     }
@@ -78,8 +79,8 @@ public class RelationSyInFlController {
      * @throws Exception
      */
     @PostMapping("/link-fl")
-    public AdmResponse createSy(@RequestBody SyInFlList syInFlList, @RequestParam("projectId") String projectId) throws Exception {
-        log.info("创建系统所在楼层关系link-fl方法开始,参数projectId为{}", projectId);
+    public AdmResponse createSy(@RequestBody SyInFlList syInFlList) throws Exception {
+        log.info("创建系统所在楼层关系link-fl方法开始,参数projectId为{}", AdmContextUtil.toDmpContext().getProjectId());
         //系统Id
         String sysId = syInFlList.getSysId();
         //楼层Id
@@ -96,7 +97,7 @@ public class RelationSyInFlController {
             voList.add(relation);
         }
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         log.info("创建系统所在楼层关系link-fl方法结束");
         return AdmResponse.success();
@@ -107,8 +108,8 @@ public class RelationSyInFlController {
      * 所在楼层的系统,楼层一对多系统
      */
     @PostMapping("/link-sy")
-    public AdmResponse createSy(@RequestBody FlInSyList flInSyList, @RequestParam("projectId") String projectId) {
-        log.info("创建系统所在楼层关系link-sy方法开始,参数projectId为{}", projectId);
+    public AdmResponse createSy(@RequestBody FlInSyList flInSyList) {
+        log.info("创建系统所在楼层关系link-sy方法开始,参数projectId为{}", AdmContextUtil.toDmpContext().getProjectId());
         String floorId = flInSyList.getFloorId();
         List<String> sysIdList = flInSyList.getSysIdList();
         if (StringUtils.isBlank(floorId) || CollectionUtils.isEmpty(sysIdList)) {
@@ -122,7 +123,7 @@ public class RelationSyInFlController {
             RelationDTO relation = new RelationDTO(null, graphCode, relCode, null, sysId, floorId);
             voList.add(relation);
         }
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         log.info("创建系统所在楼层关系link-sy方法结束");
         return AdmResponse.success();
@@ -133,8 +134,8 @@ public class RelationSyInFlController {
      * 系统所在楼层,系统一对多楼层,此方法不会覆盖
      */
     @PostMapping("/link-fl-sy")
-    public AdmResponse createSyFl(@RequestBody SyInFlList syInFlList, @RequestParam("projectId") String projectId) {
-        log.info("创建系统所在楼层关系link-fl-sy方法开始,参数projectId为{}", projectId);
+    public AdmResponse createSyFl(@RequestBody SyInFlList syInFlList) {
+        log.info("创建系统所在楼层关系link-fl-sy方法开始,参数projectId为{}", AdmContextUtil.toDmpContext().getProjectId());
         List<String> floorIdList = syInFlList.getFloorIdList();
         String sysId = syInFlList.getSysId();
         if (StringUtils.isBlank(sysId) || CollectionUtils.isEmpty(floorIdList)) {
@@ -148,7 +149,7 @@ public class RelationSyInFlController {
             RelationDTO relation = new RelationDTO(null, graphCode, relCode, null, sysId, floorId);
             voList.add(relation);
         }
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doSave(context, voList);
         log.info("创建系统所在楼层关系link-fl-sy方法结束");
         return AdmResponse.success();
@@ -160,7 +161,7 @@ public class RelationSyInFlController {
      * @return
      */
     @PostMapping("/unlink")
-    public AdmResponse delete(@RequestBody SyInFl syInFl, @RequestParam("projectId") String projectId) {
+    public AdmResponse delete(@RequestBody SyInFl syInFl) {
         String floorId = syInFl.getFloorId();
         String sysId = syInFl.getSysId();
         AdmRelationTypeEnum sy2fl = AdmRelationTypeEnum.SY2FL;
@@ -176,7 +177,7 @@ public class RelationSyInFlController {
         QueryCriteria criteria = new QueryCriteria();
         criteria.setCriteria(node);
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         service.doDelete(context,criteria);
         return AdmResponse.success();
     }

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

@@ -38,5 +38,5 @@ public class AdmBuilding extends AdmSBaseEntity<AdmBuilding>{
     private List<AdmFloor> floor;
 
     /** 建筑类型code */
-    private String classCode;
+    private String classCode = OBJ_TYPE;
 }

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

@@ -71,7 +71,7 @@ public class AdmFloor extends AdmSBaseEntity<AdmFloor>{
     /** 对象类型 */
     private String objectType = OBJ_TYPE;
     /** 楼层类型code */
-    private String classCode;
+    private String classCode = OBJ_TYPE;
 
 
     /** 空间列表 非中台信息*/

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

@@ -54,7 +54,7 @@ public class AdmProperty {
     /** 信息点 */
     private Map<String, Object> infos;
     /** 对象类型 */
-    private String objectType;
+    private String objectType = OBJ_TYPE;
     /** 位置信息 */
     private String position;
     /** 贴码状态 */

+ 2 - 0
src/main/java/com/persagy/proxy/adm/model/AdmSBaseEntity.java

@@ -27,6 +27,8 @@ public abstract class AdmSBaseEntity<T> implements Serializable, Cloneable, Comp
     private Date lastUpdate;
     /** 信息点 */
     private Map<String, Object> infos;
+    /** 集团编码 */
+    private String groupCode;
 
 
     @Override

+ 6 - 5
src/main/java/com/persagy/proxy/adm/request/AdmResponse.java

@@ -8,6 +8,7 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -36,15 +37,15 @@ public class AdmResponse {
     private List<?> content;
 
     public static AdmResponse success() {
-        return new AdmResponse(SUCCESS, "", 0L,null, 1, 500, null);
+        return new AdmResponse(SUCCESS, "", 0L,null, 1, 500, new ArrayList<>(1));
     }
 
     public static AdmResponse failure(String message) {
-        return new AdmResponse(FAILURE, message, null, null, null, null, null);
+        return new AdmResponse(FAILURE, message, null, null, null, null, new ArrayList<>(1));
     }
 
     public static AdmResponse success(List<?> content) {
-        return new AdmResponse(SUCCESS, "", CollUtil.isEmpty(content) ? 0L :content.size()*1L,null, 1, 500, content);
+        return new AdmResponse(SUCCESS, "", CollUtil.isEmpty(content) ? 0L :content.size()*1L,null, 1, 500, CollUtil.isEmpty(content) ? new ArrayList<>(1): content);
     }
 
     /**
@@ -65,9 +66,9 @@ public class AdmResponse {
         Integer pageNo = admRequest == null ? null : admRequest.getPageNumber();
         Integer pageSize = admRequest == null ? null : admRequest.getPageSize();
         if(admRequest.isOnlyCount()){
-            return new AdmResponse(SUCCESS, null, null,total, pageNo, pageSize, admVOs);
+            return new AdmResponse(SUCCESS, null, null,total, pageNo, pageSize, CollUtil.isEmpty(admVOs) ? new ArrayList<>(1) : admVOs);
         }else {
-            return new AdmResponse(SUCCESS, null, total,null, pageNo, pageSize, admVOs);
+            return new AdmResponse(SUCCESS, null, total,null, pageNo, pageSize, CollUtil.isEmpty(admVOs) ? new ArrayList<>(1) : admVOs);
         }
     }
 }

+ 4 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java

@@ -97,6 +97,10 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
         Map<String, Object> voMap = CollUtil.fieldValueMap(admVOs, BaseEntity.PROP_ID);
         Object simpleVO = admVOs.get(0);
         for(AdmQueryCriteria cascade:cascades) {
+            if(StrUtil.isBlank(cascade.getName())){
+                //处理 级联查询参数name首字母大写cascade": [ {"Name": "property"}]
+                continue;
+            }
             // 获取关联对象的Class
             Field casField = ReflectUtil.getField(simpleVO.getClass(), cascade.getName());
             CascadeColumn annotationInfo = casField.getAnnotation(CascadeColumn.class);

+ 62 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmDictBaseServiceImpl.java

@@ -206,10 +206,72 @@ public class AbstractAdmDictBaseServiceImpl<T> implements IAdmDictBaseService<T>
             }else{
                 admVO.setPath(AdmDictConstant.INFOS_EX+admVO.getCode());
             }
+
+            //信息点是否可见
+            if(admVO.getVisible() == null){
+                if("localName".equals(admVO.getCode()) || "localId".equals(admVO.getCode())){
+                    admVO.setVisible(true);
+                }else{
+                    admVO.setVisible(false);
+                }
+            }
+            //信息点是否可编辑
+            if(admVO.getEditable() == null){
+                List<String> unEditableList = checkoutDefInfoUnEditable();
+                if(unEditableList.contains(admVO.getCode())){
+                    admVO.setEditable(false);
+                }else {
+                    admVO.setEditable(true);
+                }
+            }
+            //是否禁止操作
+            if(admVO.getUnDisabled() == null){
+                List<String> unDisableList = checkoutDefInfoUnDisable();
+                if(unDisableList.contains(admVO.getCode())){
+                    admVO.setUnDisabled(false);
+                }else {
+                    admVO.setUnDisabled(true);
+                }
+            }
+
         }
     }
 
     /**
+     * 校验信息点是否可编辑
+     * @return
+     */
+    public List<String> checkoutDefInfoUnEditable(){
+        List<String> list = new ArrayList<>();
+        list.add("id");
+        list.add("name");
+        list.add("qRCodePic");
+        list.add("defaultQRCode");
+        list.add("bimId");
+        list.add("bimFamilyName");
+        list.add("bimFamilySymbol");
+        return list;
+    }
+    
+    /**
+     * 校验信息点是否禁止使用
+     * @return
+     */
+    public List<String> checkoutDefInfoUnDisable(){
+        List<String> list = new ArrayList<>();
+        list.add("id");
+        list.add("name");
+        list.add("localId");
+        list.add("localName");
+        list.add("qRCodePic");
+        list.add("defaultQRCode");
+        list.add("bimId");
+        list.add("bimFamilyName");
+        list.add("bimFamilySymbol");
+        return list;
+    }
+
+    /**
      * 字典数据格式与ADM兼容
      * @param array
      */

+ 4 - 4
src/main/java/com/persagy/proxy/common/handler/AdmContextHandler.java

@@ -19,12 +19,12 @@ public class AdmContextHandler extends HandlerInterceptorAdapter {
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
         // 从header中获取上下文
-        if(StrUtil.isNotBlank(request.getHeader("groupCode"))) {
+//        if(StrUtil.isNotBlank(request.getHeader("groupCode"))) {
             // 请求参数中包含groupCode,由于没有标识位,暂时用这种方式判断吧
             accessRequestInfo(request);
-        } else {
-            // 其他情况,按现有系统默认不验证的逻辑,其他情况就是默认放行,不必处理。最好是抛401
-        }
+//        } else {
+//            // 其他情况,按现有系统默认不验证的逻辑,其他情况就是默认放行,不必处理。最好是抛401
+//        }
         return true;
     }