Commit 0064db1a by 徐高华

社群

parent 7a8cc640
...@@ -5,6 +5,10 @@ import com.gic.haoban.manage.api.dto.chat.ChatEventDTO; ...@@ -5,6 +5,10 @@ import com.gic.haoban.manage.api.dto.chat.ChatEventDTO;
public interface GroupChatApiService { public interface GroupChatApiService {
// 群列表
// 群详情
/** /**
* *
* @Title: qwEventNotice * @Title: qwEventNotice
......
package com.gic.haoban.manage.service.service.chat.impl; package com.gic.haoban.manage.service.service.chat.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -64,6 +65,10 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -64,6 +65,10 @@ public class GroupChatServiceImpl implements GroupChatService {
private SecretSettingService secretSettingService; private SecretSettingService secretSettingService;
@Autowired @Autowired
private ChatNoticeMapper chatNoticeMapper; private ChatNoticeMapper chatNoticeMapper;
// 每次拉取成员数
private int pageSize = 10;
// 每次拉取群数
private int limit = 1;
@Override @Override
public void createChat(String corpid, String wxChatId) { public void createChat(String corpid, String wxChatId) {
...@@ -133,7 +138,7 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -133,7 +138,7 @@ public class GroupChatServiceImpl implements GroupChatService {
this.updateGroupChatDetail(qwDTO, groupChatId, false); this.updateGroupChatDetail(qwDTO, groupChatId, false);
} }
if (type == 2) { if (type == 2) {
this.updateChatStatus(qwDTO, groupChatId);
} }
if (type == 3) { if (type == 3) {
this.updateGroupChatDetail(qwDTO, groupChatId, true); this.updateGroupChatDetail(qwDTO, groupChatId, true);
...@@ -141,6 +146,33 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -141,6 +146,33 @@ public class GroupChatServiceImpl implements GroupChatService {
} }
} }
// 更新群状态
public void updateChatStatus(WxEnterpriseQwDTO qwDTO, Long groupChatId) {
TabGroupChat chat = this.groupChatMapper.selectById(groupChatId);
if (null == chat) {
logger.info("群主变更事件,群不存在");
return;
}
String staffId = chat.getStaffId();
if (StringUtils.isBlank(staffId)) {
logger.info("群主staffid不存在,groupChatId={}", groupChatId);
return;
}
TabHaobanStaff staff = this.staffMapper.selectByPrimaryKey(staffId);
if (null == staff) {
logger.info("群主已删除,staffid={}", staffId);
return;
}
String userId = staff.getWxUserId();
if (qwDTO.needOpenUserIdDk()) {
userId = staff.getWxOpenUseId();
}
this.syncGroupChat(qwDTO, Arrays.asList(userId), null, false);
}
/**
* 初始化整个群数据,拉取所有成员的所有群,并立即获取群信息、群成员、同时也会匹配客户标识
*/
@Override @Override
public void initEnterpriseGroupChat(String wxEnterpriseId) { public void initEnterpriseGroupChat(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
...@@ -149,7 +181,6 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -149,7 +181,6 @@ public class GroupChatServiceImpl implements GroupChatService {
return; return;
} }
int pageNum = 0; int pageNum = 0;
int pageSize = 10;
while (true) { while (true) {
List<TabHaobanStaff> staffList = this.staffMapper.listAllByPage(wxEnterpriseId, pageNum * pageSize, List<TabHaobanStaff> staffList = this.staffMapper.listAllByPage(wxEnterpriseId, pageNum * pageSize,
pageSize); pageSize);
...@@ -166,16 +197,16 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -166,16 +197,16 @@ public class GroupChatServiceImpl implements GroupChatService {
.map(dto -> dto.getWxUserId()).collect(Collectors.toList()); .map(dto -> dto.getWxUserId()).collect(Collectors.toList());
} }
if (CollectionUtils.isNotEmpty(userIdList)) { if (CollectionUtils.isNotEmpty(userIdList)) {
this.syncGroupChat(qwDTO, userIdList, null); this.syncGroupChat(qwDTO, userIdList, null, true);
} }
pageNum++; pageNum++;
} }
} }
// 同步成员的群 // 同步成员的群
private void syncGroupChat(WxEnterpriseQwDTO qwDTO, List<String> userIdList, String cursor) { private void syncGroupChat(WxEnterpriseQwDTO qwDTO, List<String> userIdList, String cursor,
boolean syncDetailFlag) {
logger.info("qwDTO={},idlist={},cursor={}", JSON.toJSONString(qwDTO), JSON.toJSONString(userIdList), cursor); logger.info("qwDTO={},idlist={},cursor={}", JSON.toJSONString(qwDTO), JSON.toJSONString(userIdList), cursor);
int limit = 1;
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(),
SecretTypeEnum.CUSTOMIZED_APP.getVal()); SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting) { if (null == secretSetting) {
...@@ -194,10 +225,11 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -194,10 +225,11 @@ public class GroupChatServiceImpl implements GroupChatService {
for (GroupChatListItemDTO item : list) { for (GroupChatListItemDTO item : list) {
String wxChatId = item.getChat_id(); String wxChatId = item.getChat_id();
int chatStatus = item.getStatus(); int chatStatus = item.getStatus();
this.insertGroupChat(qwDTO, wxChatId, chatStatus, true); this.insertGroupChat(qwDTO, wxChatId, chatStatus, syncDetailFlag);
} }
// 从企微拉取下一批数据
if (org.apache.commons.lang3.StringUtils.isNotBlank(cursor)) { if (org.apache.commons.lang3.StringUtils.isNotBlank(cursor)) {
this.syncGroupChat(qwDTO, userIdList, cursor); this.syncGroupChat(qwDTO, userIdList, cursor, syncDetailFlag);
} }
} }
...@@ -208,6 +240,7 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -208,6 +240,7 @@ public class GroupChatServiceImpl implements GroupChatService {
if (null != groupChat) { if (null != groupChat) {
groupChatId = groupChat.getGroupChatId(); groupChatId = groupChat.getGroupChatId();
logger.info("群已存在,chatid={},groupChatId={}", wxChatId, groupChatId); logger.info("群已存在,chatid={},groupChatId={}", wxChatId, groupChatId);
this.groupChatMapper.updateChatStatus(groupChatId, chatStatus) ;
} else { } else {
groupChatId = UniqueIdUtils.uniqueLong(); groupChatId = UniqueIdUtils.uniqueLong();
TabGroupChat chat = new TabGroupChat(); TabGroupChat chat = new TabGroupChat();
...@@ -232,7 +265,7 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -232,7 +265,7 @@ public class GroupChatServiceImpl implements GroupChatService {
} }
} }
private void initGroupChatDetail(WxEnterpriseQwDTO qwDTO, TabGroupChat chat, boolean syncMember) { private void updateGroupChatDetail(WxEnterpriseQwDTO qwDTO, TabGroupChat chat, boolean syncMember) {
// 控制同时刷新 // 控制同时刷新
Long groupChatId = chat.getGroupChatId(); Long groupChatId = chat.getGroupChatId();
String wxEnterpriseId = chat.getWxEnterpriseId(); String wxEnterpriseId = chat.getWxEnterpriseId();
...@@ -323,7 +356,7 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -323,7 +356,7 @@ public class GroupChatServiceImpl implements GroupChatService {
// 初始化群信息-不包括群状态 // 初始化群信息-不包括群状态
private void updateGroupChatDetail(WxEnterpriseQwDTO qwDTO, Long groupChatId, boolean syncMember) { private void updateGroupChatDetail(WxEnterpriseQwDTO qwDTO, Long groupChatId, boolean syncMember) {
TabGroupChat chat = this.groupChatMapper.selectById(groupChatId); TabGroupChat chat = this.groupChatMapper.selectById(groupChatId);
this.initGroupChatDetail(qwDTO, chat, syncMember); this.updateGroupChatDetail(qwDTO, chat, syncMember);
} }
// 匹配群成员-客户 // 匹配群成员-客户
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<constructor-arg index="0" value="haoban-manage-service"/> <constructor-arg index="0" value="haoban-manage-service"/>
</bean> </bean>
<dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatPlanApiService" ref="groupChatPlanApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatHmApiService" ref="groupChatHmApiService" timeout="10000"/> <dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatHmApiService" ref="groupChatHmApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatApiService" ref="groupChatApiService" timeout="10000"/> <dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatApiService" ref="groupChatApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.HaobanCommonMQApiService" ref="haobanCommonMQApiService" timeout="10000"/> <dubbo:service interface="com.gic.haoban.manage.api.service.HaobanCommonMQApiService" ref="haobanCommonMQApiService" timeout="10000"/>
......
...@@ -150,6 +150,6 @@ ...@@ -150,6 +150,6 @@
</select> </select>
<select id="listAllChatUser" resultMap="result-map-tabHaobanGroupChatUser"> <select id="listAllChatUser" resultMap="result-map-tabHaobanGroupChatUser">
select <include refid="Base_Column_List" /> from tab_haoban_group_chat_user where group_chat_id = #{groupChatId} and wx_enterprise_id = #{wxEnterpriseId} and delete_flag = 0 select <include refid="Base_Column_List" /> from tab_haoban_group_chat_user where group_chat_id = #{groupChatId} and wx_enterprise_id = #{wxEnterpriseId} and status_flag = 1 and delete_flag = 0
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
<dubbo:application name="haoban-manage3-web"/> <dubbo:application name="haoban-manage3-web"/>
<dubbo:protocol name="dubbo" port="30009"/> <dubbo:protocol name="dubbo" port="30009"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatPlanApiService" id="groupChatPlanApiService" timeout="10000"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatApiService" id="groupChatApiService" timeout="10000"/> <dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatApiService" id="groupChatApiService" timeout="10000"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatHmApiService" id="groupChatHmApiService" timeout="10000"/> <dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatHmApiService" id="groupChatHmApiService" timeout="10000"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.QwFriendApiService" id="qwFriendApiService" timeout="10000"/> <dubbo:reference interface="com.gic.haoban.manage.api.service.QwFriendApiService" id="qwFriendApiService" timeout="10000"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment