Commit 16a1bcf0 authored by 徐俊's avatar 徐俊

xujun

parent 24caba61
......@@ -5,10 +5,7 @@ import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;
import com.yiboshi.science.entity.SystemParameter;
import com.yiboshi.science.param.dto.ComProjectDTO;
import com.yiboshi.science.param.dto.ComProjectKpitDTO;
import com.yiboshi.science.param.dto.ComProjectMembersDTO;
import com.yiboshi.science.param.dto.ProjectKPIStatisticDTO;
import com.yiboshi.science.param.dto.*;
import java.io.*;
import java.util.Objects;
......@@ -63,6 +60,9 @@ public class ProjectInfoToPDF {
document.setPageSize(PageSize.A4);
document.newPage();
// 项目经费预算表
addProjectBudgetTable(document, project, bfChinese, fsChinese);
addSection(document, "二、主要技术指标", boldFont);
addContent(document, project.getTechnologyTarget(), normalFont);
......@@ -106,8 +106,6 @@ public class ProjectInfoToPDF {
}
}
/**
* 首页项目信息
* @param document
......@@ -712,6 +710,52 @@ public class ProjectInfoToPDF {
detailTable.addCell(titleCell);
}
private static void addProjectBudgetTable(Document document, ComProjectDTO project, BaseFont bfChinese, BaseFont fsChinese) throws DocumentException {
Font titleFont = new Font(bfChinese, 12, Font.BOLD);
Font contentFont = new Font(bfChinese, 12, Font.NORMAL);
// 添加表格标题
Paragraph title = new Paragraph("项目经费预算表", titleFont);
title.setAlignment(Element.ALIGN_CENTER);
title.setSpacingAfter(10f);
document.add(title);
// 添加金额单位说明
Paragraph unit = new Paragraph("金额单位:万元(保留两位小数)", contentFont);
unit.setAlignment(Element.ALIGN_RIGHT);
unit.setSpacingAfter(10f);
document.add(unit);
// 创建预算表格
PdfPTable budgetTable = new PdfPTable(5);
budgetTable.setWidthPercentage(98);
float[] widths = {2f, 1f, 1f, 1f, 1f};
budgetTable.setWidths(widths);
// 添加表头
String[] headers = {"预算科目", "总预算数", "财政资金", "自筹资金", "备注"};
for (String header : headers) {
addTitleCell(budgetTable, header, 0, 0, titleFont);
}
for (ComProjectBudgetDTO dto : project.getBudget()) {
addBudgetTitleCell(budgetTable, dto.getBudgetName(), contentFont);
addBudgetTitleCell(budgetTable, dto.getTotalBudget().toString(), contentFont);
addBudgetTitleCell(budgetTable, dto.getApplyFunds().toString(), contentFont);
addBudgetTitleCell(budgetTable, dto.getSelfFunds().toString(), contentFont);
addBudgetTitleCell(budgetTable, dto.getCalculationBasis(), contentFont);
}
document.add(budgetTable);
}
private static void addBudgetTitleCell(PdfPTable table, String title, Font contentFont) {
PdfPCell titleCell = new PdfPCell(new Phrase(title, contentFont));
titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
titleCell.setHorizontalAlignment(Element.ALIGN_LEFT);
table.addCell(titleCell);
}
/**
* 添加标签值行
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment