|
@@ -783,18 +783,27 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
file.transferTo(zipFile);
|
|
|
ZipUtil.unzip(zipFilePath, meshPath);
|
|
|
|
|
|
+ String jsonName = "";
|
|
|
+ if(fYunFileService.fileExist(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/floors.json")){
|
|
|
+ jsonName = "floors.json";
|
|
|
+ }
|
|
|
+ if(fYunFileService.fileExist(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/mesh.json")){
|
|
|
+ jsonName = "mesh.json";
|
|
|
+ }
|
|
|
+
|
|
|
//检测文件
|
|
|
- String floorsJsonPath = meshPath + File.separator + "floors.json";
|
|
|
+ String floorsJsonPath = meshPath + File.separator + jsonName;
|
|
|
if(!FileUtil.exist(floorsJsonPath)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5068);
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5068.code(), "json file is not exist!");
|
|
|
}
|
|
|
String floorsJsonStr = FileUtil.readUtf8String(floorsJsonPath);
|
|
|
JSONObject floorsJsonObj = JSON.parseObject(floorsJsonStr);
|
|
|
JSONArray floorArr = floorsJsonObj.getJSONArray("floors");
|
|
|
if(CollUtil.isEmpty(floorArr)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5069);
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5069.code(), "json content is error");
|
|
|
}
|
|
|
Set<String> floorNameSet = new HashSet<>();
|
|
|
+ String finalJsonName = jsonName;
|
|
|
floorArr.stream().forEach(item->{
|
|
|
JSONObject itemObj = (JSONObject) item;
|
|
|
//楼层目录是否存在
|
|
@@ -803,9 +812,23 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5070);
|
|
|
}
|
|
|
//检测obj文件是否存在
|
|
|
- String objPath = itemObj.getString("objPath");
|
|
|
- if(StrUtil.isEmpty(objPath) || !FileUtil.exist(path + objPath)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5070);
|
|
|
+ if("floors.json".equals(finalJsonName)){
|
|
|
+ String objPath = itemObj.getString("objPath");
|
|
|
+ if(StrUtil.isEmpty(objPath) || !FileUtil.exist(path + objPath)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5070);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ JSONArray lods = itemObj.getJSONArray("lods");
|
|
|
+ if(CollUtil.isEmpty(lods)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5069.code(), "json content is error");
|
|
|
+ }
|
|
|
+ for (Object lod : lods) {
|
|
|
+ JSONObject lodObj = (JSONObject) lod;
|
|
|
+ String objPath = lodObj.getString("objPath");
|
|
|
+ if(StrUtil.isEmpty(objPath) || !FileUtil.exist(path + objPath)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5070);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if(floorNameSet.contains(name)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5069);
|
|
@@ -814,7 +837,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
});
|
|
|
|
|
|
//读取oss上的floors.jsoon用于校验用户上传的模型楼层数是否一一对应
|
|
|
- String ossFloorsJson = fYunFileService.getFileContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/floors.json");
|
|
|
+ String ossFloorsJson = fYunFileService.getFileContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/" + jsonName);
|
|
|
JSONObject orginFloorsJsonObj = JSON.parseObject(ossFloorsJson);
|
|
|
JSONArray orginFloorArr = orginFloorsJsonObj.getJSONArray("floors");
|
|
|
Set<String> orginFloorNameSet = orginFloorArr.stream().map(item -> {
|