浏览代码

2021-1118

zhaoyk 3 年之前
父节点
当前提交
2401dcaede
共有 1 个文件被更改,包括 46 次插入2 次删除
  1. 46 2
      src/main/java/com/persagy/bdtp/adm/service/impl/SyncAppImpl.java

+ 46 - 2
src/main/java/com/persagy/bdtp/adm/service/impl/SyncAppImpl.java

@@ -6,7 +6,9 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.bdtp.adm.client.DicClient;
 import com.persagy.bdtp.adm.client.RwdClient;
@@ -189,10 +191,37 @@ public class SyncAppImpl implements ISyncApp {
 
 	private void packInfos(List<ObjectNode> dataList){
 		for(ObjectNode node : dataList) {
+			handle4Download(node);
 			DataExtrasUtil.packObjExtras(node);
 		}
 	}
 
+	/** 下载前处理数据结构 */
+	private void handle4Download(ObjectNode node){
+		JsonNode ol = node.get("outline");
+		if(ol != null){
+			try {
+				node.set("outline", objectMapper.readValue(ol.asText(), ArrayNode.class));
+			}catch (Exception e) {
+
+			}
+		}
+		JsonNode bl = node.get("bimLocation");
+		if(bl != null) {
+			try {
+				String[] arr = bl.asText().split(",");
+				ObjectNode ln = objectMapper.createObjectNode();
+				ln.put("x", Double.parseDouble(arr[0]));
+				ln.put("y", Double.parseDouble(arr[1]));
+				ln.put("z", Double.parseDouble(arr[2]));
+				node.set("location", ln);
+				node.remove("bimLocation");
+			}catch (Exception e) {
+
+			}
+		}
+	}
+
 	@Override
 	public BuildingData downloadBuildingData(String projectId, String buildingId, String uploadFlag, String lastDownloadTime) {
 		throw new RuntimeException("not supported");
@@ -383,6 +412,7 @@ public class SyncAppImpl implements ISyncApp {
 				return job.getStatus();
 		} else {
 			job = new AdmUploadJob();
+			job.setId(uploadJobId);
 			job.setProjectId(projectId);
 			job.setOperator(operator);
 			job.setStatus(AdmConst.UPLOAD_PROCESSING);
@@ -419,6 +449,7 @@ public class SyncAppImpl implements ISyncApp {
 		Iterator<ObjectNode> iter = list.iterator();
 		while (iter.hasNext()) {
 			ObjectNode entity = iter.next();
+			handle4Upload(entity);
 			DataExtrasUtil.unpackObjExtras(entity);
 			entity.remove("ts"); //调用bdtp接口前,删除ts字段
 
@@ -444,8 +475,8 @@ public class SyncAppImpl implements ISyncApp {
 				entity.put("modifier", operator);
 				entity.put("modifiedTime", time);
 
-				//修改空间信息点,轮廓不上传
-				if(AdmConst.OBJ_TYPE_SPACE.equals(entity.get("objType")))
+				//修改对象信息点,轮廓不上传
+				if(entity.get("outline") != null)
 					entity.remove("outline");
 
 				//TODO 可能需要进行删除信息点操作
@@ -608,6 +639,19 @@ public class SyncAppImpl implements ISyncApp {
 		}
 	}
 
+	/** 上传前处理数据结构 */
+	private void handle4Upload(ObjectNode node){
+		JsonNode l = node.get("location");
+		if(l != null) {
+			try {
+				node.put("bimLocation", StrUtil.join(",", l.get("x").asDouble(), l.get("y").asDouble(), l.get("z").asDouble()));
+				node.remove("location");
+			}catch (Exception e) {
+
+			}
+		}
+	}
+
 	private void markM2dState(Object item){
 		//TODO 标记数据同步状态
 	}