|
@@ -87,6 +87,9 @@ public class CommonServiceImpl implements ICommonService {
|
|
.getTime(), DateExtUtil.dateStyle6), uuid + extName);
|
|
.getTime(), DateExtUtil.dateStyle6), uuid + extName);
|
|
|
|
|
|
tempFile = new File(OssPath.localPath + ossPath);
|
|
tempFile = new File(OssPath.localPath + ossPath);
|
|
|
|
+ if(!tempFile.getParentFile().exists()){
|
|
|
|
+ tempFile.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
file.transferTo(tempFile);
|
|
file.transferTo(tempFile);
|
|
if(extName.equals(".zip")){
|
|
if(extName.equals(".zip")){
|
|
return uploadModelZip(tempFile);
|
|
return uploadModelZip(tempFile);
|
|
@@ -130,17 +133,17 @@ public class CommonServiceImpl implements ICommonService {
|
|
throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
|
|
throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
|
|
}
|
|
}
|
|
String modelFileFormat = modelFile.getName().split("\\.")[1].toLowerCase();
|
|
String modelFileFormat = modelFile.getName().split("\\.")[1].toLowerCase();
|
|
|
|
+ String url = null;
|
|
switch (modelFileFormat){
|
|
switch (modelFileFormat){
|
|
case "obj" : OBJToGLBUtil.checkObj(modelFile.getPath());
|
|
case "obj" : OBJToGLBUtil.checkObj(modelFile.getPath());
|
|
case "laz" :
|
|
case "laz" :
|
|
- case "b3dm" :
|
|
|
|
- case "shp" : uploadOss(unzipPath,modelFile); break;
|
|
|
|
|
|
+ case "shp" : url = uploadOss(unzipPath,modelFile); break;
|
|
|
|
+ case "b3dm" : url = uploadB3dm(unzipPath,modelFile); break;
|
|
case "las" :
|
|
case "las" :
|
|
- case "ply" : uploadLasOrPly(modelFile);break;
|
|
|
|
|
|
+ case "ply" : url = uploadLasOrPly(modelFile);break;
|
|
case "osgb": uploadOsgb(unzipPath,modelFile) ;break;
|
|
case "osgb": uploadOsgb(unzipPath,modelFile) ;break;
|
|
default: break;
|
|
default: break;
|
|
}
|
|
}
|
|
- String url = "";
|
|
|
|
String extName= ".zip";
|
|
String extName= ".zip";
|
|
FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(modelFileFormat);
|
|
FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(modelFileFormat);
|
|
if(fileTypeEnum == null){
|
|
if(fileTypeEnum == null){
|
|
@@ -152,25 +155,40 @@ public class CommonServiceImpl implements ICommonService {
|
|
return ResultData.ok(commonUpload);
|
|
return ResultData.ok(commonUpload);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private String uploadB3dm(String unzipPath, File modelFile) {
|
|
|
|
+ String b3dmJsonPath = FileWriterUtil.checkB3dmTileset(modelFile);
|
|
|
|
+ if(b3dmJsonPath == null){
|
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_FILE_OBJ_ERROR);
|
|
|
|
+ }
|
|
|
|
+ String ossPath = b3dmJsonPath.replace(OssPath.localPath, "");
|
|
|
|
+ uploadOss(unzipPath,modelFile);
|
|
|
|
+ if(!fYunFileServiceInterface.fileExist(ossPath)){
|
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return ossUrlPrefix + ossPath;
|
|
|
|
+ }
|
|
|
|
+
|
|
private void uploadOsgb(String unzipPath, File modelFile) {
|
|
private void uploadOsgb(String unzipPath, File modelFile) {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private void uploadOss(String unzipPath,File modelFile) {
|
|
|
|
|
|
+ private String uploadOss(String unzipPath,File modelFile) {
|
|
String ossPath = unzipPath.replace(OssPath.localPath,"");
|
|
String ossPath = unzipPath.replace(OssPath.localPath,"");
|
|
String modelOssPath = modelFile.getPath().replace(OssPath.localPath, "");
|
|
String modelOssPath = modelFile.getPath().replace(OssPath.localPath, "");
|
|
ShellUtil.yunUpload(unzipPath,ossPath);
|
|
ShellUtil.yunUpload(unzipPath,ossPath);
|
|
if(!fYunFileServiceInterface.fileExist(modelOssPath)){
|
|
if(!fYunFileServiceInterface.fileExist(modelOssPath)){
|
|
throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
|
|
throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
|
|
}
|
|
}
|
|
|
|
+ return ossUrlPrefix + modelOssPath;
|
|
}
|
|
}
|
|
|
|
|
|
- private void uploadLasOrPly(File modelFile) {
|
|
|
|
|
|
+ private String uploadLasOrPly(File modelFile) {
|
|
File mntFile = OBJToGLBUtil.lasOrPlyToBin(modelFile);
|
|
File mntFile = OBJToGLBUtil.lasOrPlyToBin(modelFile);
|
|
String ossPath = mntFile.getPath().replace(OssPath.localPath,"");
|
|
String ossPath = mntFile.getPath().replace(OssPath.localPath,"");
|
|
ShellUtil.yunUpload(mntFile.getPath(),ossPath);
|
|
ShellUtil.yunUpload(mntFile.getPath(),ossPath);
|
|
if(!fYunFileServiceInterface.fileExist(ossPath+"/webcloud/cloud.js")){
|
|
if(!fYunFileServiceInterface.fileExist(ossPath+"/webcloud/cloud.js")){
|
|
throw new BusinessException(-1,"缺少cloud.js文件");
|
|
throw new BusinessException(-1,"缺少cloud.js文件");
|
|
}
|
|
}
|
|
|
|
+ return ossUrlPrefix + ossPath + "/webcloud";
|
|
}
|
|
}
|
|
}
|
|
}
|