|
@@ -3,16 +3,31 @@ package com.usky.fire.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.usky.fire.domain.BaseCompany;
|
|
|
import com.usky.fire.domain.DemReportData;
|
|
|
+import com.usky.fire.domain.DemReportInfo;
|
|
|
import com.usky.fire.mapper.DemReportDataMapper;
|
|
|
import com.usky.fire.service.BaseCompanyService;
|
|
|
import com.usky.fire.service.DemReportDataService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.fire.service.DemReportInfoService;
|
|
|
+import com.usky.fire.service.config.pdf.MyHeaderFooter;
|
|
|
+import com.usky.fire.service.config.pdf.Watermark;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import com.itextpdf.text.*;
|
|
|
+import com.itextpdf.text.pdf.*;
|
|
|
+import com.itextpdf.text.pdf.draw.DottedLineSeparator;
|
|
|
+import com.itextpdf.text.pdf.draw.LineSeparator;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -27,16 +42,478 @@ public class DemReportDataServiceImpl extends AbstractCrudService<DemReportDataM
|
|
|
@Autowired
|
|
|
private BaseCompanyService baseCompanyService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DemReportInfoService demReportInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
public void regularReportData() {
|
|
|
- List<BaseCompany> baseCompanies = baseCompanyService.companyIdByTypeList("1");
|
|
|
- if (CollectionUtils.isNotEmpty(baseCompanies)) {
|
|
|
- for (int i = 0; i < baseCompanies.size(); i++) {
|
|
|
+ try {
|
|
|
+ List<BaseCompany> baseCompanies = baseCompanyService.companyIdByTypeList("1");
|
|
|
+ if (CollectionUtils.isNotEmpty(baseCompanies)) {
|
|
|
+ Calendar now = Calendar.getInstance();
|
|
|
+ for (int i = 0; i < baseCompanies.size(); i++) {
|
|
|
+ // 1.新建document对象
|
|
|
+ Document document = new Document(PageSize.A4);// 建立一个Document对象
|
|
|
+
|
|
|
+// 2.建立一个书写器(Writer)与document对象关联
|
|
|
+ File file = new File("/var/www/usky-file/202303/"+now.get(Calendar.YEAR)+now.get(Calendar.MONTH)+baseCompanies.get(i).getCompanyId()+".pdf");
|
|
|
+// File file = new File("D:\\"+now.get(Calendar.YEAR)+now.get(Calendar.MONTH)+baseCompanies.get(i).getCompanyId()+".pdf");
|
|
|
+ file.createNewFile();
|
|
|
+ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
|
|
|
+// writer.setPageEvent(new Watermark("hello word"));// 水印
|
|
|
+ writer.setPageEvent(new MyHeaderFooter());// 页眉/页脚
|
|
|
+ // 3.打开文档
|
|
|
+ document.open();
|
|
|
+ document.addTitle("Title@PDF-Java");// 标题
|
|
|
+ document.addAuthor("Author@umiz");// 作者
|
|
|
+ document.addSubject("Subject@iText pdf sample");// 主题
|
|
|
+ document.addKeywords("Keywords@iTextpdf");// 关键字
|
|
|
+ document.addCreator("Creator@umiz`s");// 创建者
|
|
|
|
|
|
+// 4.向文档中添加内容
|
|
|
+ this.generatePDF(document,baseCompanies.get(i).getCompanyName());
|
|
|
+
|
|
|
+// 5.关闭文档
|
|
|
+ document.close();
|
|
|
+ DemReportInfo demReportInfo = new DemReportInfo();
|
|
|
+ demReportInfo.setCompanyId(baseCompanies.get(i).getCompanyId());
|
|
|
+ demReportInfo.setCompanyCode(baseCompanies.get(i).getCompanyCode());
|
|
|
+ demReportInfo.setReportName(now.get(Calendar.YEAR)+"年"+now.get(Calendar.MONTH)+"月消防报告");
|
|
|
+ demReportInfo.setReportPath("http://172.16.120.165:9300/statics/202303/"+now.get(Calendar.YEAR)+now.get(Calendar.MONTH)+baseCompanies.get(i).getCompanyId()+
|
|
|
+ ".pdf");
|
|
|
+ demReportInfo.setCreateTime(LocalDateTime.now());
|
|
|
+ demReportInfo.setStatisticsTime(now.get(Calendar.YEAR)+"-"+now.get(Calendar.MONTH));
|
|
|
+ demReportInfo.setReportStatus(0);
|
|
|
+ demReportInfoService.save(demReportInfo);
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 定义全局的字体静态变量
|
|
|
+ private static Font titlefont;
|
|
|
+ private static Font headfont;
|
|
|
+ private static Font keyfont;
|
|
|
+ private static Font textfont;
|
|
|
+ // 最大宽度
|
|
|
+ private static int maxWidth = 520;
|
|
|
+ // 静态代码块
|
|
|
+ static {
|
|
|
+ try {
|
|
|
+// 不同字体(这里定义为同一种字体:包含不同字号、不同style)
|
|
|
+ BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
|
|
|
+ titlefont = new Font(bfChinese, 16, Font.BOLD);
|
|
|
+ headfont = new Font(bfChinese, 14, Font.BOLD);
|
|
|
+ keyfont = new Font(bfChinese, 10, Font.BOLD);
|
|
|
+ textfont = new Font(bfChinese, 10, Font.NORMAL);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 生成PDF文件
|
|
|
+ public void generatePDF(Document document,String companyName) throws Exception {
|
|
|
+
|
|
|
+// 段落
|
|
|
+ Paragraph paragraph = new Paragraph(companyName+"单位消防安全数字化管理综合分析报告", titlefont);
|
|
|
+ paragraph.setAlignment(1); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph.setIndentationLeft(12); //设置左缩进
|
|
|
+ paragraph.setIndentationRight(12); //设置右缩进
|
|
|
+ paragraph.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph.setLeading(20f); //行间距
|
|
|
+ paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph.setSpacingAfter(20f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph1 = new Paragraph(companyName+"单位:", textfont);
|
|
|
+ paragraph1.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+
|
|
|
+ Paragraph paragraph2 = new Paragraph("本次综合分析是通过贵单位在2022年1月1日-2022年12月31日期间消防设施状况、消防自主管理状况、监督执法情况、火灾风险指数和建筑整体指数进行综合评估,现将综合分析报告如下:", textfont);
|
|
|
+ paragraph2.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph2.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph2.setLeading(20f); //行间距
|
|
|
+ paragraph2.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph2.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph3 = new Paragraph("一、整体评价", headfont);
|
|
|
+ paragraph3.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph3.setFirstLineIndent(24); //设置首行缩进
|
|
|
+
|
|
|
+ Paragraph paragraph4 = new Paragraph("贵单位在期间消防安全管理指数评价为:较高风险", textfont);
|
|
|
+ paragraph4.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph4.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph4.setLeading(20f); //行间距
|
|
|
+ paragraph4.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph4.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph5 = new Paragraph("二、测评范围", headfont);
|
|
|
+ paragraph5.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph5.setFirstLineIndent(24); //设置首行缩进
|
|
|
+
|
|
|
+ Paragraph paragraph6 = new Paragraph("包含消防设施系统(火灾报警系统;消防水系统;防排烟系统;维保单位履职情况等 如实显示,没有的就不显示)、消防自主管理状况(组织制度落实情况;日常值班、巡检情况;预案、培训落实情况;微站实体化运行情况)、监督执法情况(双随机检查情况;处罚情况;投诉举报情况;重大隐患挂牌情况)和火灾风险指数(当年度火灾情况;上年度火灾情况)等项目进行综合测评。", textfont);
|
|
|
+ paragraph6.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph6.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph6.setLeading(20f); //行间距
|
|
|
+ paragraph6.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph6.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph7 = new Paragraph("三、主要风险及问题", headfont);
|
|
|
+ paragraph7.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph7.setFirstLineIndent(24); //设置首行缩进
|
|
|
+
|
|
|
+ Paragraph paragraph8 = new Paragraph("(一)消防设施问题", textfont);
|
|
|
+ paragraph8.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph8.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph8.setLeading(20f); //行间距
|
|
|
+ paragraph8.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph8.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph9 = new Paragraph("火灾报警系统:在线率低于95%,故障率高于5%;", textfont);
|
|
|
+ paragraph9.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph9.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph9.setLeading(20f); //行间距
|
|
|
+ paragraph9.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph9.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph10 = new Paragraph("防排烟系统:出现超出一个月修复或未修复的2次;", textfont);
|
|
|
+ paragraph10.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph10.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph10.setLeading(20f); //行间距
|
|
|
+ paragraph10.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph10.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph11 = new Paragraph("维保单位履职情况:检测报告体现XX系统(设施)存在故障。", textfont);
|
|
|
+ paragraph11.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph11.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph11.setLeading(20f); //行间距
|
|
|
+ paragraph11.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph11.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph12 = new Paragraph("(二)消防自主管理问题", textfont);
|
|
|
+ paragraph12.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph12.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph12.setLeading(20f); //行间距
|
|
|
+ paragraph12.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph12.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph13 = new Paragraph("组织制度落实情况:员工消防安全培训填写不符合规定;", textfont);
|
|
|
+ paragraph13.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph13.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph13.setLeading(20f); //行间距
|
|
|
+ paragraph13.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph13.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph14 = new Paragraph("消防档案:档案填写不符合规定;", textfont);
|
|
|
+ paragraph14.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph14.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph14.setLeading(20f); //行间距
|
|
|
+ paragraph14.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph14.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph15 = new Paragraph("消防重点部位:未确定消防重点部位。", textfont);
|
|
|
+ paragraph15.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph15.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph15.setLeading(20f); //行间距
|
|
|
+ paragraph15.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph15.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph16 = new Paragraph("(三)监督执法情况", textfont);
|
|
|
+ paragraph16.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph16.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph16.setLeading(20f); //行间距
|
|
|
+ paragraph16.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph16.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph17 = new Paragraph("上述时间段内监督检查发现隐患X处,其中XX未整改完成,处罚XX元。", textfont);
|
|
|
+ paragraph17.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph17.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph17.setLeading(20f); //行间距
|
|
|
+ paragraph17.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph17.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph18 = new Paragraph("(四)火灾情况", textfont);
|
|
|
+ paragraph18.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph18.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph18.setLeading(20f); //行间距
|
|
|
+ paragraph18.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph18.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph19 = new Paragraph("上一年度发生一起火灾,未造成人员伤亡,造成直接财产损失X万元。", textfont);
|
|
|
+ paragraph19.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph19.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph19.setLeading(20f); //行间距
|
|
|
+ paragraph19.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph19.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph20 = new Paragraph("四、防范对策及建议", headfont);
|
|
|
+ paragraph20.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph20.setFirstLineIndent(24); //设置首行缩进
|
|
|
+
|
|
|
+ Paragraph paragraph21 = new Paragraph("1、建议联系消防设施维保单位对本单位开展一次全面维护保养,对损坏、故障的设施要及时修复,确保消防设施完整好用;", textfont);
|
|
|
+ paragraph21.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph21.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph21.setLeading(20f); //行间距
|
|
|
+ paragraph21.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph21.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph22 = new Paragraph("2、建议对照重点单位消防档案管理办法,进一步完善员工安全培训记录、明确消防重点部位等内容;", textfont);
|
|
|
+ paragraph22.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph22.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph22.setLeading(20f); //行间距
|
|
|
+ paragraph22.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph22.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph23 = new Paragraph("3、建议对单位重点部位开展一轮全面自查,落实值班、巡查以及应急处置工作职责,确保“实名制”管理工作制度落实到位;", textfont);
|
|
|
+ paragraph23.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph23.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph23.setLeading(20f); //行间距
|
|
|
+ paragraph23.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph23.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph24 = new Paragraph("4、建议充分利用场所自身有利条件,在电子屏、明显位置循环播放宣传视频、张贴海报等形式加强消防安全提示。定期对单位员工开展消防安全教育和重点岗位专题培训,持续提高员工消防安全“一懂三会”基本能力。", textfont);
|
|
|
+ paragraph24.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph24.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph24.setLeading(20f); //行间距
|
|
|
+ paragraph24.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph24.setSpacingAfter(10f); //设置段落下空白
|
|
|
+
|
|
|
+ Paragraph paragraph25 = new Paragraph("五、具体问题清单", headfont);
|
|
|
+ paragraph25.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph25.setFirstLineIndent(24); //设置首行缩进
|
|
|
+
|
|
|
+// 直线
|
|
|
+// Paragraph p1 = new Paragraph();
|
|
|
+// p1.add(new Chunk(new LineSeparator()));
|
|
|
+
|
|
|
+// 点线
|
|
|
+// Paragraph p2 = new Paragraph();
|
|
|
+// p2.add(new Chunk(new DottedLineSeparator()));
|
|
|
+
|
|
|
+// 超链接
|
|
|
+// Anchor anchor = new Anchor("baidu");
|
|
|
+// anchor.setReference("www.baidu.com");
|
|
|
+
|
|
|
+// 定位
|
|
|
+// Anchor gotoP = new Anchor("goto");
|
|
|
+// gotoP.setReference("#top");
|
|
|
+
|
|
|
+// 添加图片
|
|
|
+ Image image = Image.getInstance("https://img-blog.csdn.net/20180801174617455?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zNzg0ODcxMA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70");
|
|
|
+ image.setAlignment(Image.ALIGN_CENTER);
|
|
|
+ image.scalePercent(40); //依照比例缩放
|
|
|
+
|
|
|
+// 表格
|
|
|
+ PdfPTable table = createTable(new float[] { 40, 120, 120, 120, 80, 80 });
|
|
|
+ table.addCell(createCell("美好的一天", headfont, Element.ALIGN_LEFT, 6, false));
|
|
|
+ table.addCell(createCell("早上9:00", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("中午11:00", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("中午13:00", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("下午15:00", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("下午17:00", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("晚上19:00", keyfont, Element.ALIGN_CENTER));
|
|
|
+ Integer totalQuantity = 0;
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ table.addCell(createCell("起床", textfont));
|
|
|
+ table.addCell(createCell("吃午饭", textfont));
|
|
|
+ table.addCell(createCell("午休", textfont));
|
|
|
+ table.addCell(createCell("下午茶", textfont));
|
|
|
+ table.addCell(createCell("回家", textfont));
|
|
|
+ table.addCell(createCell("吃晚饭", textfont));
|
|
|
+ totalQuantity ++;
|
|
|
+ }
|
|
|
+ table.addCell(createCell("总计", keyfont));
|
|
|
+ table.addCell(createCell("", textfont));
|
|
|
+ table.addCell(createCell("", textfont));
|
|
|
+ table.addCell(createCell("", textfont));
|
|
|
+ table.addCell(createCell(String.valueOf(totalQuantity) + "件事", textfont));
|
|
|
+ table.addCell(createCell("", textfont));
|
|
|
+
|
|
|
+ document.add(paragraph);
|
|
|
+ document.add(paragraph1);
|
|
|
+ document.add(paragraph2);
|
|
|
+ document.add(paragraph3);
|
|
|
+ document.add(paragraph4);
|
|
|
+ document.add(paragraph5);
|
|
|
+ document.add(paragraph6);
|
|
|
+ document.add(paragraph7);
|
|
|
+ document.add(paragraph8);
|
|
|
+ document.add(paragraph9);
|
|
|
+ document.add(paragraph10);
|
|
|
+ document.add(paragraph11);
|
|
|
+ document.add(paragraph12);
|
|
|
+ document.add(paragraph13);
|
|
|
+ document.add(paragraph14);
|
|
|
+ document.add(paragraph15);
|
|
|
+ document.add(paragraph16);
|
|
|
+ document.add(paragraph17);
|
|
|
+ document.add(paragraph18);
|
|
|
+ document.add(paragraph19);
|
|
|
+ document.add(paragraph20);
|
|
|
+ document.add(paragraph21);
|
|
|
+ document.add(paragraph22);
|
|
|
+ document.add(paragraph23);
|
|
|
+ document.add(paragraph24);
|
|
|
+ document.add(paragraph25);
|
|
|
+// document.add(anchor);
|
|
|
+// document.add(p2);
|
|
|
+// document.add(gotoP);
|
|
|
+// document.add(p1);
|
|
|
+// document.add(table);
|
|
|
+// document.add(image);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+/**------------------------创建表格单元格的方法start----------------------------*/
|
|
|
+ /**
|
|
|
+ * 创建单元格(指定字体)
|
|
|
+ * @param value
|
|
|
+ * @param font
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PdfPCell createCell(String value, Font font) {
|
|
|
+ PdfPCell cell = new PdfPCell();
|
|
|
+ cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setPhrase(new Phrase(value, font));
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 创建单元格(指定字体、水平..)
|
|
|
+ * @param value
|
|
|
+ * @param font
|
|
|
+ * @param align
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PdfPCell createCell(String value, Font font, int align) {
|
|
|
+ PdfPCell cell = new PdfPCell();
|
|
|
+ cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
+ cell.setHorizontalAlignment(align);
|
|
|
+ cell.setPhrase(new Phrase(value, font));
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 创建单元格(指定字体、水平居..、单元格跨x列合并)
|
|
|
+ * @param value
|
|
|
+ * @param font
|
|
|
+ * @param align
|
|
|
+ * @param colspan
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PdfPCell createCell(String value, Font font, int align, int colspan) {
|
|
|
+ PdfPCell cell = new PdfPCell();
|
|
|
+ cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
+ cell.setHorizontalAlignment(align);
|
|
|
+ cell.setColspan(colspan);
|
|
|
+ cell.setPhrase(new Phrase(value, font));
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 创建单元格(指定字体、水平居..、单元格跨x列合并、设置单元格内边距)
|
|
|
+ * @param value
|
|
|
+ * @param font
|
|
|
+ * @param align
|
|
|
+ * @param colspan
|
|
|
+ * @param boderFlag
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PdfPCell createCell(String value, Font font, int align, int colspan, boolean boderFlag) {
|
|
|
+ PdfPCell cell = new PdfPCell();
|
|
|
+ cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
+ cell.setHorizontalAlignment(align);
|
|
|
+ cell.setColspan(colspan);
|
|
|
+ cell.setPhrase(new Phrase(value, font));
|
|
|
+ cell.setPadding(3.0f);
|
|
|
+ if (!boderFlag) {
|
|
|
+ cell.setBorder(0);
|
|
|
+ cell.setPaddingTop(15.0f);
|
|
|
+ cell.setPaddingBottom(8.0f);
|
|
|
+ } else if (boderFlag) {
|
|
|
+ cell.setBorder(0);
|
|
|
+ cell.setPaddingTop(0.0f);
|
|
|
+ cell.setPaddingBottom(15.0f);
|
|
|
+ }
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 创建单元格(指定字体、水平..、边框宽度:0表示无边框、内边距)
|
|
|
+ * @param value
|
|
|
+ * @param font
|
|
|
+ * @param align
|
|
|
+ * @param borderWidth
|
|
|
+ * @param paddingSize
|
|
|
+ * @param flag
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PdfPCell createCell(String value, Font font, int align, float[] borderWidth, float[] paddingSize, boolean flag) {
|
|
|
+ PdfPCell cell = new PdfPCell();
|
|
|
+ cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
+ cell.setHorizontalAlignment(align);
|
|
|
+ cell.setPhrase(new Phrase(value, font));
|
|
|
+ cell.setBorderWidthLeft(borderWidth[0]);
|
|
|
+ cell.setBorderWidthRight(borderWidth[1]);
|
|
|
+ cell.setBorderWidthTop(borderWidth[2]);
|
|
|
+ cell.setBorderWidthBottom(borderWidth[3]);
|
|
|
+ cell.setPaddingTop(paddingSize[0]);
|
|
|
+ cell.setPaddingBottom(paddingSize[1]);
|
|
|
+ if (flag) {
|
|
|
+ cell.setColspan(2);
|
|
|
+ }
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+/**------------------------创建表格单元格的方法end----------------------------*/
|
|
|
+
|
|
|
+
|
|
|
+/**--------------------------创建表格的方法start------------------- ---------*/
|
|
|
+ /**
|
|
|
+ * 创建默认列宽,指定列数、水平(居中、右、左)的表格
|
|
|
+ * @param colNumber
|
|
|
+ * @param align
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PdfPTable createTable(int colNumber, int align) {
|
|
|
+ PdfPTable table = new PdfPTable(colNumber);
|
|
|
+ try {
|
|
|
+ table.setTotalWidth(maxWidth);
|
|
|
+ table.setLockedWidth(true);
|
|
|
+ table.setHorizontalAlignment(align);
|
|
|
+ table.getDefaultCell().setBorder(1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return table;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 创建指定列宽、列数的表格
|
|
|
+ * @param widths
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PdfPTable createTable(float[] widths) {
|
|
|
+ PdfPTable table = new PdfPTable(widths);
|
|
|
+ try {
|
|
|
+ table.setTotalWidth(maxWidth);
|
|
|
+ table.setLockedWidth(true);
|
|
|
+ table.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.getDefaultCell().setBorder(1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return table;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 创建空白的表格
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PdfPTable createBlankTable() {
|
|
|
+ PdfPTable table = new PdfPTable(1);
|
|
|
+ table.getDefaultCell().setBorder(0);
|
|
|
+ table.addCell(createCell("", keyfont));
|
|
|
+ table.setSpacingAfter(20.0f);
|
|
|
+ table.setSpacingBefore(20.0f);
|
|
|
+ return table;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Object buildStatistics(String companyId) {
|
|
|
Map<String, Object> map = new HashMap<>();
|