zhangqiankun 3 years ago
parent
commit
055b99a4a0

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

@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.utils.JsonNodeUtils;
 
+import java.io.IOException;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -47,6 +48,11 @@ public class AdmEntityTransferUtil {
         ArrayNode dataNode = JsonNodeUtils.toArrayNode(array, null, null);
         return toAdmMultiEntity(dataNode, projection, clazz);
     }
+    
+    public static <T> List<T> toAdmMultiEntityExtra(List array, List<String> projection, Class<T> clazz) {
+        ArrayNode dataNode = JsonNodeUtils.toArrayNode(array, null, null);
+        return toAdmMultiEntityExtra(dataNode, projection, clazz);
+    }
 
     /**
      * 转换为数据中心对象
@@ -74,6 +80,25 @@ public class AdmEntityTransferUtil {
 		}
         return null;*/
     }
+    
+    public static <T> List<T> toAdmMultiEntityExtra(ArrayNode array, List<String> projection, Class<T> clazz) {
+        if(ArrayUtil.isEmpty(array)) {
+            return null;
+        }
+        // 转换属性名
+        for(int i = 0, j = array.size();i < j;i++) {
+            JsonNode node = array.get(i);
+            if(node != null && node.isObject()) {
+                resetAdmProperty((ObjectNode) node, projection);
+            }
+        }
+        try {
+			return JSONEntityUtil.toEntity(array, clazz, "infos");
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+        return null;
+    }
 
     /**
      * 转换为数据中心对象

+ 12 - 1
src/main/java/com/persagy/proxy/object/service/impl/AdmSpaceServiceImpl.java

@@ -31,6 +31,7 @@ import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
+import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
 import com.persagy.proxy.common.client.DmpRwdClient;
 import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
@@ -85,7 +86,17 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
             voList = processHeight(spaceMapByFlId, floors);
         }
         //插入空间
-        List<AdmSpace> vosR = doInsert(context, clazz, voList);
+        List<AdmSpace> vosR = null;
+        if(CollUtil.isNotEmpty(voList)) {
+        	ArrayNode vos = AdmEntityTransferUtil.toDmpMultiEntity(voList);
+            // 调用中台新增
+            DmpResult<JSONArray> response = rwdClient.createObject(context, JSONArray.parseArray(vos.toString()));
+            if(!DmpResult.SUCCESS.equals(response.getResult())) {
+                throw new RuntimeException("调用中台查询接口出错:" + response.getMessage());
+            }
+            
+            vosR = AdmEntityTransferUtil.toAdmMultiEntityExtra(response.getData(), null, clazz);
+        }
         //添加绑定关系
         processRelations(vosR);
         //处理关系标记