Commit 97b2b5bf by 徐高华

定时

parent 1009b3fd
......@@ -25,8 +25,6 @@ public class GroupChatSearchQDTO implements Serializable {
private List<Long> groupChatIdList ;
private String sortColumn ;
private String sortType = "desc" ;
// 群列表页需要显示未关联gic商户的
private boolean chatPageFlag = false ;
// 0全部 1未满200 2已满200
private Integer hmAddStatus ;
private String departmentId ;
......@@ -66,14 +64,6 @@ public class GroupChatSearchQDTO implements Serializable {
this.hmAddStatus = hmAddStatus;
}
public boolean isChatPageFlag() {
return chatPageFlag;
}
public void setChatPageFlag(boolean chatPageFlag) {
this.chatPageFlag = chatPageFlag;
}
public List<Long> getGroupChatIdList() {
return groupChatIdList;
}
......
......@@ -58,6 +58,17 @@ public interface HaobanTimerApiService {
/**
*
* @Title: handHmChat
* @Description: 处理活码自动建群后踢群和加群
* @author xugh
* @param params
* @return
* @throws
*/
public ServiceResponse<Void> handleHmChatFull(String params);
/**
*
* @Title: handChatNotice
* @Description: 收到建群事件后,初始化群
* @author xugh
......@@ -66,4 +77,16 @@ public interface HaobanTimerApiService {
* @throws
*/
public ServiceResponse<Void> initGroupChat(String params);
/**
*
* @Title: initHaobaonGroupChat
* @Description: 初始化所有好办企业的群
* @author xugh
* @param params
* @return
* @throws
*/
public ServiceResponse<Void> initHaobaonGroupChat(String params);
}
......@@ -63,28 +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);
/**
*
* @Title: refreshChatInfo
* @Description: 刷新群信息
* @Description: 刷新群信息,从队列获取
* @author xugh
* @param groupChatId
* @return
* @throws
*/
public ServiceResponse<Void> refreshWxEnterpriseChatInfo(String wxEnterpriseId);
public ServiceResponse<Void> refreshChatInfoFromMQ(String params);
/**
*
......@@ -146,7 +135,7 @@ public interface GroupChatApiService {
* @throws
*/
public ServiceResponse<Void> transfer(String wxEnterpriseId, String staffId, List<Long> groupChatIdList);
/**
*
* @Title: getSetFlag
......@@ -156,6 +145,18 @@ public interface GroupChatApiService {
* @return
* @throws
*/
public ServiceResponse<Boolean> getSetGicFlag(String wxEnterpriseId) ;
public ServiceResponse<Boolean> getSetGicFlag(String wxEnterpriseId);
/**
*
* @Title: listChatByIdList
* @Description: 通过id列表查询
* @author xugh
* @param wxEnterpriseId
* @param groupChatIdList
* @return
* @throws
*/
public ServiceResponse<List<GroupChatDTO>> listChatByIdList(String wxEnterpriseId, List<Long> groupChatIdList);
}
package com.gic.haoban.manage.service.dao.mapper.chat;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
......@@ -19,7 +20,9 @@ public interface ChatNoticeMapper {
public int insert(TabChatNotice entity);
public int closeAll(@Param("list") List<Integer> typeList);
public int closeAll(@Param("list") List<Integer> typeList, @Param("startTime") Date startTime,
@Param("endTime") Date endTime);
public List<TabChatNotice> listAll(@Param("list") List<Integer> typeList);
public List<TabChatNotice> listAll(@Param("list") List<Integer> typeList, @Param("startTime") Date startTime,
@Param("endTime") Date endTime);
}
\ No newline at end of file
package com.gic.haoban.manage.service.dao.mapper.chat;
import java.util.List;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatInit;
/**
*
* @ClassName: TabHaobanGroupChatInitMapper
* @Description: TODO
* @Author 徐高华
* @Date 2022年12月18日 11:33:08
* @Modify
* @CopyRight
*/
public interface GroupChatInitMapper {
/**
* 更新
* @Title: update
* @Description: TODO
* @Param @param TabHaobanGroupChatInit
* @Throws
*/
public int update(String wxEnterprseId, int status);
/**
* 通过主键查询
* @Title: selectById
* @Description: TODO
* @Param @param id
* @Param @return
* @Return TabHaobanGroupChatInit
* @Throws
*/
public TabGroupChatInit selectById(String wxEnterpriseId);
/**
* 通过条件查询
* @Title: listAll
* @Description: TODO
* @Param @param TabHaobanGroupChatInit
* @Param @return
* @Return List
* @Throws
*/
public List<TabGroupChatInit> listAllInit();
}
\ No newline at end of file
package com.gic.haoban.manage.service.entity.chat;
import java.io.Serializable;
/**
*
* @ClassName: TabHaobanGroupChatInit
* @Description: TODO
* @Author 徐高华
* @Date 2022年12月18日 11:33:08
* @Modify
* @CopyRight
*/
public class TabGroupChatInit implements Serializable {
private static final long serialVersionUID = 687982270695000L;
private String wxEnterpriseId;
/**1待初始化2完成3暂停*/
private Integer statusFlag;
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
public Integer getStatusFlag() {
return statusFlag;
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ import com.gic.haoban.manage.api.dto.qdto.chat.ChatHmSearchQDTO;
import com.gic.haoban.manage.service.pojo.bo.chat.GroupChatHmBO;
public interface GroupChatHmService {
/**
*
* @Title: saveHm
......@@ -31,7 +31,7 @@ public interface GroupChatHmService {
* @param groupChat
* @throws
*/
public void handleChatOff(Long groupChat);
public void handleChatOff(String wxEnterpriseId, Long groupChat);
public void discard(Long chatHmId, String wxEnterpriseId, String clerkId, String clerkName);
......
......@@ -22,8 +22,7 @@ public interface GroupChatService {
// 更新同步群信息
public void updateChat(String corpid, String wxChatId, String updateDetail, String msg);
// 初始化企业群
public void initEnterpriseGroupChat(String wxEnterpriseId);
public void initHaobaonGroupChat(String params);
// 处理企微群事件
public void handChatNotice(String params);
......@@ -67,6 +66,8 @@ public interface GroupChatService {
*/
public Page<GroupChatDTO> listPage(GroupChatSearchQDTO qdto, BasePageInfo basePageInfo);
public List<GroupChatBO> listChatByIdList(List<Long> idList);
public void updateChatEnterpriseId(String wxEnterpriseId, String enterpriseId, List<Long> groupChatIdList);
/**
......@@ -118,4 +119,14 @@ public interface GroupChatService {
*/
public void matchGicMember(String wxEnterpriseId, String enterpriseId, String memberId, String externalUserId);
/**
*
* @Title: handleHmChatFull
* @Description: 定时轮询群满后的活码处理
* @author xugh
* @param params
* @throws
*/
public void handleHmChatFull(String params);
}
\ No newline at end of file
package com.gic.haoban.manage.service.service.chat.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
......@@ -28,10 +29,12 @@ import com.gic.haoban.manage.api.dto.chat.GroupChatHmDTO;
import com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.ChatHmSearchQDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.service.dao.mapper.chat.ChatNoticeMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatHmMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatHmRelationMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatMapper;
import com.gic.haoban.manage.service.dao.mapper.hm.HmLinkChatMapper;
import com.gic.haoban.manage.service.entity.chat.TabChatNotice;
import com.gic.haoban.manage.service.entity.chat.TabGroupChat;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatHm;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatHmRelation;
......@@ -64,6 +67,8 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
private GroupChatHmRelationMapper groupChatHmRelationMapper;
@Autowired
private HmLinkChatMapper hmLinkChatMapper;
@Autowired
private ChatNoticeMapper chatNoticeMapper;
@Override
public Page<GroupChatHmBO> listPage(ChatHmSearchQDTO qdto, BasePageInfo basePageInfo) {
......@@ -82,14 +87,15 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
PageHelper.startPage(basePageInfo);
List<TabGroupChatHm> list = this.groupChatHmMapper.list(qdto);
Page<GroupChatHmBO> retPage = PageHelperUtils.changePageHelperToCurrentPage(list, GroupChatHmBO.class);
if(CollectionUtils.isNotEmpty(retPage.getResult())) {
List<Long> hmIdList = retPage.getResult().stream().map(o->o.getChatHmId()).collect(Collectors.toList()) ;
List<GroupChatHmRelationBO> boList = this.groupChatHmRelationMapper.getHmValidChatCount(hmIdList) ;
Map<Long, Integer> map = boList.stream().collect(Collectors.toMap(GroupChatHmRelationBO::getChatHmId, GroupChatHmRelationBO::getUsableChatCount)) ;
retPage.getResult().forEach(item->{
Long hmId = item.getChatHmId() ;
if(null != map.get(hmId)) {
if (CollectionUtils.isNotEmpty(retPage.getResult())) {
List<Long> hmIdList = retPage.getResult().stream().map(o -> o.getChatHmId()).collect(Collectors.toList());
List<GroupChatHmRelationBO> boList = this.groupChatHmRelationMapper.getHmValidChatCount(hmIdList);
Map<Long, Integer> map = boList.stream().collect(
Collectors.toMap(GroupChatHmRelationBO::getChatHmId, GroupChatHmRelationBO::getUsableChatCount));
retPage.getResult().forEach(item -> {
Long hmId = item.getChatHmId();
if (null != map.get(hmId)) {
item.setUsableChatCount(map.get(hmId));
}
});
......@@ -120,11 +126,18 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
}
}
// 群加满后,处理活码,剔除满的群,加入企微自动建的群
@Override
public void handleChatOff(Long groupChatId) {
public void handleChatOff(String wxEnterpriseId, Long groupChatId) {
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId,
SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting) {
logger.info("未配置代开发");
return;
}
List<Long> hmIdList = this.groupChatHmRelationMapper.listChatHmId(groupChatId);
if (CollectionUtils.isEmpty(hmIdList)) {
logger.info("群下线,处理群活码,无关联活码,chatid={}", groupChatId);
logger.info("群加满后,处理活码,取未关联活码,chatid={}", groupChatId);
return;
}
for (Long chatHmId : hmIdList) {
......@@ -142,14 +155,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
logger.info("群活码无关联群,chatHmId={}", chatHmId);
continue;
}
String wxEnterpriseId = hm.getWxEnterpriseId();
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId,
SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting) {
logger.info("没有配置代开应用");
continue;
}
this.handleAutoCreateRoom(wxEnterpriseId, secretSetting.getSecretVal(), hm, chatRelation);
this.handleAutoCreateRoom(wxEnterpriseId, secretSetting.getSecretVal(), hm, chatRelation, groupChatId);
}
}
......@@ -157,7 +163,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
* 处理开启自动建群的,如果群满自动下线后,需要从活码中提出.注意使用的是代开发应用
*/
private void handleAutoCreateRoom(String wxEnterpriseId, String secret, TabGroupChatHm hm,
List<TabGroupChatHmRelation> chatRelation) {
List<TabGroupChatHmRelation> chatRelation, Long thisGroupChatId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
String configId = hm.getWxConfigId();
ServiceResponse<AddJoinWayDTO> joinResp = this.qywxChatApiService.getJoinWay(qwDTO.getDkCorpid(), secret,
......@@ -169,6 +175,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
if (CollectionUtils.isNotEmpty(qwChatIdList)) {
if (qwChatIdList.size() == 1) {
logger.info("只有1个群");
this.saveChatFullNotice(wxEnterpriseId, thisGroupChatId);
return;
}
List<Long> chatIdList = chatRelation.stream().map(dto -> dto.getGroupChatId())
......@@ -180,6 +187,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
List<String> qwList = RolesListUtils.differenceList(qwChatIdList, hbIdList);
if (qwChatIdList.size() == hbIdList.size() && CollectionUtils.isEmpty(qwList)) {
logger.info("群未变化");
this.saveChatFullNotice(wxEnterpriseId, thisGroupChatId);
return;
}
if (CollectionUtils.isNotEmpty(qwChatIdList)) {
......@@ -340,4 +348,16 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
return null;
}
private void saveChatFullNotice(String wxEnterpriseId, Long groupChatId) {
TabChatNotice entity = new TabChatNotice();
entity.setId(UniqueIdUtils.uniqueLong());
entity.setWxEnterpriseId(wxEnterpriseId);
entity.setChatId(groupChatId);
entity.setType(4);
entity.setCreateTime(new Date());
entity.setStatusFlag(0);
entity.setMsg(null);
this.chatNoticeMapper.insert(entity);
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ 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.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.PageHelperUtils;
......@@ -40,6 +41,7 @@ import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.ChatNoticeMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatHmRelationMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatInitMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatOwnerHistoryMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatOwnerMapper;
......@@ -52,6 +54,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.entity.chat.TabChatNotice;
import com.gic.haoban.manage.service.entity.chat.TabGroupChat;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatHmRelation;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatInit;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatOwner;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatOwnerHistory;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatUser;
......@@ -66,6 +69,7 @@ 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.redis.data.util.RedisUtil;
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;
......@@ -115,6 +119,8 @@ public class GroupChatServiceImpl implements GroupChatService {
private GroupChatHmRelationMapper groupChatHmRelationMapper;
@Autowired
private DepartmentService departmentService;
@Autowired
private GroupChatInitMapper groupChatInitMapper;
private static GicMQClient mqClient = GICMQClientUtil.getClientInstance();
......@@ -217,6 +223,13 @@ public class GroupChatServiceImpl implements GroupChatService {
}
@Override
public List<GroupChatBO> listChatByIdList(List<Long> idList) {
List<TabGroupChat> chatList = this.groupChatMapper.listByIdSet(new HashSet<>(idList));
List<GroupChatBO> list = EntityUtil.changeEntityListByJSON(GroupChatBO.class, chatList);
return list;
}
@Override
public Page<GroupChatDTO> listPage(GroupChatSearchQDTO qdto, BasePageInfo basePageInfo) {
if (null != qdto.getChatHmId()) {
List<TabGroupChatHmRelation> list = this.groupChatHmRelationMapper.listByChatHmId(qdto.getChatHmId());
......@@ -243,27 +256,33 @@ public class GroupChatServiceImpl implements GroupChatService {
this.sendMQ(json.toJSONString());
}
// 处理群通知
@Override
public void handChatNotice(String params) {
// 处理群通知
List<TabChatNotice> list = this.chatNoticeMapper.listAll(Arrays.asList(1, 2, 3));
this.chatNoticeMapper.closeAll(Arrays.asList(1, 2, 3));
List<Integer> typeList = Arrays.asList(1, 2, 3);
Date endTime = new Date();
Date startTime = DateUtil.addNumForMinute(endTime, -30);
List<TabChatNotice> list = this.chatNoticeMapper.listAll(typeList, startTime, endTime);
this.chatNoticeMapper.closeAll(typeList, startTime, endTime);
for (TabChatNotice item : list) {
int type = item.getType();
String wxEnterpriseId = item.getWxEnterpriseId();
Long groupChatId = item.getChatId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (type == 1) {
this.updateGroupChatDetail(qwDTO, groupChatId, false);
}
if (type == 2) {
this.updateChatStatus(qwDTO, groupChatId);
}
if (type == 3) {
this.updateGroupChatDetail(qwDTO, groupChatId, true);
try {
int type = item.getType();
String wxEnterpriseId = item.getWxEnterpriseId();
Long groupChatId = item.getChatId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (type == 1) {
this.updateGroupChatDetail(qwDTO, groupChatId, false);
}
if (type == 2) {
this.updateChatStatus(qwDTO, groupChatId);
}
if (type == 3) {
this.updateGroupChatDetail(qwDTO, groupChatId, true);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
......@@ -311,11 +330,41 @@ public class GroupChatServiceImpl implements GroupChatService {
this.syncGroupChatList(qwDTO, Arrays.asList(userId), null, false);
}
@Override
public void initHaobaonGroupChat(String params) {
String key = "initHaobaonGroupChat";
try {
Object o = RedisUtil.getCache(key);
if (null != o) {
logger.info("企业群初始化进行中");
return;
}
RedisUtil.setCache(key, "1");
List<TabGroupChatInit> initList = this.groupChatInitMapper.listAllInit();
logger.info("开始企业群待初始化,数量={}", initList.size());
if (CollectionUtils.isNotEmpty(initList)) {
for (TabGroupChatInit init : initList) {
try {
this.initEnterpriseGroupChat(init.getWxEnterpriseId());
this.groupChatInitMapper.update(init.getWxEnterpriseId(), 2);
} catch (Exception e) {
logger.info("初始化异常,wxEid={}", init.getWxEnterpriseId());
this.groupChatInitMapper.update(init.getWxEnterpriseId(), 4);
e.printStackTrace();
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
RedisUtil.delCache(key);
}
}
/**
* 初始化整个群数据,拉取所有成员的所有群,并立即获取群信息、群成员、同时也会匹配客户标识
*/
@Override
public void initEnterpriseGroupChat(String wxEnterpriseId) {
private void initEnterpriseGroupChat(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (null == qwDTO) {
logger.info("wxEnterpriseId不存在,id={}", wxEnterpriseId);
......@@ -812,11 +861,38 @@ public class GroupChatServiceImpl implements GroupChatService {
}
// 如果群的人数达到上限,则群GIC侧的下线,记录状态,且从活码中剔除
public void chatOff(TabGroupChat chat) {
private void chatOff(TabGroupChat chat) {
Long groupChatId = chat.getGroupChatId();
// 群下线
this.groupChatMapper.chatOff(groupChatId);
// 通知处理群活码
this.groupChatHmService.handleChatOff(groupChatId);
this.groupChatHmService.handleChatOff(chat.getWxEnterpriseId(), groupChatId);
}
@Override
public void handleHmChatFull(String params) {
List<Integer> typeList = Arrays.asList(4);
Date endTime = new Date();
Date startTime = DateUtil.addNumForMinute(endTime, -30);
List<TabChatNotice> list = this.chatNoticeMapper.listAll(typeList, startTime, endTime);
this.chatNoticeMapper.closeAll(typeList, startTime, endTime);
for (TabChatNotice item : list) {
String wxEnterpriseId = item.getWxEnterpriseId();
Long groupChatId = item.getChatId();
// 通知处理群活码
try {
TabGroupChat chat = this.groupChatMapper.selectById(groupChatId);
if (null == chat || chat.getHmAddStatus() == 1 || null == chat.getOffTime()) {
continue;
}
if (chat.getOffTime().getTime() + 1000 * 60 * 60 * 24 < new Date().getTime()) {
logger.info("超过一天不再重试groupChatId={}", groupChatId);
continue;
}
this.groupChatHmService.handleChatOff(wxEnterpriseId, groupChatId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
\ No newline at end of file
......@@ -52,4 +52,15 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService {
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> initHaobaonGroupChat(String params) {
this.groupChatService.initHaobaonGroupChat(params);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> handleHmChatFull(String params) {
this.groupChatService.handleHmChatFull(params);
return ServiceResponse.success();
}
}
......@@ -141,12 +141,6 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
}
@Override
public ServiceResponse<Void> refreshWxEnterpriseChatInfo(String wxEnterpriseId) {
this.groupChatService.initEnterpriseGroupChat(wxEnterpriseId);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> updateChatEnterpriseId(String wxEnterpriseId, String enterpriseId,
List<Long> groupChatIdList) {
this.groupChatService.updateChatEnterpriseId(wxEnterpriseId, enterpriseId, groupChatIdList);
......@@ -190,6 +184,12 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
}
@Override
public ServiceResponse<List<GroupChatDTO>> listChatByIdList(String wxEnterpriseId, List<Long> groupChatIdList) {
List<GroupChatBO> list = this.groupChatService.listChatByIdList(groupChatIdList);
return ServiceResponse.success(EntityUtil.changeEntityListByJSON(GroupChatDTO.class, list));
}
@Override
public ServiceResponse<Boolean> getSetGicFlag(String wxEnterpriseId) {
List<TabHaobanWxEnterpriseRelated> list = this.wxEnterpriseRelatedService.getByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(list) && list.size() == 1) {
......@@ -201,7 +201,7 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
@Override
public ServiceResponse<Void> refreshChatInfoFromMQ(String params) {
JSONObject json = JSONObject.parseObject(params);
List<Long> arr = json.parseArray(json.getString("groupChatIdList"), Long.class);
List<Long> arr = JSONObject.parseArray(json.getString("groupChatIdList"), Long.class);
for (Long id : arr) {
this.refreshChatInfo(id);
}
......
......@@ -50,15 +50,15 @@
UPDATE tab_haoban_chat_notice SET
status_flag=1,
update_time=now()
where create_time > DATE_ADD(NOW(),INTERVAL -30 MINUTE)
where create_time > #{startTime} and create_time <![CDATA[<=]]> #{endTime}
and type in
<foreach collection="list" close=")" index="index" item="type" open="(" separator=",">
#{type}
</foreach>
</foreach> and status_flag = 0
</update>
<select id="listAll" resultMap="result-map-tabHaobanChatNotice">
select wx_enterprise_id wxEnterpriseId , chat_id chatId , type from tab_haoban_chat_notice where create_time > DATE_ADD(NOW(),INTERVAL -30 MINUTE) and status_flag = 0
select wx_enterprise_id wxEnterpriseId , chat_id chatId , type from tab_haoban_chat_notice where create_time > #{startTime} and create_time <![CDATA[<=]]> #{endTime} and status_flag = 0
and type in
<foreach collection="list" close=")" index="index" item="type" open="(" separator=",">
#{type}
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.gic.haoban.manage.service.dao.mapper.chat.GroupChatInitMapper">
<resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatInit"
id="result-map-tabHaobanGroupChatInit">
<result column="wx_enterprise_id" property="wxEnterpriseId" />
<result column="status_flag" property="statusFlag" />
</resultMap>
<sql id="Base_Column_List">
wx_enterprise_id,
status_flag
</sql>
<!-- ==================更新 ========== -->
<update id="update">
<![CDATA[
UPDATE tab_haoban_group_chat_init SET
status_flag=#{statusFlag,jdbcType=INTEGER}
where wx_enterprise_id = #{wxEnterpriseId}
]]>
</update>
<!-- ============ 查询============= -->
<select id="selectById" resultMap="result-map-tabHaobanGroupChatInit">
SELECT
<include refid="Base_Column_List" />
FROM tab_haoban_group_chat_init WHERE wx_enterprise_id =
#{wxEnterpriseId}
</select>
<select id="listAllInit" resultMap="result-map-tabHaobanGroupChatInit">
select
<include refid="Base_Column_List" />
from tab_haoban_group_chat_init where status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -255,11 +255,11 @@
left join tab_haoban_staff_department_related depart on a.staff_id = depart.staff_id and depart.status_flag = 1
</if>
where a.wx_enterprise_id=#{wxEnterpriseId}
<if test="chatPageFlag==true">
and (a.enterprise_id = #{enterpriseId} or a.enterprise_id is null)
<if test="null != gicFlag and gicFlag ==0 ">
and a.enterprise_id is null
</if>
<if test="chatPageFlag==false">
and a.enterprise_id = #{enterpriseId}
<if test="null == gicFlag or gicFlag ==1 ">
and a.enterprise_id = #{enterpriseId}
</if>
<if test="null != staffId">
and a.staff_id = #{staffId}
......@@ -294,12 +294,6 @@
<if test="null != dismissStartDate">
and a.chat_dissolve_time <![CDATA[ >=]]> #{startDate} and a.chat_dissolve_time <![CDATA[ <= ]]> #{endDate}
</if>
<if test="null != gicFlag and gicFlag ==0 ">
and a.gic_flag = 0
</if>
<if test="null == gicFlag or gicFlag ==1 ">
and a.gic_flag = 1
</if>
<if test="null != groupChatIdList and groupChatIdList.size>0">
and a.group_chat_id in
<foreach collection="groupChatIdList" close=")" open="(" index="index" item="groupChatId" separator=",">
......@@ -329,9 +323,6 @@
<if test="null != sortColumn">
order by a.${sortColumn} ${sortType}
</if>
</select>
<update id="updateChatEnterpriseId">
......
......@@ -17,6 +17,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatOwnerDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatOwnerHistoryDTO;
......@@ -24,7 +25,13 @@ import com.gic.haoban.manage.api.dto.chat.GroupChatUserDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatSearchQDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatUserSearchQDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.OwnerSearchQDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.chat.GroupChatApiService;
import com.gic.haoban.manage.web.log.LogRecordUserServiceImpl;
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;
/**
*
......@@ -42,7 +49,9 @@ public class GroupChatController {
@Autowired
private GroupChatApiService groupChatApiService;
@Autowired
private StaffApiService staffApiService ;
@RequestMapping("get-set-gic-flag")
public RestResponse<Object> getFlag() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
......@@ -62,6 +71,7 @@ public class GroupChatController {
* @throws
*/
@RequestMapping("set-gic-enterprise")
@GicLogRecord(value = "${#logValue}", category = GicLogRecordCategoryEnum.HUOMA, optType = GicLogRecordOptTypeEnum.HM_LINK_ADD, userFunc = LogRecordUserServiceImpl.class, optPage = "客户群列表-客户群认领")
public RestResponse<Object> save(@RequestBody GroupChatSearchQDTO qdto) {
List<Long> groupChatIdList = qdto.getGroupChatIdList();
if (CollectionUtils.isEmpty(groupChatIdList)) {
......@@ -71,8 +81,22 @@ public class GroupChatController {
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String enterpriseId = loginUser.getEnterpriseId();
this.groupChatApiService.updateChatEnterpriseId(wxEnterpriseId, enterpriseId, groupChatIdList);
String logContent = "认领【"+this.getChatNames(wxEnterpriseId, groupChatIdList)+"】";
GicLogRecordEvaluationContext.putAttribute("logValue", logContent);
GicLogRecordEvaluationContext.putOptTargetId(AuthWebRequestUtil.getLoginUser().getClerkId());
return RestResponse.successResult();
}
private String getChatNames(String wxEnterpriseId, List<Long> groupChatIdList) {
ServiceResponse<List<GroupChatDTO>> chatResp = this.groupChatApiService.listChatByIdList(wxEnterpriseId, groupChatIdList);
List<GroupChatDTO> chatList = chatResp.getResult() ;
StringBuilder content = new StringBuilder() ;
for(GroupChatDTO item : chatList) {
content.append(item.getGroupChatId()).append("-").append(item.getName()).append(",") ;
}
return content.toString() ;
}
@RequestMapping("page")
public RestResponse<Object> page(GroupChatSearchQDTO qdto, BasePageInfo basePageInfo) {
......@@ -96,7 +120,6 @@ public class GroupChatController {
qdto.setSortColumn(sortColumn);
qdto.setWxEnterpriseId(loginUser.getWxEnterpriseId());
qdto.setEnterpriseId(loginUser.getEnterpriseId());
qdto.setChatPageFlag(true);
ServiceResponse<Page<GroupChatDTO>> page = this.groupChatApiService.listPage(qdto, basePageInfo);
return RestResponse.successResult(page.getResult());
}
......@@ -146,6 +169,7 @@ public class GroupChatController {
}
@RequestMapping("transfer")
@GicLogRecord(value = "${#logValue}", category = GicLogRecordCategoryEnum.HUOMA, optType = GicLogRecordOptTypeEnum.HM_LINK_ADD, userFunc = LogRecordUserServiceImpl.class, optPage = "客户群列表")
public RestResponse<Object> transfer(String staffId, List<Long> groupChatIdList) {
if(StringUtils.isEmpty(staffId)) {
return RestResponse.failure("1", "请选择继承的群主");
......@@ -156,6 +180,10 @@ public class GroupChatController {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
ServiceResponse<Void> resp = this.groupChatApiService.transfer(wxEnterpriseId, staffId, groupChatIdList);
StaffDTO staff = this.staffApiService.selectById(staffId) ;
String logContent = "将【"+this.getChatNames(wxEnterpriseId, groupChatIdList)+"】分配给【"+staff.getStaffName()+"】继承";
GicLogRecordEvaluationContext.putAttribute("logValue", logContent);
GicLogRecordEvaluationContext.putOptTargetId(AuthWebRequestUtil.getLoginUser().getClerkId());
return RestResponse.successResult(resp.getResult());
}
......
......@@ -43,9 +43,13 @@ import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatSearchQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmLinkChatQDTO;
import com.gic.haoban.manage.api.service.chat.GroupChatApiService;
import com.gic.haoban.manage.api.service.chat.GroupChatHmApiService;
import com.gic.haoban.manage.web.log.LogRecordUserServiceImpl;
import com.gic.haoban.manage.web.utils.CreatorUtils;
import com.gic.haoban.manage.web.vo.chat.GroupChatHmVO;
import com.gic.haoban.manage.web.vo.chat.HmLinkChatListVO;
import com.gic.log.record.anno.GicLogRecord;
import com.gic.log.record.util.GicLogRecordCategoryEnum;
import com.gic.log.record.util.GicLogRecordOptTypeEnum;
import com.gic.qcloud.BucketNameEnum;
import com.gic.qcloud.FileUploadUtil;
import com.gic.web.common.utils.DataPermissionExport;
......@@ -72,6 +76,7 @@ public class GroupChatHmController {
private DownloadReportService downloadReportService;
@RequestMapping("add")
@GicLogRecord(value = "${#logValue}", category = GicLogRecordCategoryEnum.HUOMA, optType = GicLogRecordOptTypeEnum.HM_LINK_ADD, userFunc = LogRecordUserServiceImpl.class, optPage = "客户群列表")
public RestResponse<Object> save(@RequestBody GroupChatHmDTO dto) {
if (CollectionUtils.isEmpty(dto.getChatIdList())) {
return RestResponse.failure("1", "请选择加入的群");
......@@ -94,6 +99,7 @@ public class GroupChatHmController {
}
@RequestMapping("update")
@GicLogRecord(value = "${#logValue}", category = GicLogRecordCategoryEnum.HUOMA, optType = GicLogRecordOptTypeEnum.HM_LINK_ADD, userFunc = LogRecordUserServiceImpl.class, optPage = "客户群列表")
public RestResponse<Object> update(@RequestBody GroupChatHmDTO dto) {
if (CollectionUtils.isEmpty(dto.getChatIdList())) {
return RestResponse.failure("1", "请选择加入的群");
......@@ -158,6 +164,7 @@ public class GroupChatHmController {
* @throws
*/
@RequestMapping("discard")
@GicLogRecord(value = "${#logValue}", category = GicLogRecordCategoryEnum.HUOMA, optType = GicLogRecordOptTypeEnum.HM_LINK_ADD, userFunc = LogRecordUserServiceImpl.class, optPage = "客户群列表")
public RestResponse<Object> discard(Long chatHmId) {
if (null == chatHmId) {
return RestResponse.failure("1", "群活码ID空");
......
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