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
24caba61
Commit
24caba61
authored
Feb 13, 2025
by
徐俊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xujun
parent
4955bed5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
426 additions
and
28 deletions
+426
-28
ComProjectKpitDTO.java
...java/com/yiboshi/science/param/dto/ComProjectKpitDTO.java
+2
-2
ComProjectController.java
...ava/com/yiboshi/science/rest/v1/ComProjectController.java
+8
-5
DateUtils.java
...in/src/main/java/com/yiboshi/science/utils/DateUtils.java
+22
-0
ProjectInfoToPDF.java
...main/java/com/yiboshi/science/utils/ProjectInfoToPDF.java
+394
-21
WINGDNG2.ttf
science-admin/src/main/resources/fonts/WINGDNG2.ttf
+0
-0
No files found.
science-admin/src/main/java/com/yiboshi/science/param/dto/ComProjectKpitDTO.java
View file @
24caba61
...
@@ -49,10 +49,10 @@ public class ComProjectKpitDTO extends BaseDTO {
...
@@ -49,10 +49,10 @@ public class ComProjectKpitDTO extends BaseDTO {
private
Integer
displayOrder
;
private
Integer
displayOrder
;
/** 一级指标显示 */
/** 一级指标显示 */
@ApiModelProperty
(
value
=
"一级指标显示"
,
position
=
7
)
@ApiModelProperty
(
value
=
"一级指标显示"
,
position
=
7
)
private
b
oolean
oneDisplay
;
private
B
oolean
oneDisplay
;
/** 二级指标显示 */
/** 二级指标显示 */
@ApiModelProperty
(
value
=
"二级指标显示"
,
position
=
7
)
@ApiModelProperty
(
value
=
"二级指标显示"
,
position
=
7
)
private
b
oolean
towDisplay
;
private
B
oolean
towDisplay
;
/** 一级指标行合并数 */
/** 一级指标行合并数 */
@ApiModelProperty
(
value
=
"一级指标行合并数"
,
position
=
7
)
@ApiModelProperty
(
value
=
"一级指标行合并数"
,
position
=
7
)
private
Integer
oneRowSpan
;
private
Integer
oneRowSpan
;
...
...
science-admin/src/main/java/com/yiboshi/science/rest/v1/ComProjectController.java
View file @
24caba61
...
@@ -5,10 +5,7 @@ import com.yiboshi.arch.base.ResponseDataModel;
...
@@ -5,10 +5,7 @@ import com.yiboshi.arch.base.ResponseDataModel;
import
com.yiboshi.science.base.Pagination
;
import
com.yiboshi.science.base.Pagination
;
import
com.yiboshi.science.config.annotation.Logs
;
import
com.yiboshi.science.config.annotation.Logs
;
import
com.yiboshi.science.config.security.SecurityUserHolder
;
import
com.yiboshi.science.config.security.SecurityUserHolder
;
import
com.yiboshi.science.entity.ComProject
;
import
com.yiboshi.science.entity.*
;
import
com.yiboshi.science.entity.ComProjectAudit
;
import
com.yiboshi.science.entity.ComProjectTask
;
import
com.yiboshi.science.entity.SelectListItem
;
import
com.yiboshi.science.enumeration.CommonEnum
;
import
com.yiboshi.science.enumeration.CommonEnum
;
import
com.yiboshi.science.param.dto.*
;
import
com.yiboshi.science.param.dto.*
;
import
com.yiboshi.science.param.query.ComProjectQueryVO
;
import
com.yiboshi.science.param.query.ComProjectQueryVO
;
...
@@ -16,6 +13,7 @@ import com.yiboshi.science.rest.BaseController;
...
@@ -16,6 +13,7 @@ import com.yiboshi.science.rest.BaseController;
import
com.yiboshi.science.service.ComFileService
;
import
com.yiboshi.science.service.ComFileService
;
import
com.yiboshi.science.service.ComProjectService
;
import
com.yiboshi.science.service.ComProjectService
;
import
com.yiboshi.science.service.ComProjectTaskService
;
import
com.yiboshi.science.service.ComProjectTaskService
;
import
com.yiboshi.science.service.SystemParameterService
;
import
com.yiboshi.science.utils.ProjectInfoToPDF
;
import
com.yiboshi.science.utils.ProjectInfoToPDF
;
import
com.yiboshi.science.utils.StringUtil
;
import
com.yiboshi.science.utils.StringUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -43,6 +41,9 @@ public class ComProjectController extends BaseController<ComProjectService, ComP
...
@@ -43,6 +41,9 @@ public class ComProjectController extends BaseController<ComProjectService, ComP
@Autowired
@Autowired
private
ComProjectService
comProjectService
;
private
ComProjectService
comProjectService
;
@Autowired
private
SystemParameterService
systemParameterService
;
@Autowired
@Autowired
private
ComProjectTaskService
comProjectTaskService
;
private
ComProjectTaskService
comProjectTaskService
;
...
@@ -215,8 +216,9 @@ public class ComProjectController extends BaseController<ComProjectService, ComP
...
@@ -215,8 +216,9 @@ public class ComProjectController extends BaseController<ComProjectService, ComP
@PostMapping
@PostMapping
public
ResponseDataModel
<
String
>
projectExport
(
@PathVariable
String
id
)
throws
DocumentException
,
IOException
{
public
ResponseDataModel
<
String
>
projectExport
(
@PathVariable
String
id
)
throws
DocumentException
,
IOException
{
ComProjectDTO
dto
=
comProjectService
.
getProjectById
(
id
);
ComProjectDTO
dto
=
comProjectService
.
getProjectById
(
id
);
List
<
SystemParameter
>
list
=
systemParameterService
.
getListByType
(
67
);
String
outputPath
=
"D:\\申请书和合同书.pdf"
;
String
outputPath
=
"D:\\申请书和合同书.pdf"
;
ProjectInfoToPDF
.
generateProjectPDF
(
dto
,
outputPath
);
ProjectInfoToPDF
.
generateProjectPDF
(
dto
,
outputPath
,
list
);
return
ResponseDataModel
.
ok
(
"项目信息导入成功!"
);
return
ResponseDataModel
.
ok
(
"项目信息导入成功!"
);
}
}
}
}
\ No newline at end of file
science-admin/src/main/java/com/yiboshi/science/utils/DateUtils.java
View file @
24caba61
...
@@ -16,4 +16,26 @@ public class DateUtils {
...
@@ -16,4 +16,26 @@ public class DateUtils {
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
sdf
.
format
(
date
);
return
sdf
.
format
(
date
);
}
}
/**
* 格式化起止年限
* @param date 开始日期
* @return 格式化后的日期范围字符串
*/
public
static
String
formatDateRange
(
Date
date
,
int
type
)
{
// 定义日期格式
SimpleDateFormat
sdf
;
if
(
type
==
1
)
sdf
=
new
SimpleDateFormat
(
"yyyy年MM月"
);
else
sdf
=
new
SimpleDateFormat
(
"yyyy年MM月dd日"
);
return
sdf
.
format
(
date
);
}
public
static
int
getDateYear
(
Date
date
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
// 将Date对象设置到Calendar对象中
return
calendar
.
get
(
Calendar
.
YEAR
);
}
}
}
science-admin/src/main/java/com/yiboshi/science/utils/ProjectInfoToPDF.java
View file @
24caba61
package
com
.
yiboshi
.
science
.
utils
;
package
com
.
yiboshi
.
science
.
utils
;
import
com.itextpdf.kernel.font.PdfFont
;
import
com.itextpdf.kernel.font.PdfFontFactory
;
import
com.itextpdf.text.*
;
import
com.itextpdf.text.*
;
import
com.itextpdf.text.pdf.*
;
import
com.itextpdf.text.pdf.*
;
import
com.yiboshi.science.entity.SystemParameter
;
import
com.yiboshi.science.param.dto.ComProjectDTO
;
import
com.yiboshi.science.param.dto.ComProjectDTO
;
import
org.springframework.core.io.ClassPathResource
;
import
com.yiboshi.science.param.dto.ComProjectKpitDTO
;
import
com.yiboshi.science.param.dto.ComProjectMembersDTO
;
import
com.yiboshi.science.param.dto.ProjectKPIStatisticDTO
;
import
java.io.*
;
import
java.io.*
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
public
class
ProjectInfoToPDF
{
public
class
ProjectInfoToPDF
{
...
@@ -16,7 +23,7 @@ public class ProjectInfoToPDF {
...
@@ -16,7 +23,7 @@ public class ProjectInfoToPDF {
* @param project 项目信息
* @param project 项目信息
* @param outputPath 输出路径
* @param outputPath 输出路径
*/
*/
public
static
void
generateProjectPDF
(
ComProjectDTO
project
,
String
outputPath
)
throws
DocumentException
,
IOException
{
public
static
void
generateProjectPDF
(
ComProjectDTO
project
,
String
outputPath
,
List
<
SystemParameter
>
projAttributeList
)
throws
DocumentException
,
IOException
{
Document
document
=
new
Document
(
PageSize
.
A4
);
Document
document
=
new
Document
(
PageSize
.
A4
);
PdfWriter
writer
=
PdfWriter
.
getInstance
(
document
,
new
FileOutputStream
(
outputPath
));
PdfWriter
writer
=
PdfWriter
.
getInstance
(
document
,
new
FileOutputStream
(
outputPath
));
document
.
open
();
document
.
open
();
...
@@ -25,6 +32,8 @@ public class ProjectInfoToPDF {
...
@@ -25,6 +32,8 @@ public class ProjectInfoToPDF {
BaseFont
bfChinese
=
loadChineseFont
(
"/fonts/simsun.ttc"
);
BaseFont
bfChinese
=
loadChineseFont
(
"/fonts/simsun.ttc"
);
// 仿宋
// 仿宋
BaseFont
fsChinese
=
loadChineseFont
(
"/fonts/simfang.ttf"
);
BaseFont
fsChinese
=
loadChineseFont
(
"/fonts/simfang.ttf"
);
// WINGDNG2
BaseFont
WINGDNG2
=
loadChineseFont
(
"/fonts/WINGDNG2.ttf"
);
Font
normalFont
=
new
Font
(
bfChinese
,
12
,
Font
.
NORMAL
);
Font
normalFont
=
new
Font
(
bfChinese
,
12
,
Font
.
NORMAL
);
Font
boldFont
=
new
Font
(
bfChinese
,
12
,
Font
.
BOLD
);
Font
boldFont
=
new
Font
(
bfChinese
,
12
,
Font
.
BOLD
);
...
@@ -38,7 +47,20 @@ public class ProjectInfoToPDF {
...
@@ -38,7 +47,20 @@ public class ProjectInfoToPDF {
// 添加项目内容章节
// 添加项目内容章节
addSection
(
document
,
"一、项目基本情况"
,
boldFont
);
addSection
(
document
,
"一、项目基本情况"
,
boldFont
);
addProjectBasicTable
(
document
,
project
,
bfChinese
,
fsChinese
);
// 添加项目基本信息表格
addProjectBasicTable
(
document
,
project
,
bfChinese
,
fsChinese
);
// 添加项目基本信息表格
// 添加新页面
// 添加横向页面
document
.
setPageSize
(
PageSize
.
A4
.
rotate
());
document
.
newPage
();
// 添加项目组主要成员表格
addProjectMembersTable
(
document
,
project
,
bfChinese
,
fsChinese
);
document
.
newPage
();
// 添加项目绩效目标表
addProjectKPITable
(
document
,
project
,
projAttributeList
,
bfChinese
,
fsChinese
,
WINGDNG2
);
// 恢复为纵向页面
document
.
setPageSize
(
PageSize
.
A4
);
document
.
newPage
();
document
.
newPage
();
addSection
(
document
,
"二、主要技术指标"
,
boldFont
);
addSection
(
document
,
"二、主要技术指标"
,
boldFont
);
...
@@ -84,21 +106,7 @@ public class ProjectInfoToPDF {
...
@@ -84,21 +106,7 @@ public class ProjectInfoToPDF {
}
}
}
}
/**
* 格式化起止年限
* @param date 开始日期
* @return 格式化后的日期范围字符串
*/
private
static
String
formatDateRange
(
Date
date
,
int
type
)
{
// 定义日期格式
SimpleDateFormat
sdf
;
if
(
type
==
1
)
sdf
=
new
SimpleDateFormat
(
"yyyy年MM月"
);
else
sdf
=
new
SimpleDateFormat
(
"yyyy年MM月dd日"
);
return
sdf
.
format
(
date
);
}
/**
/**
* 首页项目信息
* 首页项目信息
...
@@ -168,8 +176,8 @@ public class ProjectInfoToPDF {
...
@@ -168,8 +176,8 @@ public class ProjectInfoToPDF {
addTableRow
(
table
,
"推荐部门(丙方):"
,
""
,
labelFont
,
valueFont
);
addTableRow
(
table
,
"推荐部门(丙方):"
,
""
,
labelFont
,
valueFont
);
addTableRow
(
table
,
"项目负责人:"
,
project
.
getAppPersonName
(),
labelFont
,
valueFont
);
addTableRow
(
table
,
"项目负责人:"
,
project
.
getAppPersonName
(),
labelFont
,
valueFont
);
addTableRow
(
table
,
"联系电话:"
,
project
.
getMobile
(),
labelFont
,
valueFont
);
addTableRow
(
table
,
"联系电话:"
,
project
.
getMobile
(),
labelFont
,
valueFont
);
addTableRow
(
table
,
"起止年限:"
,
formatDateRange
(
project
.
getStartDate
(),
1
)
+
"至"
+
formatDateRange
(
project
.
getEndDate
(),
1
),
labelFont
,
valueFont
);
addTableRow
(
table
,
"起止年限:"
,
DateUtils
.
formatDateRange
(
project
.
getStartDate
(),
1
)
+
"至"
+
DateUtils
.
formatDateRange
(
project
.
getEndDate
(),
1
),
labelFont
,
valueFont
);
addTableRow
(
table
,
"填报日期:"
,
formatDateRange
(
project
.
getCreated
(),
2
),
labelFont
,
valueFont
);
addTableRow
(
table
,
"填报日期:"
,
DateUtils
.
formatDateRange
(
project
.
getCreated
(),
2
),
labelFont
,
valueFont
);
document
.
add
(
table
);
document
.
add
(
table
);
return
document
;
return
document
;
...
@@ -258,7 +266,7 @@ public class ProjectInfoToPDF {
...
@@ -258,7 +266,7 @@ public class ProjectInfoToPDF {
// 第一行
// 第一行
addBasicTableCell
(
personTable
,
"姓 名"
,
project
.
getAppPersonName
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
personTable
,
"姓 名"
,
project
.
getAppPersonName
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
personTable
,
"性别"
,
project
.
getSex
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
personTable
,
"性别"
,
project
.
getSex
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
personTable
,
"出生年月"
,
formatDateRange
(
project
.
getBirthday
(),
1
),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
personTable
,
"出生年月"
,
DateUtils
.
formatDateRange
(
project
.
getBirthday
(),
1
),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
personTable
,
"民族"
,
project
.
getNationName
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
personTable
,
"民族"
,
project
.
getNationName
(),
2
,
labelFont
,
valueFont
);
// 第二行
// 第二行
...
@@ -329,7 +337,7 @@ public class ProjectInfoToPDF {
...
@@ -329,7 +337,7 @@ public class ProjectInfoToPDF {
addBasicTableCell
(
projTable
,
"学科代码"
,
project
.
getKnowledgeName
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"学科代码"
,
project
.
getKnowledgeName
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"选题范围"
,
project
.
getSubjectScope
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"选题范围"
,
project
.
getSubjectScope
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"项目类别"
,
project
.
getProjClassName
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"项目类别"
,
project
.
getProjClassName
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"研究期限"
,
formatDateRange
(
project
.
getStartDate
(),
1
),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"研究期限"
,
DateUtils
.
formatDateRange
(
project
.
getStartDate
(),
1
),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"项目总经费(万元)"
,
project
.
getTotalFunding
().
toString
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"项目总经费(万元)"
,
project
.
getTotalFunding
().
toString
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"申请经费"
,
project
.
getGovFunding
().
toString
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"申请经费"
,
project
.
getGovFunding
().
toString
(),
2
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"项目摘要"
,
project
.
getProjAbstract
(),
4
,
labelFont
,
valueFont
);
addBasicTableCell
(
projTable
,
"项目摘要"
,
project
.
getProjAbstract
(),
4
,
labelFont
,
valueFont
);
...
@@ -368,6 +376,371 @@ public class ProjectInfoToPDF {
...
@@ -368,6 +376,371 @@ public class ProjectInfoToPDF {
table
.
addCell
(
valueCell
);
table
.
addCell
(
valueCell
);
}
}
/**
* 添加项目组主要成员表格
* @param document PDF文档
* @param project 项目信息
* @param bfChinese 宋体字体
* @param fsChinese 仿宋字体
* @throws DocumentException
*/
private
static
void
addProjectMembersTable
(
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
.
add
(
new
Chunk
(
" (注:不包括项目申请人)"
,
contentFont
));
title
.
setAlignment
(
Element
.
ALIGN_CENTER
);
title
.
setSpacingAfter
(
10
f
);
document
.
add
(
title
);
// 创建表格
PdfPTable
table
=
new
PdfPTable
(
12
);
// 12列
table
.
setWidthPercentage
(
98
);
// 设置列宽度比例
float
[]
widths
=
{
0.5f
,
1
f
,
1
f
,
0.8f
,
0.8f
,
0.8f
,
2
f
,
0.8f
,
1.2f
,
1
f
,
1.2f
,
1
f
};
table
.
setWidths
(
widths
);
// 添加表头
String
[]
headers
=
{
"序号"
,
"姓名"
,
"出生年月"
,
"性别"
,
"职称"
,
"学位"
,
"工作单位"
,
"电话"
,
"电子邮箱"
,
"证件号码"
,
"项目分工"
,
"每年工作时间(月)"
};
for
(
String
header
:
headers
)
{
PdfPCell
cell
=
new
PdfPCell
(
new
Phrase
(
header
,
contentFont
));
cell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
cell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
cell
.
setMinimumHeight
(
25
f
);
table
.
addCell
(
cell
);
}
List
<
ComProjectMembersDTO
>
members
=
project
.
getMembers
();
// 添加成员数据
if
(
members
!=
null
&&
!
members
.
isEmpty
())
{
int
index
=
1
;
for
(
ComProjectMembersDTO
member
:
members
)
{
// 序号
addCenterCell
(
table
,
String
.
valueOf
(
index
++),
contentFont
);
// 姓名
addCenterCell
(
table
,
member
.
getName
(),
contentFont
);
// 出生年月
addCenterCell
(
table
,
DateUtils
.
formatDateRange
(
member
.
getBirthday
(),
1
),
contentFont
);
// 性别
addCenterCell
(
table
,
member
.
getSex
(),
contentFont
);
// 职称
addCenterCell
(
table
,
member
.
getTitleName
(),
contentFont
);
// 学位
addCenterCell
(
table
,
member
.
getDegreeName
(),
contentFont
);
// 工作单位
addCenterCell
(
table
,
member
.
getWorkUnit
(),
contentFont
);
// 电话
addCenterCell
(
table
,
member
.
getMobile
(),
contentFont
);
// 电子邮箱
addCenterCell
(
table
,
member
.
getEmail
(),
contentFont
);
// 证件号码
addCenterCell
(
table
,
member
.
getCertId
(),
contentFont
);
// 项目分工
addCenterCell
(
table
,
member
.
getProjWork
(),
contentFont
);
// 每年工作时间
addCenterCell
(
table
,
member
.
getForMonths
().
toString
(),
contentFont
);
}
}
// 如果成员数量少于9个,添加空行到9行
int
emptyRows
=
9
-
(
members
!=
null
?
members
.
size
()
:
0
);
for
(
int
i
=
0
;
i
<
emptyRows
;
i
++)
{
for
(
int
j
=
0
;
j
<
12
;
j
++)
{
addCenterCell
(
table
,
""
,
contentFont
);
}
}
document
.
add
(
table
);
// 项目组成员统计表格
PdfPTable
statsTable
=
new
PdfPTable
(
7
);
// 7列
statsTable
.
setWidthPercentage
(
98
);
statsTable
.
setSpacingBefore
(
20
f
);
// 与上表格保持间距
// 设置列宽度比例
float
[]
statsWidths
=
{
1
f
,
1
f
,
1
f
,
1
f
,
1
f
,
1
f
,
1
f
};
statsTable
.
setWidths
(
statsWidths
);
// 添加表头
String
[]
statsHeaders
=
{
"总人数"
,
"高级"
,
"中级"
,
"初级"
,
"博士后"
,
"博士生"
,
"硕士生"
};
for
(
String
header
:
statsHeaders
)
{
PdfPCell
cell
=
new
PdfPCell
(
new
Phrase
(
header
,
contentFont
));
cell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
cell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
cell
.
setMinimumHeight
(
25
f
);
statsTable
.
addCell
(
cell
);
}
// 添加数据行
addCenterCell
(
statsTable
,
project
.
getMemCount
()
!=
null
?
project
.
getMemCount
().
toString
()
:
""
,
contentFont
);
addCenterCell
(
statsTable
,
project
.
getMemHighCount
()
!=
null
?
project
.
getMemHighCount
().
toString
()
:
""
,
contentFont
);
addCenterCell
(
statsTable
,
project
.
getMemMiddleCount
()
!=
null
?
project
.
getMemMiddleCount
().
toString
()
:
""
,
contentFont
);
addCenterCell
(
statsTable
,
project
.
getMemLowCount
()
!=
null
?
project
.
getMemLowCount
().
toString
()
:
""
,
contentFont
);
addCenterCell
(
statsTable
,
project
.
getMemBshCount
()
!=
null
?
project
.
getMemBshCount
().
toString
()
:
""
,
contentFont
);
addCenterCell
(
statsTable
,
project
.
getMemBsCount
()
!=
null
?
project
.
getMemBsCount
().
toString
()
:
""
,
contentFont
);
addCenterCell
(
statsTable
,
project
.
getMemSsCount
()
!=
null
?
project
.
getMemSsCount
().
toString
()
:
""
,
contentFont
);
document
.
add
(
statsTable
);
}
/**
* 添加项目绩效目标表
* @param document PDF文档
* @param project 项目信息
* @param bfChinese 宋体字体
* @param fsChinese 仿宋字体
* @throws DocumentException
*/
private
static
void
addProjectKPITable
(
Document
document
,
ComProjectDTO
project
,
List
<
SystemParameter
>
projAttributeList
,
BaseFont
bfChinese
,
BaseFont
fsChinese
,
BaseFont
WINGDNG2
)
throws
DocumentException
,
IOException
{
ProjectKPIStatisticDTO
kpitDTO
=
project
.
getProjectKPI
();
List
<
ComProjectKpitDTO
>
detail
=
project
.
getProjectKPI
().
getThreeLevel
();
Font
titleFont
=
new
Font
(
bfChinese
,
12
,
Font
.
BOLD
);
Font
contentFont
=
new
Font
(
bfChinese
,
12
,
Font
.
NORMAL
);
Font
wingdng2Font
=
new
Font
(
WINGDNG2
,
12
,
Font
.
NORMAL
);
// 添加表格标题
Paragraph
title
=
new
Paragraph
(
"绩效目标表"
,
titleFont
);
title
.
setAlignment
(
Element
.
ALIGN_CENTER
);
title
.
setSpacingAfter
(
10
f
);
document
.
add
(
title
);
// 创建主表格
PdfPTable
mainTable
=
new
PdfPTable
(
5
);
mainTable
.
setWidthPercentage
(
98
);
float
[]
widths
=
{
0.8f
,
1
f
,
2
f
,
1
f
,
2
f
};
mainTable
.
setWidths
(
widths
);
// 添加年度标题
PdfPCell
yearCell
=
new
PdfPCell
(
new
Phrase
(
kpitDTO
.
getReportYear
()
+
"年度"
,
titleFont
));
yearCell
.
setColspan
(
5
);
yearCell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
yearCell
.
setMinimumHeight
(
25
f
);
mainTable
.
addCell
(
yearCell
);
// 项目名称
addLabelValueRow
(
mainTable
,
"项目名称"
,
kpitDTO
.
getProjName
(),
5
,
titleFont
,
contentFont
);
// 主管处室和实施单位
addLabelValueRow
(
mainTable
,
"主管处室"
,
kpitDTO
.
getManagerDept
(),
2
,
titleFont
,
contentFont
);
addLabelValueRow
(
mainTable
,
"实施单位"
,
kpitDTO
.
getAppUnitName
(),
1
,
titleFont
,
contentFont
);
// 项目属性
PdfPCell
labelCell
=
new
PdfPCell
(
new
Phrase
(
"项目属性"
,
titleFont
));
labelCell
.
setMinimumHeight
(
25
f
);
labelCell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
mainTable
.
addCell
(
labelCell
);
// 创建复选框和文字组合
Phrase
checkboxPhrase
=
new
Phrase
();
if
(
Objects
.
nonNull
(
kpitDTO
.
getProjAttribute
()))
{
for
(
SystemParameter
param
:
projAttributeList
)
{
if
(
param
.
getId
().
toLowerCase
().
equals
(
kpitDTO
.
getProjAttribute
().
toLowerCase
()))
{
checkboxPhrase
.
add
(
new
Chunk
(
"R"
,
wingdng2Font
));
// 选中状态
}
else
{
checkboxPhrase
.
add
(
new
Chunk
(
"£"
,
wingdng2Font
));
// 未选中状态
}
checkboxPhrase
.
add
(
new
Chunk
(
" "
+
param
.
getName
()
+
" "
,
contentFont
));
// 使用中文字体显示文字
}
}
else
{
checkboxPhrase
.
add
(
new
Chunk
(
"£"
,
wingdng2Font
));
checkboxPhrase
.
add
(
new
Chunk
(
" 新增项目 "
,
contentFont
));
checkboxPhrase
.
add
(
new
Chunk
(
"£"
,
wingdng2Font
));
checkboxPhrase
.
add
(
new
Chunk
(
" 延续项目"
,
contentFont
));
}
PdfPCell
valueCell
=
new
PdfPCell
(
checkboxPhrase
);
valueCell
.
setMinimumHeight
(
25
f
);
valueCell
.
setColspan
(
2
);
mainTable
.
addCell
(
valueCell
);
// 项目期
addLabelValueRow
(
mainTable
,
"项目期"
,
kpitDTO
.
getProjDeadline
(),
1
,
titleFont
,
contentFont
);
// 项目资金(万元)标题行
PdfPCell
fundTitle
=
new
PdfPCell
(
new
Phrase
(
"项目资金\n(万元)"
,
titleFont
));
fundTitle
.
setRowspan
(
3
);
fundTitle
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
fundTitle
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
mainTable
.
addCell
(
fundTitle
);
// 总体资金总额和年度资金总额
addLabelValueRow
(
mainTable
,
"总体资金总额"
,
kpitDTO
.
getTotalBudget
().
toString
(),
1
,
titleFont
,
contentFont
);
addLabelValueRow
(
mainTable
,
"年度资金总额"
,
kpitDTO
.
getYearTotal
().
toString
(),
1
,
titleFont
,
contentFont
);
// 其中:财政拨款(两行)
addLabelValueRow
(
mainTable
,
"其中:财政拨款"
,
kpitDTO
.
getApplyFunds
().
toString
(),
1
,
titleFont
,
contentFont
);
addLabelValueRow
(
mainTable
,
"其中:财政拨款"
,
kpitDTO
.
getYearApply
().
toString
(),
1
,
titleFont
,
contentFont
);
// 其他资金(两行)
addLabelValueRow
(
mainTable
,
"其他资金"
,
kpitDTO
.
getSelfFunds
().
toString
(),
1
,
titleFont
,
contentFont
);
addLabelValueRow
(
mainTable
,
"其他资金"
,
kpitDTO
.
getYearSelf
().
toString
(),
1
,
titleFont
,
contentFont
);
document
.
add
(
mainTable
);
// 总体考核目标
PdfPTable
middleTable
=
new
PdfPTable
(
5
);
middleTable
.
setWidthPercentage
(
98
);
float
[]
middleWidths
=
{
0.8f
,
3.2f
,
1
f
,
1
f
,
1
f
};
middleTable
.
setWidths
(
middleWidths
);
// 添加左侧标题单元格
PdfPCell
titleCell
=
new
PdfPCell
(
new
Phrase
(
"总体考核\n目标"
,
titleFont
));
titleCell
.
setRowspan
(
3
);
// 合并三行
titleCell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
titleCell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
middleTable
.
addCell
(
titleCell
);
// 添加总体目标标题行
int
startYear
=
DateUtils
.
getDateYear
(
kpitDTO
.
getStartDate
());
int
endYear
=
DateUtils
.
getDateYear
(
kpitDTO
.
getEndDate
());
PdfPCell
totalTargetCell
=
new
PdfPCell
(
new
Phrase
(
"总体目标("
+
startYear
+
"年—"
+
endYear
+
"年)"
,
titleFont
));
totalTargetCell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
totalTargetCell
.
setMinimumHeight
(
25
f
);
middleTable
.
addCell
(
totalTargetCell
);
// 添加分年度指标标题行
PdfPCell
yearlyTitleCell
=
new
PdfPCell
(
new
Phrase
(
"分年度指标"
,
titleFont
));
yearlyTitleCell
.
setColspan
(
3
);
// 合并三列
yearlyTitleCell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
yearlyTitleCell
.
setMinimumHeight
(
25
f
);
middleTable
.
addCell
(
yearlyTitleCell
);
// 添加总体目标内容
PdfPCell
totalTargetContentCell
=
new
PdfPCell
(
new
Phrase
(
kpitDTO
.
getYearTarget
(),
contentFont
));
totalTargetContentCell
.
setRowspan
(
2
);
// 合并两行
totalTargetContentCell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
totalTargetContentCell
.
setMinimumHeight
(
50
f
);
// 设置较大的高度以容纳多行内容
middleTable
.
addCell
(
totalTargetContentCell
);
// 添加年度标题行
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
PdfPCell
yearCCell
=
new
PdfPCell
(
new
Phrase
((
startYear
+
i
)
+
"年"
,
titleFont
));
yearCCell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
yearCCell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
yearCCell
.
setMinimumHeight
(
25
f
);
middleTable
.
addCell
(
yearCCell
);
}
// 添加年度内容
PdfPCell
yearContentCell
=
new
PdfPCell
(
new
Phrase
(
kpitDTO
.
getYear1Goal
(),
contentFont
));
yearContentCell
.
setMinimumHeight
(
50
f
);
yearContentCell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
middleTable
.
addCell
(
yearContentCell
);
yearContentCell
=
new
PdfPCell
(
new
Phrase
(
kpitDTO
.
getYear2Goal
(),
contentFont
));
yearContentCell
.
setMinimumHeight
(
50
f
);
yearContentCell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
middleTable
.
addCell
(
yearContentCell
);
yearContentCell
=
new
PdfPCell
(
new
Phrase
(
kpitDTO
.
getYear3Goal
(),
contentFont
));
yearContentCell
.
setMinimumHeight
(
50
f
);
yearContentCell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
middleTable
.
addCell
(
yearContentCell
);
document
.
add
(
middleTable
);
addTargetDetailTable
(
document
,
kpitDTO
,
titleFont
,
contentFont
);
}
private
static
void
addTargetDetailTable
(
Document
document
,
ProjectKPIStatisticDTO
kpitDTO
,
Font
titleFont
,
Font
contentFont
)
throws
DocumentException
{
PdfPTable
detailTable
=
new
PdfPTable
(
11
);
detailTable
.
setWidthPercentage
(
98
);
float
[]
detailWidths
=
{
0.5f
,
0.5f
,
0.5f
,
1.5f
,
0.5f
,
0.5f
,
0.5f
,
1.5f
,
0.5f
,
0.5f
,
0.5f
};
detailTable
.
setWidths
(
detailWidths
);
//总考核目标
addTitleCell
(
detailTable
,
"总体考核目标"
,
0
,
kpitDTO
.
getTotalRowSpan
(),
titleFont
);
//一级指标
addTitleCell
(
detailTable
,
"一级指标"
,
0
,
2
,
titleFont
);
//二级指标
addTitleCell
(
detailTable
,
"二级指标"
,
0
,
2
,
titleFont
);
//三级指标
addTitleCell
(
detailTable
,
"三级指标"
,
0
,
2
,
titleFont
);
//指标值
addTitleCell
(
detailTable
,
"指标值"
,
0
,
2
,
titleFont
);
//绩效标准
addTitleCell
(
detailTable
,
"绩效标准"
,
0
,
2
,
titleFont
);
//二级指标
addTitleCell
(
detailTable
,
"二级指标"
,
0
,
2
,
titleFont
);
//三级指标
addTitleCell
(
detailTable
,
"三级指标"
,
0
,
2
,
titleFont
);
//指标值
addTitleCell
(
detailTable
,
"指标值"
,
3
,
0
,
titleFont
);
int
startYear
=
DateUtils
.
getDateYear
(
kpitDTO
.
getStartDate
());
addTitleCell
(
detailTable
,
startYear
+
"年"
,
0
,
0
,
contentFont
);
addTitleCell
(
detailTable
,
(
startYear
+
1
)
+
"年"
,
0
,
0
,
contentFont
);
addTitleCell
(
detailTable
,
(
startYear
+
2
)
+
"年"
,
0
,
0
,
contentFont
);
List
<
ComProjectKpitDTO
>
list
=
kpitDTO
.
getThreeLevel
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
ComProjectKpitDTO
model
=
list
.
get
(
i
);
if
(
model
.
getOneDisplay
())
addTitleCell
(
detailTable
,
model
.
getOneLevelName
(),
0
,
model
.
getOneRowSpan
(),
contentFont
);
if
(
model
.
getTowDisplay
())
addTitleCell
(
detailTable
,
model
.
getTowLevelName
(),
0
,
model
.
getTowRowSpan
(),
contentFont
);
addTitleCell
(
detailTable
,
model
.
getKpitName
(),
0
,
0
,
contentFont
);
addTitleCell
(
detailTable
,
model
.
getTargetValue
()
!=
null
?
model
.
getTargetValue
().
toString
()
:
""
,
0
,
0
,
contentFont
);
addTitleCell
(
detailTable
,
model
.
getPerformanceStandard
()
!=
null
?
model
.
getPerformanceStandard
().
toString
()
:
""
,
0
,
0
,
contentFont
);
if
(
model
.
getTowDisplay
())
addTitleCell
(
detailTable
,
model
.
getTowLevelName
(),
0
,
model
.
getTowRowSpan
(),
contentFont
);
addTitleCell
(
detailTable
,
model
.
getKpitName
(),
0
,
0
,
contentFont
);
addTitleCell
(
detailTable
,
model
.
getYearValue1
()
!=
null
?
model
.
getYearValue1
().
toString
()
:
""
,
0
,
0
,
contentFont
);
addTitleCell
(
detailTable
,
model
.
getYearValue2
()
!=
null
?
model
.
getYearValue2
().
toString
()
:
""
,
0
,
0
,
contentFont
);
addTitleCell
(
detailTable
,
model
.
getYearValue3
()
!=
null
?
model
.
getYearValue3
().
toString
()
:
""
,
0
,
0
,
contentFont
);
}
document
.
add
(
detailTable
);
}
private
static
void
addTitleCell
(
PdfPTable
detailTable
,
String
title
,
int
colSpan
,
int
rowSpan
,
Font
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
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
detailTable
.
addCell
(
titleCell
);
}
/**
* 添加标签值行
*/
private
static
void
addLabelValueRow
(
PdfPTable
table
,
String
label
,
String
value
,
int
valueColspan
,
Font
titleFont
,
Font
contentFont
)
{
PdfPCell
labelCell
=
new
PdfPCell
(
new
Phrase
(
label
,
titleFont
));
labelCell
.
setMinimumHeight
(
25
f
);
labelCell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
labelCell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
table
.
addCell
(
labelCell
);
PdfPCell
valueCell
=
new
PdfPCell
(
new
Phrase
(
value
!=
null
?
value
:
""
,
contentFont
));
valueCell
.
setMinimumHeight
(
25
f
);
valueCell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
valueCell
.
setHorizontalAlignment
(
Element
.
ALIGN_LEFT
);
valueCell
.
setColspan
(
valueColspan
);
table
.
addCell
(
valueCell
);
}
/**
* 添加居中对齐的单元格
*/
private
static
void
addCenterCell
(
PdfPTable
table
,
String
content
,
Font
font
)
{
PdfPCell
cell
=
new
PdfPCell
(
new
Phrase
(
content
!=
null
?
content
:
""
,
font
));
cell
.
setHorizontalAlignment
(
Element
.
ALIGN_CENTER
);
cell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
cell
.
setMinimumHeight
(
25
f
);
table
.
addCell
(
cell
);
}
private
static
void
addSection
(
Document
document
,
String
title
,
Font
font
)
throws
DocumentException
{
private
static
void
addSection
(
Document
document
,
String
title
,
Font
font
)
throws
DocumentException
{
Paragraph
section
=
new
Paragraph
(
title
,
font
);
Paragraph
section
=
new
Paragraph
(
title
,
font
);
section
.
setSpacingBefore
(
15
);
section
.
setSpacingBefore
(
15
);
...
...
science-admin/src/main/resources/fonts/WINGDNG2.ttf
0 → 100644
View file @
24caba61
File added
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