Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
cddde4a4
提交
cddde4a4
authored
5月 27, 2022
作者:
fit2cloud-chenyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf: 优化操作日志
上级
75c1bc62
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
72 行增加
和
47 行删除
+72
-47
LogExcel.java
backend/src/main/java/io/dataease/dto/log/LogExcel.java
+0
-20
LogService.java
...src/main/java/io/dataease/service/sys/log/LogService.java
+67
-27
messages_en_US.properties
backend/src/main/resources/i18n/messages_en_US.properties
+2
-0
messages_zh_CN.properties
backend/src/main/resources/i18n/messages_zh_CN.properties
+1
-0
messages_zh_TW.properties
backend/src/main/resources/i18n/messages_zh_TW.properties
+2
-0
没有找到文件。
backend/src/main/java/io/dataease/dto/log/LogExcel.java
deleted
100644 → 0
浏览文件 @
75c1bc62
package
io
.
dataease
.
dto
.
log
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.Data
;
@Data
public
class
LogExcel
{
@ExcelProperty
(
value
=
{
"optype"
},
index
=
0
)
private
String
optype
;
@ExcelProperty
(
value
=
{
"detail"
},
index
=
1
)
private
String
detail
;
@ExcelProperty
(
value
=
{
"user"
},
index
=
2
)
private
String
user
;
@ExcelProperty
(
value
=
{
"time"
},
index
=
3
)
private
String
time
;
}
backend/src/main/java/io/dataease/service/sys/log/LogService.java
浏览文件 @
cddde4a4
...
...
@@ -2,22 +2,19 @@ package io.dataease.service.sys.log;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.google.gson.Gson
;
import
io.dataease.auth.api.dto.CurrentUserDto
;
import
io.dataease.commons.constants.SysLogConstants
;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.BeanUtils
;
import
io.dataease.commons.utils.CustomCellWriteUtil
;
import
io.dataease.commons.utils.ServletUtils
;
import
io.dataease.controller.sys.base.BaseGridRequest
;
import
io.dataease.controller.sys.base.ConditionEntity
;
import
io.dataease.dto.SysLogDTO
;
import
io.dataease.dto.SysLogGridDTO
;
import
io.dataease.dto.log.FolderItem
;
import
io.dataease.
dto.log.LogExcel
;
import
io.dataease.
exception.DataEaseException
;
import
io.dataease.ext.ExtSysLogMapper
;
import
io.dataease.ext.query.GridExample
;
import
io.dataease.i18n.Translator
;
...
...
@@ -26,10 +23,12 @@ import io.dataease.plugins.common.base.mapper.SysLogMapper;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.ss.usermodel.*
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.OutputStream
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -57,8 +56,8 @@ public class LogService {
// 授权相关操作
private
static
Integer
[]
AUTH_OPERATE
=
{
6
,
7
};
// 授权相关资源 数据源 仪表板 数据集
private
static
Integer
[]
AUTH_SOURCE
=
{
1
,
2
,
3
};
// 授权相关资源 数据源 仪表板 数据集
菜单
private
static
Integer
[]
AUTH_SOURCE
=
{
1
,
2
,
3
,
11
};
...
...
@@ -212,33 +211,74 @@ public class LogService {
sysLogMapper
.
insert
(
sysLogWithBLOBs
);
}
public
void
exportExcel
(
BaseGridRequest
request
)
throws
Exception
{
public
void
exportExcel
(
BaseGridRequest
request
)
throws
Exception
{
request
=
detailRequest
(
request
);
HttpServletResponse
response
=
ServletUtils
.
response
();
OutputStream
outputStream
=
response
.
getOutputStream
();
try
{
GridExample
gridExample
=
request
.
convertExample
();
List
<
SysLogWithBLOBs
>
lists
=
extSysLogMapper
.
query
(
gridExample
);
List
<
LogExcel
>
excels
=
lists
.
stream
().
map
(
item
->
{
LogExcel
logExcel
=
new
LogExcel
();
List
<
String
[]>
details
=
lists
.
stream
().
map
(
item
->
{
String
operateTypeName
=
SysLogConstants
.
operateTypeName
(
item
.
getOperateType
());
String
sourceTypeName
=
SysLogConstants
.
sourceTypeName
(
item
.
getSourceType
());
logExcel
.
setOptype
(
Translator
.
get
(
operateTypeName
)
+
" "
+
Translator
.
get
(
sourceTypeName
));
logExcel
.
setDetail
(
logManager
.
detailInfo
(
item
));
logExcel
.
setUser
(
item
.
getNickName
());
logExcel
.
setTime
(
DateUtil
.
formatDateTime
(
new
Date
(
item
.
getTime
())));
return
logExcel
;
String
[]
row
=
new
String
[
4
];
row
[
0
]
=
Translator
.
get
(
operateTypeName
)
+
" "
+
Translator
.
get
(
sourceTypeName
);
row
[
1
]
=
logManager
.
detailInfo
(
item
);
row
[
2
]
=
item
.
getNickName
();
row
[
3
]
=
DateUtil
.
formatDateTime
(
new
Date
(
item
.
getTime
()));
return
row
;
}).
collect
(
Collectors
.
toList
());
// 导出时候会出现中⽂⽆法识别问题,需要转码
String
name
=
"log.xlsx"
;
String
fileName
=
new
String
(
name
.
getBytes
(
"gb2312"
),
"ISO8859-1"
);
response
.
setContentType
(
"application/vnd.ms-excel;chartset=utf-8"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
fileName
);
//调⽤⼯具类
ExcelWriter
writer
=
EasyExcel
.
write
(
response
.
getOutputStream
()).
build
();
WriteSheet
sheet
=
EasyExcel
.
writerSheet
(
0
,
"sheet"
).
head
(
LogExcel
.
class
).
registerWriteHandler
(
new
CustomCellWriteUtil
()).
build
();
writer
.
write
(
excels
,
sheet
);
writer
.
finish
();
// 使⽤完毕之后要关闭
String
[]
headArr
=
{
"操作类型"
,
"详情"
,
"用户"
,
"时间"
};
details
.
add
(
0
,
headArr
);
HSSFWorkbook
wb
=
new
HSSFWorkbook
();
//明细sheet
HSSFSheet
detailsSheet
=
wb
.
createSheet
(
"数据"
);
//给单元格设置样式
CellStyle
cellStyle
=
wb
.
createCellStyle
();
Font
font
=
wb
.
createFont
();
//设置字体大小
font
.
setFontHeightInPoints
((
short
)
12
);
//设置字体加粗
font
.
setBold
(
true
);
//给字体设置样式
cellStyle
.
setFont
(
font
);
//设置单元格背景颜色
cellStyle
.
setFillForegroundColor
(
IndexedColors
.
GREY_25_PERCENT
.
getIndex
());
//设置单元格填充样式(使用纯色背景颜色填充)
cellStyle
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
if
(
CollectionUtils
.
isNotEmpty
(
details
))
{
for
(
int
i
=
0
;
i
<
details
.
size
();
i
++)
{
HSSFRow
row
=
detailsSheet
.
createRow
(
i
);
String
[]
rowData
=
details
.
get
(
i
);
if
(
rowData
!=
null
)
{
for
(
int
j
=
0
;
j
<
rowData
.
length
;
j
++)
{
HSSFCell
cell
=
row
.
createCell
(
j
);
cell
.
setCellValue
(
rowData
[
j
]);
if
(
i
==
0
)
{
// 头部
cell
.
setCellStyle
(
cellStyle
);
//设置列的宽度
detailsSheet
.
setColumnWidth
(
j
,
255
*
20
);
}
}
}
}
}
response
.
setContentType
(
"application/vnd.ms-excel"
);
//文件名称
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename=log.xlsx"
);
wb
.
write
(
outputStream
);
outputStream
.
flush
();
outputStream
.
close
();
}
catch
(
Exception
e
)
{
DataEaseException
.
throwException
(
e
);
}
}
...
...
backend/src/main/resources/i18n/messages_en_US.properties
浏览文件 @
cddde4a4
...
...
@@ -152,5 +152,6 @@ SOURCE_TYPE_DEPT=ORG
SOURCE_TYPE_ROLE
=
ROLE
SOURCE_TYPE_DRIVER
=
DRIVER
SOURCE_TYPE_DRIVER_FILE
=
DRIVER FILE
SOURCE_TYPE_MENU
=
MENU
I18N_DRIVER_NOT_DELETE
=
Drivers in use cannot be deleted
\ No newline at end of file
backend/src/main/resources/i18n/messages_zh_CN.properties
浏览文件 @
cddde4a4
...
...
@@ -150,6 +150,7 @@ SOURCE_TYPE_DEPT=组织
SOURCE_TYPE_ROLE
=
角色
SOURCE_TYPE_DRIVER
=
驱动
SOURCE_TYPE_DRIVER_FILE
=
驱动文件
SOURCE_TYPE_MENU
=
菜单
I18N_OPERATE_TYPE
=
操作类型
I18N_DETAIL
=
操作详情
...
...
backend/src/main/resources/i18n/messages_zh_TW.properties
浏览文件 @
cddde4a4
...
...
@@ -151,5 +151,6 @@ SOURCE_TYPE_DEPT=組織
SOURCE_TYPE_ROLE
=
角色
SOURCE_TYPE_DRIVER
=
驅動
SOURCE_TYPE_DRIVER_FILE
=
驅動文件
SOURCE_TYPE_MENU
=
菜單
I18N_DRIVER_NOT_DELETE
=
使用中的驅動不允許删除
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论