|
@@ -72,8 +72,6 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
@Autowired
|
|
|
ISceneService sceneService;
|
|
|
|
|
|
- @Value("${upload.query-path}")
|
|
|
- private String queryPath;
|
|
|
@Value("${spring.profiles.active}")
|
|
|
private String environment;
|
|
|
|
|
@@ -265,17 +263,42 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
if(scene == null){
|
|
|
throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
|
|
|
}
|
|
|
- String mesh3DtilesPath = scene.getWebPath() + String.format(FilePath.OBJ_OSS_PATH,num) + "/images/3dtiles/tileset.json";
|
|
|
+ String mesh3DtilesPath = String.format(FilePath.OBJ_OSS_PATH,num) + "/images/3dtiles/tileset.json";
|
|
|
String sizePath = scene.getWebPath() + String.format(FilePath.OBJ_OSS_PATH,num) + "/images/3dtiles";
|
|
|
- if(localToOssUtil.existKey(mesh3DtilesPath)){
|
|
|
+ if(localToOssUtil.existKey(scene.getWebPath() +mesh3DtilesPath)){
|
|
|
model.setModelDateType("b3dm");
|
|
|
model.setModelType("b3dm");
|
|
|
- model.setModelGlbUrl(JSONArray.toJSONString(Arrays.asList(queryPath +mesh3DtilesPath)));
|
|
|
- model.setModelSize(FileWriterUtil.setFileSize(localToOssUtil.getSize( sizePath)));
|
|
|
+ model.setModelGlbUrl(JSONArray.toJSONString(Arrays.asList(scene.getMapping() +File.separator +mesh3DtilesPath)));
|
|
|
+ model.setModelSize(FileWriterUtil.setFileSize(localToOssUtil.getSizeCount( sizePath)));
|
|
|
}else {
|
|
|
- model.setModelObjUrl(String.format(FilePath.OBJ_LOCAL_PATH,environment ,num) +"/mesh.obj");
|
|
|
- model.setModelGlbUrl(getGlbUrl(type,num,model,scene.getWebPath()));
|
|
|
- model.setModelType("glb");
|
|
|
+ String meshPath = String.format(FilePath.OBJ_OSS_PATH, num)+"/data/mesh";
|
|
|
+ if(localToOssUtil.existKey( scene.getWebPath() +meshPath +"/mesh.obj")){
|
|
|
+ Long size = localToOssUtil.getSizeCount( scene.getWebPath() +meshPath);
|
|
|
+ model.setModelSize(FileWriterUtil.setFileSize(size));
|
|
|
+ model.setModelGlbUrl(JSONArray.toJSONString(Arrays.asList(scene.getMapping()+File.separator + meshPath+"/mesh.obj")));
|
|
|
+ }else {
|
|
|
+ List<String> objPaths = new ArrayList<>();
|
|
|
+ String meshPathjs = String.format(FilePath.OBJ_OSS_PATH, num)+"/data/";
|
|
|
+
|
|
|
+ String jsonPath =scene.getWebPath() + meshPath + "/floors.json";
|
|
|
+ if(!localToOssUtil.existKey(jsonPath)){
|
|
|
+ jsonPath =scene.getWebPath() + meshPath +"mesh.json";
|
|
|
+ }
|
|
|
+ if(localToOssUtil.existKey(jsonPath)){
|
|
|
+ String objectContent = localToOssUtil.getObjectContent(meshPath + "/floors.json");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(objectContent);
|
|
|
+ JSONArray floors1 = jsonObject.getJSONArray("floors");
|
|
|
+ for (Object object : floors1) {
|
|
|
+ JSONObject jb = (JSONObject) object;
|
|
|
+ String string = jb.getString("objPath");
|
|
|
+ objPaths.add(scene.getMapping()+File.separator +meshPathjs + string);
|
|
|
+ }
|
|
|
+ model.setModelGlbUrl(JSONArray.toJSONString(objPaths));
|
|
|
+ Long size = localToOssUtil.getSize(scene.getWebPath() +meshPath);
|
|
|
+ model.setModelSize(FileWriterUtil.setFileSize(size));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ model.setModelType("obj");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -353,15 +376,6 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void copyOssResource(String modelGlbUrl,Integer oldModelId,Integer newModelId) {
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(modelGlbUrl);
|
|
|
- for (Object object : jsonArray) {
|
|
|
- String ossUrl = (String) object;
|
|
|
- String oldOssPath = ossUrl.replaceAll(queryPath,"");
|
|
|
- String newOssPath = oldOssPath.replaceAll(oldModelId+"",newModelId+"");
|
|
|
- localToOssUtil.copyFile(oldOssPath,newOssPath);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
@@ -372,9 +386,13 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
|
|
|
private String getGlbUrl(Integer type, String num,Model model,String scenePath) {
|
|
|
if(type == 0 || type == 1 || type == 4 || type == 6 || type == 7){ //看看,看见
|
|
|
-// String objPath = String.format(FilePath.OBJ_LOCAL_PATH ,environment,num);
|
|
|
-// ShellUtil.yunDownload(String.format(FilePath.OBJ_OSS_PATH, num)+"/data/mesh" ,objPath);
|
|
|
- String objPath = scenePath + String.format(FilePath.OBJ_OSS_PATH, num)+"/data/mesh";
|
|
|
+ //ShellUtil.yunDownload(String.format(FilePath.OBJ_OSS_PATH, num)+"/data/mesh" ,objPath);
|
|
|
+
|
|
|
+ String objPathSource = scenePath + String.format(FilePath.OBJ_OSS_PATH, num)+"/data/mesh";
|
|
|
+ String objPath = String.format(FilePath.OBJ_LOCAL_PATH ,environment,num);
|
|
|
+ ShellUtil.yunDownload(objPathSource ,objPath);
|
|
|
+
|
|
|
+
|
|
|
List<String> localGlbPaths = new ArrayList<>();
|
|
|
List<String> ossGlbPaths = new ArrayList<>();
|
|
|
File localFile = new File(objPath);
|
|
@@ -386,13 +404,13 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
localToOssUtil.uploadOss(localGlbPath,ossGlbPath);
|
|
|
if(ossGlbPath.contains("lod_")){
|
|
|
if(ossGlbPath.contains("lod_0")){
|
|
|
- ossGlbPaths.add(queryPath +ossGlbPath);
|
|
|
+ ossGlbPaths.add(CacheUtil.mapping +File.separator +ossGlbPath);
|
|
|
modelSize += localToOssUtil.getSize(ossGlbPath);
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
modelSize += localToOssUtil.getSize(ossGlbPath);
|
|
|
- ossGlbPaths.add(queryPath +ossGlbPath);
|
|
|
+ ossGlbPaths.add( CacheUtil.mapping +File.separator+ossGlbPath);
|
|
|
}
|
|
|
model.setModelSize(FileWriterUtil.setFileSize(modelSize));
|
|
|
FileUtil.del(objPath);
|