Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
428a9f2d
Commit
428a9f2d
authored
Feb 25, 2022
by
墨竹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:改为分批
parent
0682cfd8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
QywxClerkSyncOperation.java
...ic/haoban/manage/service/task/QywxClerkSyncOperation.java
+3
-3
TestController.java
.../com/gic/haoban/manage/web/controller/TestController.java
+24
-9
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/QywxClerkSyncOperation.java
View file @
428a9f2d
...
@@ -138,12 +138,12 @@ public class QywxClerkSyncOperation implements BaseSyncOperation {
...
@@ -138,12 +138,12 @@ public class QywxClerkSyncOperation implements BaseSyncOperation {
// 每1秒产生5个令牌
// 每1秒产生5个令牌
rateLimiter
.
trySetRate
(
RateType
.
OVERALL
,
5
,
1
,
RateIntervalUnit
.
SECONDS
);
rateLimiter
.
trySetRate
(
RateType
.
OVERALL
,
5
,
1
,
RateIntervalUnit
.
SECONDS
);
int
pageNum
=
1
;
int
pageNum
=
1
;
while
(
true
){
while
(
true
)
{
// 获取令牌
// 获取令牌
rateLimiter
.
acquire
();
rateLimiter
.
acquire
();
//企微转换最多支持1000个
//企微转换最多支持1000个
//批量处理wx_user_id to wx_open_user_id
//批量处理wx_user_id to wx_open_user_id
Page
<
StaffDTO
>
staffDTOPageInfo
=
pageStaffListByWxEnterpriseId
(
wxEnterpriseId
,
pageNum
,
1000
);
Page
<
StaffDTO
>
staffDTOPageInfo
=
staffApiService
.
listUserIdByWxEnterpriseId
(
wxEnterpriseId
,
pageNum
,
1000
);
List
<
StaffDTO
>
staffDTOS
=
staffDTOPageInfo
.
getResult
();
List
<
StaffDTO
>
staffDTOS
=
staffDTOPageInfo
.
getResult
();
if
(
CollectionUtils
.
isEmpty
(
staffDTOS
))
{
if
(
CollectionUtils
.
isEmpty
(
staffDTOS
))
{
logger
.
info
(
"转换完成,为最后一个"
);
logger
.
info
(
"转换完成,为最后一个"
);
...
@@ -166,7 +166,7 @@ public class QywxClerkSyncOperation implements BaseSyncOperation {
...
@@ -166,7 +166,7 @@ public class QywxClerkSyncOperation implements BaseSyncOperation {
private
Page
<
StaffDTO
>
pageStaffListByWxEnterpriseId
(
String
wxEnterpriseId
,
Integer
pageNum
,
Integer
pageSize
)
{
private
Page
<
StaffDTO
>
pageStaffListByWxEnterpriseId
(
String
wxEnterpriseId
,
Integer
pageNum
,
Integer
pageSize
)
{
return
staffApiService
.
listUserIdByWxEnterpriseId
(
wxEnterpriseId
,
pageNum
,
pageSize
);
return
staffApiService
.
listUserIdByWxEnterpriseId
(
wxEnterpriseId
,
pageNum
,
pageSize
);
}
}
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/TestController.java
View file @
428a9f2d
...
@@ -17,6 +17,9 @@ import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
...
@@ -17,6 +17,9 @@ import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.redisson.api.RRateLimiter
;
import
org.redisson.api.RateIntervalUnit
;
import
org.redisson.api.RateType
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -219,7 +222,7 @@ public class TestController extends WebBaseController {
...
@@ -219,7 +222,7 @@ public class TestController extends WebBaseController {
if
(
wxEnterpriseDTO
==
null
)
{
if
(
wxEnterpriseDTO
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10012
);
return
resultResponse
(
HaoBanErrCode
.
ERR_10012
);
}
}
wxEnterpriseApiService
.
agreeExternalUseridFlag
(
wxEnterpriseDTO
.
getWxEnterpriseId
(),
1
);
wxEnterpriseApiService
.
agreeExternalUseridFlag
(
wxEnterpriseDTO
.
getWxEnterpriseId
(),
1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
else
{
}
else
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
);
return
resultResponse
(
HaoBanErrCode
.
ERR_0
);
...
@@ -249,15 +252,27 @@ public class TestController extends WebBaseController {
...
@@ -249,15 +252,27 @@ public class TestController extends WebBaseController {
*/
*/
@RequestMapping
(
"/useridToOpenuserid"
)
@RequestMapping
(
"/useridToOpenuserid"
)
public
HaobanResponse
useridToOpenuserid
(
String
corpid
,
String
suiteId
,
String
wxEnterpriseId
)
{
public
HaobanResponse
useridToOpenuserid
(
String
corpid
,
String
suiteId
,
String
wxEnterpriseId
)
{
//批量处理wx_user_id to wx_open_user_id
// 限流器
List
<
StaffDTO
>
staffDTOS
=
staffApiService
.
listUserIdByWxEnterpriseId
(
wxEnterpriseId
);
RRateLimiter
rateLimiter
=
RedisUtil
.
getRedisClient
().
getRateLimiter
(
"haoban:manage3:updateWxOpenUserId:limit"
);
logger
.
info
(
"useridToOpenuserid请求:corpid:{}"
,
corpid
);
// 每1秒产生5个令牌
List
<
QywxNewUseridDTO
>
qywxNewUseridDTOS
=
qywxUserApiService
.
useridToOpenuserid
(
corpid
,
suiteId
,
staffDTOS
.
stream
().
map
(
StaffDTO:
:
getWxUserId
).
collect
(
Collectors
.
toList
()));
rateLimiter
.
trySetRate
(
RateType
.
OVERALL
,
5
,
1
,
RateIntervalUnit
.
SECONDS
);
if
(
CollectionUtils
.
isNotEmpty
(
qywxNewUseridDTOS
))
{
int
pageNum
=
1
;
for
(
QywxNewUseridDTO
qywxNewUseridDTO
:
qywxNewUseridDTOS
)
{
while
(
true
)
{
staffApiService
.
updateOpenUserIdsByUserId
(
wxEnterpriseId
,
qywxNewUseridDTO
.
getUserid
(),
qywxNewUseridDTO
.
getOpen_userid
());
rateLimiter
.
acquire
();
//批量处理wx_user_id to wx_open_user_id
Page
<
StaffDTO
>
staffDTOPageInfo
=
staffApiService
.
listUserIdByWxEnterpriseId
(
wxEnterpriseId
,
pageNum
,
1000
);
List
<
StaffDTO
>
staffDTOS
=
staffDTOPageInfo
.
getResult
();
if
(
CollectionUtils
.
isEmpty
(
staffDTOS
))
{
break
;
}
logger
.
info
(
"useridToOpenuserid请求:corpid:{}"
,
corpid
);
List
<
QywxNewUseridDTO
>
qywxNewUseridDTOS
=
qywxUserApiService
.
useridToOpenuserid
(
corpid
,
suiteId
,
staffDTOS
.
stream
().
map
(
StaffDTO:
:
getWxUserId
).
collect
(
Collectors
.
toList
()));
if
(
CollectionUtils
.
isNotEmpty
(
qywxNewUseridDTOS
))
{
for
(
QywxNewUseridDTO
qywxNewUseridDTO
:
qywxNewUseridDTOS
)
{
staffApiService
.
updateOpenUserIdsByUserId
(
wxEnterpriseId
,
qywxNewUseridDTO
.
getUserid
(),
qywxNewUseridDTO
.
getOpen_userid
());
}
}
}
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
qywxNewUseridDTOS
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
}
}
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