浏览代码

导览下载

dsx 1 年之前
父节点
当前提交
6be8e8079f
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/main/java/com/fdkankan/scene/service/impl/DownloadTourVideoServiceImpl.java

+ 4 - 2
src/main/java/com/fdkankan/scene/service/impl/DownloadTourVideoServiceImpl.java

@@ -2,6 +2,7 @@ package com.fdkankan.scene.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.exceptions.ExceptionUtil;
+import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.lang.UUID;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
@@ -83,7 +84,7 @@ public class DownloadTourVideoServiceImpl extends ServiceImpl<IDownloadTourVideo
         if(!tempFile.getParentFile().exists()){
             tempFile.getParentFile().mkdirs();
         }
-        file.transferTo(tempFile);
+        FileUtil.writeFromStream(file.getInputStream(), srcPath);
 
         //先将旧纪录置为无效
         this.removeByNum(num);
@@ -124,7 +125,7 @@ public class DownloadTourVideoServiceImpl extends ServiceImpl<IDownloadTourVideo
 
         String destPath = null;
         try {
-            ScenePlus scenePlus = scenePlusService.getById(downloadTourVideo.getNum());
+            ScenePlus scenePlus = scenePlusService.getScenePlusByNum(downloadTourVideo.getNum());
             ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
             String bucket = scenePlusExt.getYunFileBucket();
             String destFileName = UUID.randomUUID().toString() + ".mp4";
@@ -141,6 +142,7 @@ public class DownloadTourVideoServiceImpl extends ServiceImpl<IDownloadTourVideo
             downloadTourVideo.setDownloadPath(ossPath);
             downloadTourVideo.setState(1);
             this.updateById(downloadTourVideo);
+            FileUtil.del(srcPath);
         }catch (Exception e) {
             log.error("导览视频转换失败,num:" + downloadTourVideo.getNum() + "源路径:" + downloadTourVideo.getLocalPath(), e);
             downloadTourVideo.setReason(ExceptionUtil.stacktraceToString(e, 3000));