Commit 022f553a by 徐高华

parent 768f1fb3
......@@ -17,9 +17,9 @@ import com.gic.haoban.manage.service.entity.chat.TabGroupChatHmRelation;
*/
public interface GroupChatHmRelationMapper {
public int insert(TabGroupChatHmRelation entity);
public int insertBatch(List<TabGroupChatHmRelation> list);
public int deleteById(@Param("chatHmId") Long chatHmId, @Param("groupChatId") Long groupChatId);
public int delete(@Param("chatHmId") Long chatHmId, @Param("groupChatIdList") List<Long> groupChatIdList);
public int updateStatus(@Param("chatHmId") Long chatHmId, @Param("groupChatId") Long groupChatId,
@Param("statusFlag") int statusFlag);
......
......@@ -48,6 +48,9 @@ public interface GroupChatMapper {
public TabGroupChat selectByWxChatId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("wxChatId") String wxChatId);
public List<TabGroupChat> listByWxWxChatIdList(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("wxChatIdList") List<String> wxChatIdList) ;
public List<TabGroupChat> listAllNeedInit();
......
......@@ -40,6 +40,7 @@ import com.gic.haoban.manage.service.service.chat.GroupChatHmService;
import com.gic.wechat.api.dto.qywx.chat.AddJoinWayDTO;
import com.gic.wechat.api.service.qywx.QywxChatApiService;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Sets;
@Service("groupChatHmService")
public class GroupChatHmServiceImpl implements GroupChatHmService {
......@@ -164,7 +165,13 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
logger.info("hm={},群={},要删={}", wxChatId, qwChatIdList, cid.getWxChatId());
qwChatIdList.remove(cid.getWxChatId());
// 保存活码
GroupChatHmDTO hmDTO = EntityUtil.changeEntityByJSON(GroupChatHmDTO.class, hm);
List<TabGroupChat> list = this.groupChatMapper.listByWxWxChatIdList(wxEnterpriseId,
qwChatIdList);
List<Long> groupChatIdList = list.stream().map(dto -> dto.getGroupChatId())
.collect(Collectors.toList());
hmDTO.setChatIdList(groupChatIdList);
this.saveHm(hmDTO);
}
}
}
......@@ -183,10 +190,9 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
return;
}
boolean updateFlag = false;
Long hmid = UniqueIdUtils.uniqueLong();
if (null != dto.getChatHmId()) {
Long hmid =dto.getChatHmId() ;
if (null != hmid) {
updateFlag = true;
hmid = dto.getChatHmId();
} else {
hmid = UniqueIdUtils.uniqueLong();
}
......@@ -207,17 +213,39 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
joinDTO.setChat_id_list(wxChatidList);
TabGroupChatHm hm = EntityUtil.changeEntityByJSON(TabGroupChatHm.class, dto);
hm.setDeleteFlag(0);
hm.setCreateTime(new Date());
hm.setUpdateTime(new Date());
hm.setChatCount(wxChatidList.size());
List<TabGroupChatHmRelation> relationList = new ArrayList<>();
if (updateFlag) {
joinDTO.setConfig_id(hm.getWxConfigId());
ServiceResponse<Void> updateResp = this.qywxChatApiService.updateJoinWay(qwDTO.getDkCorpid(),
/*ServiceResponse<Void> updateResp = this.qywxChatApiService.updateJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), joinDTO);
if (updateResp.isSuccess()) {
this.groupChatHmMapper.updateById(hm);
}*/
List<TabGroupChatHmRelation> oldList = this.groupChatHmRelationMapper.listByChatHmId(hmid);
List<Long> oldIdList = oldList.stream().map(o -> o.getGroupChatId()).collect(Collectors.toList());
List<Long> newIdList = dto.getChatIdList();
Sets.SetView<Long> delView = Sets.difference(Sets.newHashSet(oldIdList), Sets.newHashSet(newIdList));
List<Long> delIdList = delView.stream().collect(Collectors.toList());
logger.info("要删除的群={}", delIdList);
if (CollectionUtils.isNotEmpty(delIdList)) {
this.groupChatHmRelationMapper.delete(hmid, delIdList);
}
Sets.SetView<Long> addView = Sets.difference(Sets.newHashSet(newIdList), Sets.newHashSet(oldIdList));
List<Long> addIdList = addView.stream().collect(Collectors.toList());
logger.info("要新加的群={}", addIdList);
for (Long chatId : addIdList) {
TabGroupChatHmRelation entity = new TabGroupChatHmRelation();
entity.setChatHmId(hm.getChatHmId());
entity.setWxEnterpriseId(wxEnterpriseId);
entity.setGroupChatId(chatId);
entity.setEnterpriseId(hm.getEnterpriseId());
entity.setRelationId(UniqueIdUtils.uniqueLong());
relationList.add(entity);
}
if(CollectionUtils.isNotEmpty(relationList)) {
this.groupChatHmRelationMapper.insertBatch(relationList);
}
} else {
ServiceResponse<String> addResp = this.qywxChatApiService.addJoinWay(qwDTO.getDkCorpid(),
......@@ -237,8 +265,9 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
TabGroupChatHmRelation entity = EntityUtil.changeEntity(TabGroupChatHmRelation.class, item);
entity.setChatHmId(hm.getChatHmId());
entity.setRelationId(UniqueIdUtils.uniqueLong());
this.groupChatHmRelationMapper.insert(entity);
relationList.add(entity);
}
this.groupChatHmRelationMapper.insertBatch(relationList);
}
}
......
......@@ -89,9 +89,9 @@
#{creatorName},
#{modifierId},
#{modifierName},
#{deleteFlag},
#{createTime},
#{updateTime},
0,
now(),
now(),
#{chatCount},
0 , 1
)
......
......@@ -26,38 +26,40 @@
create_time,
update_time
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert"
parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatHmRelation">
<![CDATA[
INSERT INTO tab_haoban_group_chat_hm_relation(
relation_id,
wx_enterprise_id,
enterprise_id,
chat_hm_id,
group_chat_id,
delete_flag,
status_flag,
create_time,
update_time
)VALUES(
#{relationId},
#{wxEnterpriseId},
#{enterpriseId},
#{chatHmId},
#{groupChatId},
0,
1,
now(),
now()
)
]]>
<insert id="insertBatch">
INSERT INTO tab_haoban_group_chat_hm_relation(
relation_id,
wx_enterprise_id,
enterprise_id,
chat_hm_id,
group_chat_id,
delete_flag,
status_flag,
create_time,
update_time
)VALUES
<foreach collection="list" item="item" separator="," >
( #{item.relationId},
#{item.wxEnterpriseId},
#{item.enterpriseId},
#{item.chatHmId},
#{item.groupChatId},
0,
1,
now(),
now()
)
</foreach>
</insert>
<!-- =====================删除==================== -->
<delete id="deleteById">
UPDATE tab_haoban_group_chat_hm_relation SET delete_flag = 1 WHERE
where chat_hm_id = #{chatHmId} and group_chat_id= #{groupChatId}
<delete id="delete">
UPDATE tab_haoban_group_chat_hm_relation SET delete_flag = 1 , update_time=now() WHERE
chat_hm_id = #{chatHmId} and group_chat_id in
<foreach collection="groupChatIdList" item="id" close=")" index="index" open="(" separator=",">
#{id}
</foreach>
</delete>
......
......@@ -183,7 +183,17 @@
and delete_flag = 0
</select>
<select id="listByWxWxChatIdList" resultMap="result-map-tabHaobanGroupChat">
select
<include refid="Base_Column_List" />
FROM tab_haoban_group_chat WHERE wx_chat_id in
<foreach collection="wxChatIdList" 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>
......
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