|
|
@@ -31,6 +31,7 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.HashMap;
|
|
|
@@ -260,6 +261,9 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
|
|
|
private void zipOssFiles(ZipOutputStream out, List<String> ossFilePaths, String num, AtomicInteger count,
|
|
|
int total, String resolution, int imagesVersion, Set<String> cacheKeys) throws Exception{
|
|
|
+ if(CollUtil.isEmpty(ossFilePaths)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
String imageNumPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(this.zipNthreads);
|
|
|
List<Future> futureList = new ArrayList<>();
|
|
|
@@ -275,9 +279,19 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
futureList.add(executorService.submit(call));
|
|
|
}
|
|
|
//这里一定要加阻塞,不然会导致oss文件还没打包好,主程序已经结束返回了
|
|
|
+ Boolean zipSuccess = true;
|
|
|
for (Future future : futureList) {
|
|
|
- future.get();
|
|
|
+ try {
|
|
|
+ future.get();
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("打包oss文件失败", e);
|
|
|
+ zipSuccess = false;
|
|
|
+ }
|
|
|
}
|
|
|
+ if(!zipSuccess){
|
|
|
+ throw new Exception("打包oss文件失败");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void zipOssFilesHandler(ZipOutputStream out, String num,
|
|
|
@@ -468,8 +482,8 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
return;
|
|
|
}
|
|
|
cacheKeys.add(key);
|
|
|
- String url = this.resourceUrl + key + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
- log.info("oss文件路径:{}", url);
|
|
|
+ String fileName = key.substring(key.lastIndexOf("/") + 1);
|
|
|
+ String url = this.resourceUrl + key.replace(fileName, URLEncoder.encode(fileName, "UTF-8")) + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
if(key.contains("hot.json") || key.contains("link-scene.json")){
|
|
|
String content = FileUtils.getStringFromUrl(url);
|
|
|
|
|
|
@@ -514,6 +528,9 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
progress.setStatus(status);
|
|
|
progress.setUrl(url);
|
|
|
}
|
|
|
+ if(status == 1003){
|
|
|
+ log.info(JSONUtil.toJsonStr(progress));
|
|
|
+ }
|
|
|
redisUtil.set(key, JSONUtil.toJsonStr(progress));
|
|
|
|
|
|
}
|