|
@@ -7,23 +7,27 @@ import cn.hutool.core.date.TimeInterval;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
+import cn.hutool.http.ContentType;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
-import com.fdkankan.common.constant.CommonStatus;
|
|
|
-import com.fdkankan.common.constant.ErrorCode;
|
|
|
-import com.fdkankan.common.constant.SceneKind;
|
|
|
+import com.dtflys.forest.Forest;
|
|
|
+import com.dtflys.forest.config.ForestConfiguration;
|
|
|
+import com.fdkankan.common.constant.*;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.download.bean.*;
|
|
|
import com.fdkankan.download.constant.CommonConstant;
|
|
|
-import com.fdkankan.download.bean.ImageType;
|
|
|
-import com.fdkankan.download.bean.ImageTypeDetail;
|
|
|
-import com.fdkankan.download.bean.SceneEditControlsBean;
|
|
|
-import com.fdkankan.download.bean.SceneViewInfoBean;
|
|
|
import com.fdkankan.download.entity.ScenePlus;
|
|
|
import com.fdkankan.download.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.download.httpclient.HttpClient;
|
|
|
import com.fdkankan.download.service.IDownloadService;
|
|
|
import com.fdkankan.download.service.IScenePlusExtService;
|
|
|
import com.fdkankan.download.service.IScenePlusService;
|
|
@@ -41,6 +45,7 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
@@ -62,6 +67,10 @@ import javax.annotation.Resource;
|
|
|
@Service
|
|
|
public class DownloadServiceImpl implements IDownloadService {
|
|
|
|
|
|
+ private static final String[] prefixArr4v3 = new String[]{
|
|
|
+ "data/data%s/", "images/images%s/", "voice/voice%s/", "video/video%s/"
|
|
|
+ };
|
|
|
+
|
|
|
// private static final List<ImageType> imageTypes = Lists.newArrayList();
|
|
|
// static{
|
|
|
// imageTypes.add(ImageType.builder().name("4k_face").size("4096").ranges(new String[]{"0", "511", "1023", "1535", "2047","2559","3071","3583"}).build());
|
|
@@ -102,6 +111,8 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
private String zipOssFormat;
|
|
|
// @Value("${cutImgType}")
|
|
|
// private String cutImgType;
|
|
|
+ @Value("${url.v3.getInfo}")
|
|
|
+ private String v3GetInfoUrl;
|
|
|
|
|
|
@Autowired
|
|
|
private IScenePlusService scenePlusService;
|
|
@@ -166,7 +177,7 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
log.info("打包固定文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
|
|
|
//oss文件写入
|
|
|
- this.zipOssFiles(num, resolution, imagesVersion, cacheKeys, "v4");
|
|
|
+ this.zipOssFiles(num, resolution, true, SceneVersionType.V4.code());
|
|
|
log.info("打包oss文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
|
|
|
//重新写入scene.json(去掉密码访问设置)
|
|
@@ -193,6 +204,193 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void downloadWithoutCutImg(String num) throws Exception {
|
|
|
+
|
|
|
+ //zip包路径
|
|
|
+ try {
|
|
|
+ TimeInterval timer = DateUtil.timer();
|
|
|
+
|
|
|
+ SceneViewInfoBean sceneViewInfo = this.getSceneJson(num);
|
|
|
+ String resolution = sceneViewInfo.getSceneResolution();
|
|
|
+ //国际版存在已经切好图的情况,下载时不需要再切图,只需要把文件直接下载下来打包就可以了
|
|
|
+ if(SceneKind.FACE.code().equals(sceneViewInfo.getSceneKind())){
|
|
|
+ resolution = "notNeadCut";
|
|
|
+ }
|
|
|
+
|
|
|
+ //固定文件写入
|
|
|
+ this.zipLocalFiles(num, "v4");
|
|
|
+ log.info("打包固定文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
+
|
|
|
+ //oss文件写入
|
|
|
+ this.zipOssFiles(num, resolution, false, SceneVersionType.V4.code());
|
|
|
+ log.info("打包oss文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
+
|
|
|
+ //重新写入scene.json(去掉密码访问设置)
|
|
|
+ this.zipSceneJson(num, sceneViewInfo);
|
|
|
+
|
|
|
+ //写入启动命令
|
|
|
+ this.zipBat(num, "v4");
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ //更新进度为下载失败
|
|
|
+ log.error("场景下载失败,num:{}", num, e);
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void downloadMeshScene(String num) throws Exception {
|
|
|
+ //zip包路径
|
|
|
+ try {
|
|
|
+ TimeInterval timer = DateUtil.timer();
|
|
|
+
|
|
|
+ SceneViewInfoBean sceneViewInfo = this.getSceneJson(num);
|
|
|
+ String resolution = sceneViewInfo.getSceneResolution();
|
|
|
+ //国际版存在已经切好图的情况,下载时不需要再切图,只需要把文件直接下载下来打包就可以了
|
|
|
+ if(SceneKind.FACE.code().equals(sceneViewInfo.getSceneKind())){
|
|
|
+ resolution = "notNeadCut";
|
|
|
+ }
|
|
|
+
|
|
|
+ //固定文件写入
|
|
|
+ this.zipLocalFiles(num, "v4");
|
|
|
+ log.info("打包固定文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
+
|
|
|
+ //oss文件写入
|
|
|
+ this.zipOssFiles(num, resolution, true, SceneVersionType.V4.code());
|
|
|
+ log.info("打包oss文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
+
|
|
|
+ //重新写入scene.json(去掉密码访问设置)
|
|
|
+ this.zipSceneJson(num, sceneViewInfo);
|
|
|
+
|
|
|
+ //写入启动命令
|
|
|
+ this.zipBat(num, "v4");
|
|
|
+
|
|
|
+ this.zip(String.format(this.sourceLocal, num, ""), String.format(zipLocalFormat, num, num));
|
|
|
+
|
|
|
+// String uploadPath = String.format(this.zipOssFormat, num);
|
|
|
+// fYunFileService.uploadFile(String.format(zipLocalFormat, num, num), uploadPath);
|
|
|
+
|
|
|
+ log.info("总耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ //更新进度为下载失败
|
|
|
+ log.error("场景下载失败,num:{}", num, e);
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void downloadMeshSceneV3(String num) throws Exception {
|
|
|
+
|
|
|
+ try {
|
|
|
+ TimeInterval timer = DateUtil.timer();
|
|
|
+
|
|
|
+ //删除资源目录
|
|
|
+ FileUtil.del(String.format(this.sourceLocal, num, ""));
|
|
|
+
|
|
|
+ //定义压缩包d
|
|
|
+ String resolution = "2k";
|
|
|
+ cn.hutool.json.JSONObject getInfoJson = this.getInfo(num);
|
|
|
+ // 转台、激光显示4k图片
|
|
|
+ if (getInfoJson.getInt("sceneSource") == 3 || getInfoJson.getInt("sceneSource") == 4) {
|
|
|
+ resolution = "4k";
|
|
|
+ }
|
|
|
+
|
|
|
+ //固定文件写入
|
|
|
+ timer.intervalRestart();
|
|
|
+ this.zipLocalFiles(num, "v3");
|
|
|
+ log.info("打包固定文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
+
|
|
|
+ //oss文件写入
|
|
|
+ this.zipOssFiles(num, resolution, true, SceneVersionType.V3.code());
|
|
|
+ log.info("打包oss文件耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
+
|
|
|
+ //重新写入scene.json(去掉密码访问设置)
|
|
|
+ this.zipGetInfoJson(num, getInfoJson);
|
|
|
+
|
|
|
+ //写入启动命令
|
|
|
+ this.zipBat(num, "v3");
|
|
|
+
|
|
|
+ //打压缩包
|
|
|
+
|
|
|
+ this.zip(String.format(this.sourceLocal, num, ""), String.format(zipLocalFormat, num, num));
|
|
|
+
|
|
|
+ log.info("总耗时, num:{}, time:{}", num, timer.intervalRestart());
|
|
|
+
|
|
|
+ //上传压缩包
|
|
|
+ String uploadPath = String.format(this.zipOssFormat, num);
|
|
|
+ fYunFileService.uploadFile(String.format(zipLocalFormat, num, num), uploadPath);
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ //更新进度为下载失败
|
|
|
+ log.error("场景下载失败,num:{}", num, e);
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void downloadLaserScene(String num) throws Exception {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void zipGetInfoJson(String num, cn.hutool.json.JSONObject getInfo) throws Exception{
|
|
|
+
|
|
|
+ //访问密码置0
|
|
|
+ String getInfoKey = String.format("data/data%s/", num) + "getInfo.json";
|
|
|
+ String getInfoStr = getInfo.toString().replace(this.publicUrl, "");
|
|
|
+ FileUtil.writeUtf8String(getInfoStr, String.format(this.sourceLocal, num, this.wwwroot + getInfoKey));
|
|
|
+ }
|
|
|
+ private cn.hutool.json.JSONObject getInfo(String num){
|
|
|
+ String url = String.format(v3GetInfoUrl, num);
|
|
|
+ String getInfoResult = HttpUtil.get(url);
|
|
|
+ cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(getInfoResult);
|
|
|
+ if(Objects.isNull(jsonObject)
|
|
|
+ || !ServerCode.SUCCESS.code().equals(jsonObject.getInt("code"))
|
|
|
+ || Objects.isNull(jsonObject.getJSONObject("data"))){
|
|
|
+ throw new RuntimeException("获取getInfo信息失败,url=" + url);
|
|
|
+ }
|
|
|
+ cn.hutool.json.JSONObject data = jsonObject.getJSONObject("data");
|
|
|
+ if (data.getInt("sceneSource") != 2)
|
|
|
+ {
|
|
|
+ data.set("sceneScheme", 3);
|
|
|
+ }
|
|
|
+ data.set("needKey", 0);
|
|
|
+ data.set("sceneKey", "");
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, List<String>> getAllFilesV3(String num, String v3localPath, String bucket) throws Exception{
|
|
|
+ //列出oss所有文件路径
|
|
|
+ List<String> ossFilePaths = new ArrayList<>();
|
|
|
+ for (String prefix : prefixArr4v3) {
|
|
|
+ prefix = String.format(prefix, num);
|
|
|
+ List<String> keys = fYunFileService.listRemoteFiles(bucket, prefix);
|
|
|
+ if(CollUtil.isEmpty(keys)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(FYunTypeEnum.AWS.code().equals(this.uploadType)){
|
|
|
+ keys = keys.stream().filter(key->{
|
|
|
+ if(key.contains("x-oss-process")){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ ossFilePaths.addAll(keys);
|
|
|
+ }
|
|
|
+
|
|
|
+ //列出v3local所有文件路径
|
|
|
+ File file = new File(v3localPath);
|
|
|
+ List<String> localFilePaths = FileUtils.list(file);
|
|
|
+
|
|
|
+ HashMap<String, List<String>> map = new HashMap<>();
|
|
|
+ map.put("ossFilePaths", ossFilePaths);
|
|
|
+ map.put("localFilePaths", localFilePaths);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
private void zipBat(String num, String version) throws Exception{
|
|
|
String batContent = String.format(this.exeContent, num);
|
|
|
if("v3".equals(version)){
|
|
@@ -210,15 +408,41 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
FileUtil.writeUtf8String(JSON.toJSONString(sceneViewInfo, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero), String.format(this.sourceLocal, num, this.wwwroot + sceneJsonPath));
|
|
|
}
|
|
|
|
|
|
- private void zipOssFiles(String num, String resolution, int imagesVersion, Set<String> cacheKeys, String version) throws Exception{
|
|
|
+ private void zipOssFiles(String num, String resolution, boolean cutImg, String version) throws Exception{
|
|
|
|
|
|
// fYunFileService.downloadFileByCommand(String.format(sourceLocal, num, this.wwwroot).concat(String.format(UploadFilePath.VIEW_PATH, num)), String.format(UploadFilePath.VIEW_PATH, num));
|
|
|
// FileUtil.del(String.format(sourceLocal, num, this.wwwroot).concat(String.format(UploadFilePath.IMG_VIEW_PATH, num)).concat("tiles"));
|
|
|
- List<String> strings = fYunFileService.listRemoteFiles(String.format(UploadFilePath.VIEW_PATH, num));
|
|
|
+ List<String> strings = new ArrayList<>();
|
|
|
+ if(version.equals(SceneVersionType.V4.code())){
|
|
|
+ strings = fYunFileService.listRemoteFiles(String.format(UploadFilePath.VIEW_PATH, num));
|
|
|
+ }
|
|
|
+ if(version.equals(SceneVersionType.V3.code())){
|
|
|
+ List<String> dataList = fYunFileService.listRemoteFiles(String.format(prefixArr4v3[0], num));
|
|
|
+ if(CollUtil.isNotEmpty(dataList)){
|
|
|
+ strings.addAll(dataList);
|
|
|
+ }
|
|
|
+ List<String> imgList = fYunFileService.listRemoteFiles(String.format(prefixArr4v3[1], num));
|
|
|
+ if(CollUtil.isNotEmpty(imgList)){
|
|
|
+ strings.addAll(imgList);
|
|
|
+ }
|
|
|
+ List<String> voiceList = fYunFileService.listRemoteFiles(String.format(prefixArr4v3[2], num));
|
|
|
+ if(CollUtil.isNotEmpty(voiceList)){
|
|
|
+ strings.addAll(voiceList);
|
|
|
+ }
|
|
|
+ List<String> videoList = fYunFileService.listRemoteFiles(String.format(prefixArr4v3[3], num));
|
|
|
+ if(CollUtil.isNotEmpty(videoList)){
|
|
|
+ strings.addAll(videoList);
|
|
|
+ }
|
|
|
+ }
|
|
|
strings.stream().forEach(str->{
|
|
|
- if(!str.contains("/tiles/4k/") && !str.contains("/tiles/2k/")){
|
|
|
+ if(!str.contains("/tiles/4k/") && !str.contains("/tiles/2k/")
|
|
|
+ && !str.contains("dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam") && !str.endsWith("/")){
|
|
|
fYunFileService.downloadFile(str, String.format(sourceLocal, num, this.wwwroot).concat(str));
|
|
|
}
|
|
|
+ if(str.contains("dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam")){
|
|
|
+ log.info("url:{}", "http://4dkankan.oss-cn-shenzhen-internal.aliyuncs.com/" + str);
|
|
|
+ HttpUtil.downloadFile("http://4dkankan.oss-cn-shenzhen-internal.aliyuncs.com/" + str, String.format(sourceLocal, num, this.wwwroot).concat(str));
|
|
|
+ }
|
|
|
});
|
|
|
// fYunFileService.downloadFile(String.format(UploadFilePath.VIEW_PATH, num), String.format(sourceLocal, num, this.wwwroot));
|
|
|
|
|
@@ -226,43 +450,122 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
this.reWriteFile(num);
|
|
|
|
|
|
//切图
|
|
|
- String filePath = String.format(sourceLocal, num, this.wwwroot + String.format(UploadFilePath.IMG_VIEW_PATH, num) + "tiles/");
|
|
|
- log.info("开始切图:{}", num);
|
|
|
- this.cutImg(num, filePath, resolution, "tiles");
|
|
|
- log.info("结束切图:{}", num);
|
|
|
-
|
|
|
- //切图-场景关联
|
|
|
- String panoramaPath = String.format(sourceLocal, num, this.wwwroot + String.format(UploadFilePath.IMG_VIEW_PATH, num) + "panorama/");
|
|
|
- if(FileUtil.exist(panoramaPath)){
|
|
|
- Path directoryPath = Paths.get(panoramaPath); // 替换为你要查询的目录路径
|
|
|
- // 获取目录下的第一层子目录
|
|
|
- List<String> panoramaIdList = Files.list(directoryPath).filter(Files::isDirectory).map(file -> file.getFileName().toString()).collect(Collectors.toList());
|
|
|
- if(CollUtil.isNotEmpty(panoramaIdList)){
|
|
|
- for (String panoramaId : panoramaIdList) {
|
|
|
- this.cutImg(num, panoramaPath.concat(panoramaId).concat("/tiles/"), resolution, "panorama/".concat(panoramaId).concat("/tiles"));
|
|
|
+ if(cutImg){
|
|
|
+ String filePath = String.format(sourceLocal, num, this.wwwroot + String.format(UploadFilePath.IMG_VIEW_PATH, num) + "tiles/");
|
|
|
+ if(version.equals(SceneVersionType.V3.code())){
|
|
|
+ filePath = String.format(sourceLocal, num, this.wwwroot + String.format(prefixArr4v3[1], num) + "tiles/");
|
|
|
+ }
|
|
|
+ log.info("开始切图:{}", num);
|
|
|
+ this.cutImg(num, filePath, resolution, "tiles", version);
|
|
|
+ log.info("结束切图:{}", num);
|
|
|
+
|
|
|
+ //切图-场景关联
|
|
|
+ String panoramaPath = String.format(sourceLocal, num, this.wwwroot + String.format(UploadFilePath.IMG_VIEW_PATH, num) + "panorama/");
|
|
|
+ if(version.equals(SceneVersionType.V3.code())){
|
|
|
+ panoramaPath = String.format(sourceLocal, num, this.wwwroot + String.format(prefixArr4v3[1], num) + "panorama/");
|
|
|
+ }
|
|
|
+ if(FileUtil.exist(panoramaPath)){
|
|
|
+ Path directoryPath = Paths.get(panoramaPath); // 替换为你要查询的目录路径
|
|
|
+ // 获取目录下的第一层子目录
|
|
|
+ List<String> panoramaIdList = Files.list(directoryPath).filter(Files::isDirectory).map(file -> file.getFileName().toString()).collect(Collectors.toList());
|
|
|
+ if(CollUtil.isNotEmpty(panoramaIdList)){
|
|
|
+ for (String panoramaId : panoramaIdList) {
|
|
|
+ this.cutImg(num, panoramaPath.concat(panoramaId).concat("/tiles/"), resolution, "panorama/".concat(panoramaId).concat("/tiles"), version);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- Path directoryPath = Paths.get("D:\\test"); // 替换为你要查询的目录路径
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+// String cmd = "cd " + "D:\\xuhua\\data\\downloads\\scenes\\SG-9D3ny9LYZgf" + " && zip -r " + "D:\\xuhua\\data\\downloads\\scenes\\SG-9D3ny9LYZgf.zip" + " *";
|
|
|
+// CmdUtils.callLine(cmd, 200);
|
|
|
+
|
|
|
+ // 获取 Forest 全局配置对象
|
|
|
+ ForestConfiguration configuration = Forest.config();
|
|
|
+// 连接池最大连接数
|
|
|
+ configuration.setMaxConnections(1000);
|
|
|
+// 连接超时时间,单位为毫秒
|
|
|
+ configuration.setConnectTimeout(Integer.MAX_VALUE);
|
|
|
+// 数据读取超时时间,单位为毫秒
|
|
|
+ configuration.setReadTimeout(Integer.MAX_VALUE);
|
|
|
+ configuration.setTimeout(Integer.MAX_VALUE);
|
|
|
+
|
|
|
+
|
|
|
+ String errorPath = "D:\\lindongshneg2-2\\1-1\\error.txt";
|
|
|
+ String token = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2NjY2NjY2NjY2NiIsImxvZ2luVHlwZSI6InVzZXIiLCJ1c2VyTmFtZSI6IjY2NjY2NjY2NjY2IiwiaWF0IjoxNzE1NTg1ODMyLCJqdGkiOiI4MTUxYTAxZi1hM2ZkLTQwOGYtYWE5Yy0yN2ExNzUzOTc0NzgifQ.lVyl1N6scL8NMgLZ_nIws2fWSbbdNobI73ESdVm789A";
|
|
|
+ List<File> files = FileUtil.loopFiles(new File("D:\\lindongshneg2-2\\1-1"));
|
|
|
+ for (File file : files) {
|
|
|
+ File parentFile = file.getParentFile();
|
|
|
+ String num = parentFile.getName();
|
|
|
+ System.out.println("开始上传,num:" + file.getName());
|
|
|
+// Map<String, String> headers = new HashMap<>();
|
|
|
+// headers.put("token", token);
|
|
|
+// headers.put("Content-Type", ContentType.MULTIPART.getValue());
|
|
|
+ try {
|
|
|
+
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
+// params.put("num",num);
|
|
|
+// params.put("file", new File("D:\\lindongsheng\\img\\" + string));
|
|
|
+// HttpResponse execute = HttpRequest.post("https://www.4dkankan.com/service/scene/edit/uploadPanorama")
|
|
|
+// .form(params)
|
|
|
+// .addHeaders(headers)
|
|
|
+// .execute();
|
|
|
+// String body = execute.body();
|
|
|
+
|
|
|
+ HttpClient client = Forest.client(HttpClient.class);
|
|
|
+ String body = client.upload(file, token, num);
|
|
|
+
|
|
|
+ ResultData<Map<String, String>> resultData = JSON.parseObject(body, ResultData.class);
|
|
|
+ if(resultData.getCode() != ServerCode.SUCCESS.code()){
|
|
|
+ throw new RuntimeException("上传全景图失败了, 场景码:" + file.getName());
|
|
|
+ }
|
|
|
|
|
|
- try {
|
|
|
- // 获取目录下的第一层子目录
|
|
|
- Files.list(directoryPath)
|
|
|
- .filter(Files::isDirectory)
|
|
|
- .forEach(file -> {
|
|
|
- System.out.println(file.getFileName().toString());
|
|
|
- });
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ boolean exit = false;
|
|
|
+ while (!exit){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("func", "panorama");
|
|
|
+ map.put("module", "repair");
|
|
|
+ map.put("num", num);
|
|
|
+// HttpResponse execute = HttpRequest.post("https://www.4dkankan.com/service/scene/edit/getAsynOperLog")
|
|
|
+// .form(map)
|
|
|
+// .header("token", token)
|
|
|
+// .execute();
|
|
|
+// body = execute.body();
|
|
|
+ body = client.getStatus(token, map);
|
|
|
+ System.out.println("异步处理结果:" + body);
|
|
|
+ ResultData<JSONArray> resultData1 = JSON.parseObject(body, ResultData.class);
|
|
|
+ if(resultData1.getCode() != ServerCode.SUCCESS.code()){
|
|
|
+ throw new RuntimeException("上传全景图失败了, 场景码:" + file.getName());
|
|
|
+ }
|
|
|
+ JSONObject resp = (JSONObject) resultData1.getData().get(0);
|
|
|
+ Integer state = resp.getInteger("state");
|
|
|
+ if(state == -1){
|
|
|
+ throw new RuntimeException("上传全景图失败了, 场景码:" + file.getName());
|
|
|
+ }
|
|
|
+ if(state == 1){
|
|
|
+ exit = true;
|
|
|
+ }
|
|
|
+ Thread.sleep(2000L);
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ FileUtil.appendUtf8Lines(Lists.newArrayList(file.getName()), errorPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("结束上传,num:" + file.getName());
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
@Override
|
|
|
- public void cutImg(String num, String path, String resolution, String subPath) throws Exception {
|
|
|
+ public void cutImg(String num, String path, String resolution, String subPath, String version) throws Exception {
|
|
|
|
|
|
String imageNumPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
+ if(version.equals(SceneVersionType.V3.code())){
|
|
|
+ imageNumPath = String.format(prefixArr4v3[1], num);
|
|
|
+ }
|
|
|
String tilesOssPath = imageNumPath.concat(subPath + "/" + resolution);
|
|
|
List<String> cubeList = fYunFileService.listRemoteFiles(tilesOssPath);
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(this.zipNthreads);
|
|
@@ -497,10 +800,11 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
}
|
|
|
|
|
|
private void zip(String sourcePath, String zipPath) throws Exception {
|
|
|
- zipPath = zipPath.replace("mnt", "data");
|
|
|
- String target = String.format("/mnt/scenes/%s", DateExtUtil.format(new Date(), DateExtUtil.dateStyle6));
|
|
|
- String cmd = "cd " + sourcePath + " && zip -r " + zipPath + " * && mv -f " + zipPath + " " + target;
|
|
|
+ FileUtil.mkParentDirs(zipPath);
|
|
|
+ String cmd = "cd " + sourcePath + " && zip -r " + zipPath + " *";//&& mv -f " + zipPath + " " + target
|
|
|
CmdUtils.callLineSh(cmd, 200);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|