|
|
@@ -4,9 +4,9 @@ import cn.hutool.Hutool;
|
|
|
import cn.hutool.core.codec.Base64;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.lowagie.text.Document;
|
|
|
-import com.lowagie.text.Font;
|
|
|
+import com.lowagie.text.*;
|
|
|
import com.lowagie.text.pdf.BaseFont;
|
|
|
+import com.lowagie.text.pdf.PdfPCell;
|
|
|
import com.lowagie.text.pdf.PdfPTable;
|
|
|
import com.lowagie.text.pdf.PdfWriter;
|
|
|
import com.xunmei.common.core.utils.uuid.UUID;
|
|
|
@@ -191,6 +191,25 @@ public class LocalSysFileServiceImpl implements ISysFileService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public String generateResumptionPdf(Map<String, Object> data) throws Exception {
|
|
|
+ PdfFilePathVo pathVo = getLocalFilePath(localFilePath, "resumption", data.get("fileName").toString());
|
|
|
+ log.info("开始生成履职登记簿,当前绝对地址为:{}", pathVo.getAbsolutePath());
|
|
|
+ final ItextPdfTableVo pdfTableVo = PdfUtil.createTable(pathVo.getAbsolutePath(), 6, 10);
|
|
|
+ final Document document = pdfTableVo.getDocument();
|
|
|
+ final PdfWriter writer = pdfTableVo.getWriter();
|
|
|
+ final PdfPTable table = pdfTableVo.getTable();
|
|
|
+ final BaseFont fs = pdfTableVo.getFs();
|
|
|
+ final Font tableFont = pdfTableVo.getTableFont();
|
|
|
+ PdfUtil.dealHeader(document, fs, "保 安 履 职", 24);
|
|
|
+ PdfUtil.dealResumptionBody(document, table, tableFont, data);
|
|
|
+ document.close();
|
|
|
+ writer.close();
|
|
|
+ log.info("履职登记簿生成结束,当前绝对地址为:{}", pathVo.getAbsolutePath());
|
|
|
+ //此处返回 /statics/edu/xxx.pdf
|
|
|
+ return this.prefix + pathVo.getRelativePath();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public String generateDrillPdf(Map<String, Object> data) throws Exception {
|
|
|
PdfFilePathVo pathVo = getLocalFilePath(localFilePath, "drill", data.get("fileName").toString());
|
|
|
log.info("开始生成预案演练登记簿,当前绝对地址为:{}", pathVo.getAbsolutePath());
|
|
|
@@ -216,4 +235,255 @@ public class LocalSysFileServiceImpl implements ISysFileService {
|
|
|
String filePath = FileUploadUtils.uploadBase64(localFilePath, file);
|
|
|
return filePath;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 履职转pdf
|
|
|
+ * @param dest
|
|
|
+ * @throws IOException
|
|
|
+ * @throws DocumentException
|
|
|
+ */
|
|
|
+ public void dataToPdf(String dest) throws IOException, DocumentException {
|
|
|
+ Document document = new Document();
|
|
|
+ PdfWriter.getInstance(document, new FileOutputStream(dest));
|
|
|
+ document.open();
|
|
|
+
|
|
|
+ // 使用语言包字体
|
|
|
+ BaseFont abf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);
|
|
|
+ //字体
|
|
|
+ Font font = new Font(abf, 8);
|
|
|
+
|
|
|
+ //段落
|
|
|
+ Paragraph p = new Paragraph("测试结算单", new Font(abf, 12, Font.BOLD));
|
|
|
+ p.setAlignment(Paragraph.ALIGN_CENTER);
|
|
|
+ document.add(p);
|
|
|
+
|
|
|
+ //表格
|
|
|
+ PdfPTable table = new PdfPTable(8);//numcolumns:列数
|
|
|
+ table.setSpacingBefore(16f);//表格与上面段落的空隙
|
|
|
+
|
|
|
+ //表格列创建并赋值
|
|
|
+ PdfPCell cell = new PdfPCell(new Phrase("单位名称:测试有限公司", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_LEFT);//居中
|
|
|
+ cell.disableBorderSide(13);//去除左右上边框,保留下边框
|
|
|
+ cell.setColspan(4);//合并列数
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("日期:2020-06-05", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.disableBorderSide(13);
|
|
|
+ cell.setColspan(3);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("单位(元)", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ cell.disableBorderSide(13);
|
|
|
+ cell.setColspan(1);
|
|
|
+ table.addCell(cell);
|
|
|
+ //首行
|
|
|
+ cell = new PdfPCell(new Phrase("期间", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setColspan(2);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("月份", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("分类", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("年利率", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("日利率", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("基数", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("利息", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ cell = new PdfPCell(new Phrase("起始日:2020-03-26\n" +
|
|
|
+ "结束日:2020-04-25", font));
|
|
|
+ cell.setPadding(16f);
|
|
|
+ cell.setVerticalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setRowspan(3);
|
|
|
+ cell.setColspan(2);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("4", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("资金", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("1.10%", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("0.000031", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("10598164.91", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("325.01", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ cell = new PdfPCell(new Phrase("4", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("资金", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("1.10%", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("0.000031", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("-", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("-", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ cell = new PdfPCell(new Phrase("4", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("资金", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("1.10%", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("0.000031", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("-", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("-", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ cell = new PdfPCell(new Phrase("合计", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setColspan(7);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("325.01", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ cell = new PdfPCell(new Phrase("会计制单:", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ cell.disableBorderSide(14);
|
|
|
+ cell.setColspan(4);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("复核:", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ cell.disableBorderSide(14);
|
|
|
+ cell.setColspan(4);
|
|
|
+ table.addCell(cell);
|
|
|
+ table.setSpacingBefore(16f);
|
|
|
+ document.add(table);
|
|
|
+
|
|
|
+ //下一页
|
|
|
+ document.newPage();
|
|
|
+ //段落
|
|
|
+ Paragraph p1 = new Paragraph("下一页测试结算单", new Font(abf, 12, Font.BOLD));
|
|
|
+ p1.setAlignment(Paragraph.ALIGN_CENTER);
|
|
|
+ document.add(p1);
|
|
|
+
|
|
|
+ //表格
|
|
|
+ table = new PdfPTable(8);//numcolumns:列数
|
|
|
+ table.setSpacingBefore(16f);//表格与上面段落的空隙
|
|
|
+
|
|
|
+ //表格列创建并赋值
|
|
|
+ cell = new PdfPCell(new Phrase("单位名称:测试有限公司", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_LEFT);//居中
|
|
|
+ cell.disableBorderSide(13);//去除左右上边框,保留下边框
|
|
|
+ cell.setColspan(4);//合并列数
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("日期:2020-06-05", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.disableBorderSide(13);
|
|
|
+ cell.setColspan(3);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("单位(元)", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ cell.disableBorderSide(13);
|
|
|
+ cell.setColspan(1);
|
|
|
+ table.addCell(cell);
|
|
|
+ //首行
|
|
|
+ cell = new PdfPCell(new Phrase("期间", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setColspan(2);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("月份", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("分类", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("年利率", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("日利率", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("基数", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("利息", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ cell = new PdfPCell(new Phrase("起始日:2020-04-26\n" +
|
|
|
+ "结束日:2020-05-25", font));
|
|
|
+ cell.setPadding(16f);
|
|
|
+ cell.setVerticalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setColspan(2);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("4", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("资金", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("1.10%", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("0.000031", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("10598164.91", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("325.01", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ cell = new PdfPCell(new Phrase("合计", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ cell.setColspan(7);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("325.01", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ cell = new PdfPCell(new Phrase("会计制单:", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ cell.disableBorderSide(14);
|
|
|
+ cell.setColspan(4);
|
|
|
+ table.addCell(cell);
|
|
|
+ cell = new PdfPCell(new Phrase("复核:", font));
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ cell.disableBorderSide(14);
|
|
|
+ cell.setColspan(4);
|
|
|
+ table.addCell(cell);
|
|
|
+ table.setSpacingBefore(16f);
|
|
|
+ document.add(table);
|
|
|
+
|
|
|
+ document.close();
|
|
|
+ }
|
|
|
}
|