|
@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.fdkankan.common.constant.*;
|
|
import com.fdkankan.common.constant.*;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.response.ResultData;
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
|
+import com.fdkankan.common.util.FileUtil;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.fyun.constant.StorageType;
|
|
import com.fdkankan.fyun.constant.StorageType;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
@@ -35,6 +36,8 @@ import com.fdkankan.scene.service.ISceneProService;
|
|
import com.fdkankan.scene.vo.*;
|
|
import com.fdkankan.scene.vo.*;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.errorprone.annotations.Var;
|
|
import com.google.errorprone.annotations.Var;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -49,6 +52,7 @@ import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.io.InputStreamReader;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -421,4 +425,60 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
.eq(SceneEditInfo::getId, id));
|
|
.eq(SceneEditInfo::getId, id));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<String> uploadPanorama(String num, MultipartFile file) throws Exception {
|
|
|
|
+
|
|
|
|
+ //压缩包保存到本地
|
|
|
|
+// String path = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, param.getNum());
|
|
|
|
+ String path = "F:\\mnt\\4Dkankan\\scene\\t-ieXdyGl6Md\\caches\\images\\";
|
|
|
|
+ String targetFilePath = path + File.separator + file.getOriginalFilename();
|
|
|
|
+ File targetFile = new File(targetFilePath);
|
|
|
|
+ if(!targetFile.getParentFile().exists()){
|
|
|
|
+ targetFile.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ file.transferTo(targetFile);
|
|
|
|
+
|
|
|
|
+ //解压zip包
|
|
|
|
+ FileUtil.unZip(targetFilePath, path);
|
|
|
|
+ //删除压缩包
|
|
|
|
+ FileUtil.delFile(targetFilePath);
|
|
|
|
+
|
|
|
|
+ //获取解压后的文件列表
|
|
|
|
+ List<String> uploadFileList = FileUtil.getFileList(path);
|
|
|
|
+ if(CollUtil.isEmpty(uploadFileList)){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //列出caches/images中的文件列表
|
|
|
|
+ String imgCachePath = String.format(UploadFilePath.IMG_CACHES_PATH, num);
|
|
|
|
+ List<String> keyList = uploadToOssUtil.listKeys(imgCachePath);
|
|
|
|
+
|
|
|
|
+ //比对图片列表,不存在的要返回名称集合
|
|
|
|
+ List<String> notExistFileList = uploadFileList.stream().filter(filePath -> {
|
|
|
|
+ filePath = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
|
|
|
+ for (String key : keyList) {
|
|
|
|
+ key = key.substring(key.lastIndexOf("/") + 1);
|
|
|
|
+ if (filePath.equals(key)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }).map(filePath -> {
|
|
|
|
+ return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //删除云caches/images
|
|
|
|
+ uploadToOssUtil.deleteFile(imgCachePath);
|
|
|
|
+
|
|
|
|
+ //上传
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ uploadFileList.stream().forEach(filePath->{
|
|
|
|
+ map.put(filePath, filePath.replace(path, imgCachePath));
|
|
|
|
+ });
|
|
|
|
+ uploadToOssUtil.uploadMulFiles(map);
|
|
|
|
+
|
|
|
|
+ return notExistFileList;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|