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
d5f001a8
Commit
d5f001a8
authored
Oct 24, 2022
by
李健华
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/wechat-job-sql-optimize-20221024' into 'master'
优化微信定时任务SQL慢查询 See merge request
!101
parents
fe0d68d5
b1f1b7c4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
23 deletions
+32
-23
WechatFollowServiceImpl.java
...oup/xyqb/service/wechat/impl/WechatFollowServiceImpl.java
+32
-23
No files found.
src/main/java/cn/quantgroup/xyqb/service/wechat/impl/WechatFollowServiceImpl.java
View file @
d5f001a8
...
...
@@ -7,6 +7,7 @@ import cn.quantgroup.xyqb.repository.IWeChatInfoRelationRepository;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatFollowService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -96,6 +97,9 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
// 游标值
private
String
cursorValue
=
""
;
// 分组数
private
Integer
groupSize
=
1000
;
@PostConstruct
private
void
init
()
{
// 公众号
...
...
@@ -143,13 +147,16 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
WechatUserListResponse
wechatUserListResponse
=
JSONObject
.
parseObject
(
response
,
WechatUserListResponse
.
class
);
if
(
wechatUserListResponse
.
getErrcode
()
==
null
&&
wechatUserListResponse
.
getCount
()
>
0
)
{
nextOpenId
=
wechatUserListResponse
.
getNext_openid
();
List
<
String
>
opendIdList
=
wechatUserListResponse
.
getData
().
get
(
"openid"
);
if
(!
opendIdList
.
isEmpty
())
{
List
<
String
>
opendIdAllList
=
wechatUserListResponse
.
getData
().
get
(
"openid"
);
if
(!
opendIdAllList
.
isEmpty
())
{
List
<
List
<
String
>>
openIdLists
=
Lists
.
partition
(
opendIdAllList
,
groupSize
);
for
(
List
<
String
>
opendIdList
:
openIdLists
)
{
String
[]
openIds
=
opendIdList
.
toArray
(
new
String
[
0
]);
String
openIdStrs
=
String
.
join
(
"\',\'"
,
openIds
);
openIdStrs
=
"\'"
+
openIdStrs
+
"\'"
;
// 查询微信信息
String
wxSql
=
String
.
format
(
"SELECT `user_id`, `open_id`, `union_id` from wechat_userinfo where app_name='%s' and user_id is not null and `open_id` IN (%s)"
,
WECHAT_XYQB
,
openIdStrs
);
System
.
out
.
println
(
wxSql
);
List
<
Map
<
String
,
Object
>>
wxInfoList
=
jdbcTemplate
.
queryForList
(
wxSql
);
ArrayList
<
Object
[]>
objectArrayList
=
new
ArrayList
<>();
if
(!
wxInfoList
.
isEmpty
())
{
...
...
@@ -166,12 +173,14 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
jdbcTemplate
.
batchUpdate
(
sql
,
objectArrayList
);
long
etime
=
System
.
currentTimeMillis
();
System
.
out
.
printf
(
"执行时间:%d 毫秒"
,
(
etime
-
stime
));
}
}
}
if
(
nextOpenId
!=
""
)
{
executeWechatFollowStatus
(
nextOpenId
,
period
);
}
return
JsonResult
.
buildSuccessResult
(
""
,
opendIdList
);
return
JsonResult
.
buildSuccessResult
(
""
,
opendId
All
List
);
}
else
{
return
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