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
0b5da5ef
Commit
0b5da5ef
authored
Mar 26, 2024
by
盖献康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
检验报告修改 - 名称、占位符换行展示、商标、样品数量
parent
f5c66bba
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
7 deletions
+29
-7
InspectionReportPdfVO.java
.../main/java/com/ruoyi/domain/vo/InspectionReportPdfVO.java
+5
-0
PdfTemplateManagementServiceImpl.java
.../ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
+20
-4
TaskMapper.xml
quality-review/src/main/resources/mapper/TaskMapper.xml
+4
-3
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 @
0b5da5ef
...
@@ -160,4 +160,9 @@ public class InspectionReportPdfVO {
...
@@ -160,4 +160,9 @@ public class InspectionReportPdfVO {
*/
*/
private
String
sampleNumberSummary
;
private
String
sampleNumberSummary
;
/**
* 品牌图片
*/
private
String
brandImage
;
}
}
quality-review/src/main/java/com/ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
View file @
0b5da5ef
package
com
.
ruoyi
.
service
.
impl
;
package
com
.
ruoyi
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.itextpdf.text.*
;
import
com.itextpdf.text.*
;
import
com.itextpdf.text.pdf.*
;
import
com.itextpdf.text.pdf.*
;
import
com.ruoyi.common.core.domain.entity.SysDictData
;
import
com.ruoyi.common.core.domain.entity.SysDictData
;
...
@@ -89,7 +90,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
...
@@ -89,7 +90,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
InspectionReportPdfVO
inspectionReportPdfVO
=
requireData
(
taskId
);
InspectionReportPdfVO
inspectionReportPdfVO
=
requireData
(
taskId
);
// 渲染数据
// 渲染数据
renderData
(
fields
,
inspectionReportPdfVO
);
renderData
(
fields
,
inspectionReportPdfVO
,
ps
);
//必须要调用这个,否则文档不会生成的
//必须要调用这个,否则文档不会生成的
ps
.
setFormFlattening
(
true
);
ps
.
setFormFlattening
(
true
);
...
@@ -106,7 +107,12 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
...
@@ -106,7 +107,12 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
}
}
}
}
assert
bos
!=
null
;
assert
bos
!=
null
;
return
uploadMinio
(
bos
,
"检验报告_"
+
taskId
);
// 名字
return
uploadMinio
(
bos
,
"整车信息安全检验报告-"
+
getReportName
());
}
private
String
getReportName
()
{
return
DateUtils
.
parseDateToStr
(
"yyyyMMddHHmm"
,
new
Date
());
}
}
/**
/**
...
@@ -252,8 +258,9 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
...
@@ -252,8 +258,9 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* 渲染数据
* 渲染数据
* @param fields
* @param fields
*/
*/
private
void
renderData
(
AcroFields
fields
,
InspectionReportPdfVO
inspectionReportPdfVO
)
throws
Exception
{
private
void
renderData
(
AcroFields
fields
,
InspectionReportPdfVO
inspectionReportPdfVO
,
PdfStamper
ps
)
throws
Exception
{
// 取出当前对象所有属性,并赋值到模板里
// 取出当前对象所有属性,并赋值到模板里
// 文本域
Class
<?
extends
InspectionReportPdfVO
>
aClass
=
inspectionReportPdfVO
.
getClass
();
Class
<?
extends
InspectionReportPdfVO
>
aClass
=
inspectionReportPdfVO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
for
(
Field
field
:
declaredFields
)
{
for
(
Field
field
:
declaredFields
)
{
...
@@ -266,6 +273,15 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
...
@@ -266,6 +273,15 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
fields
.
setField
(
key
,
value
);
fields
.
setField
(
key
,
value
);
}
}
}
}
// 图片域
// 样品
String
url
=
inspectionReportPdfVO
.
getBrandImage
();
if
(
StrUtil
.
isNotBlank
(
url
))
{
if
(
url
.
startsWith
(
","
))
{
url
=
inspectionReportPdfVO
.
getBrandImage
().
substring
(
1
);
}
addImageToPdf
(
"brand"
,
fields
,
ps
,
"http://49.232.167.247:22038"
+
url
.
split
(
","
)[
0
]);
}
}
}
...
@@ -314,7 +330,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
...
@@ -314,7 +330,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
// 获取操作的页面
// 获取操作的页面
PdfContentByte
under
=
stamper
.
getOverContent
(
pageNo
);
PdfContentByte
under
=
stamper
.
getOverContent
(
pageNo
);
// 根据域的大小缩放图片
// 根据域的大小缩放图片
image
.
scaleToFit
(
signRect
.
getWidth
()
*
2
,
signRect
.
getHeight
());
image
.
scaleToFit
(
signRect
.
getWidth
(),
signRect
.
getHeight
());
// 添加图片并设置位置(个人通过此设置使得图片垂直水平居中,可参考,具体情况已实际为准)
// 添加图片并设置位置(个人通过此设置使得图片垂直水平居中,可参考,具体情况已实际为准)
image
.
setAbsolutePosition
(
x
,
y
);
image
.
setAbsolutePosition
(
x
,
y
);
under
.
addImage
(
image
);
under
.
addImage
(
image
);
...
...
quality-review/src/main/resources/mapper/TaskMapper.xml
View file @
0b5da5ef
...
@@ -311,14 +311,15 @@
...
@@ -311,14 +311,15 @@
GROUP_CONCAT(distinct s.sample_sender) AS sampleSender,
GROUP_CONCAT(distinct s.sample_sender) AS sampleSender,
GROUP_CONCAT(distinct DATE_FORMAT(s.delivery_date, '%Y-%m-%d')) AS sampleDeliveryDate,
GROUP_CONCAT(distinct DATE_FORMAT(s.delivery_date, '%Y-%m-%d')) AS sampleDeliveryDate,
count(s.id) AS sampleQuantity,
count(s.id) AS sampleQuantity,
sum(s.number_of_samples
) AS sampleSum,
CONVERT(sum(s.number_of_samples), UNSIGNED
) AS sampleSum,
GROUP_CONCAT(distinct DATE_FORMAT(s.manufacture_date, '%Y-%m-%d')) AS sampleDeliveryDate,
GROUP_CONCAT(distinct DATE_FORMAT(s.manufacture_date, '%Y-%m-%d')) AS sampleDeliveryDate,
t.product_model AS vehicle
Type
,
t.product_model AS vehicle
Model
,
t.id AS taskNumber,
t.id AS taskNumber,
GROUP_CONCAT(distinct s.sample_number) AS sampleNumberSummary,
GROUP_CONCAT(distinct s.sample_number) AS sampleNumberSummary,
GROUP_CONCAT(distinct s.identification_code) AS vehicleIdentificationNumber,
GROUP_CONCAT(distinct s.identification_code) AS vehicleIdentificationNumber,
t.task_list AS inspectionItem,
t.task_list AS inspectionItem,
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate,
GROUP_CONCAT(distinct s.trademark) AS brandImage
from
from
t_task t
t_task t
left join t_task_sample_relation tsr on t.id = tsr.task_id
left join t_task_sample_relation tsr on t.id = tsr.task_id
...
...
quality-review/src/main/resources/template/receipt_template_02_27.pdf
View file @
0b5da5ef
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