Commit bb764b8c by 徐高华

群事件

parent 0064db1a
......@@ -56,4 +56,14 @@ public interface HaobanTimerApiService {
*/
public ServiceResponse<Void> handChatNotice(String params);
/**
*
* @Title: handChatNotice
* @Description: 收到建群事件后,初始化群
* @author xugh
* @param params
* @return
* @throws
*/
public ServiceResponse<Void> initGroupChat(String params);
}
......@@ -35,5 +35,5 @@ public interface GroupChatMapper {
public TabGroupChat selectByWxChatId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("wxChatId") String wxChatId);
public List<TabGroupChat> listAll(TabGroupChat tabHaobanGroupChat);
public List<TabGroupChat> listAllNeedInit();
}
\ No newline at end of file
......@@ -50,10 +50,18 @@ public class TabGroupChat implements Serializable{
private Integer quitMemberCount;
/**gic企业ID*/
private String enterpriseId;
/**gic侧状态1可用,2不可用*/
private Integer statusFlag;
private Integer initFlag ;
public void setGroupChatId(Long groupChatId){
public Integer getInitFlag() {
return initFlag;
}
public void setInitFlag(Integer initFlag) {
this.initFlag = initFlag;
}
public void setGroupChatId(Long groupChatId){
this.groupChatId = groupChatId;
}
......
......@@ -16,4 +16,7 @@ public interface GroupChatService {
// 处理企微群事件
public void handChatNotice(String params);
// 定时初始化新建的群
public void initGroupChatForTimer(String params);
}
\ No newline at end of file
......@@ -146,6 +146,21 @@ public class GroupChatServiceImpl implements GroupChatService {
}
}
@Override
public void initGroupChatForTimer(String params) {
List<TabGroupChat> list = this.groupChatMapper.listAllNeedInit();
if (list.isEmpty()) {
return;
}
logger.info("待初始化群数={}", list.size());
for (TabGroupChat item : list) {
String wxEnterpriseId = item.getWxEnterpriseId();
Long groupChatId = item.getGroupChatId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
this.updateGroupChatDetail(qwDTO, groupChatId, true);
}
}
// 更新群状态
public void updateChatStatus(WxEnterpriseQwDTO qwDTO, Long groupChatId) {
TabGroupChat chat = this.groupChatMapper.selectById(groupChatId);
......@@ -233,14 +248,16 @@ public class GroupChatServiceImpl implements GroupChatService {
}
}
// 新增群记录
/**
* 新增群记录, 如果是更新,只更新群状态,新增只记录群id和群状态,其他数据都在详情修改维护
*/
private void insertGroupChat(WxEnterpriseQwDTO qwDTO, String wxChatId, int chatStatus, boolean syncDetailFlag) {
TabGroupChat groupChat = this.groupChatMapper.selectByWxChatId(qwDTO.getWxEnterpriseId(), wxChatId);
Long groupChatId = null;
if (null != groupChat) {
groupChatId = groupChat.getGroupChatId();
logger.info("群已存在,chatid={},groupChatId={}", wxChatId, groupChatId);
this.groupChatMapper.updateChatStatus(groupChatId, chatStatus) ;
this.groupChatMapper.updateChatStatus(groupChatId, chatStatus);
} else {
groupChatId = UniqueIdUtils.uniqueLong();
TabGroupChat chat = new TabGroupChat();
......
......@@ -45,5 +45,11 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService {
this.groupChatService.handChatNotice(params);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> initGroupChat(String params) {
this.groupChatService.initGroupChatForTimer(params);
return ServiceResponse.success();
}
}
......@@ -23,6 +23,7 @@
<result column="quit_member_count" property="quitMemberCount" />
<result column="enterprise_id" property="enterpriseId" />
<result column="status_flag" property="statusFlag" />
<result column="init_flag" property="initFlag" />
</resultMap>
<sql id="Base_Column_List">
group_chat_id,
......@@ -44,7 +45,7 @@
quit_count,
quit_member_count,
enterprise_id,
status_flag
status_flag , init_flag
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert"
......@@ -70,28 +71,28 @@
quit_count,
quit_member_count,
enterprise_id,
status_flag
status_flag , init_flag
)VALUES(
#{groupChatId,jdbcType=BIGINT},
#{wxEnterpriseId,jdbcType=CHAR},
#{name,jdbcType=VARCHAR},
#{staffId,jdbcType=CHAR},
#{wxChatId,jdbcType=VARCHAR},
#{chatAddTime,jdbcType=TIMESTAMP},
#{chatDissolveTime,jdbcType=TIMESTAMP},
#{chatNotice,jdbcType=VARCHAR},
#{chatStatus,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},
#{deleteFlag,jdbcType=INTEGER},
#{totalCount,jdbcType=INTEGER},
#{totalMemberCount,jdbcType=INTEGER},
#{addMemberCount,jdbcType=INTEGER},
#{addCount,jdbcType=INTEGER},
#{quitCount,jdbcType=INTEGER},
#{quitMemberCount,jdbcType=INTEGER},
#{enterpriseId,jdbcType=CHAR},
#{statusFlag,jdbcType=INTEGER}
#{groupChatId},
#{wxEnterpriseId},
#{name},
#{staffId},
#{wxChatId},
#{chatAddTime},
#{chatDissolveTime},
#{chatNotice},
#{chatStatus},
#{createTime},
#{updateTime},
#{deleteFlag},
#{totalCount},
#{totalMemberCount},
#{addMemberCount},
#{addCount},
#{quitCount},
#{quitMemberCount},
#{enterpriseId},
#{statusFlag} , #{initFlag}
)
]]>
</insert>
......@@ -109,15 +110,15 @@
parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChat">
<![CDATA[
UPDATE tab_haoban_group_chat SET
group_chat_id=#{groupChatId,jdbcType=BIGINT},
name=#{name,jdbcType=VARCHAR},
staff_id=#{staffId,jdbcType=CHAR},
chat_add_time=#{chatAddTime,jdbcType=TIMESTAMP},
chat_dissolve_time=#{chatDissolveTime,jdbcType=TIMESTAMP},
chat_notice=#{chatNotice,jdbcType=VARCHAR},
chat_status=#{chatStatus,jdbcType=INTEGER},
group_chat_id=#{groupChatId},
name=#{name},
staff_id=#{staffId},
chat_add_time=#{chatAddTime},
chat_dissolve_time=#{chatDissolveTime},
chat_notice=#{chatNotice},
chat_status=#{chatStatus},
update_time=now(),
status_flag=#{statusFlag,jdbcType=INTEGER}
status_flag=#{statusFlag}
where group_chat_id = #{groupChatId}
]]>
</update>
......@@ -160,9 +161,7 @@
and delete_flag = 0
</select>
<select id="listAll"
parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChat"
resultMap="result-map-tabHaobanGroupChat">
select * from tab_haoban_group_chat
<select id="listAllNeedInit" resultMap="result-map-tabHaobanGroupChat">
select <include refid="Base_Column_List" /> from tab_haoban_group_chat where create_time > DATE_ADD(NOW(),INTERVAL -7 day) and init_flag = 0
</select>
</mapper>
\ No newline at end of file
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