|
@@ -44,7 +44,11 @@ import com.fdkankan.push.PushMsgUtil;
|
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import com.fdkankan.scene.bean.PointBean;
|
|
|
import com.fdkankan.scene.bean.SceneJsonBean;
|
|
|
+import com.fdkankan.scene.bean.SegmentBean;
|
|
|
+import com.fdkankan.scene.bean.VertexBean;
|
|
|
+import com.fdkankan.scene.bean.WallBean;
|
|
|
import com.fdkankan.scene.entity.SceneEditControls;
|
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
|
import com.fdkankan.scene.entity.SceneEditInfoExt;
|
|
@@ -55,7 +59,6 @@ import com.fdkankan.scene.entity.ScenePro;
|
|
|
import com.fdkankan.scene.entity.SceneProExt;
|
|
|
import com.fdkankan.scene.service.IBuildSceneDTService;
|
|
|
import com.fdkankan.scene.service.IBuildScenePostService;
|
|
|
-import com.fdkankan.scene.service.IBuildScenePreService;
|
|
|
import com.fdkankan.scene.service.ISceneEditControlsService;
|
|
|
import com.fdkankan.scene.service.ISceneEditInfoExtService;
|
|
|
import com.fdkankan.scene.service.ISceneEditInfoService;
|
|
@@ -66,10 +69,11 @@ import com.fdkankan.scene.service.ISceneProExtService;
|
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
|
import com.fdkankan.scene.service.ISceneService;
|
|
|
import com.fdkankan.scene.vo.SceneEditControlsVO;
|
|
|
-import com.sun.org.apache.bcel.internal.generic.RETURN;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.Calendar;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -104,6 +108,8 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
|
|
|
private String ossType;
|
|
|
@Value("${oss.prefix.ali}")
|
|
|
private String prefixAli;
|
|
|
+ @Value("${oss.bucket:4dkankan}")
|
|
|
+ private String bucket;
|
|
|
|
|
|
@Autowired
|
|
|
ISceneService sceneService;
|
|
@@ -240,6 +246,9 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
|
|
|
//拷贝部分文件到编辑目录,用于用户编辑
|
|
|
this.copyToEditDir(sceneCode);
|
|
|
|
|
|
+ //生成houseTypejson并上传
|
|
|
+ this.uploadHouseTypeJson(sceneCode);
|
|
|
+
|
|
|
// //上传日志文件
|
|
|
// buildScenePreService.uploadLogFile(sceneCode, sceneProExt.getDataSource());
|
|
|
|
|
@@ -779,4 +788,117 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
|
|
|
}
|
|
|
return new Object[]{sceneEditInfo, sceneEditInfoExt, sceneEditControls};
|
|
|
}
|
|
|
+
|
|
|
+ public void uploadHouseTypeJson(String num) throws IOException {
|
|
|
+
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("name", "houseType.json");
|
|
|
+ result.put("version", "2.1");
|
|
|
+
|
|
|
+ String floorplanCadPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan_cad.json";
|
|
|
+ String floorcadStr = uploadToOssUtil.getObjectContent(this.bucket, floorplanCadPath);
|
|
|
+
|
|
|
+ JSONObject floorcadObj = JSON.parseObject(floorcadStr);
|
|
|
+ JSONArray floors = floorcadObj.getJSONArray("floors");
|
|
|
+
|
|
|
+ JSONArray targetFloors = new JSONArray();
|
|
|
+ result.put("floors", targetFloors);
|
|
|
+ for(int i = 0; i < floors.size(); i++){
|
|
|
+ JSONObject floor = (JSONObject)floors.get(i);
|
|
|
+ JSONArray[] pointsAndWalls = this.createHouseTypeJsonHandler(floor);
|
|
|
+ JSONArray points = pointsAndWalls[0];
|
|
|
+ JSONArray walls = pointsAndWalls[1];
|
|
|
+ JSONObject targetFloor = new JSONObject();
|
|
|
+ targetFloor.put("points", points);
|
|
|
+ targetFloor.put("walls", walls);
|
|
|
+ targetFloors.add(targetFloor);
|
|
|
+ }
|
|
|
+
|
|
|
+ String hourseTypeJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "houseType.json";
|
|
|
+ uploadToOssUtil.upload(result.toJSONString().getBytes(), hourseTypeJsonPath);
|
|
|
+
|
|
|
+ cn.hutool.core.io.FileUtil.writeString(result.toJSONString(), "F:\\test\\hourseType.json", StandardCharsets.UTF_8);
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONArray[] createHouseTypeJsonHandler(JSONObject floor){
|
|
|
+
|
|
|
+ JSONArray[] result = new JSONArray[2];
|
|
|
+
|
|
|
+ //处理点
|
|
|
+ Map<Integer, VertexBean> vertexMap = new HashMap<>();
|
|
|
+ Map<String, PointBean> pointMap = new HashMap<>();
|
|
|
+ Map<Integer, String> vpMap = new HashMap<>();
|
|
|
+ JSONArray vertexArr = floor.getJSONArray("vertex-xy");
|
|
|
+ for(int i = 0; i < vertexArr.size(); i++){
|
|
|
+ Object o = vertexArr.get(i);
|
|
|
+
|
|
|
+ VertexBean vertexBean = JSON.parseObject(JSON.toJSONString(o), VertexBean.class);
|
|
|
+ Integer vertexId = vertexBean.getId();
|
|
|
+ vertexMap.put(vertexId, vertexBean);
|
|
|
+
|
|
|
+ String pointId = "Point" + i;
|
|
|
+ pointMap.put(pointId, PointBean.builder().vectorId(pointId).x(vertexBean.getX()).y(vertexBean.getY()).build());
|
|
|
+
|
|
|
+ vpMap.put(vertexId, pointId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理墙
|
|
|
+ Map<Integer, SegmentBean> segmentMap = new HashMap<>();
|
|
|
+ Map<String, WallBean> wallMap = new HashMap<>();
|
|
|
+ Map<Integer, String> swMap = new HashMap<>();
|
|
|
+ JSONArray segmentArr = floor.getJSONArray("segment");
|
|
|
+ Map<String, String> startMap = new HashMap<>();
|
|
|
+ Map<String, String> endMap = new HashMap<>();
|
|
|
+ for(int i = 0; i < segmentArr.size(); i++){
|
|
|
+ Object o = segmentArr.get(i);
|
|
|
+
|
|
|
+ SegmentBean segmentBean = JSON.parseObject(JSON.toJSONString(o), SegmentBean.class);
|
|
|
+ String startPointId = vpMap.get(segmentBean.getA());
|
|
|
+ String endPointId = vpMap.get(segmentBean.getB());
|
|
|
+ segmentBean.setStartPointId(startPointId);
|
|
|
+ segmentBean.setEndPointId(endPointId);
|
|
|
+
|
|
|
+ Integer segmentId = segmentBean.getId();
|
|
|
+ segmentMap.put(segmentId, segmentBean);
|
|
|
+
|
|
|
+ String wallId = "Wall" + i;
|
|
|
+ WallBean wallBean = WallBean.builder()
|
|
|
+ .vectorId(wallId)
|
|
|
+ .start(segmentBean.getStartPointId())
|
|
|
+ .end(segmentBean.getEndPointId())
|
|
|
+ .children(new String[]{})
|
|
|
+ .width(0.2d)
|
|
|
+ .build();
|
|
|
+ wallMap.put(wallId, wallBean);
|
|
|
+
|
|
|
+ startMap.put(wallBean.getStart(), wallBean.getVectorId());
|
|
|
+ endMap.put(wallBean.getEnd(), wallBean.getVectorId());
|
|
|
+
|
|
|
+ swMap.put(segmentId, wallId);
|
|
|
+ }
|
|
|
+
|
|
|
+ Collection<PointBean> pointBeans = pointMap.values();
|
|
|
+ for (PointBean pointBean : pointBeans) {
|
|
|
+ Map<String, String> parent = new HashMap<>();
|
|
|
+ String startParent = startMap.get(pointBean.getVectorId());
|
|
|
+ String endParent = endMap.get(pointBean.getVectorId());
|
|
|
+ parent.put(startParent, "start");
|
|
|
+ parent.put(endParent, "end");
|
|
|
+ pointBean.setParent(parent);
|
|
|
+ }
|
|
|
+ JSONArray pointArr = JSON.parseArray(JSON.toJSONString(pointBeans));
|
|
|
+ result[0] = pointArr;
|
|
|
+
|
|
|
+ Collection<WallBean> wallBeans = wallMap.values();
|
|
|
+ JSONArray wallArr = JSON.parseArray(JSON.toJSONString(wallBeans));
|
|
|
+ result[1] = wallArr;
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+// BuildScenePostServiceImpl.createHouseTypeJson();
|
|
|
+ }
|
|
|
+
|
|
|
}
|