认证-上报库-常规导出

This commit is contained in:
liyawei
2022-06-23 16:55:32 +08:00
parent f1a49e4070
commit ce78b75ee5
11 changed files with 518 additions and 16 deletions
@@ -1,21 +1,26 @@
package com.jero.modules.cert.report.controller;
import com.alibaba.fastjson.JSONObject;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.system.base.controller.JeroController;
import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO;
import com.jero.modules.cert.report.entity.ParamsReportDetailEO;
import com.jero.modules.cert.report.service.IParamsReportDetailEOService;
import com.jero.modules.cert.report.vo.ParamsReportDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@@ -59,23 +64,32 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
@ApiOperation(value="上报库参数项-列表查询", notes="上报库参数项-列表查询")
@GetMapping(value = "/list")
// @RequiresPermissions("report:detail:list")
public Result<List<Map<String, Object>>> queryList(ParamsCollectManifestEO paramsCollectManifestEO,
public Result<List<Map<String, Object>>> queryList(ParamsReportDetailEO paramsReportDetailEO,
@RequestParam(name = "cut") String cut) {
if (StringUtils.isNotEmpty(paramsCollectManifestEO.getNioNumber())) {
paramsCollectManifestEO.setNioNumber(paramsCollectManifestEO.getNioNumber().replace("%","\\%"));
if (StringUtils.isNotEmpty(paramsReportDetailEO.getNioNumber())) {
paramsReportDetailEO.setNioNumber(paramsReportDetailEO.getNioNumber().replace("%","\\%"));
}
if (StringUtils.isNotEmpty(paramsCollectManifestEO.getParamsName())) {
paramsCollectManifestEO.setParamsName(paramsCollectManifestEO.getParamsName().replace("%","\\%"));
if (StringUtils.isNotEmpty(paramsReportDetailEO.getParamsName())) {
paramsReportDetailEO.setParamsName(paramsReportDetailEO.getParamsName().replace("%","\\%"));
}
if (StringUtils.isNotEmpty(paramsCollectManifestEO.getSdt())) {
paramsCollectManifestEO.setSdt(paramsCollectManifestEO.getSdt().replace("%","\\%"));
if (StringUtils.isNotEmpty(paramsReportDetailEO.getSdt())) {
paramsReportDetailEO.setSdt(paramsReportDetailEO.getSdt().replace("%","\\%"));
}
if (StringUtils.isNotEmpty(paramsCollectManifestEO.getDre())) {
paramsCollectManifestEO.setDre(paramsCollectManifestEO.getDre().replace("%","\\%"));
if (StringUtils.isNotEmpty(paramsReportDetailEO.getDre())) {
paramsReportDetailEO.setDre(paramsReportDetailEO.getDre().replace("%","\\%"));
}
List<Map<String, Object>> list = paramsReportDetailEOService.queryList(paramsCollectManifestEO, cut);
List<Map<String, Object>> list = paramsReportDetailEOService.queryList(paramsReportDetailEO, cut);
return Result.OK(list);
}
@ApiOperation(value = "上报库参数项-常规导出")
@GetMapping(value = "/exportNormal")
// @RequiresPermissions("report:detail:export:normal")
public void exportSplitInfoZip(ParamsReportDetailVO paramsReportDetailVO,
HttpServletResponse response,
HttpServletRequest request) {
paramsReportDetailEOService.exportNormal(paramsReportDetailVO, response, request);
}
}
@@ -1,5 +1,6 @@
package com.jero.modules.cert.report.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jero.modules.cert.collect.entity.ParamsCollectManifestBaseEO;
@@ -2,6 +2,9 @@ package com.jero.modules.cert.report.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.modules.cert.report.entity.ParamsReportConfigDataEO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description: 上报库参数配置数据
@@ -11,4 +14,6 @@ import com.jero.modules.cert.report.entity.ParamsReportConfigDataEO;
*/
public interface ParamsReportConfigDataEOMapper extends BaseMapper<ParamsReportConfigDataEO> {
List<ParamsReportConfigDataEO> selectByConfigIdListAndCollectManifestId(@Param("configIdList") List<String> configIdList,
@Param("paramsCollectManifestId") String paramsCollectManifestId);
}
@@ -3,9 +3,11 @@ package com.jero.modules.cert.report.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO;
import com.jero.modules.cert.report.entity.ParamsReportDetailEO;
import com.jero.modules.cert.report.vo.ParamsReportDetailVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @Description: 上报库参数项
@@ -15,5 +17,9 @@ import java.util.List;
*/
public interface ParamsReportDetailEOMapper extends BaseMapper<ParamsReportDetailEO> {
List<ParamsReportDetailEO> listInfo(@Param("paramsCollectManifestEO") ParamsCollectManifestEO paramsCollectManifestEO);
List<ParamsReportDetailEO> listInfo(@Param("paramsReportDetailEO") ParamsReportDetailEO paramsReportDetailEO);
List<Map<String, Object>> listInfoForExport(@Param("idList") List<String> idList,
@Param("paramsReportDetailEO") ParamsReportDetailVO paramsReportDetailEO);
}
@@ -14,4 +14,16 @@
<result column="params_config_id" property="paramsConfigId" />
<result column="params_collect_manifest_id" property="paramsCollectManifestId" />
</resultMap>
<select id="selectByConfigIdListAndCollectManifestId" resultMap="ParamsReportConfigDataEOResultMap">
select *
from params_report_config_data prcd
left join params_report_config prc on prcd.params_config_id = prc.id
where prcd.params_collect_manifest_id = #{paramsCollectManifestId}
and prcd.params_config_id in
<foreach collection="configIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
order by prc.display_seq asc
</select>
</mapper>
@@ -55,10 +55,56 @@
</where>
</sql>
<sql id="BaseQuerySqlForExport">
<where>
<if test="paramsCollectManifestEO != null">
<if test="paramsCollectManifestEO.nioNumber !=null and paramsCollectManifestEO.nioNumber !=''">
AND prd.nio_number LIKE CONCAT(CONCAT('%',#{paramsCollectManifestEO.nioNumber}),'%')
</if>
<if test="paramsCollectManifestEO.paramsName !=null and paramsCollectManifestEO.paramsName !=''">
AND prd.params_name LIKE CONCAT(CONCAT('%',#{paramsCollectManifestEO.paramsName}),'%')
</if>
<if test="paramsCollectManifestEO.certCategory !=null and paramsCollectManifestEO.certCategory !=''">
AND prd.cert_category LIKE CONCAT(CONCAT('%',#{paramsCollectManifestEO.certCategory}),'%')
</if>
<if test="paramsCollectManifestEO.sdt !=null and paramsCollectManifestEO.sdt !=''">
AND prd.sdt LIKE CONCAT(CONCAT('%',#{paramsCollectManifestEO.sdt}),'%')
</if>
<if test="paramsCollectManifestEO.dre !=null and paramsCollectManifestEO.dre !=''">
AND prd.dre LIKE CONCAT(CONCAT('%',#{paramsCollectManifestEO.dre}),'%')
</if>
<if test="paramsCollectManifestEO.paramsManifestId !=null and paramsCollectManifestEO.paramsManifestId !=''">
AND prd.params_manifest_id = #{paramsCollectManifestEO.paramsManifestId}
</if>
</if>
</where>
</sql>
<select id="listInfo" resultMap="ParamsReportDetailEOResultMap">
select *
from params_report_detail
<include refid="BaseQuerySql"/>
order by sync_time asc
</select>
<select id="listInfoForExport" resultType="java.util.LinkedHashMap">
select
prd.id as id,
prd.nio_number as nio_number,
prd.params_name as params_name,
rccpi.params_number as cert_number,
rccpi.params_name as cert_params_name
from params_report_detail prd
left join report_cert_category_params_info rccpi on prd.nio_number = rccpi.nio_number
<include refid="BaseQuerySqlForExport"/>
<if test="idList != null">
and prd.id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by prd.nio_number ASC
</select>
</mapper>
@@ -3,6 +3,8 @@ package com.jero.modules.cert.report.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.cert.report.entity.ParamsReportConfigDataEO;
import java.util.List;
/**
* @Description: 上报库参数配置数据
* @Author: jero-boot
@@ -19,4 +21,6 @@ public interface IParamsReportConfigDataEOService extends IService<ParamsReportC
* @return
*/
ParamsReportConfigDataEO queryByConfigIdAndCollectManifestId(String paramsConfigId, String paramsCollectManifestId);
List<ParamsReportConfigDataEO> queryByConfigIdListAndCollectManifestId(List<String> paramsConfigIdList, String paramsCollectManifestId);
}
@@ -3,7 +3,10 @@ package com.jero.modules.cert.report.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO;
import com.jero.modules.cert.report.entity.ParamsReportDetailEO;
import com.jero.modules.cert.report.vo.ParamsReportDetailVO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@@ -17,11 +20,11 @@ public interface IParamsReportDetailEOService extends IService<ParamsReportDetai
/**
* 列表查询
* @param paramsCollectManifestEO
* @param paramsReportDetailEO
* @param cut
* @return
*/
List<Map<String, Object>> queryList(ParamsCollectManifestEO paramsCollectManifestEO, String cut);
List<Map<String, Object>> queryList(ParamsReportDetailEO paramsReportDetailEO, String cut);
/**
* 列表表头中英文切换
@@ -31,4 +34,6 @@ public interface IParamsReportDetailEOService extends IService<ParamsReportDetai
* @return
*/
List<Map<String, Object>> getHeader(String paramsManifestId, String flag, String cut);
void exportNormal(ParamsReportDetailVO paramsReportDetailVO, HttpServletResponse response, HttpServletRequest request);
}
@@ -7,6 +7,8 @@ import com.jero.modules.cert.report.mapper.ParamsReportConfigDataEOMapper;
import com.jero.modules.cert.report.service.IParamsReportConfigDataEOService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description: 上报库参数配置数据
* @Author: jero-boot
@@ -31,4 +33,9 @@ public class ParamsReportConfigDataEOServiceImpl extends ServiceImpl<ParamsRepor
getOne(queryWrapper);
return getOne(queryWrapper);
}
@Override
public List<ParamsReportConfigDataEO> queryByConfigIdListAndCollectManifestId(List<String> paramsConfigIdList, String paramsCollectManifestId) {
return baseMapper.selectByConfigIdListAndCollectManifestId(paramsConfigIdList, paramsCollectManifestId);
}
}
@@ -2,10 +2,14 @@ package com.jero.modules.cert.report.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ZipUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.constant.enums.ModuleEnum;
import com.jero.common.constant.enums.YesOrNoEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.oss.CosBootUtil;
import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
import com.jero.modules.cert.collect.entity.*;
@@ -19,17 +23,42 @@ import com.jero.modules.cert.report.mapper.ParamsReportDetailEOMapper;
import com.jero.modules.cert.report.service.IParamsReportConfigDataEOService;
import com.jero.modules.cert.report.service.IParamsReportConfigEOService;
import com.jero.modules.cert.report.service.IParamsReportDetailEOService;
import com.jero.modules.cert.report.vo.ParamsReportDetailVO;
import com.jero.modules.cert.template.enums.ControlTypeEnum;
import com.jero.modules.document.enums.FieldTypeEnum;
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.split.common.ConvertHtml2Excel;
import com.jero.modules.split.common.ReadExcel;
import com.jero.modules.split.dto.FileSpiltValTableExportDto;
import com.jero.modules.split.dto.FileSplitValExportDto;
import com.jero.modules.split.dto.FileSplitValImgExportDto;
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
import com.jero.modules.split.page.SarFileSplitItemsEOPage;
import com.jero.modules.split.page.SarFileSplitItemsValEOPage;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.service.ISysDictItemService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.*;
import java.util.stream.Collectors;
@@ -60,6 +89,8 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
@Autowired
private IOSSFileService ossFileService;
@Value(value = "${jero.path.upload}")
private String uploadpath;
/**
* 列表查询
@@ -67,10 +98,10 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
* @return
*/
@Override
public List<Map<String, Object>> queryList(ParamsCollectManifestEO paramsCollectManifestEO, String cut) {
String paramsManifestId = paramsCollectManifestEO.getParamsManifestId();
public List<Map<String, Object>> queryList(ParamsReportDetailEO paramsReportDetailEO, String cut) {
String paramsManifestId = paramsReportDetailEO.getParamsManifestId();
List<ParamsReportDetailEO> list = paramsReportDetailEOMapper.listInfo(paramsCollectManifestEO); // 查询固定列
List<ParamsReportDetailEO> list = paramsReportDetailEOMapper.listInfo(paramsReportDetailEO); // 查询固定列
List<ParamsReportConfigEO> paramsConfigEOList = paramsReportConfigEOService.queryList(paramsManifestId); // 查询配置列
// 普通数据字典
@@ -442,6 +473,326 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
return list;
}
@Override
public void exportNormal(ParamsReportDetailVO paramsReportDetailVO, HttpServletResponse response, HttpServletRequest request) {
OutputStream os = null;
OutputStream excelOS = null;
XSSFWorkbook workbook = new XSSFWorkbook();
String fileOriName = "上报库参数项常规导出信息";
if (org.apache.commons.lang.StringUtils.isNotEmpty(paramsReportDetailVO.getParamsName())) {
fileOriName = paramsReportDetailVO.getParamsName();
}
try{
//创建临时文件夹
String fileNowPath = uploadpath + "/tempZip/" + UUID.randomUUID().toString().replace("-","") + File.separator + fileOriName;
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
}
nowFile.mkdirs();
String fileName = fileOriName + ".xlsx";
// 设置表格相关属性
XSSFSheet sheetItems = workbook.createSheet("上报库参数项信息");
String[] titles = getWorkbookTitleForExport(paramsReportDetailVO); // 获取表头
String[] headers = titles[1].split(",");
XSSFCellStyle cellStyle =workbook.createCellStyle();
cellStyle.setWrapText(true);
// cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
XSSFCellStyle cellStyle1 =workbook.createCellStyle();
cellStyle1.setAlignment(XSSFCellStyle.ALIGN_CENTER);
XSSFCellStyle cellStyleLink =workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setColor(HSSFColor.LIGHT_BLUE.index);
cellStyleLink.setFont(font);
cellStyleLink.setWrapText(true);
// 查询需要导出的字段
String field = titles[0]; // 字符串形式
List<String> fieldList = Arrays.asList(field.split(",")); // list形式
// 查询导出数据
List<Map<String, Object>> allParamsInfoList = queryForExport(paramsReportDetailVO); // id记得去掉
// 开始处理工作表
List<OSSFile> allRelevFileList = new ArrayList<>();
// 在excel表中添加表头
XSSFRow row = sheetItems.createRow(0);
for (int i = 0; i < headers.length; i++) {
XSSFCell cell = row.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(headers[i]);
cell.setCellValue(text);
cell.setCellStyle(cellStyle1);
// 设置单元格宽度
if("参数值".equals(headers[i])) {
sheetItems.setColumnWidth(i, 80 * 256);
} else {
sheetItems.setColumnWidth(i, 20 * 256);
}
}
//放文字内容
int allRow = 0;
for(int rowNum = 0;rowNum < allParamsInfoList.size(); rowNum++){
Map<String, Object> exportDto = allParamsInfoList.get(rowNum);
// 处理文件
List<OSSFile> fileList = (List<OSSFile>) exportDto.get("fileList");
if (CollectionUtil.isNotEmpty(fileList)) {
allRelevFileList.addAll(fileList);
}
allRow++;
XSSFRow row1 = sheetItems.createRow(allRow);
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++){
if (ObjectUtils.isNotEmpty(exportDto.get(fieldList.get(cellNum)))) {
row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString());
row1.getCell(cellNum).setCellStyle(cellStyle);
}
}
}
//下载关联文件内容
if (allRelevFileList != null && !allRelevFileList.isEmpty()) {
allRelevFileList = allRelevFileList.stream().distinct().collect(Collectors.toList());
downLoadFileList(allRelevFileList,fileNowPath + File.separator + "导出文件");
}
String repFileName = fileName.replaceAll("/","_");
excelOS = new FileOutputStream(fileNowPath + File.separator + repFileName);
response.setHeader("Content-Disposition",
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
workbook.write(excelOS);
excelOS.flush();
excelOS.close();
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
int len = 0;
while ((len = fis.read()) != -1) {
os.write(len);
}
os.flush();
os.close(); // 后开先关
fis.close(); // 先开后关
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new JeroBootException("下载文件失败,请重试");
} finally {
org.apache.poi.util.IOUtils.closeQuietly(os);
org.apache.poi.util.IOUtils.closeQuietly(excelOS);
}
}
private void downLoadFileList(List<OSSFile> allRelevFileList,String fileNowPath) {
for(OSSFile fileExportDto : allRelevFileList){
String oldPath = fileExportDto.getUrl();
String newPath = fileNowPath + File.separator + fileExportDto.getFileName();
if (CosBootUtil.doesObjectExist(oldPath)){
try (InputStream in = CosBootUtil.download(oldPath);) {
copyFile1(in, newPath);
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
}
}
public void copyFile1(InputStream in, String destPath) throws IOException {
BufferedInputStream bis = new BufferedInputStream(in);
BufferedOutputStream bos =
new BufferedOutputStream(Files.newOutputStream(Paths.get(destPath),
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.WRITE));
// 打开输入流
// FileInputStream fis = new FileInputStream(srcPath);
// 打开输出流
// FileOutputStream fos = new FileOutputStream(destPath);
// 读取和写入信息
byte[] bytes = new byte[1024 * 1024];
int len;
while ((len = bis.read(bytes)) > 0) {
bos.write(bytes, 0, len);
}
// 关闭流 先开后关 后开先关
// 先开后关,先开的输入流,再开的输出流,那么应该先关输出流,再关输入流
// 先关外层,再关内层。如BufferedInputStream包装了一个FileInputStream,那么先关BufferedInputStream,再关FileInputStream。
bos.close(); // 后开先关
bis.close(); // 先开后关
}
private List<Map<String, Object>> queryForExport(ParamsReportDetailVO paramsReportDetailVO) {
List<String> idList = Arrays.asList(paramsReportDetailVO.getIds());
List<String> configIdList = Arrays.asList(paramsReportDetailVO.getConfigIds());
List<Map<String, Object>> dataList = paramsReportDetailEOMapper.listInfoForExport(idList, paramsReportDetailVO);
List<ParamsReportConfigEO> paramsConfigEOList = paramsReportConfigEOService.queryList(paramsReportDetailVO.getParamsManifestId()); // 查询所有配置列
List<OSSFile> fileList = new ArrayList<>();
// 查询配置列数据
for (Map<String, Object> record1 : dataList) {
String paramsCollectManifestId = (String) record1.get("id");
if (CollectionUtil.isNotEmpty(paramsConfigEOList)) {
//不合并
if ("1".equals(paramsReportDetailVO.getCombineFlag())) {
paramsConfigEOList = paramsConfigEOList.stream().filter(e->configIdList.contains(e.getId())).collect(Collectors.toList()); // 过滤出要导出的配置列
paramsConfigEOList.forEach(paramsConfigEO -> { // 参数配置
String paramsConfigId = paramsConfigEO.getId();
ParamsReportConfigDataEO paramsConfigDataEO = paramsReportConfigDataEOService.queryByConfigIdAndCollectManifestId(paramsConfigId, paramsCollectManifestId); // 参数配置数据
StringBuilder configDataBuilder = new StringBuilder(); // 重新组合配置数据
if (StringUtils.isNotEmpty(paramsConfigDataEO.getTextData())) {
configDataBuilder.append(paramsConfigDataEO.getTextData()).append("&");
}
if (StringUtils.isNotEmpty(paramsConfigDataEO.getPullData())) {
configDataBuilder.append(paramsConfigDataEO.getPullData()).append("&");
}
if (StringUtils.isNotEmpty(paramsConfigDataEO.getFileConnectId())) {
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(paramsConfigDataEO.getFileConnectId());
if (CollectionUtil.isNotEmpty(ossFileList)) {
configDataBuilder.append(ossFileList.get(0).getFileName()).append("&");
fileList.addAll(ossFileList);
}
}
String configData = configDataBuilder.toString();
if (configData.contains("&")) {
configData = configData.substring(0, configData.lastIndexOf("&"));
}
record1.put(paramsConfigEO.getId(), configData);
});
} else if ("2".equals(paramsReportDetailVO.getCombineFlag())) { // 合并
String configData = "";
List<ParamsReportConfigDataEO> paramsReportConfigDataEOS = paramsReportConfigDataEOService.queryByConfigIdListAndCollectManifestId(configIdList, paramsCollectManifestId);
String textDatas = paramsReportConfigDataEOS.stream()
.map(ParamsReportConfigDataEO::getTextData).distinct().collect(Collectors.joining(paramsReportDetailVO.getSeparator()));
String pullDatas = paramsReportConfigDataEOS.stream()
.map(ParamsReportConfigDataEO::getPullData).distinct().collect(Collectors.joining(paramsReportDetailVO.getSeparator()));
List<String> fileNameList = new ArrayList<>();
paramsReportConfigDataEOS.forEach(paramsReportConfigDataEO -> {
if (StringUtils.isNotEmpty(paramsReportConfigDataEO.getFileConnectId())) {
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(paramsReportConfigDataEO.getFileConnectId());
if (CollectionUtil.isNotEmpty(ossFileList)) {
fileNameList.add(ossFileList.get(0).getFileName());
fileList.addAll(ossFileList);
}
}
});
StringBuilder configDataBuilder = new StringBuilder(); // 重新组合配置数据
if (StringUtils.isNotEmpty(textDatas)) {
configDataBuilder.append(textDatas).append("&");
}
if (StringUtils.isNotEmpty(pullDatas)) {
configDataBuilder.append(pullDatas).append("&");
}
if (CollectionUtil.isNotEmpty(fileNameList)) {
configDataBuilder.append(StringUtils.join(fileNameList, ",")).append("&");
}
configData = configDataBuilder.toString();
if (configData.contains("&")) {
configData = configData.substring(0, configData.lastIndexOf("&"));
}
record1.put("params_value", configData);
}
}
record1.put("fileList", fileList);
}
return dataList;
}
/**
* 获取导出文件的表头
*
* @return
*/
private String[] getWorkbookTitleForExport(ParamsReportDetailVO paramsReportDetailVO) {
String cut = paramsReportDetailVO.getCut();
String certCategoryName = paramsReportDetailVO.getCertCategoryName();
String paramsManifestId = paramsReportDetailVO.getParamsManifestId();
String combineFlag = paramsReportDetailVO.getCombineFlag();
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.PARAMS_REPORT_DETAIL.getValue());
List<String> dbFieldNameList = new ArrayList<>();
List<String> dbFieldList = new ArrayList<>();
if (fieldList.size() != 0) {
//过滤列表字段(is_show_list-->列表是否显示0否 1是)
fieldList = fieldList.stream().filter(e -> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowList()))).collect(Collectors.toList());
}
// 固定列
List<Map<String, Object>> list = new LinkedList<>();
for (int i = 0; i < fieldList.size(); i++) {
OnlCgformField onlCgformField = fieldList.get(i);
Map<String, Object> map = new HashMap<>();
String dbFieldName = onlCgformField.getDbFieldName();
if ("nio_number".equals(dbFieldName) || "params_name".equals(dbFieldName)) {
dbFieldList.add(dbFieldName);
if(CutEnum.CN.getValue().equals(cut)){
dbFieldNameList.add(onlCgformField.getDbFieldTxt()); // 字段中文名
}else{
dbFieldNameList.add(onlCgformField.getDbFieldEnName()); // 字段英文名
}
}
}
// 认证类别列
dbFieldList.add("cert_number");
dbFieldList.add("cert_params_name");
if(CutEnum.CN.getValue().equals(cut)){
dbFieldNameList.add(certCategoryName + "编号"); // 字段中文名
dbFieldNameList.add(certCategoryName + "参数名称"); // 字段中文名
}else{
dbFieldNameList.add(certCategoryName + " Number"); // 字段中文名
dbFieldNameList.add(certCategoryName + " Params Name"); // 字段中文名
}
// 配置列
if ("1".equals(combineFlag)) {
List<ParamsReportConfigEO> paramsConfigEOList = paramsReportConfigEOService.queryList(paramsManifestId);
List<Map<String, Object>> listConfig = new LinkedList<>();
for (ParamsConfigEO paramsConfigEO : paramsConfigEOList) {
dbFieldList.add(paramsConfigEO.getId());
dbFieldNameList.add(paramsConfigEO.getConfigName());
}
} else if ("2".equals(combineFlag)) {
dbFieldList.add("params_value");
if(CutEnum.CN.getValue().equals(cut)){
dbFieldNameList.add("参数值"); // 字段中文名
}else{
dbFieldNameList.add("Params Values"); // 字段中文名
}
}
String[] title = new String[2];
String dbFieldStr = StringUtils.join(dbFieldList, ",");
String dbFieldNameStr = StringUtils.join(dbFieldNameList, ",");
title[0] = dbFieldStr;
title[1] = dbFieldNameStr;
return title;
}
/**
* 获取一个类和其父类的所有属性
*
@@ -0,0 +1,51 @@
package com.jero.modules.cert.report.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
@Data
public class ParamsReportDetailVO {
/**nio编号*/
@ApiModelProperty(value = "nio编号")
private String nioNumber;
/**参数名称*/
@ApiModelProperty(value = "参数名称")
private String paramsName;
/**认证类别*/
@ApiModelProperty(value = "认证类别")
private String certCategory;
/**工程接口人*/
@ApiModelProperty(value = "工程接口人")
private String sdt;
/**填写人*/
@ApiModelProperty(value = "填写人")
private String dre;
@ApiModelProperty(value = "参数清单id")
private String paramsManifestId;
@ApiModelProperty(value = "认证类别名称")
private String certCategoryName;
private String ids; // 勾选导出
private String configIds; // 导出的配置列
private String combineFlag; // 合并标识 1-不合并,2-合并
private String separator; // 分隔符
private String cut;
private String exportName;
}