Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
Y
yn-health-science
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐俊
yn-health-science
Commits
16a1bcf0
Commit
16a1bcf0
authored
Feb 13, 2025
by
徐俊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xujun
parent
24caba61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
6 deletions
+50
-6
ProjectInfoToPDF.java
...main/java/com/yiboshi/science/utils/ProjectInfoToPDF.java
+50
-6
No files found.
science-admin/src/main/java/com/yiboshi/science/utils/ProjectInfoToPDF.java
View file @
16a1bcf0
...
...
@@ -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
(
10
f
);
document
.
add
(
title
);
// 添加金额单位说明
Paragraph
unit
=
new
Paragraph
(
"金额单位:万元(保留两位小数)"
,
contentFont
);
unit
.
setAlignment
(
Element
.
ALIGN_RIGHT
);
unit
.
setSpacingAfter
(
10
f
);
document
.
add
(
unit
);
// 创建预算表格
PdfPTable
budgetTable
=
new
PdfPTable
(
5
);
budgetTable
.
setWidthPercentage
(
98
);
float
[]
widths
=
{
2
f
,
1
f
,
1
f
,
1
f
,
1
f
};
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
);
}
/**
* 添加标签值行
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment