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
57ada7e7
Commit
57ada7e7
authored
Dec 09, 2022
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
群统计
parent
8dd153da
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
14 deletions
+106
-14
GroupChatApiService.java
...c/haoban/manage/api/service/chat/GroupChatApiService.java
+11
-0
GroupChatMapper.java
...aoban/manage/service/dao/mapper/chat/GroupChatMapper.java
+5
-2
GroupChatServiceImpl.java
...anage/service/service/chat/impl/GroupChatServiceImpl.java
+64
-11
GroupChatApiServiceImpl.java
...ervice/service/out/impl/chat/GroupChatApiServiceImpl.java
+13
-0
GroupChatMapper.xml
...ervice/src/main/resources/mapper/chat/GroupChatMapper.xml
+13
-1
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/chat/GroupChatApiService.java
View file @
57ada7e7
...
...
@@ -63,6 +63,17 @@ public interface GroupChatApiService {
* @throws
*/
public
ServiceResponse
<
Void
>
refreshChatInfo
(
Long
groupChatId
);
/**
*
* @Title: refreshChatInfo
* @Description: 刷新群信息,从队列获取
* @author xugh
* @param groupChatId
* @return
* @throws
*/
public
ServiceResponse
<
Void
>
refreshChatInfoFromMQ
(
String
params
);
/**
*
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/chat/GroupChatMapper.java
View file @
57ada7e7
...
...
@@ -29,11 +29,14 @@ public interface GroupChatMapper {
public
void
updateWxChatIdDk
(
@Param
(
"staffId"
)
String
staffId
,
@Param
(
"name"
)
String
name
,
@Param
(
"chatAddTime"
)
Date
chatAddTime
,
@Param
(
"wxChatIdDk"
)
String
wxChatIdDk
);
public
int
updateData
();
public
int
updateData
(
@Param
(
"groupChatId"
)
Long
groupChatId
,
@Param
(
"totalCount"
)
int
totalCount
,
@Param
(
"totalMemberCount"
)
int
totalMemberCount
,
@Param
(
"addMemberCount"
)
int
addMemberCount
,
@Param
(
"addCount"
)
int
addCount
,
@Param
(
"quitCount"
)
int
quitCount
,
@Param
(
"quitMemberCount"
)
int
quitMemberCount
,
@Param
(
"updateType"
)
int
updateType
);
// 更新群状态
public
int
updateChatStatus
(
@Param
(
"groupChatId"
)
Long
groupChatId
,
@Param
(
"chatStatus"
)
int
chatStatus
);
// 更下线
public
int
chatOff
(
@Param
(
"groupChatId"
)
Long
groupChatId
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/chat/impl/GroupChatServiceImpl.java
View file @
57ada7e7
...
...
@@ -17,10 +17,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
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.EntityUtil
;
import
com.gic.commons.util.GICMQClientUtil
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.commons.util.UniqueIdUtils
;
import
com.gic.haoban.manage.api.dto.SecretSettingDTO
;
...
...
@@ -59,6 +61,7 @@ import com.gic.haoban.manage.service.service.chat.GroupChatHmService;
import
com.gic.haoban.manage.service.service.chat.GroupChatService
;
import
com.gic.member.api.dto.MemberDTO
;
import
com.gic.member.api.service.MemberService
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.wechat.api.dto.qywx.chat.FailChatListDTO
;
import
com.gic.wechat.api.dto.qywx.chat.GroupChatDetailDTO
;
import
com.gic.wechat.api.dto.qywx.chat.GroupChatDetailMemberDTO
;
...
...
@@ -105,6 +108,8 @@ public class GroupChatServiceImpl implements GroupChatService {
@Autowired
private
GroupChatHmRelationMapper
groupChatHmRelationMapper
;
private
static
GicMQClient
mqClient
=
GICMQClientUtil
.
getClientInstance
();
// 每次拉取成员数
private
int
pageSize
=
10
;
// 每次拉取群数
...
...
@@ -112,6 +117,16 @@ public class GroupChatServiceImpl implements GroupChatService {
// 群下线成员数
private
int
offNum
=
200
;
private
void
sendMQ
(
String
params
)
{
try
{
mqClient
.
sendCommonMessage
(
"haobanCommonRouter"
,
params
,
"com.gic.haoban.manage.api.service.chat.GroupChatApiService"
,
"refreshChatInfoFromMQ"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送MQ异常"
);
e
.
printStackTrace
();
}
}
@Override
public
void
createChat
(
String
corpid
,
String
wxChatId
)
{
String
wxEnterpriseId
=
this
.
getWxEnterpriesId
(
corpid
);
...
...
@@ -210,11 +225,11 @@ public class GroupChatServiceImpl implements GroupChatService {
@Override
public
void
updateChatEnterpriseId
(
String
wxEnterpriseId
,
String
enterpriseId
,
List
<
Long
>
groupChatIdList
)
{
this
.
groupChatMapper
.
updateChatEnterpriseId
(
wxEnterpriseId
,
enterpriseId
,
groupChatIdList
);
// 更新后重新同步群数据
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"groupChatIdList"
,
groupChatIdList
);
this
.
sendMQ
(
json
.
toJSONString
());
}
@Override
...
...
@@ -454,13 +469,15 @@ public class GroupChatServiceImpl implements GroupChatService {
return
;
}
List
<
GroupChatDetailMemberDTO
>
memberList
=
detail
.
getMember_list
();
if
(
CollectionUtils
.
isNotEmpty
(
memberList
)
&&
memberList
.
size
()
>=
offNum
)
{
int
totalCount
=
memberList
.
size
();
if
(
CollectionUtils
.
isNotEmpty
(
memberList
)
&&
totalCount
>=
offNum
)
{
this
.
chatOff
(
chat
);
}
List
<
TabGroupChatUser
>
userList
=
new
ArrayList
<>();
List
<
TabGroupChatUser
>
allUserList
=
this
.
groupChatUserMapper
.
listAllChatUser
(
wxEnterpriseId
,
groupChatId
);
Map
<
String
,
TabGroupChatUser
>
userMap
=
allUserList
.
stream
()
.
collect
(
Collectors
.
toMap
(
TabGroupChatUser:
:
getUserId
,
o
->
o
,
((
k1
,
k2
)
->
k1
)));
List
<
TabGroupChatUser
>
needAddUserList
=
new
ArrayList
<>();
int
totalMemberCount
=
0
;
for
(
GroupChatDetailMemberDTO
member
:
memberList
)
{
String
userId
=
member
.
getUserid
();
TabGroupChatUser
user
=
userMap
.
get
(
userId
);
...
...
@@ -469,6 +486,9 @@ public class GroupChatServiceImpl implements GroupChatService {
if
(
StringUtils
.
isEmpty
(
user
.
getMemberId
()))
{
this
.
matchGicMember
(
wxEnterpriseId
,
enterpriseId
,
member
.
getUnionid
(),
userId
,
user
);
}
if
(
user
.
getUserType
()
==
3
)
{
totalMemberCount
++;
}
this
.
groupChatUserMapper
.
update
(
user
);
continue
;
}
...
...
@@ -498,12 +518,20 @@ public class GroupChatServiceImpl implements GroupChatService {
}
}
this
.
matchGicMember
(
wxEnterpriseId
,
enterpriseId
,
member
.
getUnionid
(),
userId
,
user
);
userList
.
add
(
user
);
if
(
user
.
getUserType
()
==
3
)
{
totalMemberCount
++;
}
needAddUserList
.
add
(
user
);
}
List
<
String
>
nowUserIdList
=
memberList
.
stream
().
map
(
dto
->
dto
.
getUserid
()).
collect
(
Collectors
.
toList
());
for
(
TabGroupChatUser
item
:
userList
)
{
int
addMemberCount
=
0
;
for
(
TabGroupChatUser
item
:
needAddUserList
)
{
this
.
groupChatUserMapper
.
insert
(
item
);
if
(
item
.
getUserType
()
==
3
)
{
addMemberCount
++;
}
}
int
addCount
=
needAddUserList
.
size
();
// 删除退群的人
List
<
Long
>
deleteIdList
=
new
ArrayList
<>();
for
(
TabGroupChatUser
user
:
allUserList
)
{
...
...
@@ -511,13 +539,29 @@ public class GroupChatServiceImpl implements GroupChatService {
deleteIdList
.
add
(
user
.
getChatUserId
());
}
}
// 流失总数
int
quitCount
=
0
;
// 流水会员数
int
quitMemberCount
=
0
;
if
(
CollectionUtils
.
isNotEmpty
(
deleteIdList
))
{
this
.
groupChatUserMapper
.
dismiss
(
deleteIdList
);
quitCount
=
deleteIdList
.
size
();
for
(
Long
userId
:
deleteIdList
)
{
TabGroupChatUser
user
=
userMap
.
get
(
userId
);
if
(
null
!=
user
&&
user
.
getUserType
()
==
3
)
{
quitMemberCount
++;
}
}
}
int
addNum
=
userList
.
size
();
int
delNum
=
deleteIdList
.
size
();
// 群统计
// this.groupChatMapper.updateData();
this
.
updateDate
(
groupChatId
,
totalCount
,
totalMemberCount
,
addMemberCount
,
addCount
,
quitCount
,
quitMemberCount
,
0
);
}
private
void
updateDate
(
Long
groupChatId
,
int
totalCount
,
int
totalMemberCount
,
int
addMemberCount
,
int
addCount
,
int
quitCount
,
int
quitMemberCount
,
int
updateType
)
{
logger
.
info
(
"更新群的统计"
);
this
.
groupChatMapper
.
updateData
(
groupChatId
,
totalCount
,
totalMemberCount
,
addMemberCount
,
addCount
,
quitCount
,
quitMemberCount
,
updateType
);
}
private
void
saveOwnerHistory
(
String
wxEnterpriseId
,
Long
groupChatId
,
String
newStaffId
,
String
oldStaffId
)
{
...
...
@@ -621,6 +665,15 @@ public class GroupChatServiceImpl implements GroupChatService {
}
}
/**
*
* @Title: saveOwner
* @Description: 新增群主表/更新群主群的数量
* @author xugh
* @param wxEnterpriseId
* @param staffId
* @throws
*/
private
void
saveOwner
(
String
wxEnterpriseId
,
String
staffId
)
{
TabGroupChatOwner
owner
=
this
.
groupChatOwnerMapper
.
selectByStaffId
(
staffId
);
int
chatCount
=
this
.
groupChatMapper
.
getCountByStaffId
(
staffId
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/chat/GroupChatApiServiceImpl.java
View file @
57ada7e7
...
...
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.BasePageInfo
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
...
...
@@ -35,6 +36,8 @@ import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import
com.gic.haoban.manage.service.service.chat.GroupChatService
;
import
com.gic.haoban.manage.service.service.chat.GroupChatUserService
;
import
cn.hutool.json.JSONArray
;
@Service
(
"groupChatApiService"
)
public
class
GroupChatApiServiceImpl
implements
GroupChatApiService
{
...
...
@@ -169,4 +172,14 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
}
return
ServiceResponse
.
success
(
Boolean
.
FALSE
);
}
@Override
public
ServiceResponse
<
Void
>
refreshChatInfoFromMQ
(
String
params
)
{
JSONObject
json
=
JSONObject
.
parseObject
(
params
);
List
<
Long
>
arr
=
json
.
parseArray
(
json
.
getString
(
"groupChatIdList"
),
Long
.
class
);
for
(
Long
id
:
arr
)
{
this
.
refreshChatInfo
(
id
);
}
return
ServiceResponse
.
success
();
}
}
haoban-manage3-service/src/main/resources/mapper/chat/GroupChatMapper.xml
View file @
57ada7e7
...
...
@@ -120,6 +120,18 @@
]]>
</update>
<update
id=
"updateData"
>
update tab_haoban_group_chat set
total_count = #{totalCount} ,
total_member_count = #{totalMemberCount},
add_member_count = #{addMemberCount} + add_member_count ,
add_count = #{addCount} + add_count,
quit_count = #{quitCount} + quit_count,
quit_member_count = #{quitMemberCount} + quit_member_count
where group_chat_id = #{groupChatId}
</update>
<update
id=
"updateWxChatIdDk"
>
update tab_haoban_group_chat set wx_chat_id_dk=#{wxChatIdDk} where staff_id = #{staffId} and chat_add_time=#{chatAddTime} and name=#{name}
</update>
...
...
@@ -231,7 +243,7 @@
</select>
<update
id=
"updateChatEnterpriseId"
>
update tab_haoban_group_chat set enterprise_id = #{enterpriseId} , update_time=now() where wx_enterprise_id=#{wxEnterpriseId}
update tab_haoban_group_chat set enterprise_id = #{enterpriseId} , update_time=now()
, gic_flag = 1
where wx_enterprise_id=#{wxEnterpriseId}
<if
test=
"null != groupChatIdList and groupChatIdList.size > 0"
>
and group_chat_id
<foreach
collection=
"groupChatIdList"
item=
"id"
index=
"index"
separator=
","
open=
"("
close=
")"
>
...
...
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