Просмотр исходного кода

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

zhangqiankun 3 лет назад
Родитель
Сommit
241b156508

+ 44 - 53
src/main/java/com/persagy/proxy/object/controller/AdmSystemController.java

@@ -504,8 +504,17 @@ public class AdmSystemController {
     @PostMapping("/un-sys-equip")
     public AdmResponse queryUnEquip( @NotNull @QueryParam("sysId") String sysId,
                                      @RequestBody AdmQueryCriteria request) throws Exception {
-        AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Eq","MechSubset", AdmEquipment.OBJ_TYPE);
-        return admResponse;
+        //AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Eq","MechSubset", AdmEquipment.OBJ_TYPE);
+        ObjectNode relationTo = JsonNodeFactory.instance.objectNode();
+        relationTo.put("objFrom", sysId);
+        relationTo.put("relCode", "Sy2Eq");
+        relationTo.put("graphCode", "MechSubset");
+        relationTo.put("$bindFlag", false);
+        request.setRelationTo(relationTo);
+        request.setName(AdmEquipment.OBJ_TYPE);
+        QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
+        List<ObjectNode> obj = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObj);
+        return AdmResponse.success(obj);
     }
 
 
@@ -520,8 +529,16 @@ public class AdmSystemController {
     @PostMapping("/un-sys-shaft")
     public AdmResponse queryUnSh( @NotNull @QueryParam("sysId") String sysId,
                                   @RequestBody AdmQueryCriteria request) throws Exception {
-        AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Sh",null, AdmShaft.OBJ_TYPE);
-        return admResponse;
+        //AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Sh",null, AdmShaft.OBJ_TYPE);
+        ObjectNode relationTo = JsonNodeFactory.instance.objectNode();
+        relationTo.put("objFrom", sysId);
+        relationTo.put("relCode", "Sy2Sh");
+        relationTo.put("$bindFlag", false);
+        request.setRelationTo(relationTo);
+        request.setName(AdmShaft.OBJ_TYPE);
+        QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
+        List<ObjectNode> obj = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObj);
+        return AdmResponse.success(obj);
     }
 
 
@@ -535,8 +552,16 @@ public class AdmSystemController {
     @PostMapping("/un-sys-zoneSpaceBaseTable")
     public AdmResponse queryUnZoneSp(@NotNull @QueryParam("sysId") String sysId,
                                      @RequestBody AdmQueryCriteria request) throws Exception {
-        AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Sp",null, AdmSpace.OBJ_TYPE);
-        return admResponse;
+       // AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Sp",null, AdmSpace.OBJ_TYPE);
+        ObjectNode relationTo = JsonNodeFactory.instance.objectNode();
+        relationTo.put("objFrom", sysId);
+        relationTo.put("relCode", "Sy2Sp");
+        relationTo.put("$bindFlag", false);
+        request.setRelationTo(relationTo);
+        request.setName(AdmSpace.OBJ_TYPE);
+        QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
+        List<ObjectNode> obj = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObj);
+        return AdmResponse.success(obj);
     }
 
 
@@ -550,58 +575,24 @@ public class AdmSystemController {
     @PostMapping("/unspace-sys")
     public AdmResponse queryUnSpSy(  @QueryParam("type") String type, @QueryParam("spaceId") String spaceId,
                                      @RequestBody AdmQueryCriteria request) throws Exception {
-        if(StrUtil.isNotEmpty(spaceId)){
-            AdmResponse admResponse = queryObjectByType(spaceId, request,"Sy2Sp",null, AdmSystem.OBJ_TYPE);
-            return admResponse;
-        }else{
-            if(StrUtil.isNotEmpty(type)){
-                QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
-                ObjectNode criteriaObj = JsonNodeFactory.instance.objectNode();
-                criteriaObj.put("objType", AdmSpace.OBJ_TYPE);
-                queryCriteriaObj.setCriteria(criteriaObj);
-                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();
-                criteriaObj.put("objType", AdmSystem.OBJ_TYPE);
-                if(CollUtil.isNotEmpty(objs)){
-                    ArrayNode arrayNode = criteriaObj.putObject("id").putArray("$notcontains");
-                    for(ObjectNode objectNode: objs){
-                        arrayNode.add(objectNode.get("id").toString());
-                    }
-                }
-                queryCriteriaObj.setCriteria(criteriaObj);
-                List<ObjectNode> syses = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObjSys);
-                return AdmResponse.success(syses);
+        if(StrUtil.isNotEmpty(type)){
+            if(StrUtil.isBlank(request.getFilters())){
+                request.setFilters("classCode = '"+type+"'");
+            }else{
+                request.setFilters(request.getFilters()+";classCode = '"+type+"'");
             }
-            return AdmResponse.success();
         }
-    }
-
-
-    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);
-        criteria.put("relCode", relCode);
-        if(StrUtil.isNotEmpty(graphCode)){
-            criteria.put("graphCode", graphCode);
-        }
-        queryCriteria.setCriteria(criteria);
-        queryCriteria.setSize(request.getPageSize()*1L);
-        queryCriteria.setPage(request.getPageNumber()*1L);
-        List<ObjectRelation> relations = DigitalRelationFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteria);
+        //AdmResponse admResponse = queryObjectByType(spaceId, request,"Sy2Sp",null, AdmSystem.OBJ_TYPE);
 
+        ObjectNode relationFrom = JsonNodeFactory.instance.objectNode();
+        relationFrom.put("objTo", spaceId);
+        relationFrom.put("relCode", "Sy2Sp");
+        relationFrom.put("$bindFlag", false);
+        request.setRelationFrom(relationFrom);
+        request.setName(AdmSystem.OBJ_TYPE);
         QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
-        ObjectNode criteriaObj = JsonNodeFactory.instance.objectNode();
-        criteriaObj.put("objType", objType);
-        if(CollUtil.isNotEmpty(relations)){
-            Map<String, ObjectRelation> objectRelationMap = CollUtil.fieldValueMap(relations,BaseEntity.PROP_ID);
-            ArrayNode arrayNode = criteriaObj.putObject("id").putArray("$notcontains");
-            objectRelationMap.keySet().stream().forEach(id -> arrayNode.add(id));
-        }
-        queryCriteriaObj.setCriteria(criteriaObj);
         List<ObjectNode> obj = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObj);
         return AdmResponse.success(obj);
     }
+
 }