Browse Source

Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java
linhuili 3 years ago
parent
commit
a406ef8d56

+ 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);
     }
 }

+ 23 - 45
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);
     }
 
     /**
@@ -168,11 +148,9 @@ public class AdmEquipmentController {
      * @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);
+    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);
     }
 
 }

+ 4 - 14
src/main/java/com/persagy/proxy/adm/controller/AdmProjectController.java

@@ -1,20 +1,16 @@
 package com.persagy.proxy.adm.controller;
 
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmProject;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmProjectService;
-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;
-
 /**
  * ADM 项目 API
  * @author Charlie Yu
@@ -26,23 +22,17 @@ 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(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmProject.OBJ_TYPE);
-        return service.doQuery(context, request, AdmProject.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmProject.class);
     }
 
     /**
@@ -53,6 +43,6 @@ public class AdmProjectController {
      */
     @PostMapping("/query/obj")
     public AdmResponse queryObj(@RequestBody AdmQueryCriteria request) throws Exception {
-        return query(null, request);
+        return query(request);
     }
 }

+ 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);
     }
 }

+ 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(), queryCriteria, 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);
     }
 }

+ 47 - 88
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;
@@ -29,9 +28,7 @@ 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;
@@ -58,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);
     }
 
     /**
@@ -86,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);
     }
 
@@ -101,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");
@@ -112,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())){
@@ -123,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);
     }
 
@@ -134,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();
     }
 
@@ -149,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);
     }
 
     /**
@@ -181,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());
@@ -193,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");
@@ -240,7 +217,6 @@ public class AdmSystemController {
      * 未明确建筑/未明确楼层 中台定制接口
      *
      * 这个参见中心代码,
-     * @param projectId
      * @param buildingId buildingId=1,未明确建筑
      * @param floorId   floorId=1,未明确楼层
      * @param request
@@ -248,10 +224,8 @@ 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 {
-        // 组装上下文条件
-        InstanceUrlParam context = AdmContextUtil.toDmpContext();
         AdmResponse syses = new AdmResponse();
         if(StrUtil.isAllEmpty(buildingId,floorId)){
             //case one 查询全部系统,级联建筑,建筑级联楼层
@@ -266,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();
@@ -317,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{
@@ -338,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);
                     }
                 }
@@ -363,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)){
@@ -378,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;
@@ -392,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;
         }
@@ -409,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())) {
@@ -442,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;
     }
 
@@ -477,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;
     }
 
@@ -495,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;
     }
 
@@ -513,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)){
@@ -532,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();
@@ -544,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();
@@ -552,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);
@@ -563,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();
@@ -574,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);
     }
 
 }

+ 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