兴安出门证样式优化
This commit is contained in:
@@ -37,7 +37,7 @@ public class PdfWatermark extends PdfPageEventHelper {
|
||||
|
||||
// 计算位置(确保在页面内)
|
||||
float x = document.right() - watermark.getScaledWidth() - 20;
|
||||
float y = document.bottom() + watermark.getScaledHeight() - 50;
|
||||
float y = document.bottom() + watermark.getScaledHeight();
|
||||
|
||||
watermark.setAbsolutePosition(x, y);
|
||||
|
||||
|
||||
@@ -599,66 +599,39 @@ public class VisCarryStuffController extends BaseController {
|
||||
Font titleFont = new Font(bfChinese, 14, Font.BOLD);
|
||||
|
||||
// 创建主表格(2列:左边表单,右边二维码)
|
||||
PdfPTable mainTable = new PdfPTable(2);
|
||||
mainTable.setWidthPercentage(100);
|
||||
mainTable.setSpacingBefore(10f);
|
||||
|
||||
// 左边列:表单数据
|
||||
PdfPTable leftColumn = new PdfPTable(1);
|
||||
leftColumn.setWidthPercentage(100);
|
||||
// PdfPTable mainTable = new PdfPTable(2);
|
||||
// mainTable.setWidthPercentage(100);
|
||||
// mainTable.setSpacingBefore(10f);
|
||||
|
||||
// 添加标题
|
||||
Paragraph title = new Paragraph("出门证详情", titleFont);
|
||||
Paragraph title = new Paragraph("兴安化工出门证", titleFont);
|
||||
title.setAlignment(Element.ALIGN_CENTER);
|
||||
leftColumn.addCell(createCell(title, Element.ALIGN_CENTER));
|
||||
leftColumn.addCell(createCell(new Paragraph("\n"), Element.ALIGN_CENTER));
|
||||
document.add(title);
|
||||
|
||||
// 添加表单内容
|
||||
PdfPTable formTable = new PdfPTable(2);
|
||||
formTable.setWidthPercentage(90);
|
||||
formTable.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
|
||||
addFormRow(formTable, "出门证编号:", visExitOutVo.getExitPermitNo(), contentFont);
|
||||
addFormRow(formTable, "申请人姓名:", visExitOutVo.getName(), contentFont);
|
||||
addFormRow(formTable, "申请单位:", visExitOutVo.getVisitingUnit(), contentFont);
|
||||
addFormRow(formTable, "申请日期:", DateUtil.format(visExitOutVo.getVisTime(), DatePattern.NORM_DATE_PATTERN), contentFont);
|
||||
addFormRow(formTable, "事由:", visExitOutVo.getReason(), contentFont);
|
||||
|
||||
leftColumn.addCell(createCell(formTable, Element.ALIGN_CENTER));
|
||||
leftColumn.addCell(createCell(new Paragraph("\n\n"), Element.ALIGN_CENTER));
|
||||
// 创建数据表格
|
||||
float[] widths = {15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f};
|
||||
PdfPTable dataForm = new PdfPTable(widths);
|
||||
dataForm.setWidthPercentage(100);
|
||||
dataForm.setSpacingBefore(10f);
|
||||
|
||||
// 右边列:二维码
|
||||
PdfPTable rightColumn = new PdfPTable(1);
|
||||
rightColumn.setWidthPercentage(100);
|
||||
|
||||
// 生成二维码图片
|
||||
CheckCodeVo checkCodeVo = visCarryStuffService.selectStuffCheckCode(id);
|
||||
if (ObjectUtil.isNotNull(checkCodeVo) && StrUtil.isNotBlank(checkCodeVo.getCode())) {
|
||||
BarcodeQRCode qrCode = new BarcodeQRCode(checkCodeVo.getCode(), 100, 100, null);
|
||||
Image qrCodeImage = qrCode.getImage();
|
||||
qrCodeImage.scaleAbsolute(100, 100);
|
||||
qrCodeImage.setAlignment(Element.ALIGN_CENTER);
|
||||
// 添加表头
|
||||
addFromHeader(dataForm, contentFont);
|
||||
|
||||
// 添加二维码到右边列
|
||||
rightColumn.addCell(createCell(qrCodeImage, Element.ALIGN_CENTER));
|
||||
rightColumn.addCell(createCell(new Paragraph("出门证二维码", contentFont), Element.ALIGN_CENTER));
|
||||
}
|
||||
|
||||
// 将左右列添加到主表格
|
||||
mainTable.addCell(createCell(leftColumn, Element.ALIGN_LEFT));
|
||||
mainTable.addCell(createCell(rightColumn, Element.ALIGN_RIGHT));
|
||||
|
||||
document.add(mainTable);
|
||||
document.add(new Paragraph("\n\n"));
|
||||
// 添加表单的表格数据
|
||||
addFromRow(dataForm, visExitOutVo, contentFont);
|
||||
document.add(dataForm);
|
||||
|
||||
// 下半部分:物资信息表格保持不变
|
||||
Paragraph tableTitle = new Paragraph("物资信息", titleFont);
|
||||
tableTitle.setAlignment(Element.ALIGN_CENTER);
|
||||
document.add(tableTitle);
|
||||
document.add(new Paragraph("\n"));
|
||||
// Paragraph tableTitle = new Paragraph("物资信息", titleFont);
|
||||
// tableTitle.setAlignment(Element.ALIGN_CENTER);
|
||||
// document.add(tableTitle);
|
||||
|
||||
// 创建数据表格
|
||||
float[] widths = {15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f};
|
||||
PdfPTable dataTable = new PdfPTable(widths);
|
||||
dataTable.setWidthPercentage(100);
|
||||
dataTable.setSpacingBefore(10f);
|
||||
@@ -668,12 +641,25 @@ public class VisCarryStuffController extends BaseController {
|
||||
|
||||
// 添加表格数据
|
||||
if(CollUtil.isNotEmpty(stuffList)){
|
||||
int i = 1;
|
||||
for (VisStuffInfoVo vo : stuffList) {
|
||||
addTableRow(dataTable, vo, contentFont);
|
||||
addTableRow(dataTable, vo, contentFont, i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
document.add(dataTable);
|
||||
|
||||
// 生成二维码图片
|
||||
CheckCodeVo checkCodeVo = visCarryStuffService.selectStuffCheckCode(id);
|
||||
if (ObjectUtil.isNotNull(checkCodeVo) && StrUtil.isNotBlank(checkCodeVo.getCode())) {
|
||||
BarcodeQRCode qrCode = new BarcodeQRCode(checkCodeVo.getCode(), 120, 120, null);
|
||||
Image qrCodeImage = qrCode.getImage();
|
||||
qrCodeImage.scaleAbsolute(100, 100);
|
||||
qrCodeImage.setAlignment(Element.ALIGN_CENTER);
|
||||
}
|
||||
|
||||
|
||||
document.close();
|
||||
|
||||
// 转换为MultipartFile并上传
|
||||
@@ -732,8 +718,8 @@ public class VisCarryStuffController extends BaseController {
|
||||
}
|
||||
|
||||
// 添加表格表头
|
||||
private void addTableHeader(PdfPTable table, Font font) {
|
||||
String[] headers = {"物品名称", "规格型号", "物品类型", "数量", "用途", "是否返厂", "返厂时间", "返厂数量"};
|
||||
private void addFromHeader(PdfPTable table, Font font) {
|
||||
String[] headers = {"出门证编号", "申请人姓名", "申请单位", "申请日期", "事由", "工具", "车牌号", "部门审核", "生产或设备审核人", "人力综合部审核人"};
|
||||
for (String header : headers) {
|
||||
PdfPCell cell = new PdfPCell(new Paragraph(header, font));
|
||||
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
@@ -744,16 +730,44 @@ public class VisCarryStuffController extends BaseController {
|
||||
}
|
||||
|
||||
// 添加表格行数据
|
||||
private void addTableRow(PdfPTable table, VisStuffInfoVo vo, Font font) {
|
||||
private void addFromRow(PdfPTable table, VisExitOutVo vo, Font font) {
|
||||
table.addCell(createCell(vo.getExitPermitNo(), font));
|
||||
table.addCell(createCell(vo.getName(), font));
|
||||
table.addCell(createCell(vo.getVisitingUnit(), font));
|
||||
table.addCell(createCell(DateUtil.format(vo.getVisTime(), DatePattern.NORM_DATE_PATTERN), font));
|
||||
table.addCell(createCell(vo.getReason(), font));
|
||||
table.addCell(createCell(StrUtil.isBlank(vo.getVehicle()) ? "" : vo.getVehicle(), font));
|
||||
table.addCell(createCell(StrUtil.isBlank(vo.getCarNo()) ? "" : vo.getCarNo(), font));
|
||||
table.addCell(createCell(vo.getReviewerName1(), font));
|
||||
table.addCell(createCell(vo.getReviewerName2(), font));
|
||||
table.addCell(createCell(vo.getReviewerName3(), font));
|
||||
}
|
||||
|
||||
// 添加表格表头
|
||||
private void addTableHeader(PdfPTable table, Font font) {
|
||||
String[] headers = {"序号", "物资名称", "规格型号", "物资类型", "物资用途", "数量","计量单位", "是否返厂", "返厂时间", "返厂数量"};
|
||||
for (String header : headers) {
|
||||
PdfPCell cell = new PdfPCell(new Paragraph(header, font));
|
||||
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||
cell.setFixedHeight(25);
|
||||
table.addCell(cell);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加表格行数据
|
||||
private void addTableRow(PdfPTable table, VisStuffInfoVo vo, Font font, int i) {
|
||||
String backTime = vo.getBackTime() != null ?
|
||||
DateUtil.format(vo.getBackTime(), DatePattern.NORM_DATE_PATTERN) : "";
|
||||
String isBack = vo.getIsBack() == 1 ? "是" : "否";
|
||||
|
||||
table.addCell(createCell(String.valueOf(i), font));
|
||||
table.addCell(createCell(vo.getName(), font));
|
||||
table.addCell(createCell(vo.getModel(), font));
|
||||
table.addCell(createCell(vo.getTypeName(), font));
|
||||
table.addCell(createCell(vo.getNumber() == null ? "" : String.valueOf(vo.getNumber()), font));
|
||||
table.addCell(createCell(vo.getPurpose(), font));
|
||||
table.addCell(createCell(vo.getNumber() == null ? "" : String.valueOf(vo.getNumber()), font));
|
||||
table.addCell(createCell(vo.getUnit(), font));
|
||||
table.addCell(createCell(isBack, font));
|
||||
table.addCell(createCell(backTime, font));
|
||||
table.addCell(createCell(vo.getBackNumber() == null ? "" : String.valueOf(vo.getBackNumber()), font));
|
||||
|
||||
Reference in New Issue
Block a user