|
@@ -13,6 +13,7 @@ import com.fdkankan.common.util.DateExtUtil;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.manage.constant.FileTypeEnum;
|
|
|
import com.fdkankan.manage.entity.CommonUpload;
|
|
|
+import com.fdkankan.manage.entity.Dict;
|
|
|
import com.fdkankan.manage.entity.DictFile;
|
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
|
import com.fdkankan.manage.service.ICommonService;
|
|
@@ -22,6 +23,7 @@ import java.util.*;
|
|
|
|
|
|
import com.fdkankan.manage.service.ICommonUploadService;
|
|
|
import com.fdkankan.manage.service.IDictFileService;
|
|
|
+import com.fdkankan.manage.service.IDictService;
|
|
|
import com.fdkankan.manage.util.FileWriterUtil;
|
|
|
import com.fdkankan.manage.util.OBJToGLBUtil;
|
|
|
import com.fdkankan.manage.util.ShellUtil;
|
|
@@ -85,6 +87,8 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
ICommonUploadService commonUploadService;
|
|
|
@Autowired
|
|
|
IDictFileService dictFileService;
|
|
|
+ @Autowired
|
|
|
+ IDictService dictService;
|
|
|
|
|
|
@Override
|
|
|
public ResultData uploadFileNew(MultipartFile file,Integer dictId) {
|
|
@@ -96,6 +100,18 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
String uuid = UUID.randomUUID().toString().replace("-","");
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
|
String extName = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase();
|
|
|
+
|
|
|
+ if(dictId != null){
|
|
|
+ Dict dict = dictService.getById(dictId);
|
|
|
+ if(dict == null ){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ if("animation".equals(dict.getUseType()) && !(extName.equalsIgnoreCase(".zip") || extName.equalsIgnoreCase(".glb"))){
|
|
|
+ throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
String ossPath = String.format(OssPath.MANAGE_MODEL_FILE_PATH, uuid + extName);
|
|
|
|
|
|
tempFile = new File(OssPath.localPath + ossPath);
|
|
@@ -141,6 +157,23 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
|
|
|
}
|
|
|
File modelFile = fileList.get(0);
|
|
|
+ String modelFileFormat = modelFile.getName().split("\\.")[1].toLowerCase();
|
|
|
+
|
|
|
+ FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(modelFileFormat);
|
|
|
+ if(fileTypeEnum == null){
|
|
|
+ throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(dictId != null){
|
|
|
+ Dict dict = dictService.getById(dictId);
|
|
|
+ if(dict == null ){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ if("animation".equals(dict.getUseType()) && !(modelFileFormat.equals("glb") || modelFileFormat.equals("obj"))){
|
|
|
+ throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if(FileWriterUtil.isChinese(modelFile.getName())){
|
|
|
throw new BusinessException(ResultCode.FILE_TYPE_ERROR23);
|
|
@@ -148,12 +181,12 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
if(FileWriterUtil.isChinese(modelFile.getPath())){
|
|
|
throw new BusinessException(ResultCode.FILE_TYPE_ERROR23);
|
|
|
}
|
|
|
- String modelFileFormat = modelFile.getName().split("\\.")[1].toLowerCase();
|
|
|
String url = null;
|
|
|
String resultFormat = modelFileFormat;
|
|
|
switch (modelFileFormat){
|
|
|
case "obj" : resultFormat = "glb";
|
|
|
url = uploadObjOss(unzipPath,modelFile);break;
|
|
|
+ case "glb" : url = uploadOss(unzipPath,modelFile);break;
|
|
|
case "laz" : url = uploadLazOss(unzipPath,modelFile); break;
|
|
|
case "shp" : url = uploadOss(unzipPath,modelFile); break;
|
|
|
case "b3dm" : url = uploadB3dm(unzipPath,modelFile); break;
|
|
@@ -163,10 +196,7 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
uploadOsgb(unzipPath,modelFile) ;break;
|
|
|
default: break;
|
|
|
}
|
|
|
- FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(modelFileFormat);
|
|
|
- if(fileTypeEnum == null){
|
|
|
- throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
|
|
|
- }
|
|
|
+
|
|
|
Integer status = StringUtils.isNotBlank(url) ?1:-1;
|
|
|
CommonUpload commonUpload = commonUploadService.add(oldName,url, String.valueOf(tempFile.length()),
|
|
|
null, fileTypeEnum, modelFileFormat,resultFormat,status,unzipPath,dictId);
|