|
|
@@ -3,13 +3,19 @@ package com.xunmei.file.utils;
|
|
|
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.lowagie.text.*;
|
|
|
import com.lowagie.text.pdf.*;
|
|
|
import com.xunmei.common.core.constant.DictConstants;
|
|
|
import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystem;
|
|
|
+import com.xunmei.common.core.domain.letter.domain.CoreIntroduceLetterOutInRequestUser;
|
|
|
+import com.xunmei.common.core.domain.letter.dto.CoreIntroduceLetterUserAddDto;
|
|
|
+import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.security.utils.DictUtils;
|
|
|
+import com.xunmei.file.enums.IdTypeEnums;
|
|
|
import com.xunmei.file.vo.ItextPdfTableVo;
|
|
|
import com.xunmei.system.api.domain.AccessDataVo;
|
|
|
import com.xunmei.system.api.domain.CheckDataVo;
|
|
|
@@ -26,6 +32,7 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -39,7 +46,7 @@ public class PdfUtil {
|
|
|
}
|
|
|
|
|
|
public static ItextPdfTableVo createTable(String filename, int numColumns, int fontSize) throws Exception {
|
|
|
- Document document = createDocument(0, 0, 50, 50);
|
|
|
+ Document document = createDocument(0, 0, 50, 12);
|
|
|
File file = FileUtils.getFile(filename);
|
|
|
FileOutputStream fos = new FileOutputStream(file);
|
|
|
final PdfWriter writer = PdfWriter.getInstance(document, fos);
|
|
|
@@ -52,7 +59,7 @@ public class PdfUtil {
|
|
|
PdfPTable table = new PdfPTable(numColumns);
|
|
|
// 设置各列列宽
|
|
|
// table.setTotalWidth(new float[]{90, 100, 100, 120, 100, 100});
|
|
|
- table.setSpacingBefore(16f);
|
|
|
+// table.setSpacingBefore(16f);
|
|
|
table.setSplitRows(true);
|
|
|
table.setSplitLate(false);
|
|
|
ItextPdfTableVo itextPdfTableVo = new ItextPdfTableVo();
|
|
|
@@ -78,6 +85,80 @@ public class PdfUtil {
|
|
|
return cell;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建单元格 - 固定单元格大小
|
|
|
+ * @param tableFont
|
|
|
+ * @param table
|
|
|
+ * @param content
|
|
|
+ * @param align
|
|
|
+ * @param colspan
|
|
|
+ * @param rowspan
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static PdfPCell createOutInPDFCell(Font tableFont, PdfPTable table, String content, int align, Integer colspan, Integer rowspan) {
|
|
|
+ final PdfPCell cell = outInCell(tableFont, content, align, colspan, rowspan);
|
|
|
+ table.addCell(cell);
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ public static PdfPCell createOutInPDFCell(Font tableFont, PdfPTable table, String content, int align, Integer colspan, Integer rowspan, Float fixedHeight) {
|
|
|
+ final PdfPCell cell = OutInCell(tableFont, content, align, colspan, rowspan, fixedHeight);
|
|
|
+ table.addCell(cell);
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static PdfPCell OutInCell(Font tableFont, String content, int align, Integer colspan, Integer rowspan, Float fixedHeight) {
|
|
|
+ PdfPCell cell = new PdfPCell(new Phrase(content, tableFont));
|
|
|
+ if (colspan != null && colspan > 0) {
|
|
|
+ cell.setColspan(colspan);
|
|
|
+ }
|
|
|
+ if (rowspan != null && rowspan > 0) {
|
|
|
+ cell.setRowspan(rowspan);
|
|
|
+ }
|
|
|
+
|
|
|
+ cell.setPaddingTop(2f);
|
|
|
+ cell.setPaddingBottom(7f);
|
|
|
+ cell.setPaddingLeft(8f);
|
|
|
+ cell.setPaddingRight(8f);
|
|
|
+
|
|
|
+ cell.setFixedHeight(fixedHeight);
|
|
|
+
|
|
|
+ cell.setLeading(0F, 1.2F);
|
|
|
+ if (PdfPCell.ALIGN_MIDDLE != align) {
|
|
|
+ cell.setHorizontalAlignment(align);
|
|
|
+ } else {
|
|
|
+ //设置单元格的垂直方向对齐方式
|
|
|
+ cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
|
|
|
+ //设置单元格的水平方向对齐方式
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ }
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static PdfPCell outInCell(Font tableFont, String content, int align, Integer colspan, Integer rowspan) {
|
|
|
+ PdfPCell cell = new PdfPCell(new Phrase(content, tableFont));
|
|
|
+ if (colspan != null && colspan > 0) {
|
|
|
+ cell.setColspan(colspan);
|
|
|
+ }
|
|
|
+ if (rowspan != null && rowspan > 0) {
|
|
|
+ cell.setRowspan(rowspan);
|
|
|
+ }
|
|
|
+ cell.setPaddingTop(2f);
|
|
|
+ cell.setPaddingBottom(7f);
|
|
|
+ cell.setPaddingLeft(8f);
|
|
|
+ cell.setPaddingRight(8f);
|
|
|
+
|
|
|
+ cell.setLeading(0f, 1.2F);
|
|
|
+ if (PdfPCell.ALIGN_MIDDLE != align) {
|
|
|
+ cell.setHorizontalAlignment(align);
|
|
|
+ } else {
|
|
|
+ //设置单元格的垂直方向对齐方式
|
|
|
+ cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
|
|
|
+ //设置单元格的水平方向对齐方式
|
|
|
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ }
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
private static PdfPCell cell(Font tableFont, String content, int align, Integer colspan, Integer rowspan) {
|
|
|
PdfPCell cell = new PdfPCell(new Phrase(content, tableFont));
|
|
|
if (colspan != null && colspan > 0) {
|
|
|
@@ -110,10 +191,10 @@ public class PdfUtil {
|
|
|
if (rowspan != null && rowspan > 0) {
|
|
|
cell.setRowspan(rowspan);
|
|
|
}
|
|
|
- // cell.setPaddingTop(8f);
|
|
|
+// cell.setPaddingTop(8f);
|
|
|
cell.setPaddingLeft(paddingLeft);
|
|
|
cell.setPaddingRight(paddingRight);
|
|
|
- cell.setPaddingBottom(8f);
|
|
|
+// cell.setPaddingBottom(8f);
|
|
|
cell.setLeading(1F, 1.5F);
|
|
|
if (PdfPCell.ALIGN_MIDDLE != align) {
|
|
|
cell.setHorizontalAlignment(align);
|
|
|
@@ -223,7 +304,7 @@ public class PdfUtil {
|
|
|
document.add(table);
|
|
|
PdfPTable imageTable = new PdfPTable(6);
|
|
|
final List<List<String>> listList = ListUtil.split((List<String>) data.get("fileImage"), 2);
|
|
|
- createPDFCell(tableFont, imageTable, "图片附件", Element.ALIGN_MIDDLE, 1, listList.size()==0?1:listList.size());
|
|
|
+ createPDFCell(tableFont, imageTable, "图片附件", Element.ALIGN_MIDDLE, 1, listList.size() == 0 ? 1 : listList.size());
|
|
|
for (List<String> stringList : listList) {
|
|
|
PdfPTable innerTable = new PdfPTable(5);
|
|
|
innerTable.setWidthPercentage(100F);
|
|
|
@@ -273,7 +354,7 @@ public class PdfUtil {
|
|
|
//序号
|
|
|
PdfUtil.createPDFCell(tableFont, table, String.valueOf(o), PdfPCell.ALIGN_MIDDLE, 2, 0);
|
|
|
// 检查内容
|
|
|
- String rowContent = listVo.get("pointName")+"";
|
|
|
+ String rowContent = listVo.get("pointName") + "";
|
|
|
PdfUtil.createPDFCell(tableFont, table, rowContent, Element.ALIGN_LEFT, 6, 0);
|
|
|
// 检查情况
|
|
|
PdfUtil.createPDFCell(tableFont, table, ObjectUtil.isEmpty(listVo.get("resValue")) ? "" : (((Integer) listVo.get("resValue")) == 0 ? "正常" : "异常"), Element.ALIGN_MIDDLE, 2, 0);
|
|
|
@@ -404,150 +485,274 @@ public class PdfUtil {
|
|
|
return result.toString();
|
|
|
}
|
|
|
|
|
|
+ // public static void dealOutInBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
|
|
|
+// table.setSplitLate(false);
|
|
|
+// table.setSplitRows(true);
|
|
|
+// //第一行
|
|
|
+// createPDFCell(tableFont, table, "接待机构", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("inOrg").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// createPDFCell(tableFont, table, "接待日期", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("time").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// //第二行
|
|
|
+// createPDFCell(tableFont, table, "出入事由", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("reasons").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// createPDFCell(tableFont, table, "陪同人员", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("accompanyingPerson").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+//
|
|
|
+// //第三行
|
|
|
+// createPDFCell(tableFont, table, "申请单位", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("outOrgName").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// createPDFCell(tableFont, table, "出入人员", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("userName").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// //第四行
|
|
|
+// createPDFCell(tableFont, table, "证件类型", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("idType").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// createPDFCell(tableFont, table, "证件号码", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("idCard").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// //第五行
|
|
|
+// createPDFCell(tableFont, table, "进入时间", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("inTime").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// createPDFCell(tableFont, table, "离开时间", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("outTime").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+//
|
|
|
+// //第六行
|
|
|
+// createPDFCell(tableFont, table, "审批人", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("approveUser").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+// createPDFCell(tableFont, table, "登记人", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// createPDFCell(tableFont, table, data.get("createBy").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+//
|
|
|
+// //第七行
|
|
|
+// createPDFCell(tableFont, table, "审批人签字", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// dealImageCell((List<String>) data.get("approveSign"), table, 1, 80, 30, 2, 1);
|
|
|
+// createPDFCell(tableFont, table, "登记人签字", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// dealImageCell((List<String>) data.get("submitSign"), table, 1, 80, 30, 2, 1);
|
|
|
+//// //第8行
|
|
|
+//// createPDFCell(tableFont, table, "备注", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+//// createPDFCell(tableFont, table, data.get("remark").toString(), Element.ALIGN_MIDDLE, 5, 1);
|
|
|
+//
|
|
|
+//
|
|
|
+// //证件图片
|
|
|
+// createPDFCell(tableFont, table, "证件图片", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// //证件图片 图片填充
|
|
|
+// final PdfPTable imageTable1 = getImage((List<String>) data.get("imageFile"), 2, 190, 130, 2,0f);
|
|
|
+// final PdfPCell cell1 = new PdfPCell();
|
|
|
+// cell1.setNoWrap(false);
|
|
|
+// cell1.setPaddingLeft(4f);
|
|
|
+// cell1.setPaddingRight(4f);
|
|
|
+// cell1.setPaddingBottom(4f);
|
|
|
+// cell1.setPaddingTop(4f);
|
|
|
+// cell1.setColspan(5);
|
|
|
+// cell1.setRowspan(1);
|
|
|
+// //cell1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
+// cell1.addElement(imageTable1);
|
|
|
+// table.addCell(cell1);
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// List<String> files= (List<String>) data.get("file");
|
|
|
+// List<String> files1=new ArrayList<>();
|
|
|
+// List<String> files2= new ArrayList<>();
|
|
|
+// // 没有备注图片时 需要把介绍信图片上移
|
|
|
+// if(ObjectUtil.isNotEmpty(files))
|
|
|
+// {
|
|
|
+// files1= files.subList(0,1);
|
|
|
+// if(files.size()>1)
|
|
|
+// {
|
|
|
+// files2= files.subList(1,files.size());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// files2=files;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(ObjectUtil.isNotEmpty(files1))
|
|
|
+// {
|
|
|
+// createPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// final PdfPTable imageTable3 = getImage(files1, 1, 380, 320, 1,0f);
|
|
|
+// final PdfPCell cell3 = new PdfPCell();
|
|
|
+// cell3.setNoWrap(false);
|
|
|
+// cell3.setPaddingLeft(4f);
|
|
|
+// cell3.setPaddingRight(4f);
|
|
|
+// cell3.setPaddingBottom(4f);
|
|
|
+// cell3.setPaddingTop(4f);
|
|
|
+// cell3.setColspan(5);
|
|
|
+// cell3.setRowspan(1);
|
|
|
+// //cell1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
+// cell3.addElement(imageTable3);
|
|
|
+// table.addCell(cell3);
|
|
|
+// document.add(table);
|
|
|
+// }
|
|
|
+// else { // 紧急类型的出入 可能没有介绍信图片
|
|
|
+// document.add(table);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(files2.size()>0)
|
|
|
+// {
|
|
|
+// PdfPTable innerTable = new PdfPTable(6);
|
|
|
+// createPDFCell(tableFont, innerTable, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+//
|
|
|
+// // createPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// final PdfPTable imageTable2 = getImage(files2, 2, 380, 340, 1,8f);
|
|
|
+// final PdfPCell cell2 = new PdfPCell();
|
|
|
+// cell2.setNoWrap(false);
|
|
|
+// cell2.setPaddingLeft(4f);
|
|
|
+// cell2.setPaddingRight(4f);
|
|
|
+// cell2.setPaddingBottom(4f);
|
|
|
+// cell2.setPaddingTop(4f);
|
|
|
+// cell2.setColspan(5);
|
|
|
+// cell2.setRowspan(1);
|
|
|
+// cell2.addElement(imageTable2);
|
|
|
+// innerTable.addCell(cell2);
|
|
|
+// document.newPage();
|
|
|
+// document.add(innerTable);
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<String> checkImages= (List<String>) data.get("checkImage");
|
|
|
+//
|
|
|
+// PdfPTable innerTable2 = new PdfPTable(6);
|
|
|
+// createPDFCell(tableFont, innerTable2, "备注", Element.ALIGN_MIDDLE, 1, checkImages.isEmpty()?1:2);
|
|
|
+// createPDFCell(tableFont, innerTable2, data.get("remark").toString(), Element.ALIGN_LEFT, 5, 1);
|
|
|
+// // 核查结果图片为非必填,没有图片时不显示
|
|
|
+// if(!checkImages.isEmpty())
|
|
|
+// {
|
|
|
+// final PdfPTable imageTable3 = getImage((List<String>) data.get("checkImage"), 2, 190, 190, 2,0f);
|
|
|
+// final PdfPCell cell3 = new PdfPCell();
|
|
|
+// cell3.setNoWrap(false);
|
|
|
+// cell3.setPaddingLeft(4f);
|
|
|
+// cell3.setPaddingRight(4f);
|
|
|
+// cell3.setPaddingBottom(4f);
|
|
|
+// cell3.setPaddingTop(4f);
|
|
|
+// cell3.setColspan(5);
|
|
|
+// cell3.setRowspan(1);
|
|
|
+// //cell1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
+// cell3.addElement(imageTable3);
|
|
|
+// innerTable2.addCell(cell3);
|
|
|
+// }
|
|
|
+// document.add(innerTable2);
|
|
|
+// }
|
|
|
public static void dealOutInBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
|
|
|
table.setSplitLate(false);
|
|
|
table.setSplitRows(true);
|
|
|
- //第一行
|
|
|
- createPDFCell(tableFont, table, "接待机构", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("inOrg").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- createPDFCell(tableFont, table, "接待日期", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("time").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- //第二行
|
|
|
- createPDFCell(tableFont, table, "出入事由", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("reasons").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- createPDFCell(tableFont, table, "陪同人员", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("accompanyingPerson").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ //第1行
|
|
|
+ createOutInPDFCell(tableFont, table, "接待机构", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, data.get("inOrg").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, "接待日期", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, data.get("time").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ //第2行
|
|
|
+ createOutInPDFCell(tableFont, table, "出入事由", Element.ALIGN_MIDDLE, 1, 1,33F);
|
|
|
+ createOutInPDFCell(tableFont, table, data.get("reasons").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, "陪同人员", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, data.get("accompanyingPerson").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+
|
|
|
+ //第3行
|
|
|
+ createOutInPDFCell(tableFont, table, "审批人", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, data.get("approveUser").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, "登记人", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, data.get("createBy").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+
|
|
|
+ //第4行
|
|
|
+ createOutInPDFCell(tableFont, table, "审批人签字", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ dealImageCell((List<String>) data.get("approveSign"), table, 1, 100, 50, 2, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, "登记人签字", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ dealImageCell((List<String>) data.get("checkSign"), table, 1, 100, 50, 2, 1);
|
|
|
+
|
|
|
+
|
|
|
+ List<String> letterFiles = (List<String>) data.get("letterFile");
|
|
|
+
|
|
|
+ List<String> files1 = new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> files2 = new ArrayList<>();
|
|
|
|
|
|
- //第三行
|
|
|
- createPDFCell(tableFont, table, "申请单位", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("outOrgName").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- createPDFCell(tableFont, table, "出入人员", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("userName").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- //第四行
|
|
|
- createPDFCell(tableFont, table, "证件类型", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("idType").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- createPDFCell(tableFont, table, "证件号码", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("idCard").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- //第五行
|
|
|
- createPDFCell(tableFont, table, "进入时间", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("inTime").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- createPDFCell(tableFont, table, "离开时间", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("outTime").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
-
|
|
|
- //第六行
|
|
|
- createPDFCell(tableFont, table, "审批人", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("approveUser").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- createPDFCell(tableFont, table, "登记人", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("createBy").toString(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
-
|
|
|
- //第七行
|
|
|
- createPDFCell(tableFont, table, "审批人签字", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- dealImageCell((List<String>) data.get("approveSign"), table, 1, 80, 30, 2, 1);
|
|
|
- createPDFCell(tableFont, table, "登记人签字", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- dealImageCell((List<String>) data.get("submitSign"), table, 1, 80, 30, 2, 1);
|
|
|
-// //第8行
|
|
|
-// createPDFCell(tableFont, table, "备注", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
-// createPDFCell(tableFont, table, data.get("remark").toString(), Element.ALIGN_MIDDLE, 5, 1);
|
|
|
-
|
|
|
-
|
|
|
- //证件图片
|
|
|
- createPDFCell(tableFont, table, "证件图片", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- //证件图片 图片填充
|
|
|
- final PdfPTable imageTable1 = getImage((List<String>) data.get("imageFile"), 2, 190, 130, 2,0f);
|
|
|
- final PdfPCell cell1 = new PdfPCell();
|
|
|
- cell1.setNoWrap(false);
|
|
|
- cell1.setPaddingLeft(4f);
|
|
|
- cell1.setPaddingRight(4f);
|
|
|
- cell1.setPaddingBottom(4f);
|
|
|
- cell1.setPaddingTop(4f);
|
|
|
- cell1.setColspan(5);
|
|
|
- cell1.setRowspan(1);
|
|
|
- //cell1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
- cell1.addElement(imageTable1);
|
|
|
- table.addCell(cell1);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- List<String> files= (List<String>) data.get("file");
|
|
|
- List<String> files1=new ArrayList<>();
|
|
|
- List<String> files2= new ArrayList<>();
|
|
|
// 没有备注图片时 需要把介绍信图片上移
|
|
|
- if(ObjectUtil.isNotEmpty(files))
|
|
|
- {
|
|
|
- files1= files.subList(0,1);
|
|
|
- if(files.size()>1)
|
|
|
- {
|
|
|
- files2= files.subList(1,files.size());
|
|
|
+ if (ObjectUtil.isNotEmpty(letterFiles)) {
|
|
|
+
|
|
|
+ if (letterFiles.size() == 1) {
|
|
|
+ letterFilesModelOne(tableFont, table, letterFiles);
|
|
|
+ }
|
|
|
+ if (letterFiles.size() == 2) {
|
|
|
+ letterFilesModelTwo(tableFont, table, letterFiles);
|
|
|
+ }
|
|
|
+ if (letterFiles.size() > 2) {
|
|
|
+ letterFilesModelThree(tableFont, table, letterFiles);
|
|
|
}
|
|
|
}
|
|
|
- else{
|
|
|
- files2=files;
|
|
|
- }
|
|
|
-
|
|
|
- if(ObjectUtil.isNotEmpty(files1))
|
|
|
- {
|
|
|
- createPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- final PdfPTable imageTable3 = getImage(files1, 1, 380, 320, 1,0f);
|
|
|
- final PdfPCell cell3 = new PdfPCell();
|
|
|
- cell3.setNoWrap(false);
|
|
|
- cell3.setPaddingLeft(4f);
|
|
|
- cell3.setPaddingRight(4f);
|
|
|
- cell3.setPaddingBottom(4f);
|
|
|
- cell3.setPaddingTop(4f);
|
|
|
- cell3.setColspan(5);
|
|
|
- cell3.setRowspan(1);
|
|
|
- //cell1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
- cell3.addElement(imageTable3);
|
|
|
- table.addCell(cell3);
|
|
|
- document.add(table);
|
|
|
- }
|
|
|
- else { // 紧急类型的出入 可能没有介绍信图片
|
|
|
- document.add(table);
|
|
|
+
|
|
|
+ // 个人信息部分
|
|
|
+ String userInfos = JSON.toJSONString(data.get("userInfos"));
|
|
|
+ List<CoreIntroduceLetterOutInRequestUser> personInfoList = JSON.parseArray(userInfos, CoreIntroduceLetterOutInRequestUser.class);
|
|
|
+ if (ObjectUtil.isNotEmpty(personInfoList)) {
|
|
|
+ personInfoList.forEach(item -> {
|
|
|
+
|
|
|
+ createOutInPDFCell(tableFont, table, "工作单位", Element.ALIGN_MIDDLE, 1, 1,33F);
|
|
|
+ createOutInPDFCell(tableFont, table, item.getCompanyName(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+
|
|
|
+//
|
|
|
+ createOutInPDFCell(tableFont, table, "出入人员", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, item.getUserName(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+//第二行 30
|
|
|
+ createOutInPDFCell(tableFont, table, "证件类型", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, IdTypeEnums.description(item.getIdType()), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+
|
|
|
+ createOutInPDFCell(tableFont, table, "证件号码", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, item.getIdCard(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd日 HH时mm分");
|
|
|
+ String arrivalTime = sdf.format(item.getArrivalTime());
|
|
|
+ String departureTime = sdf.format(item.getDepartureTime());
|
|
|
+ createOutInPDFCell(tableFont, table, "进入时间", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, arrivalTime, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, "离开时间", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ createOutInPDFCell(tableFont, table, departureTime, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+
|
|
|
+ createOutInPDFCell(tableFont, table, "证件图片", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+
|
|
|
+ List<String> images = new ArrayList<>(Arrays.asList(item.getImgFile().split(",")));
|
|
|
+
|
|
|
+ try {
|
|
|
+ PdfPTable image = getImage(images, 2, 168, 104, 2, 0f);
|
|
|
+ PdfPCell cell = new PdfPCell();
|
|
|
+ cell.setNoWrap(false);
|
|
|
+ cell.setPaddingLeft(4f);
|
|
|
+ cell.setPaddingRight(4f);
|
|
|
+ cell.setPaddingBottom(8f);
|
|
|
+ cell.setPaddingTop(8f);
|
|
|
+ cell.setColspan(5);
|
|
|
+ cell.setRowspan(1);
|
|
|
+ cell.addElement(image);
|
|
|
+ table.addCell(cell);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("出入管理登记簿,证件图片处理失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
}
|
|
|
+ document.add(table);
|
|
|
|
|
|
- if(files2.size()>0)
|
|
|
- {
|
|
|
- PdfPTable innerTable = new PdfPTable(6);
|
|
|
- createPDFCell(tableFont, innerTable, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
-
|
|
|
- // createPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
- final PdfPTable imageTable2 = getImage(files2, 2, 380, 340, 1,8f);
|
|
|
- final PdfPCell cell2 = new PdfPCell();
|
|
|
- cell2.setNoWrap(false);
|
|
|
- cell2.setPaddingLeft(4f);
|
|
|
- cell2.setPaddingRight(4f);
|
|
|
- cell2.setPaddingBottom(4f);
|
|
|
- cell2.setPaddingTop(4f);
|
|
|
- cell2.setColspan(5);
|
|
|
- cell2.setRowspan(1);
|
|
|
- cell2.addElement(imageTable2);
|
|
|
- innerTable.addCell(cell2);
|
|
|
- document.newPage();
|
|
|
- document.add(innerTable);
|
|
|
- }
|
|
|
-
|
|
|
- List<String> checkImages= (List<String>) data.get("checkImage");
|
|
|
-
|
|
|
- PdfPTable innerTable2 = new PdfPTable(6);
|
|
|
- createPDFCell(tableFont, innerTable2, "备注", Element.ALIGN_MIDDLE, 1, checkImages.isEmpty()?1:2);
|
|
|
- createPDFCell(tableFont, innerTable2, data.get("remark").toString(), Element.ALIGN_LEFT, 5, 1);
|
|
|
- // 核查结果图片为非必填,没有图片时不显示
|
|
|
- if(!checkImages.isEmpty())
|
|
|
- {
|
|
|
- final PdfPTable imageTable3 = getImage((List<String>) data.get("checkImage"), 2, 190, 190, 2,0f);
|
|
|
- final PdfPCell cell3 = new PdfPCell();
|
|
|
- cell3.setNoWrap(false);
|
|
|
- cell3.setPaddingLeft(4f);
|
|
|
- cell3.setPaddingRight(4f);
|
|
|
- cell3.setPaddingBottom(4f);
|
|
|
- cell3.setPaddingTop(4f);
|
|
|
- cell3.setColspan(5);
|
|
|
- cell3.setRowspan(1);
|
|
|
- //cell1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
- cell3.addElement(imageTable3);
|
|
|
- innerTable2.addCell(cell3);
|
|
|
- }
|
|
|
- document.add(innerTable2);
|
|
|
+ String remark = (String) data.get("remark");
|
|
|
+ List<String> remarkImage = (List<String>) data.get("remarkImage");
|
|
|
+
|
|
|
+ if (!StringUtil.isNullOrEmpty(remark) || ObjectUtil.isNotEmpty(remarkImage)) {
|
|
|
+ PdfPTable remarkTable = new PdfPTable(6);
|
|
|
+ createOutInPDFCell(tableFont, remarkTable, "备注", Element.ALIGN_MIDDLE, 1, remarkImage.isEmpty() ? 1 : 2);
|
|
|
+ if (StrUtil.isNotEmpty(remark)) {
|
|
|
+ createOutInPDFCell(tableFont, remarkTable, data.get("remark").toString(), Element.ALIGN_LEFT, 5, 1);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(remarkImage)) {
|
|
|
+ PdfPTable remarkImageTable = getImage(remarkImage, 2, 168, 104, 2, 0f);
|
|
|
+ PdfPCell remarkImageCell = new PdfPCell();
|
|
|
+ remarkImageCell.setNoWrap(false);
|
|
|
+ remarkImageCell.setPaddingLeft(4f);
|
|
|
+ remarkImageCell.setPaddingRight(4f);
|
|
|
+ remarkImageCell.setPaddingBottom(8f);
|
|
|
+ remarkImageCell.setPaddingTop(8f);
|
|
|
+ remarkImageCell.setColspan(5);
|
|
|
+ remarkImageCell.setRowspan(1);
|
|
|
+ remarkImageCell.addElement(remarkImageTable);
|
|
|
+ remarkTable.addCell(remarkImageCell);
|
|
|
+ }
|
|
|
+ document.add(remarkTable);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static void dealDrillBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
|
|
|
@@ -594,7 +799,7 @@ public class PdfUtil {
|
|
|
document.add(table);
|
|
|
PdfPTable imageTable = new PdfPTable(6);
|
|
|
final List<List<String>> listList = ListUtil.split((List<String>) data.get("fileImage"), 2);
|
|
|
- createPDFCell(tableFont, imageTable, "图片附件", Element.ALIGN_MIDDLE, 1, listList.size()==0?1:listList.size());
|
|
|
+ createPDFCell(tableFont, imageTable, "图片附件", Element.ALIGN_MIDDLE, 1, listList.size() == 0 ? 1 : listList.size());
|
|
|
for (List<String> stringList : listList) {
|
|
|
PdfPTable innerTable = new PdfPTable(5);
|
|
|
innerTable.setWidthPercentage(100F);
|
|
|
@@ -650,6 +855,72 @@ public class PdfUtil {
|
|
|
table.addCell(outCell);
|
|
|
}
|
|
|
|
|
|
+ private static void letterFilesModelOne(Font tableFont, PdfPTable table, List<String> letterFiles) throws Exception {
|
|
|
+ createPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ PdfPTable letterFileTable = getImage(letterFiles, 1, 380, 386, 1, 0f);
|
|
|
+ PdfPCell cell = new PdfPCell();
|
|
|
+ cell.setNoWrap(false);
|
|
|
+ cell.setPaddingLeft(4f);
|
|
|
+ cell.setPaddingRight(4f);
|
|
|
+ cell.setPaddingBottom(4f);
|
|
|
+ cell.setPaddingTop(4f);
|
|
|
+ cell.setColspan(5);
|
|
|
+ cell.setRowspan(1);
|
|
|
+ cell.addElement(letterFileTable);
|
|
|
+ table.addCell(cell);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void letterFilesModelTwo(Font tableFont, PdfPTable table, List<String> letterFiles) throws Exception {
|
|
|
+ createPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ PdfPTable letterFileTable = getImage(letterFiles, 2, 380, 286, 1, 4f);
|
|
|
+ PdfPCell cell = new PdfPCell();
|
|
|
+ cell.setNoWrap(false);
|
|
|
+ cell.setPaddingLeft(4f);
|
|
|
+ cell.setPaddingRight(4f);
|
|
|
+ cell.setPaddingBottom(4f);
|
|
|
+ cell.setPaddingTop(4f);
|
|
|
+ cell.setColspan(5);
|
|
|
+ cell.setRowspan(1);
|
|
|
+ cell.addElement(letterFileTable);
|
|
|
+ table.addCell(cell);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void letterFilesModelThree(Font tableFont, PdfPTable table, List<String> letterFiles) throws Exception {
|
|
|
+
|
|
|
+ List<String> headFiles = letterFiles.subList(0, 2);
|
|
|
+ List<String> otherFiles = letterFiles.subList(2, letterFiles.size());
|
|
|
+
|
|
|
+ createOutInPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ PdfPTable headLetterFileTable = getImage(headFiles, 2, 380, 286, 1, 4f);
|
|
|
+ PdfPCell headCell = new PdfPCell();
|
|
|
+ headCell.setNoWrap(false);
|
|
|
+ headCell.setPaddingLeft(4f);
|
|
|
+ headCell.setPaddingRight(4f);
|
|
|
+ headCell.setPaddingBottom(4f);
|
|
|
+ headCell.setPaddingTop(4f);
|
|
|
+ headCell.setColspan(5);
|
|
|
+ headCell.setRowspan(1);
|
|
|
+ headCell.addElement(headLetterFileTable);
|
|
|
+ table.addCell(headCell);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ int otherFilesSize = otherFiles.size();
|
|
|
+
|
|
|
+ createOutInPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ PdfPTable otherLetterFileTable = getImage(otherFiles, otherFilesSize, 380, 378, 1, 4f);
|
|
|
+ PdfPCell ohterCell = new PdfPCell();
|
|
|
+ ohterCell.setNoWrap(false);
|
|
|
+ ohterCell.setPaddingLeft(4f);
|
|
|
+ ohterCell.setPaddingRight(4f);
|
|
|
+ ohterCell.setPaddingBottom(4f);
|
|
|
+ ohterCell.setPaddingTop(4f);
|
|
|
+ ohterCell.setColspan(5);
|
|
|
+ ohterCell.setRowspan(1);
|
|
|
+ ohterCell.addElement(otherLetterFileTable);
|
|
|
+ table.addCell(ohterCell);
|
|
|
+ }
|
|
|
+
|
|
|
public static void dealEduImageCell2(List<String> imageList, PdfPTable table, Integer imageNumsOfRow, Integer imageWith, Integer imageHigh) throws Exception {
|
|
|
//签字区域
|
|
|
PdfPCell outCell = new PdfPCell();
|
|
|
@@ -726,7 +997,7 @@ public class PdfUtil {
|
|
|
table.addCell(outCell);
|
|
|
}
|
|
|
|
|
|
- private static PdfPTable getImage(List<String> images, int totalImages, float imageWidth, float imageHeight, Integer ImageNumsOfRow,Float paddingBottom) throws Exception {
|
|
|
+ private static PdfPTable getImage(List<String> images, int totalImages, float imageWidth, float imageHeight, Integer ImageNumsOfRow, Float paddingBottom) throws Exception {
|
|
|
if (images == null) {
|
|
|
images = new ArrayList<>();
|
|
|
}
|
|
|
@@ -800,14 +1071,14 @@ public class PdfUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void dealAccessTimes(Document document, PdfPTable table, Font tableFont, Font tableTitleFont, List<String> data)throws DocumentException {
|
|
|
- if(ObjectUtil.isNotEmpty(data)){
|
|
|
- for (int i = 1; i <= data.size() ; i++) {
|
|
|
+ public static void dealAccessTimes(Document document, PdfPTable table, Font tableFont, Font tableTitleFont, List<String> data) throws DocumentException {
|
|
|
+ if (ObjectUtil.isNotEmpty(data)) {
|
|
|
+ for (int i = 1; i <= data.size(); i++) {
|
|
|
String time = data.get(i - 1);
|
|
|
PdfUtil.createPDFCell(tableFont, table, String.valueOf(i), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
PdfUtil.createPDFCell(tableFont, table, time, Element.ALIGN_MIDDLE, 17, 1);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 17, 1);
|
|
|
}
|
|
|
@@ -897,7 +1168,7 @@ public class PdfUtil {
|
|
|
for (CheckDataVo checkDataVo : data.getCheckDatas()) {
|
|
|
PdfUtil.createPDFCell(tableFont, table, String.valueOf(data.getCheckDatas().indexOf(checkDataVo) + 1), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
PdfUtil.createPDFCell(tableFont, table, checkDataVo.getPointName(), Element.ALIGN_MIDDLE, 10, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, ObjectUtil.equal(Boolean.TRUE, checkDataVo.getCheckStatus())?"正常":"异常", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, ObjectUtil.equal(Boolean.TRUE, checkDataVo.getCheckStatus()) ? "正常" : "异常", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
}
|
|
|
} else {
|
|
|
PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 2, 1);
|