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
a9ac1c9a
Commit
a9ac1c9a
authored
1 year ago
by
wdy
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://gitlab.91isoft.com:90/wangfei/vehicle-quality-review
into wangdingyi
parents
03723626
507c2f6f
dev
gaixiankang
gaoying
master
songyuanshuo
wangdingyi
wangfei
19.0
18.0
17.0
16.0
15.0
14.0
13.0
12.0
11.0
10.0
9.0
8.0
7.0
6.0
5.0
4.0
3.0
2.0
1.0
2 merge requests
!211
dev - master
,
!128
数据统计&编辑任务&暂存任务
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
4961 additions
and
13 deletions
+4961
-13
PdfTemplateManagementService.java
.../java/com/ruoyi/service/PdfTemplateManagementService.java
+7
-0
PdfTemplateManagementServiceImpl.java
.../ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
+113
-4
TestScenarioServiceImpl.java
.../java/com/ruoyi/service/impl/TestScenarioServiceImpl.java
+3
-0
TestTypeServiceImpl.java
...main/java/com/ruoyi/service/impl/TestTypeServiceImpl.java
+3
-0
TestUseCaseServiceImpl.java
...n/java/com/ruoyi/service/impl/TestUseCaseServiceImpl.java
+3
-0
PdfTemplateManagementController.java
...n/java/com/ruoyi/web/PdfTemplateManagementController.java
+19
-0
PdfBaseWriter.java
...n/src/main/java/com/ruoyi/common/utils/PdfBaseWriter.java
+102
-9
vehicle-quality-review-2024-03-05-13-09.sql
sql/vehicle-quality-review-2024-03-05-13-09.sql
+4711
-0
No files found.
quality-review/src/main/java/com/ruoyi/service/PdfTemplateManagementService.java
View file @
a9ac1c9a
...
...
@@ -14,4 +14,11 @@ public interface PdfTemplateManagementService {
* @throws Exception
*/
void
generateInspectionReport
(
HttpServletResponse
response
)
throws
Exception
;
/**
* 企业留档文件PDF下载
* @return
* @throws Exception
*/
String
generateRetentionFile
()
throws
Exception
;
}
This diff is collapsed.
Click to expand it.
quality-review/src/main/java/com/ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
View file @
a9ac1c9a
package
com
.
ruoyi
.
service
.
impl
;
import
com.itextpdf.text.DocumentException
;
import
com.itextpdf.text.Image
;
import
com.itextpdf.text.Rectangle
;
import
com.itextpdf.text.*
;
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.PhotoStorageVO
;
import
com.ruoyi.service.PdfTemplateManagementService
;
import
io.minio.MinioClient
;
import
io.minio.ObjectWriteArgs
;
import
io.minio.PutObjectArgs
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.lang.reflect.Field
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.List
;
/**
* PDF模板管理Service业务层处理
...
...
@@ -24,6 +31,18 @@ import java.util.Map;
@Transactional
public
class
PdfTemplateManagementServiceImpl
implements
PdfTemplateManagementService
{
@Value
(
"${minio.bucketName}"
)
private
String
bucketName
;
@Value
(
"${minio.url}"
)
private
String
minioEndpoint
;
@Value
(
"${minio.accessKey}"
)
private
String
accessKey
;
@Value
(
"${minio.secretKey}"
)
private
String
secretKey
;
/**
* 检验报告PDF下载
* @param response
...
...
@@ -88,6 +107,96 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
}
}
/**
* 企业留档文件PDF下载
* @return
*/
@Override
public
String
generateRetentionFile
()
throws
Exception
{
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
// 新建
PdfBaseWriter
document
=
new
PdfBaseWriter
(
outputStream
);
// 打开
document
.
open
();
// 内容
// 封面
document
.
setParagraph
(
"检验中心名称"
,
12
f
,
0
,
60
,
15
f
,
120
f
);
document
.
setParagraph
(
"企业留档文件"
,
30
f
,
Element
.
ALIGN_CENTER
,
0
,
15
f
,
180
f
);
PdfPTable
customTable
=
new
PdfPTable
(
new
float
[]{
15
,
50
});
customTable
.
setWidthPercentage
(
70
);
document
.
writeNoBorderCell
(
"检验依据:"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
document
.
writeBottomCell
(
"GB xxxx-xxxx 汽车整车信息安全技术要求"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
document
.
writeNoBorderCell
(
"检验项目:"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
document
.
writeBottomCell
(
"汽车信息安全管理要求、车辆信息安全一般要求、车辆信息安全技术要求"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
document
.
writeNoBorderCell
(
"创建时间:"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
document
.
writeBottomCell
(
"2024-07-01"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
document
.
writeNoBorderCell
(
"委托单位名称:"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
document
.
writeBottomCell
(
"xxxxxxxxxxxxxxxxxxx"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
document
.
addContent
(
customTable
);
document
.
setParagraph
(
"检验中心名称"
,
20
f
,
Element
.
ALIGN_CENTER
,
0
,
100
f
,
0
f
);
// 下一页
document
.
newPage
();
document
.
setParagraph
(
"检验中心名称"
,
12
f
,
0
,
30
,
15
f
,
20
f
);
// 创建表格
List
<
String
>
list
=
Arrays
.
asList
(
"文件名称"
,
"文件目录"
,
"标准章节"
,
"标准要求"
,
"审查要点"
);
float
[]
columnWidths
=
{
20
,
20
,
20
,
70
,
70
};
PdfPTable
table
=
document
.
createWithHeaderTable
(
list
,
columnWidths
);
document
.
writeCell
(
"A文件"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"B文件"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"C文件"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"车辆制造商应具备车辆全生命周期的汽车信息安全管理体系"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"E文件"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"F文件"
,
Element
.
ALIGN_LEFT
,
1
,
2
,
table
);
document
.
writeCell
(
"1.1"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"5.1"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"要求1"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"要点1"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"1.2"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"5.2"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"要求2"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
writeCell
(
"要点2"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
table
);
document
.
addContent
(
table
);
// 关闭
document
.
close
();
// 上传到Minio
return
uploadMinio
(
outputStream
,
"企业留档文件"
);
}
/**
* 上传到minio
* @param outputStream 输出流
* @param fileName 文件名
* @return minio存储地址
*/
private
String
uploadMinio
(
ByteArrayOutputStream
outputStream
,
String
fileName
)
throws
Exception
{
// 1.连接Minio
MinioClient
minioClient
=
MinioClient
.
builder
()
.
endpoint
(
minioEndpoint
)
.
credentials
(
accessKey
,
secretKey
)
.
build
();
// 2.上传
// 把os流转为is流
ByteArrayInputStream
inputStream
=
new
ByteArrayInputStream
(
outputStream
.
toByteArray
());
String
newFileName
=
assemblyPdfName
(
fileName
);
PutObjectArgs
putObjectArgs
=
PutObjectArgs
.
builder
()
.
bucket
(
bucketName
)
.
object
(
newFileName
)
.
contentType
(
"application/pdf"
)
.
stream
(
inputStream
,
inputStream
.
available
(),
ObjectWriteArgs
.
MIN_MULTIPART_SIZE
).
build
();
minioClient
.
putObject
(
putObjectArgs
);
return
newFileName
;
}
/**
* 拼接pdf文件名
* @param name
* @return
*/
public
String
assemblyPdfName
(
String
name
)
{
return
StringUtils
.
format
(
"{}/{}.pdf"
,
DateUtils
.
datePath
(),
name
);
}
/**
* 渲染数据
* @param fields
...
...
This diff is collapsed.
Click to expand it.
quality-review/src/main/java/com/ruoyi/service/impl/TestScenarioServiceImpl.java
View file @
a9ac1c9a
...
...
@@ -20,6 +20,9 @@ public class TestScenarioServiceImpl extends ServiceImpl<TestScenarioMapper, Tes
@Override
public
List
<
TestScenario
>
selectTestScenarioList
(
TestScenarioRequest
testScenarioRequest
){
if
(
testScenarioRequest
.
getTestScenario
()
!=
null
&&
(
testScenarioRequest
.
getTestScenario
().
contains
(
"%"
)
||
testScenarioRequest
.
getTestScenario
().
contains
(
"_"
)
)){
testScenarioRequest
.
setTestScenario
(
testScenarioRequest
.
getTestScenario
().
toString
().
replaceAll
(
"%"
,
"/%"
).
replaceAll
(
"_"
,
"/_"
));
}
return
testScenarioMapper
.
selectTestScenarioList
(
testScenarioRequest
);
}
}
This diff is collapsed.
Click to expand it.
quality-review/src/main/java/com/ruoyi/service/impl/TestTypeServiceImpl.java
View file @
a9ac1c9a
...
...
@@ -29,6 +29,9 @@ public class TestTypeServiceImpl extends ServiceImpl<TestTypeMapper, TestType> i
@Override
public
List
<
TestType
>
selectTestTypeList
(
TestTypeRequest
testTypeRequest
)
{
if
(
testTypeRequest
.
getTestType
()
!=
null
&&
(
testTypeRequest
.
getTestType
().
contains
(
"%"
)
||
testTypeRequest
.
getTestType
().
contains
(
"_"
)
)){
testTypeRequest
.
setTestType
(
testTypeRequest
.
getTestType
().
toString
().
replaceAll
(
"%"
,
"/%"
).
replaceAll
(
"_"
,
"/_"
));
}
return
testTypeMapper
.
selectTestTypeList
(
testTypeRequest
);
}
}
This diff is collapsed.
Click to expand it.
quality-review/src/main/java/com/ruoyi/service/impl/TestUseCaseServiceImpl.java
View file @
a9ac1c9a
...
...
@@ -31,6 +31,9 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
*/
@Override
public
List
<
TestUseCase
>
selectseCaseList
(
TestUserCaseRequest
testUserCaseRequest
){
if
(
testUserCaseRequest
.
getSearchKeywords
()
!=
null
&&
(
testUserCaseRequest
.
getSearchKeywords
().
contains
(
"%"
)
||
testUserCaseRequest
.
getSearchKeywords
().
contains
(
"_"
)
)){
testUserCaseRequest
.
setSearchKeywords
(
testUserCaseRequest
.
getSearchKeywords
().
toString
().
replaceAll
(
"%"
,
"/%"
).
replaceAll
(
"_"
,
"/_"
));
}
return
testUseCaseMapper
.
selectseCaseList
(
testUserCaseRequest
);
}
...
...
This diff is collapsed.
Click to expand it.
quality-review/src/main/java/com/ruoyi/web/PdfTemplateManagementController.java
View file @
a9ac1c9a
package
com
.
ruoyi
.
web
;
import
com.ruoyi.common.annotation.Anonymous
;
import
com.ruoyi.common.core.domain.R
;
import
com.ruoyi.service.PdfTemplateManagementService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -39,4 +40,22 @@ public class PdfTemplateManagementController {
}
}
/**
* 企业留档文件PDF下载
* @param response
*/
@Anonymous
@ApiOperation
(
"企业留档文件PDF下载"
)
@GetMapping
(
value
=
"/retentionFile"
,
produces
=
"application/json"
)
public
R
<
String
>
downloadRetentionFile
()
{
try
{
// demo-模板
String
url
=
pdfTemplateManagementService
.
generateRetentionFile
();
return
R
.
ok
(
url
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
R
.
fail
();
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/utils/PdfBaseWriter.java
View file @
a9ac1c9a
package
com
.
ruoyi
.
common
.
utils
;
import
com.google.common.collect.ListMultimap
;
import
com.itextpdf.text.*
;
import
com.itextpdf.text.pdf.BaseFont
;
import
com.itextpdf.text.pdf.PdfPCell
;
...
...
@@ -39,6 +38,11 @@ public class PdfBaseWriter extends Document{
* 浅黄色
*/
public
final
BaseColor
LIGHT_YELLOW_COLOR
=
new
BaseColor
(
255
,
255
,
153
);
/**
* 灰色
*/
public
final
BaseColor
LIGHT_GRAY_COLOR
=
new
BaseColor
(
241
,
241
,
241
);
/**
* 浅蓝色
*/
...
...
@@ -81,7 +85,7 @@ public class PdfBaseWriter extends Document{
}
// 根据写入数据宽度创建表格
List
<
String
>
headers
=
new
ArrayList
<
String
>(
rows
.
get
(
0
).
keySet
());
PdfPTable
table
=
createWithHeaderTable
(
headers
);
PdfPTable
table
=
createWithHeaderTable
(
headers
,
null
);
for
(
LinkedHashMap
<
String
,
Object
>
row
:
rows
)
{
for
(
String
k
:
headers
)
{
...
...
@@ -92,20 +96,28 @@ public class PdfBaseWriter extends Document{
addContent
(
table
);
return
table
;
}
/**
* 创建带表头的表格 {@link PdfPTable}
* @param headers 表头数据集
* @param columnWidths 每一列的宽度
* @return 表格 {@link PdfPTable}
*/
public
PdfPTable
createWithHeaderTable
(
List
<
String
>
headers
)
{
int
numColumns
=
calculateColumnNumber
(
headers
);
PdfPTable
headerTable
=
new
PdfPTable
(
numColumns
);
public
PdfPTable
createWithHeaderTable
(
List
<
String
>
headers
,
float
[]
columnWidths
)
{
PdfPTable
headerTable
=
null
;
if
(
columnWidths
==
null
)
{
int
numColumns
=
calculateColumnNumber
(
headers
);
headerTable
=
new
PdfPTable
(
numColumns
);
}
else
{
headerTable
=
new
PdfPTable
(
columnWidths
);
}
headerTable
.
setWidthPercentage
(
100
);
headerTable
.
setSpacingBefore
(
10
);
for
(
String
text
:
headers
)
{
writeCell
(
text
,
Element
.
ALIGN_CENTER
,
calculateColumnNumber
(
text
),
1
,
headerTable
,
defaultFont
(),
0
f
,
Rectangle
.
BOX
,
LIGHT_BLUE_COLOR
);
if
(
columnWidths
==
null
)
{
writeCell
(
text
,
Element
.
ALIGN_CENTER
,
calculateColumnNumber
(
text
),
1
,
headerTable
,
defaultFont
(),
0
f
,
Rectangle
.
BOX
,
LIGHT_BLUE_COLOR
);
}
else
{
writeCell
(
text
,
Element
.
ALIGN_CENTER
,
1
,
1
,
headerTable
,
defaultFont
(),
0
f
,
Rectangle
.
BOX
,
LIGHT_GRAY_COLOR
);
}
}
return
headerTable
;
}
...
...
@@ -151,6 +163,32 @@ public class PdfBaseWriter extends Document{
return
writeCell
(
text
,
Element
.
ALIGN_CENTER
,
colspan
,
rowspan
,
table
,
defaultFont
(),
0
f
,
Rectangle
.
BOX
,
BaseColor
.
WHITE
);
}
/**
* 写入单元格 {@link PdfPCell}
* @param text 内容
* @param align 对齐方式
* @param colspan 所占列数
* @param rowspan 所占行数
* @param table 表 {@link PdfPTable}
* @return 单元格 {@link PdfPCell}
*/
public
PdfPCell
writeCell
(
String
text
,
int
align
,
int
colspan
,
int
rowspan
,
PdfPTable
table
)
{
return
writeCell
(
text
,
align
,
colspan
,
rowspan
,
table
,
defaultFont
(),
0
f
,
Rectangle
.
BOX
,
BaseColor
.
WHITE
);
}
/**
* 写入单元格 {@link PdfPCell}
* @param text 内容
* @param align 对齐方式
* @param colspan 所占列数
* @param rowspan 所占行数
* @param table 表 {@link PdfPTable}
* @return 单元格 {@link PdfPCell}
*/
public
PdfPCell
writeBottomCell
(
String
text
,
int
align
,
int
colspan
,
int
rowspan
,
PdfPTable
table
)
{
return
writeCell
(
text
,
align
,
colspan
,
rowspan
,
table
,
defaultFont
(),
0
f
,
Rectangle
.
BOTTOM
,
BaseColor
.
WHITE
);
}
/**
* 写入单元格 {@link PdfPCell}
* @param text 内容
...
...
@@ -228,6 +266,10 @@ public class PdfBaseWriter extends Document{
if
(
paddingLeft
!=
null
)
{
cell
.
setPaddingLeft
(
paddingLeft
);
}
if
(
align
==
Element
.
ALIGN_LEFT
)
{
cell
.
setPaddingLeft
(
4
);
}
cell
.
setPaddingBottom
(
10
);
if
(
isSet
)
{
table
.
addCell
(
cell
);
}
...
...
@@ -439,6 +481,27 @@ public class PdfBaseWriter extends Document{
}
}
/**
* 添加key-value似的内容
* @param frontText 前内容
* @param behindText 后内容
* @param size 大小
* @param firstLineIndent 第一行缩进
* @param spacingAfter 段间距
*/
public
void
writeUnderlineText
(
String
frontText
,
String
behindText
,
Float
size
,
int
firstLineIndent
,
Float
spacingAfter
)
{
Paragraph
paragraph
=
new
Paragraph
();
paragraph
.
setFirstLineIndent
(
firstLineIndent
);
paragraph
.
setSpacingAfter
(
spacingAfter
);
Phrase
frontPhrase
=
new
Phrase
(
frontText
,
defaultFont
(
size
));
Phrase
behindPhrase
=
new
Phrase
();
Chunk
chunk
=
new
Chunk
(
behindText
,
defaultFont
(
size
));
chunk
.
setUnderline
(
01
.
f
,
-
5
f
);
behindPhrase
.
add
(
chunk
);
paragraph
.
add
(
frontPhrase
);
paragraph
.
add
(
behindPhrase
);
addContent
(
paragraph
);
}
// /**
// * 标题
...
...
@@ -563,8 +626,29 @@ public class PdfBaseWriter extends Document{
}
/**
*
* 设置自定义文本
* @param text 文本内容
* @param size 文本字号
* @param alignment 对齐方式
* @param firstLineIndex 首行是否进行缩进
* @param spacingBefore 段落上空白
* @param spacingAfter 段落下空白
* @return
*/
public
void
setParagraph
(
String
text
,
Float
size
,
int
alignment
,
int
firstLineIndex
,
Float
spacingBefore
,
Float
spacingAfter
)
{
Paragraph
paragraph
=
new
Paragraph
(
text
,
defaultFont
(
size
));
if
(
alignment
!=
0
)
{
paragraph
.
setAlignment
(
alignment
);
}
paragraph
.
setFirstLineIndent
(
firstLineIndex
);
paragraph
.
setSpacingBefore
(
spacingBefore
);
paragraph
.
setSpacingAfter
(
spacingAfter
);
addContent
(
paragraph
);
}
/**
* 添加 PDF 内容
* 新增工具类方法时,把想生成的内容先调用此方法
* @param element
* @return 如果添加了元素,则为true ,否则为false
*/
...
...
@@ -643,6 +727,15 @@ public class PdfBaseWriter extends Document{
return
chineseFont
(
10.5f
,
Font
.
NORMAL
,
BaseColor
.
BLACK
);
}
/**
* 自定义字体的默认中文字体
* @param size
* @return
*/
public
Font
defaultFont
(
Float
size
)
{
return
chineseFont
(
size
,
Font
.
NORMAL
,
BaseColor
.
BLACK
);
}
/**
* 默认中文字体
* @return 中文字体 {@link BaseFont}
...
...
This diff is collapsed.
Click to expand it.
sql/vehicle-quality-review-2024-03-05-13-09.sql
0 → 100644
View file @
a9ac1c9a
This diff is collapsed.
Click to expand it.
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