|
@@ -17,6 +17,7 @@ import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.response.Result;
|
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
import com.fdkankan.common.util.ComputerUtil;
|
|
|
+import com.fdkankan.common.util.CreateHouseJsonUtil;
|
|
|
import com.fdkankan.common.util.CreateObjUtil;
|
|
|
import com.fdkankan.common.util.FileMd5Util;
|
|
|
import com.fdkankan.common.util.FileUtil;
|
|
@@ -35,10 +36,14 @@ import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.api.dto.SceneInfoDTO;
|
|
|
import com.fdkankan.scene.bean.BoxPhotoBean;
|
|
|
import com.fdkankan.scene.bean.IconBean;
|
|
|
+import com.fdkankan.scene.bean.PointBean;
|
|
|
import com.fdkankan.scene.bean.RequestSceneProV4;
|
|
|
import com.fdkankan.scene.bean.SceneJsonBean;
|
|
|
+import com.fdkankan.scene.bean.SegmentBean;
|
|
|
import com.fdkankan.scene.bean.StyleBean;
|
|
|
import com.fdkankan.scene.bean.TagBean;
|
|
|
+import com.fdkankan.scene.bean.VertexBean;
|
|
|
+import com.fdkankan.scene.bean.WallBean;
|
|
|
import com.fdkankan.scene.callback.FdkkMiniReqErrorCallback;
|
|
|
import com.fdkankan.scene.callback.FdkkMiniReqSuccessCallback;
|
|
|
import com.fdkankan.scene.entity.SceneDataDownload;
|
|
@@ -70,6 +75,7 @@ import java.io.File;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
@@ -655,6 +661,10 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
Byte floorPlanUser = null;
|
|
|
if(StrUtil.isNotEmpty(floorJsonData)){
|
|
|
// TODO: 2022/7/26 生成hostType
|
|
|
+ JSONObject houseTypeJson = CreateHouseJsonUtil
|
|
|
+ .createHouseTypeJson(localDataPath + "floorplan_user.json");
|
|
|
+ uploadToOssUtil.upload(houseTypeJson.toJSONString().getBytes(), editUserPath + "houseType.json");
|
|
|
+
|
|
|
floorPlanUser = CommonStatus.YES.code();
|
|
|
}
|
|
|
SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
|
|
@@ -692,7 +702,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResultData resetCad(String num){
|
|
|
+ public ResultData resetCad(String num) throws IOException {
|
|
|
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
if(Objects.isNull(scenePlus))
|
|
@@ -714,6 +724,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ //根据floorplan_cad.json生成houseType.json
|
|
|
+ this.uploadHouseTypeJson(num);
|
|
|
+
|
|
|
ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
|
|
|
SceneEditInfoExt sceneEditInfoExt = null;
|
|
@@ -746,6 +759,112 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private 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.USER_EDIT_PATH, num) + "houseType.json";
|
|
|
+ uploadToOssUtil.upload(result.toJSONString().getBytes(), hourseTypeJsonPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ResultData renameCad(RenameCadParamVO param) throws IOException {
|
|
|
|