Commit eedbce92 authored by 徐俊's avatar 徐俊

xujun

parent 16a1bcf0
...@@ -63,6 +63,9 @@ public class ProjectInfoToPDF { ...@@ -63,6 +63,9 @@ public class ProjectInfoToPDF {
// 项目经费预算表 // 项目经费预算表
addProjectBudgetTable(document, project, bfChinese, fsChinese); addProjectBudgetTable(document, project, bfChinese, fsChinese);
// 添加新页面
document.newPage();
addSection(document, "二、主要技术指标", boldFont); addSection(document, "二、主要技术指标", boldFont);
addContent(document, project.getTechnologyTarget(), normalFont); addContent(document, project.getTechnologyTarget(), normalFont);
...@@ -710,9 +713,18 @@ public class ProjectInfoToPDF { ...@@ -710,9 +713,18 @@ public class ProjectInfoToPDF {
detailTable.addCell(titleCell); detailTable.addCell(titleCell);
} }
/**
* 项目经费预算表
* @param document
* @param project
* @param bfChinese
* @param fsChinese
* @throws DocumentException
*/
private static void addProjectBudgetTable(Document document, ComProjectDTO project, BaseFont bfChinese, BaseFont fsChinese) throws DocumentException { private static void addProjectBudgetTable(Document document, ComProjectDTO project, BaseFont bfChinese, BaseFont fsChinese) throws DocumentException {
Font titleFont = new Font(bfChinese, 12, Font.BOLD); Font titleFont = new Font(bfChinese, 12, Font.BOLD);
Font contentFont = new Font(bfChinese, 12, Font.NORMAL); Font contentFont = new Font(bfChinese, 12, Font.NORMAL);
Font detailFont = new Font(fsChinese, 9, Font.NORMAL);
// 添加表格标题 // 添加表格标题
Paragraph title = new Paragraph("项目经费预算表", titleFont); Paragraph title = new Paragraph("项目经费预算表", titleFont);
...@@ -721,7 +733,7 @@ public class ProjectInfoToPDF { ...@@ -721,7 +733,7 @@ public class ProjectInfoToPDF {
document.add(title); document.add(title);
// 添加金额单位说明 // 添加金额单位说明
Paragraph unit = new Paragraph("金额单位:万元(保留两位小数)", contentFont); Paragraph unit = new Paragraph("金额单位:万元(保留两位小数)", detailFont);
unit.setAlignment(Element.ALIGN_RIGHT); unit.setAlignment(Element.ALIGN_RIGHT);
unit.setSpacingAfter(10f); unit.setSpacingAfter(10f);
document.add(unit); document.add(unit);
...@@ -729,7 +741,7 @@ public class ProjectInfoToPDF { ...@@ -729,7 +741,7 @@ public class ProjectInfoToPDF {
// 创建预算表格 // 创建预算表格
PdfPTable budgetTable = new PdfPTable(5); PdfPTable budgetTable = new PdfPTable(5);
budgetTable.setWidthPercentage(98); budgetTable.setWidthPercentage(98);
float[] widths = {2f, 1f, 1f, 1f, 1f}; float[] widths = {2f, 0.5f, 0.5f, 0.5f, 1f};
budgetTable.setWidths(widths); budgetTable.setWidths(widths);
// 添加表头 // 添加表头
...@@ -739,20 +751,42 @@ public class ProjectInfoToPDF { ...@@ -739,20 +751,42 @@ public class ProjectInfoToPDF {
} }
for (ComProjectBudgetDTO dto : project.getBudget()) { for (ComProjectBudgetDTO dto : project.getBudget()) {
addBudgetTitleCell(budgetTable, dto.getBudgetName(), contentFont); if (dto.getBudgetId().toLowerCase().equals("3b1f57d3-6aec-4129-aef5-702a1accfe01") || dto.getBudgetId().toLowerCase().equals("3b1f57d3-6aec-4129-aef5-702a1accfe08"))
addBudgetTitleCell(budgetTable, dto.getTotalBudget().toString(), contentFont); addBudgetTitleCell(budgetTable, dto.getBudgetName(), titleFont, Element.ALIGN_LEFT, 0, 0);
addBudgetTitleCell(budgetTable, dto.getApplyFunds().toString(), contentFont); else
addBudgetTitleCell(budgetTable, dto.getSelfFunds().toString(), contentFont); addBudgetTitleCell(budgetTable, dto.getBudgetName(), contentFont, Element.ALIGN_LEFT, 0, 0);
addBudgetTitleCell(budgetTable, dto.getCalculationBasis(), contentFont); addBudgetTitleCell(budgetTable, dto.getTotalBudget().toString(), contentFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, dto.getApplyFunds().toString(), contentFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, dto.getSelfFunds().toString(), contentFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, dto.getCalculationBasis(), contentFont, Element.ALIGN_LEFT, 0, 0);
}
addBudgetTitleCell(budgetTable, "三、分年度用款计划", titleFont, Element.ALIGN_LEFT, 5, 0);
addBudgetTitleCell(budgetTable, "年度", titleFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, "第一年", titleFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, "第二年", titleFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, "第三年", titleFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, "合计", titleFont, Element.ALIGN_CENTER, 0, 0);
for (ComProjectFundPlanDTO dto : project.getFundPlan()) {
addBudgetTitleCell(budgetTable, dto.getFundName(), titleFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, dto.getYearValue1().toString(), contentFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, dto.getYearValue2().toString(), contentFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, dto.getYearValue3().toString(), contentFont, Element.ALIGN_CENTER, 0, 0);
addBudgetTitleCell(budgetTable, dto.getTotalAmount().toString(), contentFont, Element.ALIGN_CENTER, 0, 0);
} }
document.add(budgetTable); document.add(budgetTable);
} }
private static void addBudgetTitleCell(PdfPTable table, String title, Font contentFont) { private static void addBudgetTitleCell(PdfPTable table, String title, Font contentFont, int HorizontalAlignment, int colSpan, int rowSpan) {
PdfPCell titleCell = new PdfPCell(new Phrase(title, contentFont)); PdfPCell titleCell = new PdfPCell(new Phrase(title, contentFont));
if (colSpan > 1)
titleCell.setColspan(colSpan);
if (rowSpan > 1)
titleCell.setRowspan(rowSpan);
titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE); titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
titleCell.setHorizontalAlignment(Element.ALIGN_LEFT); titleCell.setHorizontalAlignment(HorizontalAlignment);
table.addCell(titleCell); 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