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
1
Merge Requests
1
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
c5e81803
Commit
c5e81803
authored
Dec 18, 2021
by
墨竹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:批量更新做限流
parent
571543cc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
110 deletions
+18
-110
TabHaobanStaffClerkRelationMapper.java
...service/dao/mapper/TabHaobanStaffClerkRelationMapper.java
+0
-3
ExternalClerkRelatedApiServiceImpl.java
.../service/out/impl/ExternalClerkRelatedApiServiceImpl.java
+17
-4
StaffClerkRelationApiServiceImpl.java
...ce/service/out/impl/StaffClerkRelationApiServiceImpl.java
+0
-16
TabHaobanStaffClerkRelationMapper.xml
...in/resources/mapper/TabHaobanStaffClerkRelationMapper.xml
+1
-87
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/TabHaobanStaffClerkRelationMapper.java
View file @
c5e81803
...
...
@@ -13,13 +13,10 @@ public interface TabHaobanStaffClerkRelationMapper {
int
insert
(
TabHaobanStaffClerkRelation
record
);
int
insertSelective
(
TabHaobanStaffClerkRelation
record
);
TabHaobanStaffClerkRelation
selectByPrimaryKey
(
String
staffClerkRelationId
);
int
updateByPrimaryKeySelective
(
TabHaobanStaffClerkRelation
record
);
int
updateByPrimaryKey
(
TabHaobanStaffClerkRelation
record
);
List
<
TabHaobanStaffClerkRelation
>
listBindCode
(
@Param
(
"enterpriseId"
)
String
enterpriseId
,
@Param
(
"clerkCodeList"
)
Set
<
String
>
clerkCodeList
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/ExternalClerkRelatedApiServiceImpl.java
View file @
c5e81803
...
...
@@ -23,6 +23,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import
com.gic.haoban.manage.service.entity.ext.MemberStaffRelExtDO
;
import
com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.QywxNewExternalUseridDTO
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
com.github.pagehelper.PageHelper
;
...
...
@@ -31,6 +32,9 @@ import org.apache.commons.collections.CollectionUtils;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.redisson.api.RRateLimiter
;
import
org.redisson.api.RateIntervalUnit
;
import
org.redisson.api.RateType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -338,9 +342,18 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
* @date 2021-12-13 15:40:30
*/
private
void
updateNewExUserId
(
String
wxEnterpriseId
,
String
corpid
)
{
// 限流器
RRateLimiter
rateLimiter
=
RedisUtil
.
getRedisClient
().
getRateLimiter
(
"haoban:manage3:updateNewExUserId:limit"
);
// 每1秒产生5个令牌
rateLimiter
.
trySetRate
(
RateType
.
OVERALL
,
5
,
1
,
RateIntervalUnit
.
SECONDS
);
int
pageNum
=
1
;
// 开启消息发送
while
(
true
)
{
// 获取令牌
rateLimiter
.
acquire
();
//企微转换最多支持1000个
PageInfo
<
TabHaobanExternalClerkRelated
>
tabHaobanWxEnterprisePageInfo
=
pageExternalByWxEnterpriseId
(
wxEnterpriseId
,
pageNum
,
1000
);
List
<
TabHaobanExternalClerkRelated
>
enterprisePageInfoList
=
tabHaobanWxEnterprisePageInfo
.
getList
();
if
(
CollectionUtils
.
isEmpty
(
enterprisePageInfoList
))
{
...
...
@@ -348,13 +361,13 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
}
pageNum
++;
List
<
String
>
externalUserIdList
=
enterprisePageInfoList
.
stream
().
map
(
TabHaobanExternalClerkRelated:
:
getExternalUserId
).
collect
(
Collectors
.
toList
());
//更新新的external_user_id
List
<
QywxNewExternalUseridDTO
>
newExternalUserid
=
qywxUserApiService
.
getNewExternalUseridByList
(
corpid
,
config
.
getWxSuiteid
(),
Arrays
.
toString
(
externalUserIdList
.
toArray
()));
if
(
CollectionUtils
.
isEmpty
(
newExternalUserid
))
{
//
查询企微接口,
更新新的external_user_id
List
<
QywxNewExternalUseridDTO
>
newExternalUserid
List
=
qywxUserApiService
.
getNewExternalUseridByList
(
corpid
,
config
.
getWxSuiteid
(),
Arrays
.
toString
(
externalUserIdList
.
toArray
()));
if
(
CollectionUtils
.
isEmpty
(
newExternalUserid
List
))
{
log
.
info
(
"更新新的外部联系人id,查询企业微信接口报错"
);
break
;
}
for
(
QywxNewExternalUseridDTO
qywxNewExternalUseridDTO
:
newExternalUserid
)
{
for
(
QywxNewExternalUseridDTO
qywxNewExternalUseridDTO
:
newExternalUserid
List
)
{
tabHaobanExternalClerkRelatedMapper
.
updateExternalUserIdByOldExternalUserId
(
qywxNewExternalUseridDTO
.
getNewExternalUserid
(),
qywxNewExternalUseridDTO
.
getExternalUserid
(),
wxEnterpriseId
);
}
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffClerkRelationApiServiceImpl.java
View file @
c5e81803
...
...
@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.clerk.api.dto.ClerkDTO
;
import
com.gic.clerk.api.service.ClerkNewService
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.enterprise.api.dto.EnterpriseDTO
;
...
...
@@ -67,9 +66,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
private
WxEnterpriseRelatedService
wxEnterpriseRelatedService
;
@Autowired
private
ClerkNewService
clerkNewService
;
@Autowired
private
StaffService
staffService
;
@Autowired
...
...
@@ -181,7 +177,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
infoDTO
.
setBrandName
(
split
[
1
]);
}
}
// infoDTO.setEnterpriseName(nameMap.get(infoDTO.getEnterpriseId()));
});
return
infoDTOS
;
}
...
...
@@ -372,17 +367,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
logger
.
info
(
"没有关联企业"
);
return
null
;
}
// StaffClerkRelationDTO staffClerkRelationDTO=staffClerkRelatinService.getByClerkIdNoStatus(clerkId);
// if (staffClerkRelationDTO == null) {
// logger.info("导购未绑定");
// return null;
// }
// String clerkCode = staffClerkRelationDTO.getClerkCode();
// StaffClerkRelationDTO relationDTO = staffClerkRelatinService.getOneBindCodeNoStatus(enterpriseId, clerkCode);
// if (null == relationDTO) {
// logger.info("没有解绑信息");
// return null;
// }
Page
<
StaffClerkBindLogDetailDTO
>
retList
=
staffClerkBindLogService
.
pageUnBindLog
(
wxEnterpriseId
,
clerkId
,
enterpriseId
,
optType
,
pageInfo
);
if
(
CollectionUtils
.
isNotEmpty
(
retList
.
getResult
()))
{
retList
.
getResult
().
forEach
(
staffClerkBindLogDetailDTO
->
{
...
...
haoban-manage3-service/src/main/resources/mapper/TabHaobanStaffClerkRelationMapper.xml
View file @
c5e81803
...
...
@@ -40,79 +40,7 @@
#{clerkId,jdbcType=VARCHAR}, #{clerkCode,jdbcType=VARCHAR}, #{statusFlag,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation"
>
insert into tab_haoban_staff_clerk_relation
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"staffClerkRelationId != null"
>
staff_clerk_relation_id,
</if>
<if
test=
"staffId != null"
>
staff_id,
</if>
<if
test=
"wxEnterpriseId != null"
>
wx_enterprise_id,
</if>
<if
test=
"wxUserId != null"
>
wx_user_id,
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id,
</if>
<if
test=
"storeId != null"
>
store_id,
</if>
<if
test=
"clerkId != null"
>
clerk_id,
</if>
<if
test=
"clerkCode != null"
>
clerk_code,
</if>
<if
test=
"statusFlag != null"
>
status_flag,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"staffClerkRelationId != null"
>
#{staffClerkRelationId,jdbcType=VARCHAR},
</if>
<if
test=
"staffId != null"
>
#{staffId,jdbcType=VARCHAR},
</if>
<if
test=
"wxEnterpriseId != null"
>
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if
test=
"wxUserId != null"
>
#{wxUserId,jdbcType=VARCHAR},
</if>
<if
test=
"enterpriseId != null"
>
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if
test=
"storeId != null"
>
#{storeId,jdbcType=VARCHAR},
</if>
<if
test=
"clerkId != null"
>
#{clerkId,jdbcType=VARCHAR},
</if>
<if
test=
"clerkCode != null"
>
#{clerkCode,jdbcType=VARCHAR},
</if>
<if
test=
"statusFlag != null"
>
#{statusFlag,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation"
>
update tab_haoban_staff_clerk_relation
...
...
@@ -150,20 +78,6 @@
</set>
where staff_clerk_relation_id = #{staffClerkRelationId,jdbcType=VARCHAR}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation"
>
update tab_haoban_staff_clerk_relation
set staff_id = #{staffId,jdbcType=VARCHAR},
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
wx_user_id = #{wxUserId,jdbcType=VARCHAR},
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
store_id = #{storeId,jdbcType=VARCHAR},
clerk_id = #{clerkId,jdbcType=VARCHAR},
clerk_code = #{clerkCode,jdbcType=VARCHAR},
status_flag = #{statusFlag,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where staff_clerk_relation_id = #{staffClerkRelationId,jdbcType=VARCHAR}
</update>
<select
id=
"listBindCode"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.String"
>
select
<include
refid=
"Base_Column_List"
/>
...
...
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