|
@@ -76,8 +76,8 @@ public class InnerApiServiceImpl implements IInnerApiService {
|
|
private RedisLockUtil redisLockUtil;
|
|
private RedisLockUtil redisLockUtil;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResultData uploadMatterproData(String sceneName, String userName, String floor, String sceneKind, MultipartFile file) throws Exception {
|
|
|
|
- if(file == null || file.getSize() <=0){
|
|
|
|
|
|
+ public ResultData uploadMatterproData(String sceneName, String userName, String floor, String sceneKind, String packagePath, MultipartFile file) throws Exception {
|
|
|
|
+ if((file == null || file.getSize() <=0) && (StrUtil.isEmpty(packagePath) || !fYunFileService.fileExist(packagePath))){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -95,7 +95,7 @@ public class InnerApiServiceImpl implements IInnerApiService {
|
|
scene3dNumMatterProService.updateById(numEntity);
|
|
scene3dNumMatterProService.updateById(numEntity);
|
|
redisLockUtil.unlockLua(RedisLockKey.LOCK_GET_MATTERPRO_NUM);
|
|
redisLockUtil.unlockLua(RedisLockKey.LOCK_GET_MATTERPRO_NUM);
|
|
|
|
|
|
- String dataSource = ConstantFilePath.BUILD_MODEL_PATH + UUID.randomUUID() + File.separator ;
|
|
|
|
|
|
+ String dataSource = ConstantFilePath.BUILD_MODEL_PATH + UUID.randomUUID() + File.separator;
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
result.put("num", sceneNum);
|
|
result.put("num", sceneNum);
|
|
result.put("dataSource", dataSource);
|
|
result.put("dataSource", dataSource);
|
|
@@ -103,19 +103,28 @@ public class InnerApiServiceImpl implements IInnerApiService {
|
|
String key = String.format(RedisKey.SCENE_UPLOAD_MATTERPRO_NUM, sceneNum);
|
|
String key = String.format(RedisKey.SCENE_UPLOAD_MATTERPRO_NUM, sceneNum);
|
|
redisUtil.set(key, result.toJSONString(), RedisKey.CAMERA_EXPIRE_7_TIME);
|
|
redisUtil.set(key, result.toJSONString(), RedisKey.CAMERA_EXPIRE_7_TIME);
|
|
|
|
|
|
- File data = new File(dataSource + file.getOriginalFilename());
|
|
|
|
- if(!data.getParentFile().exists()){
|
|
|
|
- data.getParentFile().mkdirs();
|
|
|
|
|
|
+ String fileName = null;
|
|
|
|
+ if(StrUtil.isNotEmpty(packagePath)){
|
|
|
|
+ fileName = packagePath.substring(packagePath.lastIndexOf("/"));
|
|
|
|
+ fYunFileService.downloadFile(packagePath, dataSource.concat(fileName));
|
|
|
|
+ }else{
|
|
|
|
+ fileName = file.getOriginalFilename();
|
|
|
|
+ File data = new File(dataSource + fileName);
|
|
|
|
+ if(!data.getParentFile().exists()){
|
|
|
|
+ data.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ file.transferTo(data);
|
|
}
|
|
}
|
|
- file.transferTo(data);
|
|
|
|
|
|
|
|
|
|
+ String finalFileName = fileName;
|
|
CompletableFuture.runAsync(() -> {
|
|
CompletableFuture.runAsync(() -> {
|
|
try {
|
|
try {
|
|
- if(file.getOriginalFilename().toLowerCase().endsWith(".zip")){
|
|
|
|
- CreateObjUtil.unZip(dataSource + file.getOriginalFilename(), dataSource);
|
|
|
|
|
|
+ String ext = FileUtil.extName(finalFileName);
|
|
|
|
+ if(ext.toLowerCase().endsWith("zip")){
|
|
|
|
+ CreateObjUtil.unZip(dataSource + finalFileName, dataSource);
|
|
}
|
|
}
|
|
- if(file.getOriginalFilename().toLowerCase().endsWith(".rar")){
|
|
|
|
- CreateObjUtil.unRarWithPath(dataSource + file.getOriginalFilename(), dataSource);
|
|
|
|
|
|
+ if(ext.toLowerCase().endsWith("rar")){
|
|
|
|
+ CreateObjUtil.unRarWithPath(dataSource + finalFileName, dataSource);
|
|
// log.info("解压rar开始");
|
|
// log.info("解压rar开始");
|
|
// String command = "unrar x " + dataSource + file.getOriginalFilename() + " " + dataSource;
|
|
// String command = "unrar x " + dataSource + file.getOriginalFilename() + " " + dataSource;
|
|
// RuntimeUtil.exec(command);
|
|
// RuntimeUtil.exec(command);
|
|
@@ -125,7 +134,7 @@ public class InnerApiServiceImpl implements IInnerApiService {
|
|
Thread.sleep(2000L);
|
|
Thread.sleep(2000L);
|
|
|
|
|
|
//删除压缩包
|
|
//删除压缩包
|
|
- new File(dataSource + file.getOriginalFilename()).delete();
|
|
|
|
|
|
+// new File(dataSource + file.getOriginalFilename()).delete();
|
|
|
|
|
|
List<String> fileList = new ArrayList<>();
|
|
List<String> fileList = new ArrayList<>();
|
|
FileUtils.readfilePath(dataSource, fileList);
|
|
FileUtils.readfilePath(dataSource, fileList);
|