Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dataC_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
高宇
dataC_api
Commits
9cdbd322
Commit
9cdbd322
authored
Apr 29, 2024
by
高宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.导出Dto类
parent
b8e2d699
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
10 deletions
+80
-10
Jnsp7xtmController.java
...g/rcisoft/bus/jnsp7xtm/controller/Jnsp7xtmController.java
+4
-3
RoleDto.java
src/main/java/org/rcisoft/bus/jnsp7xtm/entity/RoleDto.java
+6
-6
Jnsp7xtmServiceImpl.java
...cisoft/bus/jnsp7xtm/service/impl/Jnsp7xtmServiceImpl.java
+6
-0
ExcelExportStatisticStyler.java
...ain/java/org/rcisoft/util/ExcelExportStatisticStyler.java
+41
-0
ExportToExcelUtil.java
src/main/java/org/rcisoft/util/ExportToExcelUtil.java
+23
-1
No files found.
src/main/java/org/rcisoft/bus/jnsp7xtm/controller/Jnsp7xtmController.java
View file @
9cdbd322
...
...
@@ -65,7 +65,7 @@ public class Jnsp7xtmController extends CyPaginationController<Map> {
break
;
}
List
<
RoleDto
>
all
=
jnsp7xtmDtoService
.
findAll
(
jnsp7xtm
);
CyEpExcelUtil
.
exportExcel
(
all
,
"用户详情信息"
,
"用户详情
信息"
,
RoleDto
.
class
,
excelName
,
response
);
ExportToExcelUtil
.
exportExcel
(
all
,
"明细信息"
,
"明细
信息"
,
RoleDto
.
class
,
excelName
,
response
);
}
// 导出详细信息
...
...
@@ -86,7 +86,7 @@ public class Jnsp7xtmController extends CyPaginationController<Map> {
break
;
}
List
<
RoleDto
>
information
=
jnsp7xtmServiceImpl
.
getInAllformation
(
requestInfromationDto
);
CyEpExcelUtil
.
exportExcel
(
information
,
"详细信息"
,
"详
细信息"
,
RoleDto
.
class
,
excelName
,
response
);
ExportToExcelUtil
.
exportExcel
(
information
,
"明细信息"
,
"明
细信息"
,
RoleDto
.
class
,
excelName
,
response
);
}
// 导出明细信息
...
...
@@ -107,7 +107,8 @@ public class Jnsp7xtmController extends CyPaginationController<Map> {
break
;
}
List
<
RoleDto
>
all
=
jnsp7xtmDtoService
.
findAll
(
jnsp7xtm
);
CyEpExcelUtil
.
exportExcel
(
all
,
"明细信息"
,
"明细信息"
,
RoleDto
.
class
,
excelName
,
response
);
ExportToExcelUtil
.
exportExcel
(
all
,
"明细信息"
,
"明细信息"
,
RoleDto
.
class
,
excelName
,
response
);
// CyEpExcelUtil.exportExcel(all, "明细信息", "明细信息", RoleDto.class, excelName, response);
}
// 导出统计
...
...
src/main/java/org/rcisoft/bus/jnsp7xtm/entity/RoleDto.java
View file @
9cdbd322
...
...
@@ -26,17 +26,17 @@ public class RoleDto extends CyIdIncreEntity<RoleDto> {
private
String
pn
;
@Excel
(
name
=
"mksqf"
,
orderNum
=
"6"
,
width
=
20
)
private
String
mksqf
;
@Excel
(
name
=
"xsjg"
,
orderNum
=
"12"
,
width
=
20
)
@Excel
(
name
=
"xsjg"
,
orderNum
=
"12"
,
width
=
20
,
type
=
10
)
private
String
xsjg
;
@Excel
(
name
=
"zzc"
,
orderNum
=
"9"
,
width
=
20
)
@Excel
(
name
=
"zzc"
,
orderNum
=
"9"
,
width
=
20
,
type
=
10
)
private
String
zzc
;
@Excel
(
name
=
"rmb"
,
orderNum
=
"13"
,
width
=
20
)
@Excel
(
name
=
"rmb"
,
orderNum
=
"13"
,
width
=
20
,
type
=
10
)
private
String
rmb
;
@Excel
(
name
=
"chzsa"
,
orderNum
=
"10"
,
width
=
20
)
@Excel
(
name
=
"chzsa"
,
orderNum
=
"10"
,
width
=
20
,
type
=
10
)
private
String
chzsa
;
@Excel
(
name
=
"szzt"
,
orderNum
=
"8"
,
width
=
20
)
private
String
szzt
;
@Excel
(
name
=
"chzsb"
,
orderNum
=
"14"
,
width
=
20
)
@Excel
(
name
=
"chzsb"
,
orderNum
=
"14"
,
width
=
20
,
type
=
10
)
private
String
chzsb
;
@Excel
(
name
=
"ddjsr"
,
orderNum
=
"10"
,
width
=
20
)
private
String
ddjsr
;
...
...
@@ -54,7 +54,7 @@ public class RoleDto extends CyIdIncreEntity<RoleDto> {
@Excel
(
name
=
"yyydd"
,
orderNum
=
"16"
,
width
=
20
)
private
String
yydd
;
@Excel
(
name
=
"zzcg"
,
orderNum
=
"16"
,
width
=
20
)
@Excel
(
name
=
"zzcg"
,
orderNum
=
"16"
,
width
=
20
,
type
=
10
)
private
String
zzcg
;
@Excel
(
name
=
"bz"
,
orderNum
=
"17"
,
width
=
20
)
...
...
src/main/java/org/rcisoft/bus/jnsp7xtm/service/impl/Jnsp7xtmServiceImpl.java
View file @
9cdbd322
...
...
@@ -506,6 +506,12 @@ public class Jnsp7xtmServiceImpl extends ServiceImpl<Jnsp7xtmRepository, Map> im
for
(
int
i
=
0
;
i
<
tableHeaders
.
size
();
i
++)
{
entityList
.
add
(
new
ExcelExportEntity
(
tableHeaders
.
get
(
i
).
getName
(),
tableHeaders
.
get
(
i
).
getKey
(),
20
));
}
// 将对应的列传为数值
for
(
int
i
=
0
;
i
<
entityList
.
size
();
i
++)
{
if
(
i
>
1
&&
i
<
entityList
.
size
())
{
entityList
.
get
(
i
).
setType
(
10
);
}
}
List
<
Map
<
String
,
Object
>>
dataList
=
new
ArrayList
<>();
// 获取要导出的条数
List
<
Map
<
String
,
Object
>>
exportListCount
=
baseMapper
.
getExportListCount
(
requestDto
,
months
);
...
...
src/main/java/org/rcisoft/util/ExcelExportStatisticStyler.java
0 → 100644
View file @
9cdbd322
package
org
.
rcisoft
.
util
;
/**
* @Author: gy
* @Date: 2024/4/25 16:56
* @Description: 导出从数字类型
*/
import
cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity
;
import
cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl
;
import
org.apache.poi.ss.usermodel.*
;
public
class
ExcelExportStatisticStyler
extends
ExcelExportStylerDefaultImpl
{
private
CellStyle
numberCellStyle
;
public
ExcelExportStatisticStyler
(
Workbook
workbook
)
{
super
(
workbook
);
createNumberCellStyler
();
}
private
void
createNumberCellStyler
()
{
numberCellStyle
=
workbook
.
createCellStyle
();
numberCellStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
numberCellStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 这边传的参数格式会影响你导出的数据类型
// "0.00"是自定义类型可以与数字类型直接进行计算,并不是直接导出数字类型
// "#,##0.00" 是货币类型 其他参数到源码查看
numberCellStyle
.
setDataFormat
((
short
)
BuiltinFormats
.
getBuiltinFormat
(
"0.00"
));
numberCellStyle
.
setWrapText
(
true
);
}
@Override
public
CellStyle
getStyles
(
boolean
noneStyler
,
ExcelExportEntity
entity
)
{
//自定义Dict转换
if
(
entity
!=
null
&&
10
==
entity
.
getType
())
{
return
numberCellStyle
;
}
return
super
.
getStyles
(
noneStyler
,
entity
);
}
}
src/main/java/org/rcisoft/util/ExportToExcelUtil.java
View file @
9cdbd322
package
org
.
rcisoft
.
util
;
import
cn.afterturn.easypoi.excel.ExcelExportUtil
;
import
cn.afterturn.easypoi.excel.entity.ExportParams
;
import
cn.afterturn.easypoi.excel.entity.enmus.ExcelType
;
import
cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity
;
...
...
@@ -8,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.rcisoft.core.exception.CyServiceException
;
import
org.rcisoft.core.util.CyEpExcelUtil
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -22,7 +24,7 @@ import java.util.Map;
* @Description: 动态列导出(非注解形式)
*/
@Slf4j
public
class
ExportToExcelUtil
{
public
class
ExportToExcelUtil
extends
CyEpExcelUtil
{
// 导出动态列
/**
* entityList 表头
...
...
@@ -33,6 +35,7 @@ public class ExportToExcelUtil {
Workbook
workbook
=
new
XSSFWorkbook
();
// 3、定义标题和sheetName
ExportParams
exportParams
=
new
ExportParams
(
"导出统计"
,
"sheet1"
);
exportParams
.
setStyle
(
ExcelExportStatisticStyler
.
class
);
// 默认未 ExcelType.HSSF导出失败
exportParams
.
setType
(
ExcelType
.
XSSF
);
ExcelExportService
service
=
new
ExcelExportService
();
...
...
@@ -42,6 +45,25 @@ public class ExportToExcelUtil {
}
public
static
void
exportExcel
(
List
<?>
list
,
String
title
,
String
sheetName
,
Class
<?>
pojoClass
,
String
fileName
,
HttpServletResponse
response
)
{
ExportParams
exportParams
=
new
ExportParams
(
title
,
sheetName
);
exportParams
.
setStyle
(
ExcelExportStatisticStyler
.
class
);
String
[]
format
=
fileName
.
split
(
"\\."
);
if
(
format
[
1
].
equals
(
"xlsx"
))
{
exportParams
.
setType
(
ExcelType
.
XSSF
);
}
defaultExport
(
list
,
pojoClass
,
fileName
,
response
,
exportParams
);
}
private
static
void
defaultExport
(
List
<?>
list
,
Class
<?>
pojoClass
,
String
fileName
,
HttpServletResponse
response
,
ExportParams
exportParams
)
{
Workbook
workbook
=
ExcelExportUtil
.
exportExcel
(
exportParams
,
pojoClass
,
list
);
if
(
workbook
!=
null
)
{
downLoadExcel
(
fileName
,
response
,
workbook
);
}
}
// 下载excel
private
static
void
downLoadExcel
(
String
fileName
,
HttpServletResponse
response
,
Workbook
workbook
)
{
ServletOutputStream
outputStream
=
null
;
...
...
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