|
@@ -0,0 +1,64 @@
|
|
|
+package com.fdkankan.contro.mq.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.contro.mq.service.ICommonService;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.model.utils.SceneUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class CommonServiceImpl implements ICommonService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void uploadBuildResultData(String num, String dataSource, String version) {
|
|
|
+
|
|
|
+ Map<String, String> uploadMap = new HashMap<>();
|
|
|
+
|
|
|
+ String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
|
|
|
+
|
|
|
+ //上传caches/images
|
|
|
+ String localCachesImagePath = dataSource + "/caches/images/";
|
|
|
+ String ossCachesImagePath = ossResultPath + "caches/images/";
|
|
|
+ //先清除旧的全景图
|
|
|
+ fYunFileServiceInterface.deleteFolder(ossCachesImagePath);
|
|
|
+ if(FileUtil.exist(localCachesImagePath)){
|
|
|
+ List<String> imagesList = FileUtil.listFileNames(localCachesImagePath);
|
|
|
+ if(CollUtil.isNotEmpty(imagesList)){
|
|
|
+ String visionPath = dataSource + "/results/vision.txt";
|
|
|
+ List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
|
|
|
+ imagesList.stream().forEach(fileName -> {
|
|
|
+ if (panoramaImageList.contains(fileName)) {
|
|
|
+ String srcPath = localCachesImagePath + fileName;
|
|
|
+ String ossPath = ossCachesImagePath + fileName;
|
|
|
+ uploadMap.put(localCachesImagePath, ossCachesImagePath);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传project.json
|
|
|
+ String localProjectJsonPath = dataSource + "/project.json";
|
|
|
+ String ossProjectJsonPath = ossResultPath + "project.json";
|
|
|
+ if(FileUtil.exist(localProjectJsonPath)){
|
|
|
+ uploadMap.put(localProjectJsonPath, ossProjectJsonPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ //开始上传
|
|
|
+ fYunFileServiceInterface.uploadMulFiles(uploadMap);
|
|
|
+ }
|
|
|
+}
|