|
@@ -21,6 +21,7 @@ import com.fdkankan.contro.constant.UserEditDataType;
|
|
|
import com.fdkankan.contro.entity.*;
|
|
|
import com.fdkankan.contro.mq.service.IBuildSceneService;
|
|
|
import com.fdkankan.contro.service.*;
|
|
|
+import com.fdkankan.contro.util.HttpUtilExt;
|
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
|
import com.fdkankan.fyun.constant.FYunTypeEnum;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
@@ -159,10 +160,15 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
boolean success = false;
|
|
|
String num = message.getSceneNum();
|
|
|
String batchId = (String) message.getExt().get("batchId");
|
|
|
+ String threeCamType = (String) message.getExt().get("threeCamType");
|
|
|
try {
|
|
|
|
|
|
//如果场景原始资源上传批次id不为空,则需要下载批次文件上传到oss目录
|
|
|
- this.downloadOrigFile(batchId, message.getPath());
|
|
|
+ if(StrUtil.isNotEmpty(threeCamType) && "yzl".equals(threeCamType)){
|
|
|
+ this.downloadOrigFile4Yzl(batchId, message.getPath());
|
|
|
+ }else{
|
|
|
+ this.downloadOrigFile(batchId, message.getPath());
|
|
|
+ }
|
|
|
|
|
|
//重新计算时需要删除文件夹,否知使用缓存
|
|
|
if(new File(message.getPath() + File.separator + "results").exists()){
|
|
@@ -272,6 +278,50 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void downloadOrigFile4Yzl(String batchId, String dataSource){
|
|
|
+ if(StrUtil.isEmpty(batchId)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ OrigFileUpload sceneUpData = origFileUploadService.getByBatchIdAndFileName(batchId, "scene_up_data.txt");
|
|
|
+ String sceneUpDataPath = dataSource + "/" + "scene_up_data.txt";
|
|
|
+ HttpUtilExt.downloadFileAndCheck(sceneUpData.getFileUrl(), sceneUpDataPath, 60000);
|
|
|
+ String sceneUpDataStr = FileUtil.readUtf8String(sceneUpDataPath);
|
|
|
+ JSONArray fileJsonArray = JSON.parseArray(sceneUpDataStr);
|
|
|
+ Map<String, String> fileMap = fileJsonArray.stream().collect(Collectors.toMap(v -> ((JSONObject) v).getString("fileName"), v -> ((JSONObject) v).getString("filePath")));
|
|
|
+
|
|
|
+ List<OrigFileUpload> fileList = origFileUploadService.getByBatchId(batchId);
|
|
|
+ if(CollUtil.isEmpty(fileList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String homePath = "/oss/4dkankan/" + SceneUtil.getHomePath(dataSource);
|
|
|
+
|
|
|
+
|
|
|
+ for (OrigFileUpload origFileUpload : fileList) {
|
|
|
+ String relativeFilePath = fileMap.get(origFileUpload.getFileName());
|
|
|
+ if(StrUtil.isEmpty(relativeFilePath)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int times = 0;
|
|
|
+ String filePath = homePath.concat(relativeFilePath);
|
|
|
+ do{
|
|
|
+ try {
|
|
|
+ ++times;
|
|
|
+ HttpUtil.downloadFile(origFileUpload.getFileUrl(), new File(filePath), 10 * 60 * 1000);
|
|
|
+ if(FileUtil.exist(filePath)){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("原始文件第{}次下载失败,fileUrl:{}, filePath:{}", origFileUpload.getFileUrl(), filePath);
|
|
|
+ }
|
|
|
+ }while (times < 4);
|
|
|
+
|
|
|
+ if(!FileUtil.exist(filePath)){
|
|
|
+ throw new RuntimeException("原始文件下载失败,fileUrl:" + origFileUpload.getFileUrl() + ", filePath:" + filePath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private String getOssPath(String path) {
|
|
|
String ossPath = ConstantFilePath.OSS_PREFIX
|
|
|
+ path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|