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 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 imagesList = FileUtil.listFileNames(localCachesImagePath); if(CollUtil.isNotEmpty(imagesList)){ String ossVisionPath = String.format(UploadFilePath.IMG_VIEW_PATH, num) + "vision.txt"; String visionPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "vision.txt"; fYunFileServiceInterface.downloadFile(ossVisionPath, visionPath); List panoramaImageList = SceneUtil.getPanoramaImageList(FileUtil.readUtf8String(visionPath)); imagesList.stream().forEach(fileName -> { if (panoramaImageList.contains(fileName)) { String srcPath = localCachesImagePath + fileName; String ossPath = ossCachesImagePath + fileName; uploadMap.put(srcPath, ossPath); } }); } } //上传project.json String localProjectJsonPath = dataSource + "/project.json"; String ossProjectJsonPath = ossResultPath + "project.json"; if(FileUtil.exist(localProjectJsonPath)){ uploadMap.put(localProjectJsonPath, ossProjectJsonPath); } //上传data.json String localDataJsonPath = dataSource + "/data.json"; String ossDataJsonPath = ossResultPath + "data.json"; if(FileUtil.exist(localDataJsonPath)){ uploadMap.put(localDataJsonPath, ossDataJsonPath); } //开始上传 fYunFileServiceInterface.uploadMulFiles(uploadMap); } }