Commit 59ec6e0a authored by luzhuang's avatar luzhuang

Merge remote-tracking branch 'origin/meiteng' into meiteng

parents 04e3834e 88671c48
......@@ -675,7 +675,6 @@ public class BChapterServiceImpl implements BChapterService {
public String getBatchDownload(String bFileJson) {
//批量打包下载
List<BFile> fileList = JSONObject.parseArray(bFileJson, BFile.class);
List<File> bFiles = new ArrayList<>();
if (fileList == null || fileList.size() < 1){
throw new ServiceException(ResultServiceEnums.NOT_DOWNLOAD_FILE);
}
......@@ -686,17 +685,16 @@ public class BChapterServiceImpl implements BChapterService {
}
String name = bFile.getVideoUrl().substring(bFile.getVideoUrl().lastIndexOf("/") + 1);
String filePath = global.getBASE_UPLOAD_SERVER_LOCATION() + global.getCOURSE_LOCATION() + File.separator + bFile.getLessonId();
String returnBasePath = global.getRETURN_UPLOAD_SERVER_LOCATION() + global.getCOURSE_LOCATION() + File.separator + bFile.getLessonId();
File file = new File(filePath);
File fileOld = new File(filePath + File.separator + name);
if (fileOld.exists()) {
bFiles.add(new File(returnBasePath + File.separator + name));
bFile.setFileUrl(filePath + File.separator + name);
} else {
String downLoadName = downLoadFile(bFile, file, filePath);
bFiles.add(new File(returnBasePath + File.separator + downLoadName));
bFile.setFileUrl(filePath + File.separator + downLoadName);
}
});
if (bFiles.size() < 1){
if (fileList.size() < 1){
throw new ServiceException(ResultServiceEnums.NOT_DOWNLOAD_FILE);
}
String uuid = IdGen.uuid();
......@@ -705,7 +703,7 @@ public class BChapterServiceImpl implements BChapterService {
//返回地址
String returnAddress = global.getRETURN_UPLOAD_SERVER_LOCATION() + global.getCOURSE_LOCATION() + File.separator + global.getZIP_LOCATION() + File.separator + uuid +".zip";
//打包
ZipMultiFile.zipFiles(bFiles, zipFile);
ZipMultiFile.zipFiles(fileList, zipFile);
return returnAddress;
}
......
package org.rcisoft.core.util;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.bfile.entity.BFile;
import java.io.*;
import java.util.Arrays;
......@@ -21,10 +22,10 @@ public class ZipMultiFile {
File zipFile = new File("C:\\Users\\三\\Desktop\\暂时\\deleteFile\\1234\\ZipFile.zip");
// 调用压缩方法
zipFiles(Arrays.asList(srcFiles), zipFile);
// zipFiles(Arrays.asList(srcFiles), zipFile);
}
public static String zipFiles(List<File> srcFiles, File zipFile) {
public static String zipFiles(List<BFile> srcFiles, File zipFile) {
// 判断压缩后的文件存在不,不存在则创建
if (!zipFile.getParentFile().exists()){
zipFile.getParentFile().mkdirs();
......@@ -54,9 +55,9 @@ public class ZipMultiFile {
// 遍历源文件数组
for (int i = 0; i < srcFiles.size(); i++) {
// 将源文件数组中的当前文件读入 FileInputStream 流中
fileInputStream = new FileInputStream(srcFiles.get(i));
fileInputStream = new FileInputStream(new File(srcFiles.get(i).getFileUrl()));
// 实例化 ZipEntry 对象,源文件数组中的当前文件
zipEntry = new ZipEntry(srcFiles.get(i).getName());
zipEntry = new ZipEntry(srcFiles.get(i).getFileName()+srcFiles.get(i).getFileUrl().substring(srcFiles.get(i).getFileUrl().lastIndexOf(".")));
zipOutputStream.putNextEntry(zipEntry);
// 该变量记录每次真正读的字节个数
int len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment