Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-web
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj
cloud-web
Commits
b29408b4
Commit
b29408b4
authored
Mar 10, 2026
by
“Kongxiangkun”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
阅读明细导出
parent
655a52de
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
147 additions
and
0 deletions
+147
-0
cloud-web-manage/src/main/java/com/yizhi/application/portal/controller/InformationReadListExport.java
+147
-0
No files found.
cloud-web-manage/src/main/java/com/yizhi/application/portal/controller/InformationReadListExport.java
0 → 100644
View file @
b29408b4
package
com
.
yizhi
.
application
.
portal
.
controller
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.yizhi.core.application.context.RequestContext
;
import
com.yizhi.core.application.context.TaskContext
;
import
com.yizhi.core.application.file.constant.FileConstant
;
import
com.yizhi.core.application.file.task.AbstractDefaultTask
;
import
com.yizhi.core.application.file.util.OssUpload
;
import
com.yizhi.enroll.application.feign.EnrollFeignClient
;
import
com.yizhi.enroll.application.vo.EnrollerParam
;
import
com.yizhi.enroll.application.vo.EnrollerVo
;
import
com.yizhi.site.application.feign.InformationManageFeignClients
;
import
com.yizhi.site.application.vo.domain.InformationReadNumberVo
;
import
com.yizhi.site.application.vo.domain.InformationVo
;
import
com.yizhi.system.application.system.remote.AccountClient
;
import
com.yizhi.system.application.system.remote.OrganizationClient
;
import
com.yizhi.system.application.vo.AccountVO
;
import
com.yizhi.training.application.feign.TrainingProjectClient
;
import
com.yizhi.training.application.vo.domain.TrainingProjectVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* 阅读明细
*/
@Slf4j
@Component
public
class
InformationReadListExport
extends
AbstractDefaultTask
<
String
,
Map
<
String
,
Object
>>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
InformationReadListExport
.
class
);
@Autowired
private
InformationManageFeignClients
informationManageFeignClients
;
@Override
protected
String
execute
(
Map
<
String
,
Object
>
map
)
{
log
.
info
(
"########### 导出阅读明细 开始"
);
String
uploadUrl
=
null
;
try
{
RequestContext
res
=
(
RequestContext
)
map
.
get
(
"res"
);
Long
accountId1
=
res
.
getAccountId
();
Long
siteId
=
res
.
getSiteId
();
Long
companyId
=
res
.
getCompanyId
();
Date
comitTime
=
(
Date
)
map
.
get
(
"comitTime"
);;
Long
taskId
=
(
Long
)
map
.
get
(
"taskId"
);
String
serialNo
=
(
String
)
map
.
get
(
"serialNo"
);
String
taskName
=
(
String
)
map
.
get
(
"taskName"
);
String
userName
=
(
String
)
map
.
get
(
"userName"
);
String
key
=
(
String
)
map
.
get
(
"key"
);
Long
informationId
=
(
Long
)
map
.
get
(
"informationId"
);
Integer
state
=
(
Integer
)
map
.
get
(
"state"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf2
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
TaskContext
taskContext
=
new
TaskContext
(
taskId
,
serialNo
,
taskName
,
accountId1
,
comitTime
,
siteId
,
companyId
);
working
(
taskContext
);
log
.
info
(
"########### 导出阅读明细 开始2"
);
// 根据用户关键字获取用户ID集合
List
<
InformationReadNumberVo
>
list
=
informationManageFeignClients
.
readExport
(
informationId
);
log
.
info
(
"########### 导出阅读明细 开始6"
);
try
{
XSSFWorkbook
wb
=
new
XSSFWorkbook
();
XSSFSheet
sheet
=
wb
.
createSheet
(
"项目报名明细"
);
XSSFRow
row
=
sheet
.
createRow
(
0
);
row
=
sheet
.
createRow
(
0
);
row
.
createCell
(
0
).
setCellValue
(
"用户名"
);
row
.
createCell
(
1
).
setCellValue
(
"姓名"
);
row
.
createCell
(
2
).
setCellValue
(
"所在部门"
);
row
.
createCell
(
3
).
setCellValue
(
"阅读时间"
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
InformationReadNumberVo
informationReadNumberVo
=
list
.
get
(
i
);
row
=
sheet
.
createRow
(
i
+
1
);
row
.
createCell
(
0
).
setCellValue
(
informationReadNumberVo
.
getCreateByName
());
row
.
createCell
(
1
).
setCellValue
(
informationReadNumberVo
.
getFullName
());
row
.
createCell
(
2
).
setCellValue
(
informationReadNumberVo
.
getOrgName
());
row
.
createCell
(
3
).
setCellValue
(
sdf
.
format
(
informationReadNumberVo
.
getCreateTime
()));
}
}
InformationVo
informationView
=
informationManageFeignClients
.
informationView
(
informationId
);
String
fileName
=
informationView
.
getFileName
()
+
"阅读明细"
+
sdf2
.
format
(
comitTime
)
+
".xlsx"
;
// String requestPath = "/Users/dingxiaowei/aaa";
String
requestPath
=
FileConstant
.
SAVE_PATH
;
File
fileDir
=
new
File
(
requestPath
);
if
(!
fileDir
.
exists
())
{
fileDir
.
mkdir
();
}
map
.
put
(
"fileName"
,
fileName
);
String
path
=
requestPath
+
"/"
+
fileName
;
FileOutputStream
os
=
null
;
File
file
=
null
;
try
{
os
=
new
FileOutputStream
(
path
);
wb
.
write
(
os
);
uploadUrl
=
OssUpload
.
upload
(
path
,
fileName
);
file
=
new
File
(
path
);
success
(
taskContext
,
"成功"
,
uploadUrl
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
fail
(
taskContext
,
"阅读明细下载写入过程发生错误"
);
LOGGER
.
error
(
"阅读明细下载写入过程发生错误"
);
}
finally
{
if
(
os
!=
null
)
{
os
.
close
();
}
if
(
wb
!=
null
)
{
wb
.
close
();
}
if
(
file
!=
null
)
{
file
.
delete
();
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
fail
(
taskContext
,
"阅读明细下载出现错误"
);
LOGGER
.
error
(
"阅读明细下载出现错误"
);
}
log
.
info
(
"########### 导出阅读明细 结束 {}"
,
uploadUrl
);
}
catch
(
Exception
e
)
{
log
.
error
(
"导出阅读明细 异常"
);
e
.
printStackTrace
();
}
return
uploadUrl
;
}
}
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