|
@@ -78,99 +78,6 @@ public class BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- protected void handleStudentPhotoZip(String zipName, HttpServletResponse response, List<? extends SimpleDownloadModel> downloadModels) throws IOException {
|
|
|
|
- String fileName = URLEncoder.encode(zipName, "UTF-8");
|
|
|
|
- response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".zip");
|
|
|
|
- File zipTmpFile = FileUtil.file(dfsConfig.getPath() + "\\" + RandomUtil.randomString(32) + ".zip");
|
|
|
|
- List<File> fileList = new ArrayList<>();
|
|
|
|
- for (SimpleDownloadModel simpleDownloadModel : downloadModels) {
|
|
|
|
- try {
|
|
|
|
- String url = simpleDownloadModel.getUrl();
|
|
|
|
- String newFileName = simpleDownloadModel.getNewFileName();
|
|
|
|
- if (StrUtil.isNotBlank(url)) {
|
|
|
|
- String parent = FileUtil.file(dfsConfig.getPath()).getParent();
|
|
|
|
- String filePath = "";
|
|
|
|
- if (!url.contains(parent)) {
|
|
|
|
- filePath = parent + url;
|
|
|
|
- } else {
|
|
|
|
- filePath = url;
|
|
|
|
- }
|
|
|
|
- File old = FileUtil.file(filePath);
|
|
|
|
- String extName = FileUtil.extName(old);
|
|
|
|
- String pathname = old.getParent() + "\\" + newFileName + "." + extName;
|
|
|
|
- //pathname = new String(pathname.getBytes("ISO8859-1"),"GBK");
|
|
|
|
- File tmp = new File(pathname);
|
|
|
|
- FileUtil.copyFile(old, tmp);
|
|
|
|
- fileList.add(tmp);
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("导出zip错误 ", e);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- File[] files = ArrayUtil.toArray(fileList, File.class);
|
|
|
|
-
|
|
|
|
- ZipUtil.zip(zipTmpFile, true, files);
|
|
|
|
-
|
|
|
|
- ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
- IoUtil.copy(FileUtil.getInputStream(zipTmpFile), outputStream);
|
|
|
|
-
|
|
|
|
- zipTmpFile.delete();
|
|
|
|
- files = null;
|
|
|
|
- for (File file : fileList) {
|
|
|
|
- try {
|
|
|
|
- file.delete();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected void handleApplyStudentPhotoZip(String zipName, HttpServletResponse response, List<? extends SimpleDownloadModel> downloadModels) throws IOException {
|
|
|
|
- String fileName = URLEncoder.encode(zipName, "UTF-8");
|
|
|
|
- response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".zip");
|
|
|
|
- File zipTmpFile = FileUtil.file(dfsConfig.getPath() + "\\" + RandomUtil.randomString(32) + ".zip");
|
|
|
|
- List<File> fileList = new ArrayList<>();
|
|
|
|
- for (SimpleDownloadModel simpleDownloadModel : downloadModels) {
|
|
|
|
- try {
|
|
|
|
- String url = simpleDownloadModel.getUrl();
|
|
|
|
- String newFileName = simpleDownloadModel.getNewFileName();
|
|
|
|
- if (StrUtil.isNotBlank(url)) {
|
|
|
|
- String parent = FileUtil.file(dfsConfig.getPath()).getParent();
|
|
|
|
- String filePath = "";
|
|
|
|
- if (!url.contains(parent)) {
|
|
|
|
- filePath = parent + url;
|
|
|
|
- } else {
|
|
|
|
- filePath = url;
|
|
|
|
- }
|
|
|
|
- File old = FileUtil.file(filePath);
|
|
|
|
- String extName = FileUtil.extName(old);
|
|
|
|
- File tmp =
|
|
|
|
- new File(old.getParent() + "\\" + newFileName + "." + extName);
|
|
|
|
- FileUtil.copyFile(old, tmp);
|
|
|
|
- fileList.add(tmp);
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("导出zip错误 ", e);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- File[] files = ArrayUtil.toArray(fileList, File.class);
|
|
|
|
-
|
|
|
|
- ZipUtil.zip(zipTmpFile, true, files);
|
|
|
|
-
|
|
|
|
- ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
- IoUtil.copy(FileUtil.getInputStream(zipTmpFile), outputStream);
|
|
|
|
-
|
|
|
|
- zipTmpFile.delete();
|
|
|
|
- files = null;
|
|
|
|
- for (File file : fileList) {
|
|
|
|
- try {
|
|
|
|
- file.delete();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
protected void exportPlusCombos(HttpServletResponse response, String filename, List datas, Class clz, String[] options) throws IOException {
|
|
protected void exportPlusCombos(HttpServletResponse response, String filename, List datas, Class clz, String[] options) throws IOException {
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
ExcelPlusUtil<Object> util = new ExcelPlusUtil<Object>(clz);
|
|
ExcelPlusUtil<Object> util = new ExcelPlusUtil<Object>(clz);
|
|
@@ -179,29 +86,4 @@ public class BaseController {
|
|
util.exportExcel2HttpResponse(datas, filename, outputStream, options);
|
|
util.exportExcel2HttpResponse(datas, filename, outputStream, options);
|
|
}
|
|
}
|
|
|
|
|
|
- protected void handleStudentFileZip(String zipName, HttpServletResponse response, List<? extends SimpleDownloadModel> downloadModels)throws IOException {
|
|
|
|
- String fileName = URLEncoder.encode(zipName, "UTF-8");
|
|
|
|
- response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".zip");
|
|
|
|
- File zipTmpFile = FileUtil.file(dfsConfig.getPath() + "\\" + RandomUtil.randomString(32) + ".zip");
|
|
|
|
- List<File> fileList = new ArrayList<>();
|
|
|
|
- for (SimpleDownloadModel simpleDownloadModel : downloadModels) {
|
|
|
|
- try {
|
|
|
|
- String url = simpleDownloadModel.getUrl();
|
|
|
|
- if (StrUtil.isNotBlank(url)) {
|
|
|
|
- File old = FileUtil.file("/opt"+url);
|
|
|
|
- fileList.add(old);
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("导出zip错误 ", e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- File[] files = ArrayUtil.toArray(fileList, File.class);
|
|
|
|
-
|
|
|
|
- ZipUtil.zip(zipTmpFile, true, files);
|
|
|
|
-
|
|
|
|
- ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
- IoUtil.copy(FileUtil.getInputStream(zipTmpFile), outputStream);
|
|
|
|
-
|
|
|
|
- zipTmpFile.delete();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|