Merge remote-tracking branch 'origin/dev_third_stage' into dev_third_stage
This commit is contained in:
+27
-2
@@ -2161,8 +2161,17 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl<ParamsCollec
|
||||
// os.close(); // 后开先关
|
||||
// fis.close(); // 先开后关
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new JeroBootException("下载文件失败,请重试");
|
||||
if (e instanceof JeroBootException){
|
||||
throw new JeroBootException(e.getMessage());
|
||||
} else {
|
||||
log.error(e.getMessage(), e);
|
||||
if (CutEnum.EN.getValue().equals(paramsCollectManifestVO.getCut())) {
|
||||
throw new JeroBootException("Failed to download file, please try again");
|
||||
} else {
|
||||
throw new JeroBootException("下载文件失败,请重试");
|
||||
}
|
||||
|
||||
}
|
||||
} finally {
|
||||
// IOUtils.closeQuietly(os);
|
||||
IOUtils.closeQuietly(excelOS);
|
||||
@@ -2254,10 +2263,26 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl<ParamsCollec
|
||||
Integer paramsTemplatePublishVersion = paramsCollectManifestVO.getParamsTemplatePublishVersion();
|
||||
String cut = paramsCollectManifestVO.getCut();
|
||||
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
ParamsCollectManifestEO queryEO = new ParamsCollectManifestEO();
|
||||
queryEO.setParamsManifestId(paramsManifestId);
|
||||
|
||||
String userTypes = paramsCollectManifestVO.getUserTypes();
|
||||
if (userTypes != null && CollectManifestUserTypeEnum.SDT.getValue().equals(userTypes)){
|
||||
queryEO.setUserTypes(CollectManifestUserTypeEnum.SDT.getValue());
|
||||
queryEO.setSdt(loginUser.getUsername());
|
||||
}
|
||||
|
||||
List<Map<String, Object>> dataList = paramsCollectManifestEOMapper.listInfoForExport(queryEO); // 查询导出数据
|
||||
if (dataList == null || dataList.isEmpty()){
|
||||
// 没有查到数据,进行提示
|
||||
if (CutEnum.EN.getValue().equals(paramsCollectManifestVO.getCut())) {
|
||||
throw new JeroBootException("No data, unable to export");
|
||||
} else {
|
||||
throw new JeroBootException("无数据,无法导出");
|
||||
}
|
||||
}
|
||||
|
||||
List<ParamsConfigEO> paramsConfigEOList = paramsConfigEOService.queryList(paramsManifestId); // 查询所有配置列
|
||||
|
||||
|
||||
+3
@@ -74,4 +74,7 @@ public class ParamsCollectManifestVO {
|
||||
|
||||
private String exportName; // 导出文件名
|
||||
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private String userTypes; // 用户类型
|
||||
|
||||
}
|
||||
|
||||
+23
-12
@@ -1,7 +1,5 @@
|
||||
package com.jero.modules.cert.report.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
@@ -30,6 +28,7 @@ import com.jero.modules.cert.template.enums.ControlTypeEnum;
|
||||
import com.jero.modules.ocr.util.LineHumpUtil;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.project.util.ExcelUtil;
|
||||
import com.jero.modules.project.util.WordUtil;
|
||||
import com.jero.modules.split.common.ReadExcel;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
@@ -37,7 +36,6 @@ import com.jero.modules.system.service.ISysDictItemService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.aspectj.util.FileUtil;
|
||||
@@ -753,6 +751,7 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
|
||||
paramsReportExportHistoryEO.setExportTime(new Date());
|
||||
paramsReportExportHistoryEOService.add(paramsReportExportHistoryEO);
|
||||
|
||||
uploadFileio.close();
|
||||
os.flush();
|
||||
os.close(); // 后开先关
|
||||
fis.close(); // 先开后关
|
||||
@@ -795,7 +794,7 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
|
||||
|
||||
// 查询导出数据
|
||||
List<Map> allParamsInfoList = queryForExportCustom(paramsReportDetailVO);
|
||||
Map<String, Object> params = allParamsInfoList.get(0);
|
||||
HashMap<String, String> params = (HashMap<String, String>) allParamsInfoList.get(0);
|
||||
|
||||
String templateUrl = "";
|
||||
ParamsExportTemplateEO paramsExportTemplateEO = paramsExportTemplateEOService.getById(paramsReportDetailVO.getExportTemplateId());
|
||||
@@ -807,25 +806,37 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
|
||||
// 替换模板中的占位符
|
||||
try {
|
||||
|
||||
//下载关联文件内容
|
||||
List<OSSFile> allRelevFileList = (List<OSSFile>) allParamsInfoList.get(2).get("fileListAll");
|
||||
if (allRelevFileList != null && !allRelevFileList.isEmpty()) {
|
||||
allRelevFileList = allRelevFileList.stream().distinct().collect(Collectors.toList());
|
||||
downLoadFileList(allRelevFileList,fileNowPath + File.separator + "导出文件");
|
||||
}
|
||||
|
||||
// 拿取模板
|
||||
String repFileName = fileName.replaceAll("/","_");
|
||||
wordOS = new FileOutputStream(fileNowPath + File.separator + repFileName);
|
||||
if (CosBootUtil.doesObjectExist(templateUrl)) {
|
||||
InputStream wordTemplate = CosBootUtil.download(templateUrl);
|
||||
com.qcloud.cos.utils.IOUtils.copy(wordTemplate, wordOS);
|
||||
// com.qcloud.cos.utils.IOUtils.copy(wordTemplate, wordOS);
|
||||
|
||||
ExcelUtil.variableReplace(wordTemplate, wordOS, params);
|
||||
|
||||
}
|
||||
|
||||
// 替换占位符内容
|
||||
TemplateExportParams templateExportParams = new TemplateExportParams();
|
||||
templateExportParams.setTemplateUrl(fileNowPath + File.separator + repFileName);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(templateExportParams, params);
|
||||
// poi方式
|
||||
// TemplateExportParams templateExportParams = new TemplateExportParams();
|
||||
// templateExportParams.setTemplateUrl(fileNowPath + File.separator + repFileName);
|
||||
// Workbook workbook = ExcelExportUtil.exportExcel(templateExportParams, params);
|
||||
|
||||
OutputStream word = new FileOutputStream(fileNowPath + File.separator + repFileName);
|
||||
workbook.write(word);
|
||||
|
||||
// OutputStream word = new FileOutputStream(fileNowPath + File.separator + repFileName);
|
||||
// workbook.write(word);
|
||||
wordOS.flush();
|
||||
wordOS.close();
|
||||
word.flush();
|
||||
word.close();
|
||||
// word.flush();
|
||||
// word.close();
|
||||
|
||||
// 打包导出压缩包
|
||||
response.setHeader("Content-Disposition",
|
||||
|
||||
Reference in New Issue
Block a user