|
@@ -7,8 +7,8 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.amazonaws.services.elasticsearch.model.UpgradeStatus;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.fasterxml.jackson.databind.annotation.JsonAppend.Prop;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
|
import com.fdkankan.common.constant.UploadFilePath;
|
|
@@ -43,6 +43,10 @@ import com.fdkankan.repair.service.ISceneProService;
|
|
|
import com.fdkankan.repair.service.ISceneRepairLogService;
|
|
|
import com.fdkankan.repair.service.ISceneUpgradeToV4Service;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
@@ -50,6 +54,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.Set;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -110,7 +115,7 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
};
|
|
|
|
|
|
@Override
|
|
|
- public void upgrade(long sceneProId){
|
|
|
+ public void upgrade(long sceneProId) throws Exception{
|
|
|
|
|
|
ScenePro scenePro = sceneProService.getById(sceneProId);
|
|
|
//线程开始,正在执行线程数+1
|
|
@@ -297,13 +302,57 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
}
|
|
|
|
|
|
//完成数据库操作更新进度条为10
|
|
|
- this.updateProgress(num, 10, ProgressStatus.SUCESS_DB.code());
|
|
|
+ this.updateProgress(num, 10, ProgressStatus.DO_DB.code());
|
|
|
|
|
|
//oss文件拷贝
|
|
|
- uploadToOssUtil.copyFiles(dataPath, dataViewPath);
|
|
|
- uploadToOssUtil.copyFiles(imagePath, imageViewPath);
|
|
|
- uploadToOssUtil.copyFiles(videoPath, videoViewPath);
|
|
|
- uploadToOssUtil.copyFiles(voicePath, voiceViewPath);
|
|
|
+ AtomicInteger count = new AtomicInteger(0);
|
|
|
+ AtomicInteger completeCnt = new AtomicInteger(0);
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ List<String> dataKeys = uploadToOssUtil.listKeys(dataPath);
|
|
|
+ List<String> imageKeys = uploadToOssUtil.listKeys(imagePath);
|
|
|
+ List<String> videoKeys = uploadToOssUtil.listKeys(videoPath);
|
|
|
+ List<String> voiceKeys = uploadToOssUtil.listKeys(voicePath);
|
|
|
+ if(CollUtil.isNotEmpty(dataKeys))
|
|
|
+ list.addAll(dataKeys);
|
|
|
+ count.addAndGet(dataKeys.size());
|
|
|
+ if(CollUtil.isNotEmpty(imageKeys))
|
|
|
+ list.addAll(imageKeys);
|
|
|
+ count.addAndGet(imageKeys.size());
|
|
|
+ if(CollUtil.isNotEmpty(videoKeys))
|
|
|
+ list.addAll(videoKeys);
|
|
|
+ count.addAndGet(videoKeys.size());
|
|
|
+ if(CollUtil.isNotEmpty(voiceKeys))
|
|
|
+ list.addAll(voiceKeys);
|
|
|
+ count.addAndGet(voiceKeys.size());
|
|
|
+ if(CollUtil.isNotEmpty(dataKeys)){
|
|
|
+ list.parallelStream().forEach(key->{
|
|
|
+ try {
|
|
|
+ String targetKey = null;
|
|
|
+ if(key.contains(dataPath)){
|
|
|
+ targetKey = key.replace(dataPath, dataViewPath);
|
|
|
+ }
|
|
|
+ if(key.contains(imagePath)){
|
|
|
+ targetKey = key.replace(imagePath, imageViewPath);
|
|
|
+ }
|
|
|
+ if(key.contains(videoPath)){
|
|
|
+ targetKey = key.replace(videoPath, videoViewPath);
|
|
|
+ }
|
|
|
+ uploadToOssUtil.copyObject(key, targetKey);
|
|
|
+ this.updateProgress(num,
|
|
|
+ 10 +
|
|
|
+ (new BigDecimal(completeCnt.incrementAndGet())
|
|
|
+ .divide(new BigDecimal(count.get()), 6, BigDecimal.ROUND_HALF_UP)
|
|
|
+ .multiply(new BigDecimal(0.7))
|
|
|
+ .multiply(new BigDecimal(100))
|
|
|
+ .setScale(0, RoundingMode.UP)
|
|
|
+ .intValue()),
|
|
|
+ ProgressStatus.DO_OSS.code()
|
|
|
+ );
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("文件拷贝出错,key:{}", key);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
//全景图上传、球幕视频
|
|
|
Map<String, String> map = new HashMap<>();
|
|
@@ -316,7 +365,7 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
// if(CollUtil.isNotEmpty(videosList)){
|
|
|
// videosList.stream().forEach(str -> map.put(str, str.replace(path, sceneNumPAth)));
|
|
|
// }
|
|
|
-// uploadToOssUtil.uploadMulFiles(map);
|
|
|
+ uploadToOssUtil.uploadMulFiles(map);
|
|
|
|
|
|
//拷贝模型文件到用户编辑目录
|
|
|
String editImagesPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
@@ -331,6 +380,9 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
uploadToOssUtil.copyFiles(entry.getValue(), entry.getKey());
|
|
|
}
|
|
|
|
|
|
+ //完成数据库操作更新进度条为10
|
|
|
+ this.updateProgress(num, 90, ProgressStatus.DO_OSS.code());
|
|
|
+
|
|
|
//生成二维码
|
|
|
String sceneUrl = mainUrl + "/" + sceneProNewUrl;
|
|
|
String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/" + num + ".png";
|
|
@@ -421,6 +473,8 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
sceneRepairLog.setConsumTime(consumTime);
|
|
|
sceneRepairLogService.updateById(sceneRepairLog);
|
|
|
|
|
|
+ this.updateProgress(num, 100, ProgressStatus.SUCCESS.code());
|
|
|
+
|
|
|
// TODO: 2022/4/22 调用v3接口回写数据
|
|
|
|
|
|
|