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
f7b870e2
Commit
f7b870e2
authored
Aug 13, 2023
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重试回退
parent
3ded251e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
5 deletions
+113
-5
MemberUnionidRelatedApiServiceImpl.java
.../service/out/impl/MemberUnionidRelatedApiServiceImpl.java
+2
-2
FriendClerkSyncNewOperation.java
...nage/service/task/friend/FriendClerkSyncNewOperation.java
+32
-2
FriendSyncNewOperation.java
...an/manage/service/task/friend/FriendSyncNewOperation.java
+38
-0
SelfFriendSyncNewOperation.java
...anage/service/task/friend/SelfFriendSyncNewOperation.java
+41
-1
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MemberUnionidRelatedApiServiceImpl.java
View file @
f7b870e2
...
@@ -1289,9 +1289,10 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -1289,9 +1289,10 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
String
corpid
=
qwDTO
.
getThirdCorpid
();
String
corpid
=
qwDTO
.
getThirdCorpid
();
String
userId
=
""
;
String
userId
=
""
;
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
wxUserId
,
wxEnterpriseId
);
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
wxUserId
,
wxEnterpriseId
);
List
<
String
>
list
=
new
ArrayList
<>();
if
(
staff
==
null
)
{
if
(
staff
==
null
)
{
log
.
error
(
"员工为空,wxUserId:{}"
,
wxUserId
);
log
.
error
(
"员工为空,wxUserId:{}"
,
wxUserId
);
return
null
;
return
list
;
}
}
if
(
qwDTO
.
needOpenUserId3th
())
{
if
(
qwDTO
.
needOpenUserId3th
())
{
userId
=
staff
.
getWxOpenUseId
();
userId
=
staff
.
getWxOpenUseId
();
...
@@ -1300,7 +1301,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -1300,7 +1301,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
}
}
log
.
info
(
"【获取第三方应用好友】wxEnterpriseId={},userId={}"
,
wxEnterpriseId
,
userId
);
log
.
info
(
"【获取第三方应用好友】wxEnterpriseId={},userId={}"
,
wxEnterpriseId
,
userId
);
String
wxRes
=
qywxUserApiService
.
listExternalUserid
(
corpid
,
config
.
getWxSuiteid
(),
userId
);
String
wxRes
=
qywxUserApiService
.
listExternalUserid
(
corpid
,
config
.
getWxSuiteid
(),
userId
);
List
<
String
>
list
=
new
ArrayList
<>();
log
.
info
(
"【查询第三方应用】res={}"
,
wxRes
);
log
.
info
(
"【查询第三方应用】res={}"
,
wxRes
);
if
(
"1"
.
equals
(
wxRes
))
{
if
(
"1"
.
equals
(
wxRes
))
{
log
.
info
(
"代表需要重试"
);
log
.
info
(
"代表需要重试"
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/friend/FriendClerkSyncNewOperation.java
View file @
f7b870e2
...
@@ -75,9 +75,14 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
...
@@ -75,9 +75,14 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
List
<
String
>
selfUserIdList
=
memberUnionidRelatedApiService
.
listSelfExterialList
(
wxEnterpriseId
,
dkWxUserId
);
List
<
String
>
selfUserIdList
=
memberUnionidRelatedApiService
.
listSelfExterialList
(
wxEnterpriseId
,
dkWxUserId
);
List
<
String
>
delUserIdList
=
selfUserIdList
;
List
<
String
>
delUserIdList
=
selfUserIdList
;
logger
.
info
(
"selfUserIdList={}"
,
JSONObject
.
toJSONString
(
selfUserIdList
));
logger
.
info
(
"selfUserIdList={}"
,
JSONObject
.
toJSONString
(
selfUserIdList
));
if
(
null
==
selfUserIdList
)
{
dealFlag
=
tryAgainToMq
(
dataPre
);
reason
=
"企微接口失败"
;
return
;
}
if
(
CollectionUtils
.
isEmpty
(
selfUserIdList
))
{
if
(
CollectionUtils
.
isEmpty
(
selfUserIdList
))
{
dealFlag
=
false
;
dealFlag
=
false
;
reason
=
"无外部联系人
/接口失败
"
;
reason
=
"无外部联系人"
;
return
;
return
;
}
}
String
wxUserId3th
=
staff
.
getWxUserId
()
;
String
wxUserId3th
=
staff
.
getWxUserId
()
;
...
@@ -88,9 +93,15 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
...
@@ -88,9 +93,15 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
if
(!
qwDTO
.
isSelf
())
{
if
(!
qwDTO
.
isSelf
())
{
userIdList
=
memberUnionidRelatedApiService
.
listExterialList
(
wxEnterpriseId
,
wxUserId3th
);
userIdList
=
memberUnionidRelatedApiService
.
listExterialList
(
wxEnterpriseId
,
wxUserId3th
);
delUserIdList
=
userIdList
;
delUserIdList
=
userIdList
;
if
(
null
==
userIdList
)
{
dealFlag
=
tryAgainToMq
(
dataPre
);
reason
=
"企微接口失败"
;
logger
.
info
(
"第三方服务商外部联系人调用失败进入重试:{}"
,
dataPre
.
getDataId
());
return
;
}
if
(
CollectionUtils
.
isEmpty
(
userIdList
))
{
if
(
CollectionUtils
.
isEmpty
(
userIdList
))
{
dealFlag
=
false
;
dealFlag
=
false
;
reason
=
"无外部联系人
/接口失败
"
;
reason
=
"无外部联系人"
;
return
;
return
;
}
}
}
}
...
@@ -187,4 +198,23 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
...
@@ -187,4 +198,23 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
}
}
}
}
private
boolean
tryAgainToMq
(
TabHaobanPreDealLog
dataPre
)
{
logger
.
info
(
"需要重试:{}"
,
dataPre
.
getDataId
());
String
key
=
TRY_AGAIN
+
dataPre
.
getTaskId
()
+
":"
+
dataPre
.
getDataId
();
Object
cache
=
RedisUtil
.
getCache
(
key
);
if
(
null
==
cache
)
{
RedisUtil
.
setCache
(
key
,
1
,
2L
,
TimeUnit
.
HOURS
);
}
else
{
int
count
=
Integer
.
parseInt
(
cache
.
toString
());
RedisUtil
.
setCache
(
key
,
count
+
1
);
if
(
count
>
4
)
{
return
false
;
}
}
HashSet
<
String
>
reTrysIds
=
new
HashSet
<>();
reTrysIds
.
add
(
dataPre
.
getDataId
());
dealDepartmentToMq
(
dataPre
.
getTaskId
(),
reTrysIds
,
SyncTaskStatusEnum
.
friend_clerk_sync
);
return
true
;
}
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/friend/FriendSyncNewOperation.java
View file @
f7b870e2
...
@@ -108,6 +108,7 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
...
@@ -108,6 +108,7 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
dealSuccess
(
taskId
,
dataPre
.
getDataId
(),
dataPre
.
getpDataId
(),
wxEnterpriseId
);
dealSuccess
(
taskId
,
dataPre
.
getDataId
(),
dataPre
.
getpDataId
(),
wxEnterpriseId
);
}
catch
(
WxApiLimitException
e
)
{
}
catch
(
WxApiLimitException
e
)
{
logger
.
info
(
"接口次数限制:{}"
,
JSONObject
.
toJSONString
(
dataPre
));
logger
.
info
(
"接口次数限制:{}"
,
JSONObject
.
toJSONString
(
dataPre
));
dealFlag
=
tryAgainToMq
(
dataPre
);
reason
=
"接口重试超出限制"
;
reason
=
"接口重试超出限制"
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -150,4 +151,41 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
...
@@ -150,4 +151,41 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
@Override
@Override
public
void
checkDepartmentTask
(
String
taskId
)
{
public
void
checkDepartmentTask
(
String
taskId
)
{
}
}
private
boolean
tryAgainToMq
(
TabHaobanPreDealLog
dataPre
)
{
String
key
=
TRY_AGAIN
+
dataPre
.
getTaskId
()
+
":"
+
dataPre
.
getDataId
();
Object
cache
=
RedisUtil
.
getCache
(
key
);
if
(
null
==
cache
)
{
RedisUtil
.
setCache
(
key
,
1
,
2L
,
TimeUnit
.
HOURS
);
}
else
{
Integer
count
=
Integer
.
valueOf
(
cache
.
toString
());
RedisUtil
.
setCache
(
key
,
count
+
1
);
if
(
count
>
4
)
{
return
false
;
}
}
HashSet
<
String
>
reTrysIds
=
new
HashSet
<>();
reTrysIds
.
add
(
dataPre
.
getDataId
());
dealDepartmentToMq
(
dataPre
.
getTaskId
(),
reTrysIds
,
SyncTaskStatusEnum
.
friend_sync
);
return
true
;
}
private
void
dealDepartmentToMq
(
String
taskId
,
Set
<
String
>
dealList
,
SyncTaskStatusEnum
syncTaskStatusEnum
)
{
//预处理分组任务
syncTaskService
.
updateTaskStatus
(
taskId
,
syncTaskStatusEnum
.
getVal
());
List
<
String
>
ret
=
dealList
.
stream
().
map
(
relationId
->
{
DealParamMqDTO
dealParamMqDTO
=
new
DealParamMqDTO
();
dealParamMqDTO
.
setData
(
relationId
);
dealParamMqDTO
.
setTaskId
(
taskId
);
dealParamMqDTO
.
setType
(
syncTaskStatusEnum
.
getVal
());
return
JSONObject
.
toJSONString
(
dealParamMqDTO
);
}).
collect
(
Collectors
.
toList
());
GicMQClient
clientInstance
=
GICMQClientUtil
.
getClientInstance
();
try
{
clientInstance
.
sendBatchMessages
(
"departmentSyncDealMq"
,
ret
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"发送失败:{}"
,
taskId
,
e
);
e
.
printStackTrace
();
}
}
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/friend/SelfFriendSyncNewOperation.java
View file @
f7b870e2
...
@@ -96,7 +96,8 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
...
@@ -96,7 +96,8 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
dealSuccess
(
taskId
,
dataPre
.
getDataId
(),
dataPre
.
getpDataId
(),
wxEnterpriseId
);
dealSuccess
(
taskId
,
dataPre
.
getDataId
(),
dataPre
.
getpDataId
(),
wxEnterpriseId
);
}
catch
(
WxApiLimitException
e
)
{
}
catch
(
WxApiLimitException
e
)
{
logger
.
info
(
"接口次数限制:{}"
,
JSONObject
.
toJSONString
(
dataPre
));
logger
.
info
(
"接口次数限制:{}"
,
JSONObject
.
toJSONString
(
dataPre
));
reason
=
"getCorpSelfExternalUseridInfo重试次数过多"
;
dealFlag
=
tryAgainToMq
(
dataPre
);
reason
=
"重试次数过多"
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
logger
.
info
(
"同步失败:{},{}"
,
JSONObject
.
toJSONString
(
dataPre
),
e
);
logger
.
info
(
"同步失败:{},{}"
,
JSONObject
.
toJSONString
(
dataPre
),
e
);
...
@@ -135,4 +136,43 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
...
@@ -135,4 +136,43 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
@Override
@Override
public
void
checkDepartmentTask
(
String
taskId
)
{
public
void
checkDepartmentTask
(
String
taskId
)
{
}
}
private
boolean
tryAgainToMq
(
TabHaobanPreDealLog
dataPre
)
{
logger
.
info
(
"需要重试self:{}"
,
dataPre
.
getDataId
());
String
key
=
TRY_AGAIN
+
dataPre
.
getTaskId
()
+
":"
+
dataPre
.
getDataId
();
Object
cache
=
RedisUtil
.
getCache
(
key
);
if
(
null
==
cache
)
{
RedisUtil
.
setCache
(
key
,
1
,
2L
,
TimeUnit
.
HOURS
);
}
else
{
Integer
count
=
Integer
.
valueOf
(
cache
.
toString
());
RedisUtil
.
setCache
(
key
,
count
+
1
);
if
(
count
>
4
)
{
return
false
;
}
}
HashSet
<
String
>
reTrysIds
=
new
HashSet
<>();
reTrysIds
.
add
(
dataPre
.
getDataId
());
dealDepartmentToMq
(
dataPre
.
getTaskId
(),
reTrysIds
,
SyncTaskStatusEnum
.
self_friend_sync
);
return
true
;
}
private
void
dealDepartmentToMq
(
String
taskId
,
Set
<
String
>
dealList
,
SyncTaskStatusEnum
syncTaskStatusEnum
)
{
//预处理分组任务
syncTaskService
.
updateTaskStatus
(
taskId
,
syncTaskStatusEnum
.
getVal
());
List
<
String
>
ret
=
dealList
.
stream
().
map
(
relationId
->
{
DealParamMqDTO
dealParamMqDTO
=
new
DealParamMqDTO
();
dealParamMqDTO
.
setData
(
relationId
);
dealParamMqDTO
.
setTaskId
(
taskId
);
dealParamMqDTO
.
setType
(
syncTaskStatusEnum
.
getVal
());
return
JSONObject
.
toJSONString
(
dealParamMqDTO
);
}).
collect
(
Collectors
.
toList
());
GicMQClient
clientInstance
=
GICMQClientUtil
.
getClientInstance
();
try
{
Log
.
info
(
"发送队列SelfFriendSyncNewOperation={}"
,
JSON
.
toJSONString
(
ret
));
clientInstance
.
sendBatchMessages
(
"departmentSyncDealMq2"
,
ret
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"发送失败:{},{}"
,
taskId
);
e
.
printStackTrace
();
}
}
}
}
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