From 51a66483a0c4510de30c91b174fbff1545939c73 Mon Sep 17 00:00:00 2001 From: liyawei Date: Wed, 27 Apr 2022 11:36:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A4=E8=AF=81-=E5=8F=82=E6=95=B0=E9=A1=B9?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=B8=8B=E8=BD=BD,=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ParamsInfoEOController.java | 31 +- .../entity/CertCategoryParamsInfoEO.java | 10 +- .../cert/template/entity/ParamsInfoEO.java | 36 +-- .../CertCategoryParamsInfoEOMapper.java | 5 + .../template/mapper/ParamsInfoEOMapper.java | 5 + .../xml/CertCategoryParamsInfoEOMapper.xml | 5 +- .../mapper/xml/ParamsInfoEOMapper.xml | 90 ++++++ .../service/IParamsInfoEOService.java | 25 +- .../service/impl/ParamsInfoEOServiceImpl.java | 279 ++++++++++++++++++ .../utils/CommonExcelExportStyler.java | 147 +++++++++ .../vo/CertCategoryParamsInfoEnExport.java | 74 +++++ .../cert/template/vo/ParamsInfoEnExport.java | 113 +++++++ .../cert/template/vo/ParamsInfoVO.java | 16 + 13 files changed, 805 insertions(+), 31 deletions(-) create mode 100644 jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/utils/CommonExcelExportStyler.java create mode 100644 jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/CertCategoryParamsInfoEnExport.java create mode 100644 jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/ParamsInfoEnExport.java create mode 100644 jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/ParamsInfoVO.java diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/controller/ParamsInfoEOController.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/controller/ParamsInfoEOController.java index 5199c1ecd..6c1d94d50 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/controller/ParamsInfoEOController.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/controller/ParamsInfoEOController.java @@ -1,12 +1,14 @@ package com.jero.modules.cert.template.controller; import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.template.vo.ParamsInfoVO; import com.jero.modules.cert.template.entity.ParamsInfoEO; import com.jero.modules.cert.template.service.IParamsInfoEOService; import io.swagger.annotations.Api; @@ -16,7 +18,6 @@ import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -24,7 +25,7 @@ import java.util.Arrays; import java.util.List; - /** +/** * @Description: 参数项基本信息表 * @Author: jero-boot * @Date: 2022-04-22 @@ -176,15 +177,33 @@ public class ParamsInfoEOController extends JeroController { + /*** + * 根据多个nio编号查询 + * @param nioNumber + * @return + */ List selectListByNioNumber(@Param("nioNumber") String nioNumber); int deleteByNioNumberList(@Param("list") List nioNumberList); diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/ParamsInfoEOMapper.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/ParamsInfoEOMapper.java index bc30ab0c6..95bce2855 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/ParamsInfoEOMapper.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/ParamsInfoEOMapper.java @@ -1,7 +1,11 @@ package com.jero.modules.cert.template.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.jero.modules.cert.template.vo.ParamsInfoVO; import com.jero.modules.cert.template.entity.ParamsInfoEO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @Description: 参数项基本信息表 @@ -11,4 +15,5 @@ import com.jero.modules.cert.template.entity.ParamsInfoEO; */ public interface ParamsInfoEOMapper extends BaseMapper { + List selectListWithCert(@Param("paramsInfoVO") ParamsInfoVO paramsInfoVO); } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/xml/CertCategoryParamsInfoEOMapper.xml b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/xml/CertCategoryParamsInfoEOMapper.xml index edf706584..8a054a983 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/xml/CertCategoryParamsInfoEOMapper.xml +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/xml/CertCategoryParamsInfoEOMapper.xml @@ -19,7 +19,10 @@ diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/xml/ParamsInfoEOMapper.xml b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/xml/ParamsInfoEOMapper.xml index ce4cbefa7..37b75a019 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/xml/ParamsInfoEOMapper.xml +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/mapper/xml/ParamsInfoEOMapper.xml @@ -22,4 +22,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pi.id as id, + pi.create_by as create_by, + pi.create_time as create_time, + pi.update_by as update_by, + pi.update_time as update_time, + pi.sys_org_code as sys_org_code, + pi.nio_number as nio_number, + pi.is_must as is_must, + pi.params_name as params_name, + pi.technology_territory as technology_territory, + pi.params_batch as params_batch , + pi.duty_territory as duty_territory, + pi.description as description, + pi.cert_category as cert_category, + pi.control_type as control_type, + pi.control_values as control_values, + pi.control_verify as control_verify, + pi.file_template_connect_id as file_template_connect_id, + pi.params_template_id as params_template_id, + ccpi.id as ccpi_id, + ccpi.params_number as ccpi_params_number, + ccpi.params_name as ccpi_params_name, + ccpi.description as ccpi_description, + ccpi.nio_number as ccpi_nio_number, + ccpi.cert_category as ccpi_cert_category, + ccpi.params_template_id as ccpi_params_template_id + + + + + + + AND nio_number LIKE CONCAT(CONCAT('%',#{paramsInfoVO.nioNumber}),'%') + + + AND params_name LIKE CONCAT(CONCAT('%',#{paramsInfoVO.paramsName}),'%') + + + and id in + + #{item} + + + + + + + + \ No newline at end of file diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/service/IParamsInfoEOService.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/service/IParamsInfoEOService.java index b92d22890..8229dbd75 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/service/IParamsInfoEOService.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/service/IParamsInfoEOService.java @@ -1,7 +1,12 @@ package com.jero.modules.cert.template.service; -import com.jero.modules.cert.template.entity.ParamsInfoEO; import com.baomidou.mybatisplus.extension.service.IService; +import com.jero.modules.cert.template.vo.ParamsInfoVO; +import com.jero.modules.cert.template.entity.ParamsInfoEO; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; /** @@ -58,4 +63,22 @@ public interface IParamsInfoEOService extends IService { * @return */ List queryList(); + + /** + * 模板下载 + * @param cut + * @param response + * @param request + */ + void exportTemplate(String cut, String templateName, HttpServletResponse response, HttpServletRequest request) throws IOException; + + /** + * 导出压缩包 + * @param cut + * @param paramsInfoVO + * @param exportExcelName + * @param response + * @param request + */ + void exportParamsInfo(String cut, ParamsInfoVO paramsInfoVO, String exportExcelName, HttpServletResponse response, HttpServletRequest request); } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/service/impl/ParamsInfoEOServiceImpl.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/service/impl/ParamsInfoEOServiceImpl.java index 5604afd75..2ebd3b45b 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/service/impl/ParamsInfoEOServiceImpl.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/service/impl/ParamsInfoEOServiceImpl.java @@ -2,22 +2,43 @@ package com.jero.modules.cert.template.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ZipUtil; +import com.aliyuncs.utils.IOUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.jero.common.constant.enums.CutEnum; import com.jero.common.exception.JeroBootException; import com.jero.modules.cert.template.entity.CertCategoryParamsInfoEO; import com.jero.modules.cert.template.entity.ParamsInfoEO; import com.jero.modules.cert.template.mapper.ParamsInfoEOMapper; import com.jero.modules.cert.template.service.ICertCategoryParamsInfoEOService; import com.jero.modules.cert.template.service.IParamsInfoEOService; +import com.jero.modules.cert.template.utils.CommonExcelExportStyler; +import com.jero.modules.cert.template.vo.CertCategoryParamsInfoEnExport; +import com.jero.modules.cert.template.vo.ParamsInfoEnExport; +import com.jero.modules.cert.template.vo.ParamsInfoVO; import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.oss.service.IOSSFileService; +import com.jero.modules.split.common.ReadExcel; +import com.jero.modules.system.entity.SysDictItem; +import com.jero.modules.system.service.ISysDictItemService; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Workbook; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; import java.util.*; import java.util.stream.Collectors; @@ -36,6 +57,11 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl nioNumberList = paramsInfoEOList.stream().map(ParamsInfoEO::getNioNumber).collect(Collectors.toList()); // 关联删除认证类别参数项 certCategoryParamsInfoEOService.deleteByNioNumberList(nioNumberList); + // TODO 关联删除附件模板文件信息和文件 } removeByIds(ids); @@ -195,4 +223,255 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl queryList() { return list(); } + + @Override + public void exportTemplate(String cut, String templateName, HttpServletResponse response, HttpServletRequest request) throws IOException { + Workbook workbook = null; + OutputStream os = null; + try { + //判断导出文件名称 + String fileName = ""; + if(StringUtils.isEmpty(templateName)){ + fileName="参数项模板"; + }else{ + fileName = templateName; + } + + // 导出sheet列表 + List> sheetsList = new ArrayList<>(); + + // 基本参数项 + ExportParams bussExportParams = new ExportParams(); + bussExportParams.setSheetName("企业参数表"); + bussExportParams.setType(ExcelType.XSSF); // 解决HSSFRichTextString cannot cast XSSFRichTextString问题 + bussExportParams.setStyle(CommonExcelExportStyler.class); + + Map bussExportMap = new HashMap<>(); + bussExportMap.put("title", bussExportParams); + bussExportMap.put("entity", ParamsInfoEO.class); + if (CutEnum.CN.getValue().equals(cut)) { + bussExportMap.put("data", new ArrayList()); + } else if (CutEnum.EN.getValue().equals(cut)) { + bussExportMap.put("data", new ArrayList()); + } + sheetsList.add(bussExportMap); + + // 认证类别参数项 + List sysDictItemList = sysDictItemService.selectItemsByDictCode("cert_category"); + List certCategoryNameList = sysDictItemList.stream().map(SysDictItem::getItemText).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(certCategoryNameList)) { + for (String certCategoryName : certCategoryNameList) { + ExportParams certExportParams = new ExportParams(); + certExportParams.setSheetName(certCategoryName); + certExportParams.setType(ExcelType.XSSF); // 解决HSSFRichTextString cannot cast XSSFRichTextString问题 + certExportParams.setStyle(CommonExcelExportStyler.class); + Map certExportMap = new HashMap<>(); + certExportMap.put("title", certExportParams); + certExportMap.put("entity", CertCategoryParamsInfoEO.class); + if (CutEnum.CN.getValue().equals(cut)) { + certExportMap.put("data", new ArrayList()); + } else if (CutEnum.EN.getValue().equals(cut)) { + certExportMap.put("data", new ArrayList()); + } + sheetsList.add(certExportMap); + } + } + + workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.XSSF); + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", + "attachment; filename=" + ReadExcel.encodeFileName(fileName + ".xlsx", request)); + response.flushBuffer(); + os = response.getOutputStream(); + workbook.write(os); + } catch (IOException e) { + log.error("发生异常,异常信息为:"+e.getMessage(), e); + throw new JeroBootException("下载文件失败,请重试"); + }finally { + IOUtils.closeQuietly(os); + try { + if (workbook != null) { + workbook.close(); + } + } catch (IOException e) { + log.error("发生异常,异常信息为:"+e.getMessage(), e); + } + } + } + + @Override + public void exportParamsInfo(String cut, ParamsInfoVO paramsInfoVO, String exportExcelName, HttpServletResponse response, HttpServletRequest request) { + Workbook workbook = null; + OutputStream os = null; + OutputStream excelOS = null; + try{ + //判断导出文件名称 + String exportName = ""; + if(StringUtils.isEmpty(exportName)){ + exportName="参数项导出数据"; + }else{ + exportName = exportExcelName; + } + + //创建临时文件夹 + String fileNowPath = uploadpath + "/tempZip/" + UUID.randomUUID().toString().replace("-","") + File.separator + exportName; + File nowFile = new File(fileNowPath); + if (nowFile.exists()){ // 若创建文件夹存在,删除重新创建 + nowFile.delete(); + } + nowFile.mkdirs(); + + String fileName = exportName + ".xlsx"; + + // 查询导出数据 + List paramsInfoEOList = baseMapper.selectListWithCert(paramsInfoVO); + if (CollectionUtil.isEmpty(paramsInfoEOList)) { + throw new JeroBootException("没有可导出的数据"); + } + + List fileTemplateList = new ArrayList<>(); + for (ParamsInfoEO paramsInfoEO : paramsInfoEOList) { + String fileTemplateConnectId = paramsInfoEO.getFileTemplateConnectId(); + if (StringUtils.isNotBlank(fileTemplateConnectId)) { + List ossFileList = ossFileService.getFileInfosByConnectId(fileTemplateConnectId); + List fileNameList = ossFileList.stream().map(OSSFile::getFileName).collect(Collectors.toList()); + paramsInfoEO.setFileTemplateName(StringUtils.join(fileNameList, ",")); + + fileTemplateList.addAll(ossFileList); + } + } + + // 查询导出参数项中认证类别最大级 + List nioNumber = paramsInfoEOList.stream().map(ParamsInfoEO::getNioNumber).collect(Collectors.toList()); + List certCategoryParamsInfoEOList = certCategoryParamsInfoEOService.selectListByNioNumber(StringUtils.join(nioNumber, ",")); + List certCategoryNameList = new ArrayList<>(); + Map certCategoryMap = new HashMap<>(); + if (CollectionUtil.isNotEmpty(certCategoryParamsInfoEOList)) { + List certCategoryList = certCategoryParamsInfoEOList.stream().map(CertCategoryParamsInfoEO::getCertCategory).distinct().collect(Collectors.toList()); + List sysDictItemList = sysDictItemService.selectItemsByDictCode("cert_category"); + List finalCertCategoryList = certCategoryList; + certCategoryNameList = sysDictItemList.stream().filter(e-> finalCertCategoryList.contains(e.getItemValue())).map(SysDictItem::getItemText).collect(Collectors.toList()); + certCategoryMap = sysDictItemList.stream().filter(e-> finalCertCategoryList.contains(e.getItemValue())).collect(Collectors.toMap(c->c.getItemText(),c->c.getItemValue())); + } + //导出数据 + List> sheetsList = new ArrayList<>(); + + // 创建参数对象(用来设定excel得sheet得内容等信息) + ExportParams bussExportParams = new ExportParams(); + // 设置sheet得名称 + bussExportParams.setSheetName("企业参数表"); + bussExportParams.setType(ExcelType.XSSF); // 解决HSSFRichTextString cannot cast XSSFRichTextString问题 + bussExportParams.setStyle(CommonExcelExportStyler.class); + // 创建sheet1使用得map + Map bussExportMap = new HashMap<>(); + // title的参数为ExportParams类型,目前仅仅在ExportParams中设置了sheetName + bussExportMap.put("title", bussExportParams); + // 模版导出对应得实体类型 + bussExportMap.put("entity", ParamsInfoEO.class); + // sheet中要填充得数据 + bussExportMap.put("data", paramsInfoEOList); + sheetsList.add(bussExportMap); + + // 导出认证类别参数项 + if (CollectionUtil.isNotEmpty(certCategoryNameList)) { + // 所有数据 + List certCategoryParamsInfoListExport = new ArrayList<>(); + for (ParamsInfoEO paramsInfoEO : paramsInfoEOList) { + List categoryParamsInfoEOList = paramsInfoEO.getCertCategoryParamsInfoEOList(); + certCategoryParamsInfoListExport.addAll(categoryParamsInfoEOList); + } + if (CollectionUtil.isNotEmpty(certCategoryParamsInfoListExport)) { + for (String certCategoryName : certCategoryNameList) { + // 当前认证类别数据 + Map finalCertCategoryMap = certCategoryMap; + List certCategoryParamsInfoExport = certCategoryParamsInfoListExport.stream() + .filter(e -> finalCertCategoryMap.get(certCategoryName).equals(e.getCertCategory())) + .collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(certCategoryParamsInfoExport)) { + ExportParams certExportParams = new ExportParams(); + certExportParams.setSheetName(certCategoryName); + certExportParams.setType(ExcelType.XSSF); // 解决HSSFRichTextString cannot cast XSSFRichTextString问题 + certExportParams.setStyle(CommonExcelExportStyler.class); + Map certExportMap = new HashMap<>(); + certExportMap.put("title", certExportParams); + certExportMap.put("entity", CertCategoryParamsInfoEO.class); + certExportMap.put("data", certCategoryParamsInfoExport); + sheetsList.add(certExportMap); + } + } + } + } + + workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.XSSF); + + //下载附件模板对应文件 + if (fileTemplateList != null && !fileTemplateList.isEmpty()) { + fileTemplateList = fileTemplateList.stream().distinct().collect(Collectors.toList()); + downLoadFileList(fileTemplateList,fileNowPath); + } + + + String repFileName = fileName.replaceAll("/","_"); + excelOS = new FileOutputStream(fileNowPath + File.separator + repFileName); + response.setHeader("Content-Disposition", + "attachment; filename=\""+ ReadExcel.encodeFileName(exportName+".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 { + IOUtils.closeQuietly(os); + IOUtils.closeQuietly(excelOS); + } + } + + private void downLoadFileList(List fileTemplateList,String fileNowPath) throws IOException { + for(OSSFile fileExportDto : fileTemplateList){ + String oldPath = fileExportDto.getUrl(); + String newPath = fileNowPath + File.separator + fileExportDto.getFileName(); + File oldFile = new File(oldPath); + if (oldFile.exists()){ + copyFile(oldPath, newPath); + } + } + + } + + private void copyFile(String srcPath, String destPath) throws IOException { + BufferedInputStream bis = new BufferedInputStream(Files.newInputStream(Paths.get(srcPath))); + 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); + } + // 关闭流 先开后关 后开先关 + bos.close(); // 后开先关 + bis.close(); // 先开后关 + } + } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/utils/CommonExcelExportStyler.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/utils/CommonExcelExportStyler.java new file mode 100644 index 000000000..f452c4a44 --- /dev/null +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/utils/CommonExcelExportStyler.java @@ -0,0 +1,147 @@ +package com.jero.modules.cert.template.utils; + +import org.apache.poi.ss.usermodel.*; +import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity; +import org.jeecgframework.poi.excel.export.styler.IExcelExportStyler; + +/** + * @Description + * @Author liyawei + * @Create 2021/8/10 - 16:23 + */ +public class CommonExcelExportStyler implements IExcelExportStyler { + private static final short STRING_FORMAT = (short) BuiltinFormats.getBuiltinFormat("TEXT"); + private static final short FONT_SIZE_TEN = 10; + private static final short FONT_SIZE_ELEVEN = 11; + private static final short FONT_SIZE_TWELVE = 12; + /** + * 大标题样式 + */ + private CellStyle headerStyle; + /** + * 每列标题样式 + */ + private CellStyle titleStyle; + /** + * 数据行样式 + */ + private CellStyle styles; + + public CommonExcelExportStyler(Workbook workbook) { + this.init(workbook); + } + + /** + * 初始化样式 + * + * @param workbook + */ + private void init(Workbook workbook) { +// workbook.setSheetName(0,"sheet1"); + this.headerStyle = initHeaderStyle(workbook); + this.titleStyle = initTitleStyle(workbook); + this.styles = initDataStyle(workbook); + } + + /** + * 大标题样式 + * + * @param color + * @return + */ + @Override + public CellStyle getHeaderStyle(short color) { + return headerStyle; + } + + /** + * 每列标题样式 + * + * @param color + * @return + */ + @Override + public CellStyle getTitleStyle(short color) { + return titleStyle; + } + + /** + * 数据行样式 + * + * @param parity 可以用来表示奇偶行 + * @param entity 数据内容 + * @return 样式 + */ + @Override + public CellStyle getStyles(boolean parity, ExcelExportEntity entity) { + return styles; + } + + /** + * 初始化--大标题样式 + * + * @param workbook + * @return + */ + private CellStyle initHeaderStyle(Workbook workbook) { + CellStyle style = getBaseCellStyle(workbook); + style.setFont(getFont(workbook, FONT_SIZE_TWELVE, true)); + return style; + } + + /** + * 初始化--大标题样式 + * + * @param workbook + * @return + */ + private CellStyle initTitleStyle(Workbook workbook) { + CellStyle style = getBaseCellStyle(workbook); + style.setFont(getFont(workbook, FONT_SIZE_ELEVEN, false)); + return style; + } + + /** + * 初始化--数据行样式 + * + * @param workbook + * @return + */ + private CellStyle initDataStyle(Workbook workbook) { + CellStyle style = getBaseCellStyle(workbook); + style.setFont(getFont(workbook, FONT_SIZE_ELEVEN, false)); + return style; + } + + /** + * 基础样式 + * + * @return + */ + private CellStyle getBaseCellStyle(Workbook workbook) { + CellStyle style = workbook.createCellStyle(); + style.setBorderBottom(BorderStyle.THIN); // 下边框 + style.setBorderLeft(BorderStyle.THIN); // 左边框 + style.setBorderTop(BorderStyle.THIN); // 上边框 + style.setBorderRight(BorderStyle.THIN); // 右边框 + style.setAlignment(HorizontalAlignment.CENTER); // 水平居中 + style.setVerticalAlignment(VerticalAlignment.BOTTOM); // 上下居中 + style.setWrapText(true); // 设置自动换行 + return style; + } + + /** + * 字体样式 + * + * @param size 字体大小 + * @param isBold 是否加粗 + * @return + */ + private Font getFont(Workbook workbook, short size, boolean isBold) { + Font font = workbook.createFont(); + font.setFontName("宋体"); // 字体样式 + font.setBold(isBold); // 是否加粗 + font.setFontHeightInPoints(size); // 字体大小 + return font; + } +} diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/CertCategoryParamsInfoEnExport.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/CertCategoryParamsInfoEnExport.java new file mode 100644 index 000000000..2ab222110 --- /dev/null +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/CertCategoryParamsInfoEnExport.java @@ -0,0 +1,74 @@ +package com.jero.modules.cert.template.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.jero.modules.cert.template.entity.CertCategoryParamsInfoEO; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.List; + +/** + * @Author: liyawei + * @Description: + * @Date: Created in 15:14 2022/4/25 + */ +@Data +public class CertCategoryParamsInfoEnExport { + /**主键*/ + @ApiModelProperty(value = "主键") + private String id; + + /**创建人*/ + @ApiModelProperty(value = "创建人") + private String createBy; + + /**创建日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建日期") + private java.util.Date createTime; + + /**更新人*/ + @ApiModelProperty(value = "更新人") + private String updateBy; + + /**更新日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新日期") + private java.util.Date updateTime; + + /**所属部门*/ + @ApiModelProperty(value = "所属部门") + private String sysOrgCode; + + /**编号*/ + @Excel(name = "*number", width = 15, orderNum = "2") + @ApiModelProperty(value = "编号") + private String paramsNumber; + + /**参数名称*/ + @Excel(name = "*params name", width = 15, orderNum = "3") + @ApiModelProperty(value = "参数名称") + private String paramsName; + + /**参数说明*/ + @Excel(name = "description", width = 36, orderNum = "4") + @ApiModelProperty(value = "参数说明") + private String description; + + /**nio编号*/ + @Excel(name = "*nio number", width = 15, orderNum = "1") + @ApiModelProperty(value = "nio编号") + private String nioNumber; + + /**所属认证类别*/ + @ApiModelProperty(value = "所属认证类别") + private String certCategory; + + /**参数模板id*/ + @ApiModelProperty(value = "参数模板id") + private String paramsTemplateId; +} diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/ParamsInfoEnExport.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/ParamsInfoEnExport.java new file mode 100644 index 000000000..83f432fb8 --- /dev/null +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/ParamsInfoEnExport.java @@ -0,0 +1,113 @@ +package com.jero.modules.cert.template.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.jero.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * @Author: liyawei + * @Description: + * @Date: Created in 15:14 2022/4/25 + */ +@Data +public class ParamsInfoEnExport { + /**主键*/ + @ApiModelProperty(value = "主键") + private String id; + + /**创建人*/ + @ApiModelProperty(value = "创建人") + private String createBy; + + /**创建日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建日期") + private java.util.Date createTime; + + /**更新人*/ + @ApiModelProperty(value = "更新人") + private String updateBy; + + /**更新日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新日期") + private java.util.Date updateTime; + + /**所属部门*/ + @ApiModelProperty(value = "所属部门") + private String sysOrgCode; + + /**nio编号*/ + @Excel(name = "*nio number", width = 15) + @ApiModelProperty(value = "nio编号") + private String nioNumber; + + /**是否必填*/ + @Excel(name = "*is must", width = 15, replace = {"yes_1","no_0"}) + @ApiModelProperty(value = "是否必填") + private String isMust; + + /**参数名称*/ + @Excel(name = "*param name", width = 15) + @ApiModelProperty(value = "参数名称") + private String paramsName; + + /**技术领域*/ + @Excel(name = "*technology territory", width = 15, dicCode = "technology_territory") + @Dict(dicCode = "technology_territory") + @ApiModelProperty(value = "技术领域") + private String technologyTerritory; + + /**参数批次*/ + @Excel(name = "*params batch", width = 15, dicCode = "params_batch") + @Dict(dicCode = "params_batch") + @ApiModelProperty(value = "参数批次") + private String paramsBatch; + + /**责任领域*/ + @Excel(name = "*duty territory", width = 15, dicCode = "duty_territory") + @Dict(dicCode = "duty_territory") + @ApiModelProperty(value = "责任领域") + private String dutyTerritory; + + /**参数说明*/ + @Excel(name = "description", width = 36) + @ApiModelProperty(value = "参数说明") + private String description; + + /**认证类别*/ + @Excel(name = "cert category", width = 15, dicCode = "cert_category") + @Dict(dicCode = "cert_category") + @ApiModelProperty(value = "认证类别") + private String certCategory; + + /**控件类型*/ + @Excel(name = "*control type", width = 15, replace = {"text_1","pull single_2","pull more_3","file_4","text+pull single_5","text+pull more_6","text+file_7","pull single+file_8","pull more+file_9","text+pull single+file_10"}) + @ApiModelProperty(value = "控件类型") + private String controlType; + + /**控件校验*/ + @Excel(name = "control verify", width = 15, replace = {"null_1","chinese_2","positive integer_3","positive float_4","integer decimaL_5","decimal one_6","decimal two_7","decimal three_8","decimal four_9"}) + @ApiModelProperty(value = "控件校验") + private String controlVerify; + + /**控件备选值*/ + @Excel(name = "control values", width = 15) + @ApiModelProperty(value = "控件备选值") + private String controlValues; + + /**附件模板*/ + @ApiModelProperty(value = "附件模板") + private String fileTemplateConnectId; + + @Excel(name = "file template", width = 15) + @TableField(exist = false) + private String fileTemplateName; //附件模板文件名 + +} diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/ParamsInfoVO.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/ParamsInfoVO.java new file mode 100644 index 000000000..3cc7fbed5 --- /dev/null +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/template/vo/ParamsInfoVO.java @@ -0,0 +1,16 @@ +package com.jero.modules.cert.template.vo; + +import lombok.Data; + +/** + * @Author: liyawei + * @Description: + * @Date: Created in 10:37 2022/4/25 + */ +@Data +public class ParamsInfoVO { + private String nioNumber; // nio编号 + private String paramsName; // 参数名称 + private String dutyTerritory; // 责任领域 + private String ids; // 勾选的参数项id +}