|
@@ -24,6 +24,7 @@ import com.fdkankan.fusion.service.IFusionNumService;
|
|
|
import com.fdkankan.fusion.service.IModelService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -92,42 +93,8 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
model.setUserName(username);
|
|
|
this.save(model);
|
|
|
redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"0");
|
|
|
- fileName = UUID.randomUUID().toString().replace("-","") +".zip";
|
|
|
- File newObjFile = null;
|
|
|
- File objPathFile = null;
|
|
|
- String objPath = String.format(FilePath.OBJ_LOCAL_PATH,environment , "modelId_"+model.getModelId()) ;
|
|
|
|
|
|
- newObjFile = new File(objPath +"/" + fileName);
|
|
|
- if(!newObjFile.getParentFile().exists()){
|
|
|
- newObjFile.mkdirs();
|
|
|
- }
|
|
|
- file.transferTo(newObjFile);
|
|
|
- if(fileName.toLowerCase().endsWith(".zip")){
|
|
|
- ShellUtil.unZip(newObjFile.getPath(),objPath);
|
|
|
- }
|
|
|
- objPathFile = new File(objPath );
|
|
|
- if(!objPathFile.isDirectory()){
|
|
|
- setCreateStatus(model,-1);
|
|
|
- throw new BusinessException(ResultCode.UPLOAD_FILE_TYPE_ERROR);
|
|
|
- }
|
|
|
- List<File> fileList = new ArrayList<>();
|
|
|
- FileWriterUtil.getCanRunList(fileList,objPathFile);
|
|
|
-
|
|
|
- if(fileList.size() != 1){
|
|
|
- setCreateStatus(model,-1);
|
|
|
- throw new BusinessException(ResultCode.UPLOAD_FILE_MSG_ERROR);
|
|
|
- }
|
|
|
- File file1 = fileList.get(0);
|
|
|
- if(file1 == null){
|
|
|
- setCreateStatus(model,-1);
|
|
|
- throw new BusinessException(ResultCode.UPLOAD_FILE_OBJ_ERROR);
|
|
|
- }
|
|
|
- if(com.fdkankan.fusion.common.util.StringUtils.isChinese(file1.getName())){
|
|
|
- setCreateStatus(model,-1);
|
|
|
- throw new BusinessException(ResultCode.UPLOAD_FILE_CHINA_NAME);
|
|
|
- }
|
|
|
- redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"20");
|
|
|
- runThread(file1,model,newObjFile,objPathFile,this);
|
|
|
+ runThread(file,model,this);
|
|
|
return model;
|
|
|
}
|
|
|
|
|
@@ -145,10 +112,47 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void runThread(File file1,Model model,File newObjFile,File objPathFile,IModelService modelService){
|
|
|
+ public void runThread(MultipartFile file,Model model,IModelService modelService){
|
|
|
new Thread(new Runnable() {
|
|
|
+ @SneakyThrows
|
|
|
@Override
|
|
|
public void run() {
|
|
|
+ String fileName = UUID.randomUUID().toString().replace("-","") +".zip";
|
|
|
+ File newObjFile = null;
|
|
|
+ File objPathFile = null;
|
|
|
+ String objPath = String.format(FilePath.OBJ_LOCAL_PATH,environment , "modelId_"+model.getModelId()) ;
|
|
|
+
|
|
|
+ newObjFile = new File(objPath +"/" + fileName);
|
|
|
+ if(!newObjFile.getParentFile().exists()){
|
|
|
+ newObjFile.mkdirs();
|
|
|
+ }
|
|
|
+ file.transferTo(newObjFile);
|
|
|
+ if(fileName.toLowerCase().endsWith(".zip")){
|
|
|
+ ShellUtil.unZip(newObjFile.getPath(),objPath);
|
|
|
+ }
|
|
|
+ objPathFile = new File(objPath );
|
|
|
+ if(!objPathFile.isDirectory()){
|
|
|
+ setCreateStatus(model,-1);
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_FILE_TYPE_ERROR);
|
|
|
+ }
|
|
|
+ List<File> fileList = new ArrayList<>();
|
|
|
+ FileWriterUtil.getCanRunList(fileList,objPathFile);
|
|
|
+
|
|
|
+ if(fileList.size() <=0){
|
|
|
+ setCreateStatus(model,-1);
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_FILE_MSG_ERROR);
|
|
|
+ }
|
|
|
+ File file1 = fileList.get(0);
|
|
|
+ if(file1 == null){
|
|
|
+ setCreateStatus(model,-1);
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_FILE_OBJ_ERROR);
|
|
|
+ }
|
|
|
+ if(com.fdkankan.fusion.common.util.StringUtils.isChinese(file1.getName())){
|
|
|
+ setCreateStatus(model,-1);
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_FILE_CHINA_NAME);
|
|
|
+ }
|
|
|
+ redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"20");
|
|
|
+
|
|
|
File mntFile = null;
|
|
|
try {
|
|
|
String glbOssPath = String.format(FilePath.GLB_OSS_PATH,environment, model.getModelId());
|