Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
2afe7deb
Commit
2afe7deb
authored
Jul 30, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决运营系统导出用户信息操作频繁时,并发下载出错的问题
parent
6d32f1c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
50 deletions
+34
-50
UserQueryLogController.java
.../controller/external/querylog/UserQueryLogController.java
+34
-50
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/querylog/UserQueryLogController.java
View file @
2afe7deb
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
querylog
;
import
java.io.OutputStream
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.google.gson.*
;
import
io.swagger.annotations.ApiOperation
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.entity.Address
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
...
...
@@ -15,24 +38,6 @@ import cn.quantgroup.xyqb.util.IdcardValidator;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
cn.quantgroup.xyqb.util.encrypt.MD5Util
;
import
cn.quantgroup.xyqb.util.encrypt.RSA
;
import
com.google.gson.*
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.OutputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* Created by zenglibin on 17/06/13.
...
...
@@ -321,11 +326,6 @@ public class UserQueryLogController {
LOGGER
.
info
(
"签名校验失败!"
);
}
}
// else{
// phonesMap.put("errorMsg",obj.get("msg").getAsString());
// LOGGER.info("从支付中心接口返回data为null");
// }
}
catch
(
Exception
e
)
{
phonesMap
.
put
(
"errorMsg"
,
"查询银行卡信息接口返回解析异常"
);
LOGGER
.
info
(
"查询银行卡信息接口返回解析异常"
);
...
...
@@ -336,8 +336,6 @@ public class UserQueryLogController {
@RequestMapping
(
"/exportUserInfo"
)
@ApiOperation
(
value
=
"给运营系统提供的导出用户信息的接口"
,
notes
=
"给运营系统提供的导出用户信息的接口"
,
httpMethod
=
"POST"
)
public
JsonResult
exportExcel
(
final
HttpServletResponse
response
,
HttpServletRequest
request
,
String
key
,
String
keyValues
,
String
columns
)
{
String
token
=
request
.
getHeader
(
Constants
.
X_AUTH_TOKEN
);
if
(
StringUtils
.
isEmpty
(
token
))
{
LOGGER
.
info
(
"token为空,非法查询"
);
...
...
@@ -354,16 +352,12 @@ public class UserQueryLogController {
}
List
<
UserQueryInfo
>
uqls
=
new
ArrayList
<>();
String
[]
values
=
keyValues
.
split
(
";"
);
List
<
String
>
queryV
=
Arrays
.
asList
(
values
);
if
(
queryV
!=
null
&&
queryV
.
size
()
>
3000
)
{
return
JsonResult
.
buildErrorStateResult
(
"查询记录数是"
+
queryV
.
size
()
+
",超过3000条限制"
,
null
);
}
//如果维度里面没有保护查询条件则加入条件
if
(!
columns
.
contains
(
key
))
{
columns
=
columns
+
","
+
key
;
...
...
@@ -406,7 +400,6 @@ public class UserQueryLogController {
userDetails
=
userDetailService
.
findByIdnos
(
queryV
);
}
if
(
columns
.
contains
(
"bankCard"
))
{
//需加银行卡信息
if
(
key
.
equals
(
Constants
.
PHONE_NO
))
{
...
...
@@ -457,16 +450,6 @@ public class UserQueryLogController {
}
// //不保存记录
// UserQueryLog log=new UserQueryLog();
// log.setQueryItems(columns.replace("userId","用户ID").replace(Constants.PHONE_NO,"手机号").replace("idNo","身份证号").replace("bankCard","银行卡号").replace("address","地址"));
// log.setResultAmount(Long.valueOf(userDetails.size()));
// //转换存储
// log.setQueryCondition(key.replace("userId","用户ID").replace(Constants.PHONE_NO,"手机号").replace("idNo","身份证号"));
// log.setQueryDetail(keyValues.replace("\n",";"));
// log.setLoginUserName(userName);
// userQueryLogService.save(log);
HSSFWorkbook
wb
=
new
HSSFWorkbook
();
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
HSSFSheet
sheet
=
wb
.
createSheet
(
"用户信息列表"
);
...
...
@@ -474,7 +457,8 @@ public class UserQueryLogController {
HSSFRow
row
=
sheet
.
createRow
(
0
);
// 第四步,创建单元格,并设置值表头 设置表头居中
HSSFCellStyle
style
=
wb
.
createCellStyle
();
style
.
setAlignment
(
HSSFCellStyle
.
ALIGN_CENTER
);
// 创建一个居中格式
// 创建一个居中格式
style
.
setAlignment
(
HSSFCellStyle
.
ALIGN_CENTER
);
HSSFCell
cell
=
row
.
createCell
(
0
);
cell
.
setCellValue
(
"userId"
);
...
...
@@ -496,7 +480,6 @@ public class UserQueryLogController {
cell
.
setCellStyle
(
style
);
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
//List list = CreateSimpleExcelToDisk.getStudent();
for
(
int
i
=
0
;
i
<
uqls
.
size
();
i
++)
{
row
=
sheet
.
createRow
(
i
+
1
);
...
...
@@ -505,7 +488,7 @@ public class UserQueryLogController {
if
(
user
!=
null
&&
row
!=
null
)
{
HSSFCell
cell0
=
row
.
createCell
(
0
);
if
(
cell0
!=
null
)
{
cell0
.
setCellValue
(
user
.
getUserId
()
==
null
?
" "
:
String
.
valueOf
(
user
.
getUserId
()));
//user.getUserId()==null?" ":String.valueOf(user.getUserId())
cell0
.
setCellValue
(
user
.
getUserId
()
==
null
?
" "
:
String
.
valueOf
(
user
.
getUserId
()));
}
HSSFCell
cell1
=
row
.
createCell
(
1
);
...
...
@@ -535,18 +518,19 @@ public class UserQueryLogController {
}
}
// 第六步,将文件存到指定位置
try
{
OutputStream
output
=
response
.
getOutputStream
();
/*
* 第六步,将文件存到指定位置
* 采用时间戳命名方式,避免同主机出现并发同名文件冲突引起的文件流被动关闭现象
*/
try
(
OutputStream
output
=
response
.
getOutputStream
()){
String
filename
=
"users-"
.
concat
(
LocalDateTime
.
now
().
toString
()).
concat
(
".xlsx"
);
response
.
reset
();
response
.
setHeader
(
"Content-disposition"
,
"attachment; filename=
users.xlsx"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment; filename=
"
.
concat
(
filename
)
);
response
.
setContentType
(
"application/vnd.ms-excel;charset=utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
wb
.
write
(
output
);
output
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOGGER
.
error
(
"解析运营系统用户token返回结果resultStr异常"
,
e
);
}
return
JsonResult
.
buildSuccessResult
(
"导出成功"
,
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