认证-上报库-常规导出修改

This commit is contained in:
liyawei
2022-06-28 17:39:07 +08:00
parent de94b78395
commit 404cf5e326
11 changed files with 118 additions and 33 deletions
@@ -74,4 +74,7 @@ ALTER TABLE `laws_weilai`.`params_config_data_history`
-- 上报库参数配置数据表 修改字段长度
ALTER TABLE `laws_weilai`.`params_report_config_data`
MODIFY COLUMN `text_data` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文本类型数据' AFTER `sys_org_code`,
MODIFY COLUMN `pull_data` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '下拉类型数据' AFTER `text_data`;
MODIFY COLUMN `pull_data` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '下拉类型数据' AFTER `text_data`;
-- 上报库表 添加字段
ALTER TABLE `laws_weilai`.`params_report`
ADD COLUMN `params_template_publish_version` int(11) NULL DEFAULT NULL COMMENT '对应参数模板发布版本' AFTER `old_params_manifest_id`;
@@ -1477,7 +1477,8 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl<ParamsCollec
addReportEO.setId(reportId);
addReportEO.setOldParamsManifestId(paramsManifestId);
addReportEO.setVersion(paramsManifestEO.getVersion());
paramsReportEOService.save(addReportEO);
addReportEO.setParamsTemplatePublishVersion(paramsManifestEO.getParamsTemplatePublishVersion());
paramsReportEOService.add(addReportEO);
}
// 修改收集库参数项状态
@@ -5,6 +5,7 @@ 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.collect.vo.ParamsCollectManifestVO;
import com.jero.modules.cert.report.entity.ParamsReportDetailEO;
import com.jero.modules.cert.report.service.IParamsReportDetailEOService;
import com.jero.modules.cert.report.vo.ParamsReportDetailVO;
@@ -14,10 +15,7 @@ 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 org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -92,4 +90,19 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
paramsReportDetailEOService.exportNormal(paramsReportDetailVO, response, request);
}
/**
* 冻结配置-下拉选项
*
* @param paramsReportDetailVO
* @return
*/
@AutoLog(value = "上报库参数项-配置下拉选项(常规导出)")
@ApiOperation(value="上报库参数项-配置下拉选项(常规导出)", notes="上报库参数项-配置下拉选项(常规导出)")
@PostMapping(value = "/getConfigLabelList")
// @RequiresPermissions("report:detail:export:normal")
public Result<?> getConfigLableList(ParamsReportDetailVO paramsReportDetailVO) {
List<Map<String, String>> configLabelList = paramsReportDetailEOService.getConfigLabelList(paramsReportDetailVO);
return Result.OK(configLabelList);
}
}
@@ -67,6 +67,9 @@ public class ParamsReportEO implements Serializable {
@ApiModelProperty(value = "版本")
private Integer version;
@ApiModelProperty(value = "对应参数模板发布版本")
private Integer paramsTemplatePublishVersion;
@TableField(exist = false)
@ApiModelProperty(value = "项目名称")
private String projectName;
@@ -3,6 +3,7 @@ package com.jero.modules.cert.report.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jero.modules.cert.template.entity.CertCategoryParamsInfoEO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@@ -24,4 +25,8 @@ import java.io.Serializable;
public class ReportCertCategoryParamsInfoEO extends CertCategoryParamsInfoEO implements Serializable {
private static final long serialVersionUID = 1L;
/**发布时版本*/
@ApiModelProperty(value = "发布时版本")
private Integer version;
}
@@ -65,7 +65,10 @@
AND prd.params_name LIKE CONCAT(CONCAT('%',#{paramsReportDetailVO.paramsName}),'%')
</if>
<if test="paramsReportDetailVO.certCategory !=null and paramsReportDetailVO.certCategory !=''">
AND prd.cert_category LIKE CONCAT(CONCAT('%',#{paramsReportDetailVO.certCategory}),'%')
AND rccpi.cert_category = #{paramsReportDetailVO.certCategory}
</if>
<if test="paramsReportDetailVO.paramsTemplatePublishVersion !=null and paramsReportDetailVO.paramsTemplatePublishVersion !=''">
AND rccpi.version = #{paramsReportDetailVO.paramsTemplatePublishVersion}
</if>
<if test="paramsReportDetailVO.sdt !=null and paramsReportDetailVO.sdt !=''">
AND prd.sdt LIKE CONCAT(CONCAT('%',#{paramsReportDetailVO.sdt}),'%')
@@ -98,7 +101,7 @@
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">
<if test="idList != null and idList.size > 0">
and prd.id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
@@ -12,12 +12,18 @@
<result column="version" property="version" />
<result column="project_name" property="projectName" />
<result column="old_params_manifest_id" property="oldParamsManifestId" />
<result column="params_template_publish_version" property="paramsTemplatePublishVersion" />
</resultMap>
<sql id="BaseColumnList">
pr.id as id,
pr.old_params_manifest_id as old_params_manifest_id,
pr.version as version,
pr.params_template_publish_version as params_template_publish_version,
pr.create_by as create_by,
pr.create_time as create_time,
pr.update_by as update_by,
pr.update_time as update_time,
pm.title as title,
pni.project_name as project_name
</sql>
@@ -44,6 +50,7 @@
left join project_name_info as pni on plb.project_name_id = pni.id
) tmp_tb
<include refid="BaseQuerySql"/>
order by create_time desc
</select>
</mapper>
@@ -1,7 +1,6 @@
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;
@@ -36,4 +35,7 @@ public interface IParamsReportDetailEOService extends IService<ParamsReportDetai
List<Map<String, Object>> getHeader(String paramsManifestId, String flag, String cut);
void exportNormal(ParamsReportDetailVO paramsReportDetailVO, HttpServletResponse response, HttpServletRequest request);
// 配置-下拉选项
List<Map<String, String>> getConfigLabelList(ParamsReportDetailVO paramsReportDetailVO);
}
@@ -3,6 +3,7 @@ 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.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.jero.common.constant.enums.CutEnum;
@@ -47,7 +48,9 @@ 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.util.IOUtils;
import org.apache.poi.xssf.usermodel.*;
import org.aspectj.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -480,17 +483,17 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
OutputStream excelOS = null;
XSSFWorkbook workbook = new XSSFWorkbook();
String fileOriName = "上报库参数项常规导出信息";
if (org.apache.commons.lang.StringUtils.isNotEmpty(paramsReportDetailVO.getParamsName())) {
fileOriName = paramsReportDetailVO.getParamsName();
if (org.apache.commons.lang.StringUtils.isNotEmpty(paramsReportDetailVO.getExportName())) {
fileOriName = paramsReportDetailVO.getExportName();
}
//创建临时文件夹
String fileNowPath = uploadpath + "/tempZip/" + UUID.randomUUID().toString().replace("-","") + File.separator + fileOriName;
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
}
nowFile.mkdirs();
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("上报库参数项信息");
@@ -523,7 +526,7 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
XSSFRow row = sheetItems.createRow(0);
for (int i = 0; i < headers.length; i++) {
XSSFCell cell = row.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(headers[i]);
XSSFRichTextString text = new XSSFRichTextString(headers[i]);
cell.setCellValue(text);
cell.setCellStyle(cellStyle1);
// 设置单元格宽度
@@ -585,12 +588,44 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
log.error(e.getMessage(), e);
throw new JeroBootException("下载文件失败,请重试");
} finally {
org.apache.poi.util.IOUtils.closeQuietly(os);
org.apache.poi.util.IOUtils.closeQuietly(excelOS);
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(excelOS);
File tempZipFile = new File(uploadpath + "/tempZip");
FileUtil.deleteContents(tempZipFile);
}
}
@Override
public List<Map<String, String>> getConfigLabelList(ParamsReportDetailVO paramsReportDetailVO) {
String paramsManifestId = paramsReportDetailVO.getParamsManifestId();
// 查询配置列
LambdaQueryWrapper<ParamsReportConfigEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ParamsReportConfigEO::getParamsManifestId, paramsManifestId);
queryWrapper.orderByAsc(ParamsConfigEO::getDisplaySeq);
List<ParamsReportConfigEO> paramsConfigEOList = paramsReportConfigEOService.list(queryWrapper);
List<Map<String, String>> configLabelList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(paramsConfigEOList)) {
for (ParamsConfigEO paramsConfigEO : paramsConfigEOList) {
Map<String, String> map = new HashMap<>();
map.put("label", paramsConfigEO.getConfigName());
map.put("value", paramsConfigEO.getId());
configLabelList.add(map);
}
}
return configLabelList;
}
private void downLoadFileList(List<OSSFile> allRelevFileList,String fileNowPath) {
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
}
nowFile.mkdirs();
for(OSSFile fileExportDto : allRelevFileList){
String oldPath = fileExportDto.getUrl();
String newPath = fileNowPath + File.separator + fileExportDto.getFileName();
@@ -631,18 +666,22 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
}
private List<Map<String, Object>> queryForExport(ParamsReportDetailVO paramsReportDetailVO) {
List<String> idList = Arrays.asList(paramsReportDetailVO.getIds());
List<String> configIdList = Arrays.asList(paramsReportDetailVO.getConfigIds());
List<String> idList = new ArrayList<>();
if (StringUtils.isNotEmpty(paramsReportDetailVO.getIds())) {
idList = Arrays.asList(paramsReportDetailVO.getIds().split(","));
}
List<String> configIdList = Arrays.asList(paramsReportDetailVO.getConfigIds().split(","));
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)) {
List<OSSFile> fileList = new ArrayList<>();
//不合并
if ("1".equals(paramsReportDetailVO.getCombineFlag())) {
paramsConfigEOList = paramsConfigEOList.stream().filter(e->configIdList.contains(e.getId())).collect(Collectors.toList()); // 过滤出要导出的配置列
@@ -678,10 +717,10 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
String configData = "";
List<ParamsReportConfigDataEO> paramsReportConfigDataEOS = paramsReportConfigDataEOService.queryByConfigIdListAndCollectManifestId(configIdList, paramsCollectManifestId);
String textDatas = paramsReportConfigDataEOS.stream()
String textDatas = paramsReportConfigDataEOS.stream().filter(e->StringUtils.isNotEmpty(e.getTextData()))
.map(ParamsReportConfigDataEO::getTextData).distinct().collect(Collectors.joining(paramsReportDetailVO.getSeparator()));
String pullDatas = paramsReportConfigDataEOS.stream()
String pullDatas = paramsReportConfigDataEOS.stream().filter(e->StringUtils.isNotEmpty(e.getPullData()))
.map(ParamsReportConfigDataEO::getPullData).distinct().collect(Collectors.joining(paramsReportDetailVO.getSeparator()));
List<String> fileNameList = new ArrayList<>();
@@ -713,8 +752,8 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
record1.put("params_value", configData);
}
record1.put("fileList", fileList);
}
record1.put("fileList", fileList);
}
return dataList;
}
@@ -740,7 +779,6 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
}
// 固定列
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<>();
@@ -769,11 +807,15 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
// 配置列
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());
List<String> configIdList = Arrays.asList(paramsReportDetailVO.getConfigIds().split(","));
LambdaQueryWrapper<ParamsReportConfigEO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(ParamsReportConfigEO::getId, configIdList).orderByAsc(ParamsReportConfigEO::getDisplaySeq);
List<ParamsReportConfigEO> paramsReportConfigEOList = paramsReportConfigEOService.list(wrapper);
if (CollectionUtil.isNotEmpty(paramsReportConfigEOList)) {
for (ParamsReportConfigEO paramsReportConfigEO : paramsReportConfigEOList) {
dbFieldList.add(paramsReportConfigEO.getId());
dbFieldNameList.add(paramsReportConfigEO.getConfigName());
}
}
} else if ("2".equals(combineFlag)) {
dbFieldList.add("params_value");
@@ -40,6 +40,9 @@ public class ParamsReportDetailVO {
@ApiModelProperty(value = "认证类别名称")
private String certCategoryName;
@ApiModelProperty(value = "对应参数模板发布版本")
private Integer paramsTemplatePublishVersion;
private String ids; // 勾选导出
private String configIds; // 导出的配置列
private String combineFlag; // 合并标识 1-不合并,2-合并
@@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.aspectj.util.FileUtil;
import org.checkerframework.checker.units.qual.C;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -499,6 +500,8 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
} finally {
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(excelOS);
File tempZipFile = new File(uploadpath + "/tempZip");
FileUtil.deleteContents(tempZipFile);
}
}