Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
79a3ee3c
Commit
79a3ee3c
authored
Jul 19, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改获取用户UUID定时任务
parent
d5d8d741
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
8 deletions
+86
-8
WeChatController.java
...in/java/share/web/controller/system/WeChatController.java
+70
-6
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+16
-2
No files found.
share-front/src/main/java/share/web/controller/system/WeChatController.java
View file @
79a3ee3c
...
...
@@ -5,6 +5,8 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -27,6 +29,8 @@ import share.system.service.WechatNewService;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.IntStream
;
/**
...
...
@@ -38,6 +42,8 @@ import java.util.Map;
@Api
(
tags
=
"微信 -- 开放平台"
)
public
class
WeChatController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
WeChatController
.
class
);
@Autowired
private
SConsumerCenterService
sConsumerCenterService
;
...
...
@@ -123,16 +129,74 @@ public class WeChatController {
@GetMapping
(
"/test"
)
public
void
getWechatUSERList
()
{
// List<String> list = new ArrayList<>();
// List<String> wechatUSERList = wechatNewService.getWechatUSERList(list, "");
// //当wechatUSERList大于100,以100为一批分割,分批获取WechatUsetListInfo的值
// Map<String, String> stringStringMap = new HashMap<>();
// if (wechatUSERList.size() > 100) {
// int i = 0;
// while (i < wechatUSERList.size()) {
// List<String> subList = wechatUSERList.subList(i, i + 100);
// stringStringMap.putAll(wechatNewService.WechatUsetListInfo(subList));
// System.out.println(stringStringMap);
// i = i + 100;
// }
// }
// System.out.println(stringStringMap);
// List<SConsumerToken> sConsumerTokenList = sConsumerTokenService.list(new LambdaQueryWrapper<SConsumerToken>().isNotNull(SConsumerToken::getUnionId).isNull(SConsumerToken::getOpenId));
// sConsumerTokenList.forEach(item -> {
// item.setOpenId(stringStringMap.get(item.getUnionId()));
// sConsumerTokenService.updateById(item);
// });
// System.out.println(sConsumerTokenList);
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
wechatUSERList
=
wechatNewService
.
getWechatUSERList
(
list
,
""
);
Map
<
String
,
String
>
stringStringMap
=
wechatNewService
.
WechatUsetListInfo
(
wechatUSERList
);
System
.
out
.
println
(
stringStringMap
);
List
<
SConsumerToken
>
sConsumerTokenList
=
sConsumerTokenService
.
list
(
new
LambdaQueryWrapper
<
SConsumerToken
>().
isNotNull
(
SConsumerToken:
:
getUnionId
).
isNull
(
SConsumerToken:
:
getOpenId
));
List
<
String
>
wechatUserList
=
new
ArrayList
<>();
try
{
wechatUserList
=
wechatNewService
.
getWechatUSERList
(
list
,
""
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取微信用户列表失败"
,
e
);
return
;
}
Map
<
String
,
String
>
openIdMap
=
new
ConcurrentHashMap
<>();
// 使用IntStream优化分批逻辑,并行处理各批次数据
List
<
String
>
finalWechatUserList
=
wechatUserList
;
IntStream
.
range
(
0
,
(
wechatUserList
.
size
()
+
99
)
/
100
)
.
parallel
()
.
forEach
(
i
->
{
List
<
String
>
subList
=
finalWechatUserList
.
subList
(
i
*
100
,
Math
.
min
((
i
+
1
)
*
100
,
finalWechatUserList
.
size
()));
try
{
openIdMap
.
putAll
(
wechatNewService
.
WechatUsetListInfo
(
subList
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"处理微信用户信息失败"
,
e
);
}
});
logger
.
info
(
"处理后的openIdMap: {}"
,
openIdMap
);
List
<
SConsumerToken
>
sConsumerTokenList
;
try
{
sConsumerTokenList
=
sConsumerTokenService
.
list
(
new
LambdaQueryWrapper
<
SConsumerToken
>()
.
isNotNull
(
SConsumerToken:
:
getUnionId
)
.
isNull
(
SConsumerToken:
:
getOpenId
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取消费者令牌列表失败"
,
e
);
return
;
// 或者根据实际情况进行其他处理
}
sConsumerTokenList
.
forEach
(
item
->
{
item
.
setOpenId
(
stringStringMap
.
get
(
item
.
getUnionId
()));
String
openId
=
openIdMap
.
get
(
item
.
getUnionId
());
if
(
openId
!=
null
)
{
item
.
setOpenId
(
openId
);
try
{
sConsumerTokenService
.
updateById
(
item
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"更新消费者令牌失败"
,
e
);
}
}
});
System
.
out
.
println
(
sConsumerTokenList
);
logger
.
info
(
"更新完成的消费者令牌列表: {}"
,
sConsumerTokenList
);
}
@GetMapping
(
"/test1"
)
...
...
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
79a3ee3c
...
...
@@ -30,8 +30,10 @@ import share.system.service.*;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
@Component
(
"redisTask"
)
public
class
RedisTask
{
...
...
@@ -532,10 +534,22 @@ public class RedisTask {
sConsumerTokenList
=
sConsumerTokenList
.
subList
(
0
,
100
);
}
List
<
String
>
wechatUSERList
=
wechatNewService
.
getWechatUSERList
(
list
,
""
);
Map
<
String
,
String
>
stringStringMap
=
wechatNewService
.
WechatUsetListInfo
(
wechatUSERList
);
Map
<
String
,
String
>
openIdMap
=
new
ConcurrentHashMap
<>();
// 使用IntStream优化分批逻辑,并行处理各批次数据
List
<
String
>
finalWechatUserList
=
wechatUSERList
;
IntStream
.
range
(
0
,
(
wechatUSERList
.
size
()
+
99
)
/
100
)
.
parallel
()
.
forEach
(
i
->
{
List
<
String
>
subList
=
finalWechatUserList
.
subList
(
i
*
100
,
Math
.
min
((
i
+
1
)
*
100
,
finalWechatUserList
.
size
()));
try
{
openIdMap
.
putAll
(
wechatNewService
.
WechatUsetListInfo
(
subList
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"处理微信用户信息失败"
,
e
);
}
});
List
<
SConsumerToken
>
updateList
=
new
ArrayList
<>();
sConsumerTokenList
.
forEach
(
item
->
{
item
.
setOpenId
(
stringString
Map
.
get
(
item
.
getUnionId
()));
item
.
setOpenId
(
openId
Map
.
get
(
item
.
getUnionId
()));
updateList
.
add
(
item
);
});
if
(!
CollectionUtils
.
isEmpty
(
updateList
))
sConsumerTokenService
.
updateBatchById
(
updateList
);
...
...
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