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
c3174724
Commit
c3174724
authored
Mar 13, 2024
by
盖献康
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gaixiankang' into 'dev'
检查报告 - PDF See merge request
!172
parents
e833fe6e
fcf10238
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
24 deletions
+26
-24
PdfTemplateManagementService.java
.../java/com/ruoyi/service/PdfTemplateManagementService.java
+4
-2
PdfTemplateManagementServiceImpl.java
.../ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
+10
-13
PdfTemplateManagementController.java
...n/java/com/ruoyi/web/PdfTemplateManagementController.java
+12
-9
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/service/PdfTemplateManagementService.java
View file @
c3174724
...
...
@@ -10,10 +10,12 @@ public interface PdfTemplateManagementService {
/**
* 检验报告PDF下载
* @param response
*
* @param taskId
* @return
* @throws Exception
*/
void
generateInspectionReport
(
HttpServletResponse
response
)
throws
Exception
;
String
generateInspectionReport
(
Long
taskId
)
throws
Exception
;
/**
* 企业留档文件PDF下载
...
...
quality-review/src/main/java/com/ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
View file @
c3174724
...
...
@@ -51,17 +51,19 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
/**
* 检验报告PDF下载
* @param response
*
* @param taskId
* @return
*/
@Override
public
void
generateInspectionReport
(
HttpServletResponse
response
)
throws
Exception
{
public
String
generateInspectionReport
(
Long
taskId
)
throws
Exception
{
PdfReader
reader
=
null
;
PdfStamper
ps
=
null
;
OutputStream
fos
=
null
;
ByteArrayOutputStream
bos
=
null
;
try
{
// 模板绝对路径--服务器
String
fileName
=
"/template/receipt_template_02_27.pdf"
;
// String fileName = "/template/receipt_template_02_27.pdf";
String
fileName
=
"E:/文件/PDF模板/receipt_template_02_27.pdf"
;
// 读取现有模板内容
reader
=
new
PdfReader
(
fileName
);
// 创建输出流
...
...
@@ -85,17 +87,10 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
//必须要调用这个,否则文档不会生成的
ps
.
setFormFlattening
(
true
);
ps
.
close
();
//生成pdf路径存放的路径
fos
=
response
.
getOutputStream
();
fos
.
write
(
bos
.
toByteArray
());
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
finally
{
if
(
fos
!=
null
){
fos
.
flush
();
fos
.
close
();
}
if
(
bos
!=
null
){
bos
.
close
();
}
...
...
@@ -103,6 +98,8 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
reader
.
close
();
}
}
assert
bos
!=
null
;
return
uploadMinio
(
bos
,
"检验报告_"
+
taskId
);
}
private
InspectionReportPdfVO
requireData
()
{
...
...
@@ -131,7 +128,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
.
remark
(
"备注"
)
.
taskNumber
(
"任务编号"
)
.
sampleSum
(
"样品数量"
)
.
vehicleType
(
"车
俩
类型"
)
.
vehicleType
(
"车
辆
类型"
)
.
vehicleModel
(
"车辆型号"
)
.
vehicleIdentificationNumber
(
"车辆识别码"
)
.
sampleNumberSummary
(
"样品编号汇总"
)
...
...
@@ -198,7 +195,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
document
.
close
();
// 上传到Minio
return
uploadMinio
(
outputStream
,
"企业留档文件
"
+
"
_"
+
taskId
);
return
uploadMinio
(
outputStream
,
"企业留档文件_"
+
taskId
);
}
/**
...
...
quality-review/src/main/java/com/ruoyi/web/PdfTemplateManagementController.java
View file @
c3174724
...
...
@@ -15,8 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
/**
* @author gxk
*/
...
...
@@ -33,18 +31,19 @@ public class PdfTemplateManagementController {
/**
* 检验报告PDF下载
* @param re
sponse
* @param re
quest
*/
@Anonymous
@ApiOperation
(
"检验报告PDF下载"
)
@GetMapping
(
value
=
"/inspectionReport"
,
produces
=
"application/json"
)
public
void
download
(
HttpServletResponse
response
)
{
response
.
setHeader
(
"content-disposition"
,
"attachment;fileName="
+
"ReceiptPrinter.pdf"
);
@PostMapping
(
"/inspectionReport"
)
public
R
<
String
>
download
(
@Validated
@RequestBody
PdfFileRequest
request
)
{
try
{
// demo-模板
pdfTemplateManagementService
.
generateInspectionReport
(
response
);
String
url
=
pdfTemplateManagementService
.
generateInspectionReport
(
request
.
getTaskId
());
return
R
.
ok
(
url
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
R
.
fail
();
}
}
...
...
@@ -83,7 +82,9 @@ public class PdfTemplateManagementController {
case
0
:
url
=
task
.
getVehicleInformationUrl
();
if
(
StrUtil
.
isBlank
(
url
))
{
// TODO 生成整车
// 生成整车信息安全检验报告
url
=
pdfTemplateManagementService
.
generateInspectionReport
(
request
.
getTaskId
());
taskService
.
update
(
new
UpdateWrapper
<
Task
>().
lambda
().
eq
(
Task:
:
getId
,
request
.
getTaskId
()).
set
(
Task:
:
getVehicleInformationUrl
,
url
));
}
break
;
case
1
:
...
...
@@ -123,7 +124,9 @@ public class PdfTemplateManagementController {
try
{
switch
(
request
.
getType
())
{
case
0
:
// TODO 更新整车
// 更新整车PDF文件
url
=
pdfTemplateManagementService
.
generateInspectionReport
(
request
.
getTaskId
());
taskService
.
update
(
new
UpdateWrapper
<
Task
>().
lambda
().
eq
(
Task:
:
getId
,
request
.
getTaskId
()).
set
(
Task:
:
getVehicleInformationUrl
,
url
));
break
;
case
1
:
// 根据任务ID新生成
...
...
quality-review/src/main/resources/template/receipt_template_02_27.pdf
View file @
c3174724
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