瀏覽代碼

返回字段信息对应

zhangqiankun 3 年之前
父節點
當前提交
22ee9ebd8f
共有 1 個文件被更改,包括 28 次插入8 次删除
  1. 28 8
      src/main/java/com/persagy/proxy/adm/handler/SpaceRelationInfoHandler.java

+ 28 - 8
src/main/java/com/persagy/proxy/adm/handler/SpaceRelationInfoHandler.java

@@ -27,6 +27,7 @@ import com.persagy.proxy.adm.service.IRelationReportService;
 import com.persagy.proxy.adm.strategy.RelationObjectContext;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.StrUtil;
 import lombok.RequiredArgsConstructor;
 
@@ -255,20 +256,39 @@ public class SpaceRelationInfoHandler {
 	 * @return
 	 */
 	private List<ObjectNode> fillSpaceInfo(List<ObjectNode> queryObjects, String buildingId, String floorId) {
+		if (CollectionUtil.isEmpty(queryObjects)) {
+			return null;
+		}
+		
+		List<ObjectNode> resultList = new ArrayList<ObjectNode>();
+		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+		
 		for (ObjectNode objectNode : queryObjects) {
+			ObjectNode result = objectMapper.createObjectNode();
 			String infos = objectNode.has("infos") ? objectNode.get("infos").asText() : null;
 			if (StrUtil.isNotBlank(infos)) {
 				JSONObject infoObject = JSONObject.parseObject(infos);
-				objectNode.put("bimLocation", infoObject.getString("bimLocation"));
-				objectNode.put("height", infoObject.getDouble("height"));
-				objectNode.put("outline", infoObject.getString("outline"));
-				objectNode.put("floorId", floorId);
-				objectNode.put("buildingId", buildingId);
+				
+				result.put("bimLocation", infoObject.getString("bimLocation"));
+				result.put("height", infoObject.getDouble("height"));
+				result.put("outline", infoObject.getString("outline"));
+				result.put("floorId", floorId);
+				result.put("buildingId", buildingId);
 			}
 			
-			objectNode.putPOJO("infos", new JSONObject());
-			objectNode.putPOJO("statistics", new JSONObject());
-			objectNode.put("state", objectNode.has("valid") ? (objectNode.get("valid").asInt(0) == 1 ? 0 : 1) : 0);
+			result.put("classCode", objectNode.has("classCode") ? objectNode.get("classCode").asText() : null);
+			result.put("id", objectNode.has("id") ? objectNode.get("id").asText() : null);
+			result.put("projectId", objectNode.has("projectId") ? objectNode.get("projectId").asText() : null);
+			result.put("localName", objectNode.has("localName") ? objectNode.get("localName").asText() : null);
+			result.put("name", objectNode.has("name") ? objectNode.get("name").asText() : null);
+			
+			Long creationTime = objectNode.has("creationTime") ? objectNode.get("creationTime").asLong() : null;
+			result.put("createTime", creationTime == null ? null : new DateTime(creationTime).toString());
+			result.putPOJO("infos", new JSONObject());
+			result.putPOJO("statistics", new JSONObject());
+			result.put("state", objectNode.has("valid") ? (objectNode.get("valid").asInt(0) == 1 ? 0 : 1) : 0);
+			
+			resultList.add(result);
 		}
 		
 		return queryObjects;