Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
Project
Project
Details
Activity
Releases
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
王飞
vehicle-quality-review
Commits
366a1516
Commit
366a1516
authored
Mar 12, 2024
by
盖献康
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gaixiankang' into 'dev'
PDF - 检验报告 - 除数据基本完成 See merge request
!164
parents
7e1b0a05
680b76ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
17 deletions
+60
-17
InspectionReportPdfVO.java
.../main/java/com/ruoyi/domain/vo/InspectionReportPdfVO.java
+6
-1
PdfTemplateManagementServiceImpl.java
.../ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
+54
-16
receipt_template_02_27.pdf
...ew/src/main/resources/template/receipt_template_02_27.pdf
+0
-0
No files found.
quality-review/src/main/java/com/ruoyi/domain/vo/InspectionReportPdfVO.java
View file @
366a1516
...
...
@@ -131,7 +131,7 @@ public class InspectionReportPdfVO {
private
String
taskNumber
;
/**
*
*
样品数量
*/
private
String
sampleSum
;
...
...
@@ -140,6 +140,11 @@ public class InspectionReportPdfVO {
*/
private
String
vehicleType
;
/**
* 车辆型号
*/
private
String
vehicleModel
;
/**
* 车辆识别码
*/
...
...
quality-review/src/main/java/com/ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
View file @
366a1516
...
...
@@ -5,7 +5,7 @@ import com.itextpdf.text.pdf.*;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.PdfBaseWriter
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.domain.vo.
PhotoStorage
VO
;
import
com.ruoyi.domain.vo.
InspectionReportPdf
VO
;
import
com.ruoyi.domain.vo.ReviewEnterpriseArchiveViewVO
;
import
com.ruoyi.service.PdfTemplateManagementService
;
import
com.ruoyi.service.ReviewEnterpriseArchiveService
;
...
...
@@ -76,23 +76,15 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
BaseFont
bf
=
BaseFont
.
createFont
(
"STSongStd-Light"
,
"UniGB-UCS2-H"
,
BaseFont
.
NOT_EMBEDDED
);
fields
.
addSubstitutionFont
(
bf
);
// 渲染
// fillData(fields, map, ps);
renderData
(
fields
);
// 测试数据
InspectionReportPdfVO
inspectionReportPdfVO
=
requireData
();
PhotoStorageVO
photoStorageVO
=
new
PhotoStorageVO
();
Class
<?
extends
PhotoStorageVO
>
aClass
=
photoStorageVO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
for
(
Field
field
:
declaredFields
)
{
String
name
=
field
.
getName
();
System
.
out
.
println
(
name
);
}
// 渲染数据
renderData
(
fields
,
inspectionReportPdfVO
);
//必须要调用这个,否则文档不会生成的
ps
.
setFormFlattening
(
true
);
if
(
ps
!=
null
){
ps
.
close
();
}
ps
.
close
();
//生成pdf路径存放的路径
fos
=
response
.
getOutputStream
();
fos
.
write
(
bos
.
toByteArray
());
...
...
@@ -113,6 +105,40 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
}
}
private
InspectionReportPdfVO
requireData
()
{
InspectionReportPdfVO
inspectionReportPdfVO
=
InspectionReportPdfVO
.
builder
()
.
reportNumber
(
"报告编号"
)
.
productName
(
"产品名称"
)
.
productModel
(
"产品型号"
)
.
entrustedUnit
(
"委托单位"
)
.
inspectionCenterName
(
"检验中心名称"
)
.
inspectionCenterAddress
(
"检验中心地址"
)
.
inspectionCenterTelephone
(
"检验中心电话"
)
.
inspectionCenterPostcode
(
"检验中心邮编"
)
.
clientAddress
(
"委托单位地址"
)
.
entrustedUnitTelephone
(
"委托单位电话"
)
.
clientPostalCode
(
"委托单位邮编"
)
.
sampleName
(
"样品名称"
)
.
typeSpecification
(
"型号规格"
)
.
productionEnterprise
(
"生产企业"
)
.
sampleSender
(
"送养着"
)
.
sampleDeliveryDate
(
"送样日期"
)
.
sampleQuantity
(
"样品数量"
)
.
productionDate
(
"生产日期"
)
.
inspectionItem
(
"检验项目"
)
.
testConclusion
(
"检验结论"
)
.
issueDate
(
"签发日期"
)
.
remark
(
"备注"
)
.
taskNumber
(
"任务编号"
)
.
sampleSum
(
"样品数量"
)
.
vehicleType
(
"车俩类型"
)
.
vehicleModel
(
"车辆型号"
)
.
vehicleIdentificationNumber
(
"车辆识别码"
)
.
sampleNumberSummary
(
"样品编号汇总"
)
.
build
();
return
inspectionReportPdfVO
;
}
/**
* 企业留档文件PDF下载
* @param taskId
...
...
@@ -213,8 +239,20 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* 渲染数据
* @param fields
*/
private
void
renderData
(
AcroFields
fields
)
{
private
void
renderData
(
AcroFields
fields
,
InspectionReportPdfVO
inspectionReportPdfVO
)
throws
Exception
{
// 取出当前对象所有属性,并赋值到模板里
Class
<?
extends
InspectionReportPdfVO
>
aClass
=
inspectionReportPdfVO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
for
(
Field
field
:
declaredFields
)
{
String
name
=
field
.
getName
();
String
key
=
name
.
replaceAll
(
"([a-z])([A-Z])"
,
"$1_$2"
).
toLowerCase
();
field
.
setAccessible
(
true
);
Object
o
=
field
.
get
(
inspectionReportPdfVO
);
if
(
o
!=
null
)
{
String
value
=
o
.
toString
();
fields
.
setField
(
key
,
value
);
}
}
}
...
...
quality-review/src/main/resources/template/receipt_template_02_27.pdf
View file @
366a1516
No preview for this file type
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