Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
car-database-api
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
中汽研标准应用数据库
car-database-api
Commits
88b127b5
Commit
88b127b5
authored
Sep 04, 2024
by
高滢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导出方案 加一个概要
parent
ace6e061
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
6 deletions
+99
-6
TTestPlanRecord.java
...eview/src/main/java/com/ruoyi/domain/TTestPlanRecord.java
+1
-1
TestPlanRecordController.java
...src/main/java/com/ruoyi/web/TestPlanRecordController.java
+7
-2
SystemReviewExportRequest.java
...java/com/ruoyi/web/request/SystemReviewExportRequest.java
+20
-2
ExcelMultipleSheetsUtil.java
...a/com/ruoyi/common/utils/poi/ExcelMultipleSheetsUtil.java
+71
-1
No files found.
quality-review/src/main/java/com/ruoyi/domain/TTestPlanRecord.java
View file @
88b127b5
...
...
@@ -95,7 +95,7 @@ public class TTestPlanRecord{
private
String
inspectionStandardName
;
/** 创建时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd
HH:mm:ss
"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
...
...
quality-review/src/main/java/com/ruoyi/web/TestPlanRecordController.java
View file @
88b127b5
...
...
@@ -167,8 +167,13 @@ public class TestPlanRecordController extends BaseController{
result
.
put
(
isPage
?
"车型实验"
:
"sheet1名字"
,
list
);
}
});
ExcelMultipleSheetsUtil
.
excelMultipleSheets
(
result
,
"导出方案"
+
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd"
),
XLSX_SUFFIX
,
respon
);
Map
<
String
,
String
>
cover
=
new
HashMap
<>();
cover
.
put
(
"检测标准:"
,
systemReviewExportRequest
.
getInspectionStandardName
());
cover
.
put
(
"被检车企:"
,
systemReviewExportRequest
.
getInspectCarCompanyName
());
cover
.
put
(
"车辆VIN号:"
,
systemReviewExportRequest
.
getCarModel
());
cover
.
put
(
"检测机构:"
,
systemReviewExportRequest
.
getTestOrganizationName
());
cover
.
put
(
"生成时间:"
,
systemReviewExportRequest
.
getCreateTime
());
ExcelMultipleSheetsUtil
.
excelMultipleSheets
(
result
,
"导出方案"
+
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd"
),
XLSX_SUFFIX
,
respon
,
cover
);
}
}
quality-review/src/main/java/com/ruoyi/web/request/SystemReviewExportRequest.java
View file @
88b127b5
package
com
.
ruoyi
.
web
.
request
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -21,8 +25,8 @@ public class SystemReviewExportRequest {
// @ApiModelProperty("用例编号")
// private List<String> useCaseNo;
//
//
@ApiModelProperty("标准")
//
private String inspectionStandardName;
@ApiModelProperty
(
"标准"
)
private
String
inspectionStandardName
;
@ApiModelProperty
(
"标准ID"
)
private
Long
inspectionStandardId
;
...
...
@@ -30,5 +34,19 @@ public class SystemReviewExportRequest {
@ApiModelProperty
(
"车型实验json"
)
private
CarExperimentRequest
carExperimentRequest
;
/**
* 被检车企名称
*/
@ApiModelProperty
(
"被检车企名称"
)
private
String
inspectCarCompanyName
;
@ApiModelProperty
(
"车辆型号"
)
private
String
carModel
;
@ApiModelProperty
(
"检测机构名称"
)
private
String
testOrganizationName
;
/** 创建时间 */
@ApiModelProperty
(
"生成时间"
)
private
String
createTime
;
}
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelMultipleSheetsUtil.java
View file @
88b127b5
...
...
@@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.utils.DictUtils
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -31,9 +32,32 @@ public class ExcelMultipleSheetsUtil {
* @param response 响应
* @throws IOException 异常
*/
public
static
void
excelMultipleSheets
(
Map
<
String
,
Object
>
data
,
String
excelFileName
,
String
suffixName
,
HttpServletResponse
response
)
throws
IOException
{
public
static
void
excelMultipleSheets
(
Map
<
String
,
Object
>
data
,
String
excelFileName
,
String
suffixName
,
HttpServletResponse
response
,
Map
<
String
,
String
>
cover
)
throws
IOException
{
// 创建工作簿
try
(
Workbook
workbook
=
new
XSSFWorkbook
())
{
Sheet
sheetFirst
=
workbook
.
createSheet
(
"概要"
);
sheetFirst
.
setColumnWidth
(
0
,
25
*
256
);
sheetFirst
.
setColumnWidth
(
1
,
25
*
256
);
// 创建数据行
Row
dataRowHead
=
sheetFirst
.
createRow
(
1
);
dataRowHead
.
setHeightInPoints
(
20
);
Cell
cell
=
dataRowHead
.
createCell
(
0
);
dataRowHead
.
createCell
(
1
);
cell
.
setCellValue
(
"检测方案"
);
cell
.
setCellStyle
(
getStyle
(
sheetFirst
.
getWorkbook
()));
// 合并区域:从第1行到第2行,第1列到第2列(注意:行和列的索引从0开始)
CellRangeAddress
mergeRegion
=
new
CellRangeAddress
(
1
,
2
,
0
,
1
);
// 将合并区域添加到工作表中
sheetFirst
.
addMergedRegion
(
mergeRegion
);
final
int
[]
i
=
{
2
};
cover
.
forEach
((
key
,
value
)->{
Row
dataRow
=
sheetFirst
.
createRow
(
i
[
0
]);
dataRow
.
setHeightInPoints
(
20
);
dataRow
.
createCell
(
0
).
setCellValue
(
key
);
dataRow
.
createCell
(
1
).
setCellValue
(
value
);
i
[
0
]
=
i
[
0
]
+
1
;
});
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
data
.
entrySet
())
{
String
sheetName
=
entry
.
getKey
();
Object
sheetData
=
entry
.
getValue
();
...
...
@@ -49,6 +73,49 @@ public class ExcelMultipleSheetsUtil {
}
}
private
static
CellStyle
getStyle
(
Workbook
workbook
)
{
CellStyle
style
=
workbook
.
createCellStyle
();
// 设置底边框;
style
.
setBorderBottom
(
BorderStyle
.
THIN
);
// 设置底边框颜色;
style
.
setBottomBorderColor
(
IndexedColors
.
GREY_50_PERCENT
.
getIndex
());
// 设置左边框;
style
.
setBorderLeft
(
BorderStyle
.
THIN
);
// 设置左边框颜色;
style
.
setLeftBorderColor
(
IndexedColors
.
GREY_50_PERCENT
.
getIndex
());
// 设置右边框;
style
.
setBorderRight
(
BorderStyle
.
THIN
);
// 设置右边框颜色;
style
.
setRightBorderColor
(
IndexedColors
.
GREY_50_PERCENT
.
getIndex
());
// 设置顶边框;
style
.
setBorderTop
(
BorderStyle
.
THIN
);
// 设置顶边框颜色;
style
.
setTopBorderColor
(
IndexedColors
.
GREY_50_PERCENT
.
getIndex
());
// 设置字体
Font
font
=
workbook
.
createFont
();
// 设置字体大小
font
.
setFontHeightInPoints
((
short
)
20
);
// 设置字体名字
font
.
setFontName
(
"微软雅黑"
);
// 在样式用应用设置的字体;
style
.
setFont
(
font
);
// 设置自动换行;
style
.
setWrapText
(
true
);
// 设置水平对齐的样式为居中对齐;
style
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
// 设置垂直对齐的样式为居中对齐;
style
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 设置填充样式(实心填充)
style
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
// 设置单元格颜色
style
.
setFillForegroundColor
(
IndexedColors
.
GREY_25_PERCENT
.
getIndex
());
return
style
;
}
/**
* 创建表单并填充数据
*
...
...
@@ -141,6 +208,8 @@ public class ExcelMultipleSheetsUtil {
private
static
CellStyle
createCellStyle
(
Workbook
workbook
)
{
CellStyle
cellStyle
=
workbook
.
createCellStyle
();
// 设置自动换行;
cellStyle
.
setWrapText
(
true
);
// 设置 水平和垂直 居中对齐
cellStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
cellStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
...
...
@@ -154,6 +223,7 @@ public class ExcelMultipleSheetsUtil {
cellStyle
.
setLeftBorderColor
(
IndexedColors
.
GREY_50_PERCENT
.
getIndex
());
cellStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
cellStyle
.
setRightBorderColor
(
IndexedColors
.
GREY_50_PERCENT
.
getIndex
());
// 设置字体
Font
dataFont
=
workbook
.
createFont
();
dataFont
.
setFontName
(
"Arial"
);
...
...
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