Commit 2b33d65d by 徐高华

群活码剔除

parent bf57d85f
......@@ -19,7 +19,8 @@ public interface GroupChatHmRelationMapper {
public int insertBatch(List<TabGroupChatHmRelation> list);
public int delete(@Param("chatHmId") Long chatHmId, @Param("groupChatIdList") List<Long> groupChatIdList);
public int delete(@Param("chatHmId") Long chatHmId, @Param("groupChatIdList") List<Long> groupChatIdList,
@Param("statusFlag") int statusFlag);
public int updateStatus(@Param("chatHmId") Long chatHmId, @Param("groupChatId") Long groupChatId,
@Param("statusFlag") int statusFlag);
......
......@@ -50,9 +50,15 @@ public interface GroupChatMapper {
public TabGroupChat selectByWxChatId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("wxChatId") String wxChatId);
public TabGroupChat selectByWxChatIdDk(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("wxChatIdDk") String wxChatIdDk);
public List<TabGroupChat> listByWxWxChatIdList(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("wxChatIdList") List<String> wxChatIdList) ;
public List<TabGroupChat> listByWxWxChatIdListDk(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("wxChatIdDkList") List<String> wxChatIdDkList) ;
public List<TabGroupChat> listAllNeedInit();
public List<TabGroupChat> listAllNeedInitWxChatIdDk();
......
......@@ -106,27 +106,26 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
TabGroupChatHm hm = this.groupChatHmMapper.selectById(chatHmId);
if (null == hm) {
logger.info("群活码不存在,chatHmId={}", chatHmId);
return;
continue;
}
if (hm.getAutoCreateRoom() == 0) {
logger.info("无开启自动建群,不处理自动踢群hmid={}", hm.getChatHmId());
return;
continue;
}
List<TabGroupChatHmRelation> chatRelation = this.groupChatHmRelationMapper.listByChatHmId(chatHmId);
if (CollectionUtils.isEmpty(chatRelation)) {
logger.info("群活码无关联群,chatHmId={}", chatHmId);
break;
continue;
}
String wxEnterpriseId = hm.getWxEnterpriseId();
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId,
SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting) {
logger.info("没有配置代开应用");
return;
continue;
}
this.handleAutoCreateRoom(wxEnterpriseId, secretSetting.getSecretVal(), hm, chatRelation);
}
}
/**
......@@ -150,18 +149,21 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
List<Long> chatIdList = chatRelation.stream().map(dto -> dto.getGroupChatId())
.collect(Collectors.toList());
List<TabGroupChat> chatList = this.groupChatMapper.listByIdSet(new HashSet<>(chatIdList));
List<String> hbIdList = chatList.stream().map(dto -> dto.getWxChatId()).collect(Collectors.toList());
List<String> hbIdList = chatList.stream().map(dto -> dto.getWxChatIdDk()).collect(Collectors.toList());
logger.info("企微群列表={},haoban列表={}", qwChatIdList, hbIdList);
// 差异列表
// 差异-企微比好办多的群
List<String> qwList = RolesListUtils.differenceList(qwChatIdList, hbIdList);
if (qwChatIdList.size() == hbIdList.size() && CollectionUtils.isEmpty(qwList)) {
logger.info("群未变化");
return;
}
if (CollectionUtils.isNotEmpty(qwList)) {
if (CollectionUtils.isNotEmpty(qwChatIdList)) {
// 处理要踢的
for (String wxChatId : qwList) {
TabGroupChat chat = this.groupChatMapper.selectByWxChatId(wxEnterpriseId, wxChatId);
for (String wxChatId : qwChatIdList) {
TabGroupChat chat = this.groupChatMapper.selectByWxChatIdDk(wxEnterpriseId, wxChatId);
if (null == chat) {
continue;
}
TabGroupChat cid = null;
String staffId = chat.getStaffId();
for (TabGroupChat obj : chatList) {
......@@ -177,15 +179,19 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
}
if (null != cid) {
logger.info("hm={},群={},要删={}", wxChatId, qwChatIdList, cid.getWxChatId());
qwChatIdList.remove(cid.getWxChatId());
qwChatIdList.remove(cid.getWxChatIdDk());
// 保存活码
GroupChatHmDTO hmDTO = EntityUtil.changeEntityByJSON(GroupChatHmDTO.class, hm);
List<TabGroupChat> list = this.groupChatMapper.listByWxWxChatIdList(wxEnterpriseId,
List<TabGroupChat> list = this.groupChatMapper.listByWxWxChatIdListDk(wxEnterpriseId,
qwChatIdList);
if (CollectionUtils.isEmpty(list)) {
logger.info("查询群列表空,dkList={}", qwChatIdList);
return;
}
List<Long> groupChatIdList = list.stream().map(dto -> dto.getGroupChatId())
.collect(Collectors.toList());
GroupChatHmDTO hmDTO = EntityUtil.changeEntityByJSON(GroupChatHmDTO.class, hm);
hmDTO.setChatIdList(groupChatIdList);
this.saveHm(hmDTO);
this.saveHm(hmDTO, 2);
}
}
}
......@@ -195,6 +201,20 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
@Override
public String saveHm(GroupChatHmDTO dto) {
return this.saveHm(dto, 1);
}
/**
*
* @Title: saveHm
* @Description: TODO(这里用一句话描述这个方法的作用)
* @author xugh
* @param dto
* @param autoDel 自动剔除1否 2是
* @return
* @throws
*/
private String saveHm(GroupChatHmDTO dto, int autoDel) {
String wxEnterpriseId = dto.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId,
......@@ -243,7 +263,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
List<Long> delIdList = delView.stream().collect(Collectors.toList());
logger.info("要删除的群={}", delIdList);
if (CollectionUtils.isNotEmpty(delIdList)) {
this.groupChatHmRelationMapper.delete(hmid, delIdList);
this.groupChatHmRelationMapper.delete(hmid, delIdList, autoDel);
}
Sets.SetView<Long> addView = Sets.difference(Sets.newHashSet(newIdList), Sets.newHashSet(oldIdList));
List<Long> addIdList = addView.stream().collect(Collectors.toList());
......
......@@ -307,7 +307,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
list.get(0).getSendTime(), failCount);
// 完成代办
this.pendingTaskService.updateFinish(ownerLog.getOwnerLogId() + "");
//更新计划统计
// 更新计划统计
this.groupChatPlanMapper.updateData(ownerLog.getPlanId(), 1, sendCount, failCount);
}
}
......
......@@ -790,8 +790,8 @@ public class GroupChatServiceImpl implements GroupChatService {
logger.info("群继承={}", JSON.toJSONString(resp));
}
// 群下线
private void chatOff(TabGroupChat chat) {
// 如果群的人数达到上限,则群GIC侧的下线,记录状态,且从活码中剔除
public void chatOff(TabGroupChat chat) {
Long groupChatId = chat.getGroupChatId();
// 群下线
this.groupChatMapper.chatOff(groupChatId);
......
......@@ -55,7 +55,7 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
@Override
public ServiceResponse<Page<GroupChatDTO>> listPage(GroupChatSearchQDTO qdto, BasePageInfo basePageInfo) {
if(null != qdto.getEndDate()) {
if (null != qdto.getEndDate()) {
qdto.setEndDate(DateUtil.getEndTimeOfDay(qdto.getEndDate()));
}
String sortColumn = qdto.getSortColumn();
......@@ -108,7 +108,7 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
@Override
public ServiceResponse<Page<GroupChatUserDTO>> listUserPage(GroupChatUserSearchQDTO qdto,
BasePageInfo basePageInfo) {
if(null != qdto.getEndDate()) {
if (null != qdto.getEndDate()) {
qdto.setEndDate(DateUtil.getEndTimeOfDay(qdto.getEndDate()));
}
Page<GroupChatUserDTO> page = this.groupChatUserService.listPage(qdto, basePageInfo);
......
......@@ -55,7 +55,7 @@
<!-- =====================删除==================== -->
<delete id="delete">
UPDATE tab_haoban_group_chat_hm_relation SET delete_flag = 1 , update_time=now() WHERE
UPDATE tab_haoban_group_chat_hm_relation SET delete_flag = 1 , status_flag = #{statusFlag} , update_time=now() WHERE
chat_hm_id = #{chatHmId} and group_chat_id in
<foreach collection="groupChatIdList" item="id" close=")" index="index" open="(" separator=",">
#{id}
......@@ -79,7 +79,7 @@
from tab_haoban_group_chat_hm_relation where chat_hm_id = #{chatHmId} and delete_flag = 0 and status_flag = 1
</select>
<select id="listChatHmId" resultMap="result-map-tabHaobanGroupChatHmRelation" resultType="long">
<select id="listChatHmId" resultType="long">
select
distinct(chat_hm_id)
from tab_haoban_group_chat_hm_relation where group_chat_id = #{groupChatId} and delete_flag = 0
......
......@@ -183,6 +183,14 @@
and delete_flag = 0
</select>
<select id="selectByWxChatIdDk" resultMap="result-map-tabHaobanGroupChat">
select
<include refid="Base_Column_List" />
FROM tab_haoban_group_chat WHERE wx_chat_id_dk = #{wxChatIdDk}
and wx_enterprise_id = #{wxEnterpriseId}
and delete_flag = 0
</select>
<select id="listByWxWxChatIdList" resultMap="result-map-tabHaobanGroupChat">
select
<include refid="Base_Column_List" />
......@@ -194,6 +202,18 @@
and delete_flag = 0
</select>
<select id="listByWxWxChatIdListDk" resultMap="result-map-tabHaobanGroupChat">
select
<include refid="Base_Column_List" />
FROM tab_haoban_group_chat WHERE wx_chat_id_dk in
<foreach collection="wxChatIdDkList" close=")" index="index" item="wxChatId" open="(" separator=",">
#{wxChatId}
</foreach>
and wx_enterprise_id = #{wxEnterpriseId}
and delete_flag = 0
</select>
<select id="getCountByStaffId" resultType="int">
select count(*) from tab_haoban_group_chat where staff_id = #{staffId} and delete_flag = 0
</select>
......
......@@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -46,12 +47,15 @@ public class GroupChatPlanController {
private MaterialApiService materialApiService;
@RequestMapping("total-list")
public RestResponse<Object> totalList(String clerkId, String wxEnterpriseId, String enterpriseId,
public RestResponse<Object> totalList(String clerkId, String wxEnterpriseId, String enterpriseId,String searchParams ,
BasePageInfo basePageInfo) {
GroupChatPlanSearchQDTO qdto = new GroupChatPlanSearchQDTO();
qdto.setWxEnterpriseId(wxEnterpriseId);
qdto.setEnterpriseId(enterpriseId);
qdto.setClerkId(clerkId);
if(StringUtils.isNotBlank(searchParams)) {
qdto.setSearchParams(searchParams);
}
ServiceResponse<Page<ChatOwnerTotalDTO>> pageResp = this.groupChatPlanApiService.listOwnerLogPageForWxaTotal(qdto,
basePageInfo);
Page<ChatOwnerTotalDTO> page = pageResp.getResult() ;
......
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