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
eedbce92
Commit
eedbce92
authored
Feb 14, 2025
by
徐俊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xujun
parent
16a1bcf0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
9 deletions
+43
-9
ProjectInfoToPDF.java
...main/java/com/yiboshi/science/utils/ProjectInfoToPDF.java
+43
-9
No files found.
science-admin/src/main/java/com/yiboshi/science/utils/ProjectInfoToPDF.java
View file @
eedbce92
...
@@ -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
(
"金额单位:万元(保留两位小数)"
,
content
Font
);
Paragraph
unit
=
new
Paragraph
(
"金额单位:万元(保留两位小数)"
,
detail
Font
);
unit
.
setAlignment
(
Element
.
ALIGN_RIGHT
);
unit
.
setAlignment
(
Element
.
ALIGN_RIGHT
);
unit
.
setSpacingAfter
(
10
f
);
unit
.
setSpacingAfter
(
10
f
);
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
=
{
2
f
,
1
f
,
1
f
,
1
f
,
1
f
};
float
[]
widths
=
{
2
f
,
0.5f
,
0.5f
,
0.5
f
,
1
f
};
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
);
}
}
...
...
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