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
e31be430
Commit
e31be430
authored
Aug 14, 2023
by
徐高华
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/订单储值'
parents
21639892
aab35788
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
372 additions
and
275 deletions
+372
-275
DealSyncOperationApiService.java
...aoban/manage/api/service/DealSyncOperationApiService.java
+3
-0
TestController.java
...gic/haoban/manage/web/controller/test/TestController.java
+16
-0
PreDealService.java
...com/gic/haoban/manage/service/service/PreDealService.java
+3
-3
PreDealServiceImpl.java
...aoban/manage/service/service/impl/PreDealServiceImpl.java
+21
-43
DealSyncOperationApiServiceImpl.java
...ice/service/out/impl/DealSyncOperationApiServiceImpl.java
+136
-36
ExternalClerkRelatedApiServiceImpl.java
.../service/out/impl/ExternalClerkRelatedApiServiceImpl.java
+1
-1
MemberUnionidRelatedApiServiceImpl.java
.../service/out/impl/MemberUnionidRelatedApiServiceImpl.java
+5
-2
FriendClerkSyncNewOperation.java
...nage/service/task/friend/FriendClerkSyncNewOperation.java
+26
-61
FriendSyncNewOperation.java
...an/manage/service/task/friend/FriendSyncNewOperation.java
+19
-56
SelfFriendSyncNewOperation.java
...anage/service/task/friend/SelfFriendSyncNewOperation.java
+16
-61
PreDealLogMapper.xml
...e3-service/src/main/resources/mapper/PreDealLogMapper.xml
+12
-12
GroupChatController.java
...aoban/manage/web/controller/chat/GroupChatController.java
+37
-0
GroupChatUserQuitVO.java
...om/gic/haoban/manage/web/vo/chat/GroupChatUserQuitVO.java
+77
-0
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/DealSyncOperationApiService.java
View file @
e31be430
...
...
@@ -209,4 +209,7 @@ public interface DealSyncOperationApiService {
* @param taskId
*/
void
dealTagTask
(
String
wxEnterpriseId
,
String
enterpriseId
,
List
<
String
>
tagIds
,
String
taskId
);
void
taskStatusTimer
(
String
params
)
;
void
staffTaskStatusTimer
(
String
params
)
;
}
haoban-manage3-operation-web/src/main/java/com/gic/haoban/manage/web/controller/test/TestController.java
View file @
e31be430
...
...
@@ -15,6 +15,7 @@ import com.gic.haoban.manage.web.controller.WebBaseController;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.member.tag.api.service.MemberTagImportDealService
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.sharing.core.service.api.service.MqApiService
;
import
com.task.allocation.qo.AllocationTaskQo
;
import
com.task.allocation.qo.TaskAllocationComputed
;
...
...
@@ -263,4 +264,19 @@ public class TestController extends WebBaseController {
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
@RequestMapping
(
"/get-cache"
)
public
Object
getCache
(
String
key
)
{
Object
o
=
RedisUtil
.
getCache
(
key
)
;
return
o
;
}
@RequestMapping
(
"/del-cache"
)
public
Object
delCache
(
String
key
)
{
Object
o
=
RedisUtil
.
getCache
(
key
)
;
if
(
null
!=
o
)
{
RedisUtil
.
delCache
(
key
);
}
return
o
;
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/PreDealService.java
View file @
e31be430
...
...
@@ -92,8 +92,6 @@ public interface PreDealService {
*/
public
int
countByTaskId
(
String
taskId
,
int
dataType
,
int
status
);
public
int
countByTaskId
(
String
taskId
);
/**
* 获取任务数量
*
...
...
@@ -201,5 +199,7 @@ public interface PreDealService {
*/
public
List
<
String
>
listReDataIdByPDataId
(
String
taskId
,
String
pDataId
,
Integer
dataType
);
public
void
addTaskStatusCache
(
String
taskId
)
;
public
void
addTaskStaffStatusCache
(
String
taskId
,
String
staffId
,
int
type
)
;
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/PreDealServiceImpl.java
View file @
e31be430
...
...
@@ -14,6 +14,7 @@ import com.gic.redis.data.util.RedisUtil;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.redisson.api.RSet
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -30,6 +31,9 @@ import java.util.List;
@Service
public
class
PreDealServiceImpl
implements
PreDealService
{
public
static
final
String
HAOBAN_TASK_ID_SET_CACHE
=
"haobanTaskSyncIdSetCache"
;
public
static
final
String
HAOBAN_TASK_STAFF_ID_SET_CACHE
=
"haobanTaskStaffSyncIdSetCache"
;
@Autowired
private
PreDealLogMapper
preDealLogMapper
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PreDealServiceImpl
.
class
);
...
...
@@ -93,16 +97,8 @@ public class PreDealServiceImpl implements PreDealService {
@Override
public
boolean
checkTask
(
String
taskId
,
int
dataType
)
{
String
key
=
taskId
+
"_checkTask"
+
dataType
;
Object
o
=
null
;
//RedisUtil.getCache(key) ;
if
(
null
==
o
)
{
int
i
=
preDealLogMapper
.
checkTask
(
taskId
,
dataType
,
PreDealStatusEnum
.
pre
.
getVal
());
boolean
flag
=
(
i
==
0
)
;
RedisUtil
.
setCache
(
key
,
flag
,
60
*
3
l
);
return
flag
;
}
else
{
return
(
boolean
)
o
;
}
int
i
=
preDealLogMapper
.
checkTask
(
taskId
,
dataType
,
PreDealStatusEnum
.
pre
.
getVal
());
return
(
i
==
0
)
;
}
@Override
...
...
@@ -116,19 +112,6 @@ public class PreDealServiceImpl implements PreDealService {
}
@Override
public
int
countByTaskId
(
String
taskId
)
{
String
key
=
taskId
+
"countByTaskId"
;
Object
o
=
null
;
//RedisUtil.getCache(key) ;
if
(
null
==
o
)
{
int
count
=
this
.
preDealLogMapper
.
countByTaskId
(
taskId
,-
1
,
0
)
;
RedisUtil
.
setCache
(
key
,
count
,
60
*
3
l
);
return
count
;
}
else
{
return
(
int
)
o
;
}
}
@Override
public
int
countExcepAndPreByTaskId
(
String
taskId
,
int
dataType
)
{
return
preDealLogMapper
.
countExcepAndPreByTaskId
(
taskId
,
dataType
);
}
...
...
@@ -192,34 +175,29 @@ public class PreDealServiceImpl implements PreDealService {
@Override
public
boolean
checkFriendTask
(
String
taskId
,
int
dataType
)
{
String
key
=
taskId
+
"_checkFriendTask"
+
dataType
;
Object
o
=
null
;
//RedisUtil.getCache(key) ;
if
(
null
==
o
)
{
int
i
=
preDealLogMapper
.
checkTaskFriend
(
taskId
,
null
,
dataType
);
boolean
flag
=
(
i
==
0
)
;
RedisUtil
.
setCache
(
key
,
flag
,
60
*
3
l
);
return
flag
;
}
else
{
return
(
boolean
)
o
;
}
int
i
=
preDealLogMapper
.
checkTaskFriend
(
taskId
,
null
,
dataType
);
return
(
i
==
0
)
;
}
@Override
public
boolean
checkFriendTaskByPDataId
(
String
taskId
,
String
pDataId
,
int
dataType
)
{
String
key
=
taskId
+
"_checkFriendTaskByPDataId"
+
dataType
;
Object
o
=
null
;
//RedisUtil.getCache(key) ;
if
(
null
==
o
)
{
int
i
=
preDealLogMapper
.
checkTaskFriend
(
taskId
,
pDataId
,
dataType
);
boolean
flag
=
(
i
==
0
)
;
RedisUtil
.
setCache
(
key
,
flag
,
60
*
3
l
);
return
flag
;
}
else
{
return
(
boolean
)
o
;
}
int
i
=
preDealLogMapper
.
checkTaskFriend
(
taskId
,
pDataId
,
dataType
);
return
(
i
==
0
)
;
}
@Override
public
List
<
String
>
listReDataIdByPDataId
(
String
taskId
,
String
pDataId
,
Integer
dataType
)
{
return
preDealLogMapper
.
listReDataIdByPDataId
(
taskId
,
pDataId
,
dataType
);
}
@Override
public
void
addTaskStatusCache
(
String
taskId
){
RSet
<
String
>
set
=
RedisUtil
.
getRedisClient
().
getSet
(
HAOBAN_TASK_ID_SET_CACHE
);
set
.
add
(
taskId
)
;
}
@Override
public
void
addTaskStaffStatusCache
(
String
taskId
,
String
staffId
,
int
type
)
{
String
key
=
taskId
+
"#"
+
staffId
+
"#"
+
type
;
RSet
<
String
>
set
=
RedisUtil
.
getRedisClient
().
getSet
(
HAOBAN_TASK_STAFF_ID_SET_CACHE
);
set
.
add
(
key
)
;
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/DealSyncOperationApiServiceImpl.java
View file @
e31be430
This diff is collapsed.
Click to expand it.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/ExternalClerkRelatedApiServiceImpl.java
View file @
e31be430
...
...
@@ -761,7 +761,7 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
return
;
}
staffList
=
staffList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
log
.
info
(
"
staffList={}"
,
JSON
.
toJSONString
(
staffList
));
log
.
info
(
"
刷新好友,关联导购的staff数={}"
,
staffList
.
size
(
));
for
(
String
staffId
:
staffList
)
{
this
.
dealSyncOperationApiService
.
dealWxFriendClerkSingle
(
taskId
,
staffId
,
staffId
,
wxEnterpriseId
);
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MemberUnionidRelatedApiServiceImpl.java
View file @
e31be430
...
...
@@ -1289,9 +1289,10 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
String
corpid
=
qwDTO
.
getThirdCorpid
();
String
userId
=
""
;
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
wxUserId
,
wxEnterpriseId
);
List
<
String
>
list
=
new
ArrayList
<>();
if
(
staff
==
null
)
{
log
.
error
(
"员工为空,wxUserId:{}"
,
wxUserId
);
return
null
;
return
list
;
}
if
(
qwDTO
.
needOpenUserId3th
())
{
userId
=
staff
.
getWxOpenUseId
();
...
...
@@ -1300,7 +1301,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
}
log
.
info
(
"【获取第三方应用好友】wxEnterpriseId={},userId={}"
,
wxEnterpriseId
,
userId
);
String
wxRes
=
qywxUserApiService
.
listExternalUserid
(
corpid
,
config
.
getWxSuiteid
(),
userId
);
List
<
String
>
list
=
new
ArrayList
<>();
log
.
info
(
"【查询第三方应用】res={}"
,
wxRes
);
if
(
"1"
.
equals
(
wxRes
))
{
log
.
info
(
"代表需要重试"
);
...
...
@@ -1485,6 +1485,9 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
Date
firstTime
=
new
Date
();
if
(
CollectionUtils
.
isNotEmpty
(
memberList
)){
for
(
TabHaobanExternalClerkRelated
a
:
memberList
){
if
(
null
==
a
.
getAddTime
())
{
continue
;
}
Date
addTime
=
new
Date
(
a
.
getAddTime
()
*
1000L
);
if
((
a
.
getStatusFlag
()
==
1
||
a
.
getStatusFlag
()
==
3
||
a
.
getStatusFlag
()
==
4
)
&&
opTime
.
before
(
addTime
)){
opTime
=
addTime
;
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/friend/FriendClerkSyncNewOperation.java
View file @
e31be430
...
...
@@ -50,8 +50,6 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
@Autowired
private
WxEnterpriseService
wxEnterpriseService
;
private
static
final
String
FRIEND_LOCK
=
"haoban_fresh_wx_friend_lock_"
;
private
static
final
String
TRY_AGAIN
=
"haoban_fresh_wx_friend_again_"
;
@Override
...
...
@@ -62,6 +60,7 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
try
{
String
wxEnterpriseId
=
dataPre
.
getWxEnterpriseId
();
String
staffId
=
dataPre
.
getDataId
()
;
this
.
preDealService
.
addTaskStatusCache
(
dataPre
.
getTaskId
());
TabHaobanStaff
staff
=
this
.
staffService
.
selectById
(
staffId
)
;
if
(
null
==
staff
)
{
logger
.
info
(
"staff不存在,staffId={}"
,
staffId
);
...
...
@@ -76,16 +75,14 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
List
<
String
>
selfUserIdList
=
memberUnionidRelatedApiService
.
listSelfExterialList
(
wxEnterpriseId
,
dkWxUserId
);
List
<
String
>
delUserIdList
=
selfUserIdList
;
logger
.
info
(
"selfUserIdList={}"
,
JSONObject
.
toJSONString
(
selfUserIdList
));
if
(
CollectionUtils
.
isEmpty
(
selfUserIdList
))
{
logger
.
info
(
"自建应用调用第三方接口进入重试"
);
if
(
null
==
selfUserIdList
)
{
dealFlag
=
tryAgainToMq
(
dataPre
);
reason
=
"
重试次数过多
"
;
reason
=
"
企微接口失败
"
;
return
;
}
if
(
CollectionUtils
.
isEmpty
(
selfUserIdList
))
{
logger
.
info
(
"该用户无代开外部联系人:{}"
,
JSONObject
.
toJSONString
(
dataPre
));
dealFlag
=
false
;
reason
=
"
该用户没有
外部联系人"
;
reason
=
"
无
外部联系人"
;
return
;
}
String
wxUserId3th
=
staff
.
getWxUserId
()
;
...
...
@@ -94,19 +91,17 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
}
List
<
String
>
userIdList
=
null
;
if
(!
qwDTO
.
isSelf
())
{
//第三方服务商的外部联系人
userIdList
=
memberUnionidRelatedApiService
.
listExterialList
(
wxEnterpriseId
,
wxUserId3th
);
delUserIdList
=
userIdList
;
if
(
CollectionUtils
.
isEmpty
(
selfUserIdList
)
)
{
if
(
null
==
userIdList
)
{
dealFlag
=
tryAgainToMq
(
dataPre
);
reason
=
"
重试次数过多
"
;
reason
=
"
企微接口失败
"
;
logger
.
info
(
"第三方服务商外部联系人调用失败进入重试:{}"
,
dataPre
.
getDataId
());
return
;
}
if
(
CollectionUtils
.
isEmpty
(
userIdList
))
{
logger
.
info
(
"该用户无第三方外部联系人:{}"
,
JSONObject
.
toJSONString
(
dataPre
));
dealFlag
=
false
;
reason
=
"
该用户没有
外部联系人"
;
reason
=
"
无
外部联系人"
;
return
;
}
}
...
...
@@ -158,35 +153,9 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
}
}
/**
* 重试机制
*
* @param dataPre
* @return
*/
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
;
}
@Override
public
void
dealException
(
String
taskId
,
String
dataId
,
String
enterpriseId
,
String
reason
)
{
preDealService
.
updateStatusByDataId
(
taskId
,
dataId
,
PreDealStatusEnum
.
exception
.
getVal
(),
reason
);
checkDepartmentTask
(
taskId
);
}
@Override
...
...
@@ -195,33 +164,10 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
List
<
String
>
dataIds
=
preDealService
.
listReDataIdByPDataId
(
taskId
,
dataId
,
PreDealTypeEnum
.
self_friend
.
getVal
());
logger
.
info
(
"下一步处理的数据:{},dataId={}"
,
JSONObject
.
toJSONString
(
dataIds
)
,
dataId
);
dealDepartmentToMq
(
taskId
,
new
HashSet
<>(
dataIds
),
SyncTaskStatusEnum
.
self_friend_sync
);
checkDepartmentTask
(
taskId
);
}
@Override
public
void
checkDepartmentTask
(
String
taskId
)
{
boolean
b
=
preDealService
.
checkFriendTask
(
taskId
,
PreDealTypeEnum
.
friend_clerk
.
getVal
());
if
(!
b
)
{
return
;
}
logger
.
info
(
"好友同步成功:{}"
,
taskId
);
String
key
=
"haoban_sync_friend_task_"
+
taskId
;
RedisUtil
.
lock
(
key
,
3L
);
TabHaobanSyncTask
syncTask
=
syncTaskService
.
getSyncTask
(
taskId
);
if
(
syncTask
.
getStatusFlag
()
==
SyncTaskStatusEnum
.
compute
.
getVal
()
||
syncTask
.
getStatusFlag
()
==
SyncTaskStatusEnum
.
exception_compute
.
getVal
())
{
logger
.
info
(
"已经处理成功:{}"
,
taskId
);
return
;
}
int
errCount
=
preDealService
.
countByTaskId
(
taskId
,
-
1
,
PreDealStatusEnum
.
exception
.
getVal
());
if
(
errCount
>
0
)
{
syncTaskService
.
updateTaskStatus
(
taskId
,
SyncTaskStatusEnum
.
exception_compute
.
getVal
());
}
else
{
syncTaskService
.
updateTaskStatus
(
taskId
,
SyncTaskStatusEnum
.
compute
.
getVal
());
}
String
staffLockKey
=
FRIEND_LOCK
+
syncTask
.
getAddUser
();
RedisUtil
.
delCache
(
staffLockKey
);
RedisUtil
.
unlock
(
key
);
}
...
...
@@ -252,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 @
e31be430
...
...
@@ -12,6 +12,7 @@ import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import
com.gic.haoban.manage.service.entity.TabHaobanPreDealLog
;
import
com.gic.haoban.manage.service.exception.WxApiLimitException
;
import
com.gic.haoban.manage.service.service.*
;
import
com.gic.haoban.manage.service.service.out.impl.DealSyncOperationApiServiceImpl
;
import
com.gic.haoban.manage.service.task.BaseSyncOperation
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.redis.data.util.RedisUtil
;
...
...
@@ -42,8 +43,6 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
private
MemberUnionidRelatedApiService
memberUnionidRelatedApiService
;
@Autowired
private
SyncTaskService
syncTaskService
;
@Autowired
private
FriendClerkSyncNewOperation
friendClerkSyncNewOperation
;
private
static
final
String
TRY_AGAIN
=
"haoban_fresh_wx_friend_again_"
;
...
...
@@ -123,31 +122,6 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
}
}
/**
* 重试机制
*
* @param dataPre
* @return
*/
private
boolean
tryAgainToMq
(
TabHaobanPreDealLog
dataPre
)
{
logger
.
info
(
"需要重试friend:{}"
,
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
.
friend_sync
);
return
true
;
}
public
void
dealException
(
String
taskId
,
String
dataId
,
String
pDataId
,
String
reason
,
String
relationKey
)
{
preDealService
.
updateFriendStatusByDataId
(
taskId
,
dataId
,
PreDealStatusEnum
.
exception
.
getVal
(),
reason
,
null
,
relationKey
,
PreDealTypeEnum
.
friend
.
getVal
());
checkDepartmentTask
(
taskId
,
pDataId
);
...
...
@@ -171,41 +145,30 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
* @param pDataId
*/
public
void
checkDepartmentTask
(
String
taskId
,
String
pDataId
)
{
//校验是否都已经处理完成
boolean
b
=
preDealService
.
checkFriendTaskByPDataId
(
taskId
,
pDataId
,
PreDealTypeEnum
.
friend
.
getVal
());
if
(!
b
)
{
return
;
}
logger
.
info
(
"同步第三方服务商好友结束:{},{}"
,
taskId
,
pDataId
);
String
key
=
"haoban_sync_third_friend_task_"
+
taskId
+
":"
+
pDataId
;
String
lockKey
=
"haoban_sync_third_friend_task_lock_"
+
taskId
+
":"
+
pDataId
;
RedisUtil
.
lock
(
lockKey
,
3L
);
Object
hasDealCheck
=
RedisUtil
.
getCache
(
key
);
if
(
hasDealCheck
!=
null
)
{
logger
.
info
(
"重复提交结束第三方好友:{}"
,
pDataId
);
RedisUtil
.
unlock
(
lockKey
);
return
;
}
RedisUtil
.
setCache
(
key
,
pDataId
,
30L
,
TimeUnit
.
SECONDS
);
TabHaobanPreDealLog
preDealLog
=
preDealService
.
getByDataId
(
taskId
,
pDataId
,
PreDealTypeEnum
.
friend_clerk
.
getVal
(),
PreDealStatusEnum
.
dealing
.
getVal
());
if
(
preDealLog
!=
null
)
{
preDealService
.
updateStatusByDataId
(
taskId
,
pDataId
,
PreDealTypeEnum
.
friend_clerk
.
getVal
(),
PreDealStatusEnum
.
computed
.
getVal
(),
"成功"
);
this
.
checkDepartmentTask
(
taskId
);
}
RedisUtil
.
unlock
(
lockKey
);
this
.
preDealService
.
addTaskStaffStatusCache
(
taskId
,
pDataId
,
8
);
}
@Override
public
void
checkDepartmentTask
(
String
taskId
)
{
friendClerkSyncNewOperation
.
checkDepartmentTask
(
taskId
);
}
/**
* 放入mq处理部门数据
*
* @param taskId
* @param dealList
*/
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
());
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/friend/SelfFriendSyncNewOperation.java
View file @
e31be430
...
...
@@ -48,8 +48,6 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
@Autowired
private
SyncTaskService
syncTaskService
;
@Autowired
private
FriendClerkSyncNewOperation
friendClerkSyncNewOperation
;
@Autowired
private
WxEnterpriseService
wxEnterpriseService
;
private
static
final
String
TRY_AGAIN
=
"haoban_fresh_wx_friend_again_"
;
...
...
@@ -95,11 +93,11 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
}
//更新状态
this
.
preDealService
.
updateFriendStatusByDataId
(
taskId
,
dataPre
.
getDataId
(),
PreDealStatusEnum
.
computed
.
getVal
(),
reason
,
json
.
toJSONString
(),
relationKey
,
PreDealTypeEnum
.
self_friend
.
getVal
());
dealSuccess
(
taskId
,
dataPre
.
getDataId
(),
null
,
wxEnterpriseId
);
dealSuccess
(
taskId
,
dataPre
.
getDataId
(),
dataPre
.
getpDataId
()
,
wxEnterpriseId
);
}
catch
(
WxApiLimitException
e
)
{
logger
.
info
(
"接口次数限制:{}"
,
JSONObject
.
toJSONString
(
dataPre
));
dealFlag
=
tryAgainToMq
(
dataPre
);
reason
=
"
getCorpSelfExternalUseridInfo
重试次数过多"
;
reason
=
"重试次数过多"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
info
(
"同步失败:{},{}"
,
JSONObject
.
toJSONString
(
dataPre
),
e
);
...
...
@@ -120,18 +118,25 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
}
@Override
public
void
dealSuccess
(
String
taskId
,
String
dataId
,
String
dataContent
,
String
wxEnterpriseId
)
{
TabHaobanPreDealLog
data
=
preDealService
.
getByDataId
(
taskId
,
dataId
,
PreDealTypeEnum
.
self_friend
.
getVal
(),
-
1
);
//校验成功是否都
checkDepartmentTask
(
taskId
,
data
.
getpDataId
());
public
void
dealSuccess
(
String
taskId
,
String
dataId
,
String
pDataId
,
String
wxEnterpriseId
)
{
checkDepartmentTask
(
taskId
,
pDataId
);
}
/**
*
重试机制
*
自定义处理流程
*
* @param
dataPre
* @
return
* @param
taskId
* @
param pDataId
*/
public
void
checkDepartmentTask
(
String
taskId
,
String
pDataId
)
{
this
.
preDealService
.
addTaskStaffStatusCache
(
taskId
,
pDataId
,
7
);
}
@Override
public
void
checkDepartmentTask
(
String
taskId
)
{
}
private
boolean
tryAgainToMq
(
TabHaobanPreDealLog
dataPre
)
{
logger
.
info
(
"需要重试self:{}"
,
dataPre
.
getDataId
());
String
key
=
TRY_AGAIN
+
dataPre
.
getTaskId
()
+
":"
+
dataPre
.
getDataId
();
...
...
@@ -150,55 +155,6 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
dealDepartmentToMq
(
dataPre
.
getTaskId
(),
reTrysIds
,
SyncTaskStatusEnum
.
self_friend_sync
);
return
true
;
}
/**
* 自定义处理流程
*
* @param taskId
* @param pDataId
*/
public
void
checkDepartmentTask
(
String
taskId
,
String
pDataId
)
{
//校验是否都已经处理完成
boolean
b
=
preDealService
.
checkFriendTaskByPDataId
(
taskId
,
pDataId
,
PreDealTypeEnum
.
self_friend
.
getVal
());
if
(!
b
)
{
logger
.
info
(
"校验直接返回"
);
return
;
}
logger
.
info
(
"同步第三方服务商好友开始:{},{}"
,
taskId
,
pDataId
);
String
key
=
"haoban_sync_self_friend_task_"
+
taskId
+
":"
+
pDataId
;
String
lockKey
=
"haoban_sync_self_friend_task_lock_"
+
taskId
+
":"
+
pDataId
;
RedisUtil
.
lock
(
lockKey
,
3L
);
Object
hasDealCheck
=
RedisUtil
.
getCache
(
key
);
if
(
hasDealCheck
!=
null
)
{
logger
.
info
(
"重复提交处理第三方好友:{}"
,
pDataId
);
RedisUtil
.
unlock
(
lockKey
);
return
;
}
RedisUtil
.
setCache
(
key
,
pDataId
,
30L
,
TimeUnit
.
SECONDS
);
List
<
String
>
dataIds
=
preDealService
.
listReDataIdByPDataId
(
taskId
,
pDataId
,
PreDealTypeEnum
.
friend
.
getVal
());
if
(
CollectionUtils
.
isEmpty
(
dataIds
))
{
logger
.
info
(
"第三方的数据为空"
);
//更新父级别
preDealService
.
updateStatusByDataId
(
taskId
,
pDataId
,
PreDealTypeEnum
.
friend_clerk
.
getVal
(),
PreDealStatusEnum
.
computed
.
getVal
(),
"成功"
);
//校验异常
this
.
checkDepartmentTask
(
taskId
);
}
else
{
dealDepartmentToMq
(
taskId
,
new
HashSet
<>(
dataIds
),
SyncTaskStatusEnum
.
friend_sync
);
}
RedisUtil
.
unlock
(
lockKey
);
}
@Override
public
void
checkDepartmentTask
(
String
taskId
)
{
friendClerkSyncNewOperation
.
checkDepartmentTask
(
taskId
);
}
/**
* 放入mq处理部门数据
*
* @param taskId
* @param dealList
*/
private
void
dealDepartmentToMq
(
String
taskId
,
Set
<
String
>
dealList
,
SyncTaskStatusEnum
syncTaskStatusEnum
)
{
//预处理分组任务
syncTaskService
.
updateTaskStatus
(
taskId
,
syncTaskStatusEnum
.
getVal
());
...
...
@@ -219,5 +175,4 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
e
.
printStackTrace
();
}
}
}
haoban-manage3-service/src/main/resources/mapper/PreDealLogMapper.xml
View file @
e31be430
...
...
@@ -257,6 +257,18 @@
and status_flag in(0,3)
</select>
<select
id=
"checkTaskFriend"
resultType=
"Integer"
>
select
count(*)
from tab_haoban_pre_deal_log
where task_id = #{taskId}
<if
test=
"pDataId!=null"
>
and p_data_id=#{pDataId}
</if>
and data_type=#{dataType}
and status_flag in(0,1)
</select>
<select
id=
"listRebuildDepartByTaskId"
resultMap=
"BaseResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
...
...
@@ -365,18 +377,6 @@
and data_type =#{dataType}
</select>
<select
id=
"checkTaskFriend"
resultType=
"Integer"
>
select
count(*)
from tab_haoban_pre_deal_log
where task_id = #{taskId}
<if
test=
"pDataId!=null"
>
and p_data_id=#{pDataId}
</if>
and data_type=#{dataType}
and status_flag in(0,1)
</select>
<select
id=
"listReDataIdByPDataId"
resultType=
"String"
>
select
data_id
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/chat/GroupChatController.java
View file @
e31be430
...
...
@@ -5,6 +5,8 @@ import cn.hutool.core.convert.Convert;
import
com.gic.api.base.commons.BasePageInfo
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.DateUtil
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.ExcelUtils
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.api.service.EnterpriseService
;
...
...
@@ -22,10 +24,12 @@ import com.gic.haoban.manage.api.service.StaffApiService;
import
com.gic.haoban.manage.api.service.chat.GroupChatApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.log.LogRecordUserServiceImpl
;
import
com.gic.haoban.manage.web.vo.chat.GroupChatUserQuitVO
;
import
com.gic.log.record.anno.GicLogRecord
;
import
com.gic.log.record.util.GicLogRecordCategoryEnum
;
import
com.gic.log.record.util.GicLogRecordEvaluationContext
;
import
com.gic.log.record.util.GicLogRecordOptTypeEnum
;
import
org.apache.commons.collections.ArrayStack
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -147,6 +151,39 @@ public class GroupChatController {
return
RestResponse
.
successResult
(
page
.
getResult
());
}
@RequestMapping
(
"user/quit/excel"
)
public
RestResponse
<
Boolean
>
excel
(
HttpServletRequest
request
,
HttpServletResponse
response
,
GroupChatUserSearchQDTO
qdto
,
BasePageInfo
basePageInfo
)
{
ServiceResponse
<
Page
<
GroupChatUserDTO
>>
page
=
this
.
groupChatApiService
.
listUserPage
(
qdto
,
basePageInfo
);
if
(
page
.
isSuccess
()
&&
CollUtil
.
isNotEmpty
(
page
.
getResult
().
getResult
())){
List
<
GroupChatUserQuitVO
>
voList
=
new
ArrayList
<>()
;
for
(
GroupChatUserDTO
dto
:
page
.
getResult
().
getResult
())
{
GroupChatUserQuitVO
vo
=
EntityUtil
.
changeEntityByJSON
(
GroupChatUserQuitVO
.
class
,
dto
)
;
vo
.
setUserQuitTimeExcel
(
DateUtil
.
dateToStr
(
dto
.
getUserQuitTime
(),
"yyyy-MM-dd HH:mm:ss"
));
if
(
dto
.
getUserType
()==
1
)
{
vo
.
setUserTypeExcel
(
"企业成员"
);
}
else
if
(
dto
.
getUserType
()==
2
)
{
vo
.
setUserTypeExcel
(
"外部成员"
);
}
else
{
vo
.
setUserTypeExcel
(
"客户"
);
}
voList
.
add
(
vo
)
;
}
String
fileName
=
"退群记录"
;
List
<
String
>
titleList
=
Arrays
.
asList
(
"群成员"
,
"身份"
,
"群名称"
,
"群主"
,
"退群时间"
);
List
<
String
>
fileList
=
Arrays
.
asList
(
"userName"
,
"userTypeExcel"
,
"chatName"
,
"staffName"
,
"userQuitTimeExcel"
);
try
{
ExcelUtils
.
xls
(
response
,
request
,
fileName
,
voList
,
fileList
,
titleList
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
info
(
"导出失败"
);
}
return
RestResponse
.
successResult
(
true
);
}
return
RestResponse
.
successResult
(
false
);
}
@RequestMapping
(
"detail"
)
public
RestResponse
<
Object
>
detail
(
Long
groupChatId
)
{
if
(
null
==
groupChatId
)
{
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/vo/chat/GroupChatUserQuitVO.java
0 → 100644
View file @
e31be430
package
com
.
gic
.
haoban
.
manage
.
web
.
vo
.
chat
;
import
java.io.Serializable
;
/**
*
* @ClassName: TabHaobanGroupChatUser
* @Description: TODO
* @Author 徐高华
* @Date 2022年11月25日 15:42:52
* @Modify
* @CopyRight
*/
public
class
GroupChatUserQuitVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
21771431486600L
;
/**1企业成员2外部联系人3客户*/
private
String
userTypeExcel
;
/**姓名*/
private
String
userName
;
/**昵称*/
private
String
nickName
;
/**用户退群时间*/
private
String
userQuitTimeExcel
;
private
String
chatName
;
private
String
staffName
;
public
String
getUserTypeExcel
()
{
return
userTypeExcel
;
}
public
void
setUserTypeExcel
(
String
userTypeExcel
)
{
this
.
userTypeExcel
=
userTypeExcel
;
}
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getNickName
()
{
return
nickName
;
}
public
void
setNickName
(
String
nickName
)
{
this
.
nickName
=
nickName
;
}
public
String
getUserQuitTimeExcel
()
{
return
userQuitTimeExcel
;
}
public
void
setUserQuitTimeExcel
(
String
userQuitTimeExcel
)
{
this
.
userQuitTimeExcel
=
userQuitTimeExcel
;
}
public
String
getChatName
()
{
return
chatName
;
}
public
void
setChatName
(
String
chatName
)
{
this
.
chatName
=
chatName
;
}
public
String
getStaffName
()
{
return
staffName
;
}
public
void
setStaffName
(
String
staffName
)
{
this
.
staffName
=
staffName
;
}
}
\ No newline at end of file
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