瀏覽代碼

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

zhangqiankun 3 年之前
父節點
當前提交
a1fbf2b572

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

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.request;
 
+import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.annotation.JsonAlias;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -46,6 +47,21 @@ public class AdmQueryCriteria {
     private ObjectNode relationTo;
 
     /**
+     * 拼接条件
+     * @param addFilter
+     */
+    public void addFilters(String addFilter) {
+        if(StrUtil.isBlank(addFilter)) {
+            return;
+        }
+        if(StrUtil.isBlank(filters)) {
+            filters = addFilter;
+            return;
+        }
+        filters = filters + " and " + addFilter;
+    }
+
+    /**
      * 设置关系条件
      * @param isFrom 是否查询from结果
      * @param graphCode

+ 5 - 7
src/main/java/com/persagy/proxy/object/controller/AdmISpaceController.java

@@ -1,15 +1,15 @@
 package com.persagy.proxy.object.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.persagy.proxy.object.model.AdmISpace;
+import com.persagy.dmp.common.utils.JsonHelper;
 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.object.service.IAdmISpaceService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
+import com.persagy.proxy.object.model.AdmISpace;
+import com.persagy.proxy.object.service.IAdmISpaceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -105,13 +105,11 @@ public class AdmISpaceController {
      */
     @PostMapping("/query")
     public AdmResponse query(@RequestBody JSONObject param) throws Exception {
-        AdmQueryCriteria request = new AdmQueryCriteria();
+        AdmQueryCriteria request = JsonHelper.toSingleEntity(param, AdmQueryCriteria.class);
         request.setName(AdmISpace.OBJ_TYPE);
-        request.setPageNumber(null==param.getInteger("pageNumber")?1:param.getInteger("pageNumber"));
-        request.setPageSize(null==param.getInteger("pageSize")?1:param.getInteger("pageSize"));
         if (StrUtil.isNotBlank(param.getString("floorId"))){
             String filters = " floorId = '"+param.getString("floorId")+"' ";
-            request.setFilters(filters);
+            request.addFilters(filters);
         }
         AdmResponse admResponse = service.doQuery(AdmContextUtil.toDmpContext(), request, AdmISpace.class);
         admResponse.setMessage(param.getString("floorId"));

+ 17 - 7
src/main/java/com/persagy/proxy/object/service/impl/AdmSpaceServiceImpl.java

@@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Sets;
 import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.common.constant.CommonConstant;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.helper.SpringHelper;
 import com.persagy.dmp.common.model.entity.BaseEntity;
@@ -76,7 +77,7 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
 
     @Override
     public List<AdmSpace> doInsertExt(InstanceUrlParam context, Class<AdmSpace> clazz, List<AdmSpace> voList) {
-        Map<String, AdmSpace> spaceMapByFlId = CollUtil.fieldValueMap(voList, "floorId");
+        Map<String, List<AdmSpace>> spaceMapByFlId = voList.stream().collect(Collectors.groupingBy(AdmSpace::getFloorId));
         //查询空间中floorId 对应的floor
         List<ObjectNode> floors = queryFloorsByFloorIds(context, spaceMapByFlId.keySet());
         if(CollUtil.isNotEmpty(floors)){
@@ -572,16 +573,25 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
      * @param floorList
      * @return
      */
-    private List<AdmSpace> processHeight(Map<String, AdmSpace> spaceMapByFlId, List<ObjectNode> floorList){
-    	List<AdmSpace> resultList = new ArrayList<AdmSpace>();
+    private List<AdmSpace> processHeight(Map<String, List<AdmSpace>> spaceMapByFlId, List<ObjectNode> floorList){
+    	List<AdmSpace> resultList = new ArrayList<>();
     	floorList.forEach(node -> {
     		try {
-    			if(node.has("height")){
+    		    if (!node.has("id")
+                        || !node.get("id").isTextual()){
+    		        return;
+                }
+                List<AdmSpace> spaces = spaceMapByFlId.get(node.get("id").asText());
+    		    if (CollUtil.isEmpty(spaces)){
+    		        return;
+                }
+                if(node.has("height")){
                 	String height = node.get("height").asText();
                 	if (StrUtil.isNotBlank(height)) {
-                		AdmSpace admSpace = spaceMapByFlId.get(node.get("id").asText());
-                        admSpace.setHeight(Float.parseFloat(height));
-                        resultList.add(admSpace);
+                        for (AdmSpace admSpace : spaces) {
+                            admSpace.setHeight(Float.parseFloat(height));
+                            resultList.add(admSpace);
+                        }
 					}
                 }
 			} catch (Exception e) {}

+ 6 - 2
src/main/java/com/persagy/proxy/relation/controller/RelationSpInSiController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.common.constant.CommonConstant;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.relation.model.SiInSpBase;
 import com.persagy.proxy.relation.model.SiInSpBaseList;
@@ -59,11 +60,14 @@ public class RelationSpInSiController {
         for (SiInSpBase siInSpBase : content) {
             String ispaceId = siInSpBase.getIspaceId();
             String spaceId = siInSpBase.getSpaceId();
-            String objectType = siInSpBase.getObjectType();
+            if (StrUtil.isBlank(type)){
+                type = siInSpBase.getClassCode();
+            }
             if (StrUtil.isEmpty(spaceId) || StrUtil.isBlank(ispaceId)) {
                 return AdmResponse.failure("必填项:ispaceId(元空间id)、spaceId(空间id)");
             }
-            RelationDTO relation = new RelationDTO(null, graphCode, relCode, objectType, spaceId, ispaceId);
+            RelationDTO relation = new RelationDTO(StrUtil.format(CommonConstant.DEFAULT_GRAPH_ID_FORMAT,graphCode),
+                    graphCode, relCode, type, spaceId, ispaceId);
             voList.add(relation);
         }
         service.doSave(AdmContextUtil.toDmpContext(), voList);

+ 3 - 0
src/main/java/com/persagy/proxy/relation/model/SiInSpBase.java

@@ -32,4 +32,7 @@ public class SiInSpBase {
     /** 计算标记 1 为手动 2为自动 */
     private Integer sign;
 
+    /** 计算标记 1 为手动 2为自动 */
+    private String classCode;
+
 }