diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectLawsInventoryEOController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectLawsInventoryEOController.java index 1796040b2..f5caa0ca2 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectLawsInventoryEOController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectLawsInventoryEOController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.itextpdf.text.*; import com.jero.common.api.vo.Result; import com.jero.common.aspect.annotation.AutoLog; import com.jero.common.constant.enums.CutEnum; @@ -33,15 +34,17 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; -import java.util.HashMap; +import java.io.*; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.List; -import java.util.Map; - /** +/** * @Description: 项目库-法规清单表 * @Author: jero-boot * @Date: 2022-04-14 @@ -370,12 +373,20 @@ public class ProjectLawsInventoryEOController extends JeroController change(@RequestParam(name="ids",required=true) String ids, - @RequestParam(name="cut",required=true) String cut) { - Map parmas = new HashMap<>(); - parmas.put("ids",ids); - parmas.put("cut",cut); - return this.projectLawsInventoryEOService.change(parmas); + public Result change(@RequestParam Map params) { + return this.projectLawsInventoryEOService.change(params); + } + + @AutoLog(value = "下载pdf报告") + @ApiOperation(value="下载pdf报告", notes="下载pdf报告") + @GetMapping(value = "/downloadReport") +// public void downloadReport(@RequestParam Map params, HttpServletRequest req, HttpServletResponse resp) throws DocumentException { + public void downloadReport(@RequestParam("cut")String cut,@RequestParam("id")String id, HttpServletRequest req, HttpServletResponse resp) throws DocumentException { + Map params = new HashMap<>(); + params.put("cut",cut); + params.put("id",id); + + this.projectLawsInventoryEOService.downloadReport(params,req,resp); } /** diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLawsInventoryEOService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLawsInventoryEOService.java index 85c80e477..61c7b047e 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLawsInventoryEOService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLawsInventoryEOService.java @@ -2,6 +2,7 @@ package com.jero.modules.project.service; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.service.IService; +import com.itextpdf.text.DocumentException; import com.jero.common.api.vo.Result; import com.jero.common.system.vo.LoginUser; import com.jero.modules.project.entity.ProjectLawsInventoryEO; @@ -119,4 +120,6 @@ public interface IProjectLawsInventoryEOService extends IService list, LoginUser currentUser, int isProjectRole, String cut); Result change(Map parmas); + + void downloadReport(Map params,HttpServletRequest req, HttpServletResponse resp)throws DocumentException; } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLawsInventoryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLawsInventoryEOServiceImpl.java index 2c99d2b91..0f33d185e 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLawsInventoryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLawsInventoryEOServiceImpl.java @@ -1,6 +1,9 @@ package com.jero.modules.project.service.impl; import cn.hutool.core.util.ZipUtil; +import com.itextpdf.text.*; +import com.itextpdf.text.Font; +import com.itextpdf.text.pdf.*; import com.jero.modules.dummy.entity.DummyInventoryBaseEO; import com.jero.modules.dummy.entity.DummyInventoryInfoEOEn; import com.jero.modules.dummy.enums.DummyInventoryBaseFieldEnum; @@ -74,12 +77,15 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.net.URLEncoder; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; +import java.util.List; import java.util.stream.Collectors; import static com.jero.modules.document.service.impl.BussDocumentLibraryEOServiceImpl.copyFile; @@ -132,10 +138,17 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl queryTaskInventoryFeedbackWrapper = new QueryWrapper<>(); + queryTaskInventoryFeedbackWrapper.lambda().in(ProjectTaskInventoryFeedbackEO::getProjectTaskInventoryId,idList); + List projectTaskInventoryFeedbackEOList = projectTaskInventoryFeedbackEOService.getBaseMapper().selectList(queryTaskInventoryFeedbackWrapper); + List feedbackIdList = projectTaskInventoryFeedbackEOList.stream().map(ProjectTaskInventoryFeedbackEO::getId).distinct().collect(Collectors.toList()); + QueryWrapper deleteFeedbackHistoryWrapper = new QueryWrapper<>(); + deleteFeedbackHistoryWrapper.lambda().in(FeedbackHistory::getFeedbackId,feedbackIdList); + feedbackHistoryService.remove(deleteFeedbackHistoryWrapper); + //删除反馈意见数据 QueryWrapper deleteTaskInventoryFeedbackWrapper = new QueryWrapper<>(); deleteTaskInventoryFeedbackWrapper.lambda().in(ProjectTaskInventoryFeedbackEO::getProjectTaskInventoryId,idList); @@ -3572,4 +3594,528 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl params,HttpServletRequest req, HttpServletResponse resp) throws DocumentException{ + String filename = "法规清单报告"; + + File file = null; + InputStream fin = null; + ServletOutputStream out = null; + + String filePar = null; + // 文件夹路径 + filePar = exportPdfTempPath + new Date().getTime(); + File myPath = new File(filePar); + file = new File(filePar + "/" + filename + new Date().getTime() + ".pdf"); + if (!myPath.exists()){ + myPath.mkdirs(); + } + + /*******pdf文件内容生成开始*********/ + Document document = new Document(PageSize.A4, 25, 25, 25, 25); + + //设中文字体 + BaseFont bfChinese = null; + try { + //bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED); // 该方式不好用。 + + //创建一个支持中文的字体,字体为本地下载的字体 + bfChinese = BaseFont.createFont(simfangFontFilePath, BaseFont.IDENTITY_H,BaseFont.EMBEDDED); + } catch (Exception e) { + e.printStackTrace(); + } + + //创建标题 //size:26 一号字体 + Font f26 = new Font(bfChinese, 18, Font.NORMAL); + //Font f10 = new Font(bfChinese, 10, Font.NORMAL); + //Font f12 = new Font(bfChinese, 12, Font.NORMAL); + Font f8 = new Font(bfChinese, 8, Font.NORMAL); + Paragraph title1 = new Paragraph("ComplianceReport-Template", f26); + title1.setAlignment(Element.ALIGN_CENTER); + title1.setAlignment(Element.ALIGN_CENTER); + Chapter chapter1 = new Chapter(title1, 1); + chapter1.setNumberDepth(0); + Section section1 = chapter1; + + try { + PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); + } catch (DocumentException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + document.open(); + + // 创建4列的表格 + int colNumber = 4; + PdfPTable tableBasic = new PdfPTable(colNumber); + //设置段落上下空白 + //tableBasic.setSpacingBefore(25); + //tableBasic.setSpacingAfter(25); + + section1.add(tableBasic); + document.add(chapter1); + + String cut = (String) params.get("cut"); + String id = (String) params.get("id");//法规id + + QueryWrapper lawsInventoryQueryWrapper = new QueryWrapper<>(); + lawsInventoryQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getId,id); + ProjectLawsInventoryEO projectLawsInventoryEO = this.baseMapper.selectOne(lawsInventoryQueryWrapper); + params.put("projectLawsInventoryEO",projectLawsInventoryEO); + + QueryWrapper taskInventoryQueryWrapper = new QueryWrapper<>(); + taskInventoryQueryWrapper.lambda().eq(ProjectTaskInventoryEO::getProjectLawsInventoryId,id); + ProjectTaskInventoryEO projectTaskInventoryEO = projectTaskInventoryEOService.getBaseMapper().selectOne(taskInventoryQueryWrapper); + params.put("projectTaskInventoryEO",projectTaskInventoryEO); + + QueryWrapper libraryBaseQueryWrapper = new QueryWrapper<>(); + libraryBaseQueryWrapper.lambda().eq(ProjectLibraryBase::getId,projectLawsInventoryEO.getProjectLibraryId()); + ProjectLibraryBase projectLibraryBase = projectLibraryBaseMapper.selectOne(libraryBaseQueryWrapper); + params.put("projectLibraryBase",projectLibraryBase); + + QueryWrapper projectNameQueryWrapper = new QueryWrapper<>(); + projectNameQueryWrapper.lambda().eq(ProjectNameInfoEO::getId,projectLibraryBase.getProjectNameId()); + ProjectNameInfoEO projectNameInfoEO = projectNameInfoEOMapper.selectOne(projectNameQueryWrapper); + params.put("projectNameInfoEO",projectNameInfoEO); + + //设置ProgramInformation内容 + setProgramInformation(tableBasic,document,f8,params); + + //设置ComplianceAttachments 验证符合性流程里最后通过审批的 “ 工程确认 ” 中的附件 内容 + setComplianceAttachments(new PdfPTable(2),document,f8); + + //设置ComplianceResult 内容 + setComplianceResult(new PdfPTable(2),document,f8,params); + + //审核历史表头 + String[] auditHistoryHead = new String[]{"Result", "Opinion", "Node", "Operator", "Datetime"}; + + //设置DesignComplianceCheckApprovals (设计符合性确认的审批历史数据,没有就空着) 内容 + setDesignComplianceCheckApprovals(new PdfPTable(auditHistoryHead.length),document,f8,auditHistoryHead,params); + + //设置ValidationComplianceCheckApprovals (验证符合性确认的审批历史数据,没有就空着) 内容 + setValidationComplianceCheckApprovals(new PdfPTable(auditHistoryHead.length),document,f8,auditHistoryHead,params); + + document.close(); + + try { + fin = new FileInputStream(file); + resp.setCharacterEncoding("utf-8"); + resp.setContentType("application/pdf"); + + // 设置浏览器以下载的方式处理该文件 + if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0) { + filename = URLEncoder.encode(filename, "UTF-8"); + } else { + filename = new String(filename.getBytes("UTF-8"), "ISO8859-1"); + } + resp.setHeader("Content-Disposition", "attachment;filename=" + filename + ".pdf"); + out = resp.getOutputStream(); + + // 缓冲区 + byte[] buffer = new byte[512]; + int bytesToRead = -1; + + // 通过循环将读入的Word文件的内容输出到浏览器中 + while ((bytesToRead = fin.read(buffer)) != -1) { + out.write(buffer, 0, bytesToRead); + } + }catch (Exception ex){ + ex.printStackTrace(); + }finally { + try { + if (fin != null){ + fin.close(); + } + if (out != null){ + out.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + if (file != null){ + // 删除临时文件 + file.delete(); + } + + if (myPath != null){ + // 删除临时文件夹 + myPath.delete(); + } + } + } + + private PdfPCell pdfTableStyle(String content,Font font,int high,boolean isAlignCenter,boolean isAlignMidde){ + PdfPCell pdfPCell = new PdfPCell(new Phrase(content,font)); + pdfPCell.setMinimumHeight(high); + pdfPCell.setUseAscender(true); // 设置可以居中 + if (isAlignCenter){ + pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // 设置水平居中 + } + if (isAlignMidde){ + pdfPCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); // 设置垂直居中 + } + return pdfPCell; + } + + public void setProgramInformation(PdfPTable tableBase,Document document,Font fontSize,Map params) throws DocumentException{ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + String cut = (String) params.get("cut"); + + ProjectLawsInventoryEO projectLawsInventoryEO = (ProjectLawsInventoryEO) params.get("projectLawsInventoryEO"); + ProjectTaskInventoryEO projectTaskInventoryEO = (ProjectTaskInventoryEO) params.get("projectTaskInventoryEO"); + ProjectLibraryBase projectLibraryBase = (ProjectLibraryBase) params.get("projectLibraryBase"); + ProjectNameInfoEO projectNameInfoEO = (ProjectNameInfoEO) params.get("projectNameInfoEO"); + + tableBase.setHorizontalAlignment(Element.ALIGN_CENTER);// 居左 + tableBase.setTotalWidth(500f);//表格的总宽度 + tableBase.setWidthPercentage(100);// 表格的宽度百分比 + + PdfPTable tableName = new PdfPTable(1); + //设置段落上空白 + tableName.setSpacingBefore(25); + //设置标题长度占纸张比例 + tableName.setWidthPercentage(widthPercentage); + //给表格赋值 + PdfPCell programInformation = pdfTableStyle("Program Information", fontSize, 10, false, false); + programInformation.disableBorderSide(15); + tableName.addCell(programInformation); + //将表格添加到文档对象中 + document.add(tableName); + + // cell 11 第一行 第一列 + PdfPCell cell11 = pdfTableStyle("CR No.", fontSize, 50, true, true); + tableBase.addCell(cell11); + PdfPCell cell12 = pdfTableStyle("Xxx(自动生成NIO-日期-序号)NIO-2022041301", fontSize, 50, true, true); + tableBase.addCell(cell12); + PdfPCell cell13 = pdfTableStyle("CR Status", fontSize, 50, true, true); + tableBase.addCell(cell13); + + String flowStatus = ""; + if(StringUtils.isNotEmpty(projectTaskInventoryEO.getVerifyStatus())){ + flowStatus = projectTaskInventoryEO.getVerifyStatus() + ","; + } + if(StringUtils.isNotEmpty(projectTaskInventoryEO.getPrehomoStatus())){ + flowStatus += projectTaskInventoryEO.getPrehomoStatus() + ","; + } + if(StringUtils.isNotEmpty(projectTaskInventoryEO.getVerifyStatus())){ + flowStatus += projectTaskInventoryEO.getVerifyStatus() + ","; + } + if(StringUtils.isNotEmpty(flowStatus)){ + flowStatus = flowStatus.substring(0,flowStatus.length() - 1); + } + PdfPCell cell14 = pdfTableStyle(flowStatus, fontSize, 50, true, true); + tableBase.addCell(cell14); + + // cell 21 第二行 第一列 + PdfPCell cell21 = pdfTableStyle("Regulation", fontSize, 50, true, true); + tableBase.addCell(cell21); + PdfPCell cell22 = pdfTableStyle(projectLawsInventoryEO.getSerialNumber(), fontSize, 50, true, true); + tableBase.addCell(cell22); + PdfPCell cell23 = pdfTableStyle("Subject", fontSize, 50, true, true); + tableBase.addCell(cell23); + PdfPCell cell24 = pdfTableStyle(projectLawsInventoryEO.getTitle(), fontSize, 50, true, true); + tableBase.addCell(cell24); + // cell 31 第三行 第一列 + PdfPCell cell31 = pdfTableStyle("Project", fontSize, 50, true, true); + tableBase.addCell(cell31); + PdfPCell cell32 = pdfTableStyle(projectNameInfoEO.getProjectName(), fontSize, 50, true, true); + tableBase.addCell(cell32); + PdfPCell cell33 = pdfTableStyle("Market", fontSize, 50, true, true); + tableBase.addCell(cell33); + + List regionDictList = sysDictItemServiceImpl.selectItemsByDictCode("region"); + List marketList = new ArrayList<>(); + if(StringUtils.equals(cut,CutEnum.CN.getValue())){ + marketList = regionDictList.stream().filter(e -> StringUtils.equals(e.getItemValue(), projectLibraryBase.getTargetMarket())).map(SysDictItem::getItemText).distinct().collect(Collectors.toList()); + }else if(StringUtils.equals(cut,CutEnum.EN.getValue())){ + marketList = regionDictList.stream().filter(e -> StringUtils.equals(e.getItemValue(), projectLibraryBase.getTargetMarket())).map(SysDictItem::getEnName).distinct().collect(Collectors.toList()); + } + String market = ""; + if(CollectionUtils.isNotEmpty(marketList)){ + market = marketList.get(0); + } + + PdfPCell cell34 = pdfTableStyle(market, fontSize, 50, true, true); + tableBase.addCell(cell34); + // cell 41 第四行 第一列 + PdfPCell cell41 = pdfTableStyle("NT", fontSize, 50, true, true); + tableBase.addCell(cell41); + PdfPCell cell42 = pdfTableStyle("(取项目-数字平台)", fontSize, 50, true, true); + tableBase.addCell(cell42); + PdfPCell cell43 = pdfTableStyle("NP", fontSize, 50, true, true); + tableBase.addCell(cell43); + PdfPCell cell44 = pdfTableStyle("(取项目-车型平台)", fontSize, 50, true, true); + tableBase.addCell(cell44); + + // cell 51 第五行 第一列 + PdfPCell cell51 = pdfTableStyle("Completion Date", fontSize, 50, true, true); + tableBase.addCell(cell51); + String processEndTimeStr = ""; + if(projectTaskInventoryEO.getProcessEndTime() != null){ + processEndTimeStr = sdf.format(projectTaskInventoryEO.getProcessEndTime()); + } + PdfPCell cell52 = pdfTableStyle(processEndTimeStr, fontSize, 50, true, true); + tableBase.addCell(cell52); + PdfPCell cell53 = pdfTableStyle("Responsible Field", fontSize, 50, true, true); + tableBase.addCell(cell53); + + String dutyTerritory = projectLawsInventoryEO.getDutyTerritory(); + String finalDutyTerritory = dutyTerritory; + List dutyTerritoryDictItemList = sysDictItemServiceImpl.selectItemsByDictCode("duty_territory"); + String dutyTerritoryName = ""; + if(StringUtils.equals(cut,CutEnum.CN.getValue())){ + dutyTerritoryName = dutyTerritoryDictItemList.stream() + .filter(e -> finalDutyTerritory.contains(e.getItemValue())) + .map(SysDictItem::getItemText) + .collect(Collectors.joining(",")); + }else if(StringUtils.equals(cut,CutEnum.EN.getValue())){ + dutyTerritoryName = dutyTerritoryDictItemList.stream() + .filter(e -> finalDutyTerritory.contains(e.getItemValue())) + .map(SysDictItem::getEnName) + .collect(Collectors.joining(",")); + } + PdfPCell cell54 = pdfTableStyle(dutyTerritoryName, fontSize, 50, true, true); + tableBase.addCell(cell54); + + // cell 61 第6行 第一列 + PdfPCell cell61 = pdfTableStyle("R&H Studio Engineer", fontSize, 50, true, true); + tableBase.addCell(cell61); + + String studioEngineer = projectLibraryBase.getStudioEngineer(); + QueryWrapper queryStudioUserWrapper = new QueryWrapper<>(); + queryStudioUserWrapper.lambda().eq(SysUser::getId,studioEngineer); + SysUser studioUserInfo = sysUserMapper.selectOne(queryStudioUserWrapper); + PdfPCell cell62 = pdfTableStyle(studioUserInfo.getUsername(), fontSize, 50, true, true); + tableBase.addCell(cell62); + PdfPCell cell63 = pdfTableStyle("Engineering Interface", fontSize, 50, true, true); + tableBase.addCell(cell63); + + String engineeringInterfacePerson = projectLawsInventoryEO.getEngineeringInterfacePerson(); + QueryWrapper queryEngineeringInterfaceUserWrapper = new QueryWrapper<>(); + queryEngineeringInterfaceUserWrapper.lambda().eq(SysUser::getId,engineeringInterfacePerson); + SysUser engineeringInterfaceInfo = sysUserMapper.selectOne(queryEngineeringInterfaceUserWrapper); + PdfPCell cell64 = pdfTableStyle(engineeringInterfaceInfo.getUsername(), fontSize, 50, true, true); + tableBase.addCell(cell64); + + // cell 71 第7行 第一列 + PdfPCell cell71 = pdfTableStyle("Homologation Engineer", fontSize, 50, true, true); + tableBase.addCell(cell71); + String homologationEngineerId = projectLawsInventoryEO.getHomologationEngineerId(); + QueryWrapper queryHomologationEngineerUserWrapper = new QueryWrapper<>(); + queryHomologationEngineerUserWrapper.lambda().eq(SysUser::getId,homologationEngineerId); + SysUser homologationEngineerInfo = sysUserMapper.selectOne(queryHomologationEngineerUserWrapper); + PdfPCell cell72 = pdfTableStyle(homologationEngineerInfo.getUsername(), fontSize, 50, true, true); + tableBase.addCell(cell72); + PdfPCell cell73 = pdfTableStyle("Regulation Engineer", fontSize, 50, true, true); + tableBase.addCell(cell73); + String regulationOwnerId = projectLawsInventoryEO.getRegulationOwnerId(); + QueryWrapper queryRegulationOwnerUserWrapper = new QueryWrapper<>(); + queryRegulationOwnerUserWrapper.lambda().eq(SysUser::getId,regulationOwnerId); + SysUser regulationOwnerInfo = sysUserMapper.selectOne(queryRegulationOwnerUserWrapper); + PdfPCell cell74 = pdfTableStyle(regulationOwnerInfo.getUsername(), fontSize, 50, true, true); + tableBase.addCell(cell74); + + // cell 81 第8行 第一列 + PdfPCell cell81 = pdfTableStyle(" ", fontSize, 20, true, true); + tableBase.addCell(cell81); + PdfPCell cell82 = pdfTableStyle(" ", fontSize, 20, true, true); + tableBase.addCell(cell82); + PdfPCell cell83 = pdfTableStyle(" ", fontSize, 20, true, true); + tableBase.addCell(cell83); + PdfPCell cell84 = pdfTableStyle(" ", fontSize, 20, true, true); + tableBase.addCell(cell84); + + document.add(tableBase); + + PdfPTable cell9 = new PdfPTable(2); + // 定义表格的宽度 占比 + float[] cell9Width = { 0.25f, 0.75f}; + try { + cell9.setWidths(cell9Width); + } catch (DocumentException e) { + e.printStackTrace(); + } + cell9.setWidthPercentage(widthPercentage); //设置标题长度占纸张比例 + cell9.addCell(pdfTableStyle("Description", fontSize, 50, true, true)); + cell9.addCell(pdfTableStyle(" ", fontSize, 50, true, true)); //(导出后自己填写) + document.add(cell9); + } + + public void setComplianceAttachments(PdfPTable tableBase,Document document,Font fontSize) throws DocumentException{ + // 定义表格的宽度 + float[] cellsWidth = { 0.45f, 0.55f}; + try { + tableBase.setWidths(cellsWidth); + }catch (Exception ex){ + ex.printStackTrace(); + } + + tableBase.setTotalWidth(500f);//表格的总宽度 + tableBase.setWidthPercentage(100);// 表格的宽度百分比 + + // 单元格宽度 + PdfPTable tableName = new PdfPTable(1); + //设置段落上空白 + tableName.setSpacingBefore(25); + tableName.setWidthPercentage(widthPercentage); //设置标题长度占纸张比例 + //给表格赋值 + PdfPCell programInformation = pdfTableStyle("Compliance Attachments", fontSize, 10, false, false); + programInformation.disableBorderSide(15); + tableName.addCell(programInformation); + //将表格添加到文档对象中 + document.add(tableName); + + // cell 11 第一行 第一列 + PdfPCell cell11 = pdfTableStyle("File Name", fontSize, 20, true, true); + tableBase.addCell(cell11); + PdfPCell cell12 = pdfTableStyle("catalogue", fontSize, 20, true, true); + tableBase.addCell(cell12); + // cell 21 第二行 第一列 + PdfPCell cell21 = pdfTableStyle("Checklist.doc", fontSize, 20, true, true); + tableBase.addCell(cell21); + PdfPCell cell22 = pdfTableStyle("Xxx(显示文件所在的相对路径)", fontSize, 20, true, true); + tableBase.addCell(cell22); + // cell 31 第三行 第一列 + PdfPCell cell31 = pdfTableStyle("CADreport.pdf", fontSize, 20, true, true); + tableBase.addCell(cell31); + PdfPCell cell32 = pdfTableStyle("Xxx(显示文件所在的相对路径)", fontSize, 20, true, true); + tableBase.addCell(cell32); + + document.add(tableBase); + } + + public void setComplianceResult(PdfPTable tableBase,Document document,Font fontSize,Map params) throws DocumentException{ + String cut = (String) params.get("cut"); + //法规id + String id = (String) params.get("id"); + QueryWrapper lawsInventoryQueryWrapper = new QueryWrapper<>(); + lawsInventoryQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getId,id); + ProjectLawsInventoryEO projectLawsInventoryEO = this.baseMapper.selectOne(lawsInventoryQueryWrapper); + + // 单元格宽度 + float[] cellsWidth = { 0.45f, 0.55f}; + try { + tableBase.setWidths(cellsWidth); + }catch (Exception ex){ + ex.printStackTrace(); + } + + tableBase.setTotalWidth(500f);//表格的总宽度 + tableBase.setWidthPercentage(100);// 表格的宽度百分比 + + PdfPTable tableName = new PdfPTable(1); + //设置段落上空白 + tableName.setSpacingBefore(25); + tableName.setWidthPercentage(widthPercentage); //设置标题长度占纸张比例 + //给表格赋值 + PdfPCell programInformation = pdfTableStyle("Compliance Result", fontSize, 10, false, false); + programInformation.disableBorderSide(15); + tableName.addCell(programInformation); + //将表格添加到文档对象中 + document.add(tableName); + + // cell 11 第一行 第一列 + PdfPCell cell11 = pdfTableStyle("Subject", fontSize, 20, true, true); + tableBase.addCell(cell11); + PdfPCell cell12 = pdfTableStyle("Lamp " + projectLawsInventoryEO.getTitle(), fontSize, 20, true, true); + tableBase.addCell(cell12); + // cell 21 第二行 第一列 + PdfPCell cell21 = pdfTableStyle("Conclusion", fontSize, 20, true, true); + tableBase.addCell(cell21); + PdfPCell cell22 = pdfTableStyle("", fontSize, 20, true, true); //(导出后自己填写) + tableBase.addCell(cell22); + // cell 31 第三行 第一列 + PdfPCell cell31 = pdfTableStyle("DiscussionorComments", fontSize, 20, true, true); + tableBase.addCell(cell31); + PdfPCell cell32 = pdfTableStyle("", fontSize, 20, true, true); //(导出后自己填写) + tableBase.addCell(cell32); + + document.add(tableBase); + } + + public void setDesignComplianceCheckApprovals(PdfPTable tableBase,Document document,Font fontSize,String[] auditHistoryHead,Map params) throws DocumentException{ + tableBase.setTotalWidth(500f);//表格的总宽度 + tableBase.setWidthPercentage(100);// 表格的宽度百分比 + + PdfPTable tableName = new PdfPTable(1); + //设置段落上空白 + tableName.setSpacingBefore(25); + tableName.setWidthPercentage(widthPercentage); //设置标题长度占纸张比例 + //给表格赋值 + PdfPCell programInformation = pdfTableStyle("designComplianceCheckApprovals", fontSize, 10, false, false); + programInformation.disableBorderSide(15); + tableName.addCell(programInformation); + //将表格添加到文档对象中 + document.add(tableName); + + + for (int i = 0; i < auditHistoryHead.length; i++) { + tableBase.addCell(new Paragraph(auditHistoryHead[i],fontSize)); + } + document.add(tableBase); + } + + public void setValidationComplianceCheckApprovals(PdfPTable tableBase,Document document,Font fontSize,String[] auditHistoryHead,Map params) throws DocumentException{ + List> list = new ArrayList<>(); + + Map map1 = new HashMap<>(); + map1.put("Result",""); + map1.put("Opinion","Opinion 1"); + map1.put("Node","Node 1"); + map1.put("Operator","Operator 1"); + map1.put("Datetime","Datetime 1"); + list.add(map1); + Map map2 = new HashMap<>(); + map2.put("Result","Result 2 "); + map2.put("Opinion","Opinion 2"); + map2.put("Node",""); + map2.put("Operator","Operator 2"); + map2.put("Datetime","Datetime 2"); + list.add(map2); + Map map3 = new HashMap<>(); + map3.put("Result","Result 3 "); + map3.put("Opinion","Opinion 3"); + map3.put("Node","Node 3"); + map3.put("Operator","Operator 3"); + map3.put("Datetime","Datetime 3"); + list.add(map3); + + tableBase.setTotalWidth(500f);//表格的总宽度 + tableBase.setWidthPercentage(100);// 表格的宽度百分比 + + PdfPTable tableName = new PdfPTable(1); + //设置段落上空白 + tableName.setSpacingBefore(25); + tableName.setWidthPercentage(widthPercentage); //设置标题长度占纸张比例 + //给表格赋值 + PdfPCell programInformation = pdfTableStyle("validationComplianceCheckApprovals", fontSize, 10, false, false); + programInformation.disableBorderSide(15); + tableName.addCell(programInformation); + //将表格添加到文档对象中 + document.add(tableName); + + for (int i = 0; i < auditHistoryHead.length; i++) { + tableBase.addCell(new Paragraph(auditHistoryHead[i],fontSize)); + } + + for (Map map : list) { + tableBase.addCell(new Paragraph(map.get("Result").toString(),fontSize)); + tableBase.addCell(new Paragraph(map.get("Opinion").toString(),fontSize)); + tableBase.addCell(new Paragraph(map.get("Node").toString(),fontSize)); + tableBase.addCell(new Paragraph(map.get("Operator").toString(),fontSize)); + tableBase.addCell(new Paragraph(map.get("Datetime").toString(),fontSize)); + } + document.add(tableBase); + } }