Commit 9545c8cf by 徐高华

活码链接数

parent bb9ae77d
......@@ -5,6 +5,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO;
import com.gic.haoban.manage.service.entity.hm.TabHmLink;
/**
......@@ -63,4 +64,8 @@ public interface HmLinkMapper {
public List<TabHmLink> queryPageRelationList(@Param("pageId") Long pageId,
@Param("enterpriseId") String enterpriseId, @Param("searchText") String searchText);
public List<HmLinkChatDTO> getLinkCountForHm(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("chatHmIdList") List<Long> chatHmIdList) ;
}
\ No newline at end of file
......@@ -40,6 +40,6 @@ public interface GroupChatHmService {
public void updateLinkCount(String wxEnterpriseId, Long chatHmId);
public void updateLinkCount(String wxEnterpriseId , List<Long> chatHmIdList );
public void updateLinkCount(String wxEnterpriseId , List<Long> chatHmIdList);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -383,15 +384,40 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
public void updateLinkCount(String wxEnterpriseId, List<Long> chatHmIdList) {
if (CollectionUtils.isNotEmpty(chatHmIdList)) {
Set<Long> set = new HashSet<>(chatHmIdList);
List<HmLinkChatDTO> linkCount = this.hmLinkChatService.getLinkCountForHm(wxEnterpriseId,
List<HmLinkChatDTO> linkGroup = this.hmLinkChatService.getLinkCountForHm(wxEnterpriseId,
new ArrayList<>(set));
linkCount.forEach(dto -> {
Integer count = dto.getLinkCount();
if (null == count) {
count = 0;
List<String> otherIdList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(linkGroup)) {
for (HmLinkChatDTO item : linkGroup) {
otherIdList.add(item.getChatHmId() + "_" + item.getLinkId());
}
this.groupChatHmMapper.updateLinkCount(dto.getChatHmId(), count);
});
}
List<HmLinkChatDTO> otherList = this.hmLinkMapper.getLinkCountForHm(wxEnterpriseId, chatHmIdList);
for (HmLinkChatDTO dto : otherList) {
String tmp = dto.getChatHmId() + "_" + dto.getLinkId();
if (!otherIdList.contains(tmp)) {
linkGroup.add(dto);
}
}
Map<Long, List<HmLinkChatDTO>> map = linkGroup.stream()
.collect(Collectors.groupingBy(HmLinkChatDTO::getChatHmId));
Set<Long> allSet = map.keySet();
Iterator<Long> it = allSet.iterator();
while (it.hasNext()) {
Long key = it.next();
int count = 0;
for (HmLinkChatDTO item : map.get(key)) {
count += item.getLinkCount();
}
this.groupChatHmMapper.updateLinkCount(key, count);
}
for(Long id : chatHmIdList) {
if(!allSet.contains(id)) {
this.groupChatHmMapper.updateLinkCount(id, 0);
}
}
}
}
......
......@@ -95,12 +95,12 @@
<select id="getLinkCountForHm" resultType="com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO">
select chat_hm_id chatHmId, COUNT(DISTINCT(link_id)) linkCount from tab_haoban_hm_link_chat where wx_enterprise_id = #{wxEnterpriseId}
select chat_hm_id chatHmId, link_id linkId , COUNT(*) linkCount from tab_haoban_hm_link_chat where wx_enterprise_id = #{wxEnterpriseId}
and chat_hm_id in
<foreach collection="chatHmIdList" item="item" separator="," index="index" close=")" open="(">
#{item}
</foreach>
and delete_flag = 0 group by chat_hm_id
and delete_flag = 0 group by chat_hm_id , link_id
</select>
......
......@@ -157,12 +157,21 @@
and status_flag = 1 order by create_time desc
</select>
<select id="queryPageRelationList" resultMap="result-map-tabHaobanHmLink">
select <include refid="Base_Column_List"/>
from tab_haoban_hm_link where page_id = #{pageId} and enterprise_id=#{enterpriseId}
<if test="searchText != null and searchText != '' ">
and ( link_code = #{searchText} or name like CONCAT('%', #{searchText},'%'))
</if>
</select>
<select id="queryPageRelationList" resultMap="result-map-tabHaobanHmLink">
select <include refid="Base_Column_List"/>
from tab_haoban_hm_link where page_id = #{pageId} and enterprise_id=#{enterpriseId}
<if test="searchText != null and searchText != '' ">
and ( link_code = #{searchText} or name like CONCAT('%', #{searchText},'%'))
</if>
</select>
<select id="getLinkCountForHm" resultType="com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO">
select other_chat_hm_id chatHmId, link_id linkId , 1 linkCount from tab_haoban_hm_link where wx_enterprise_id = #{wxEnterpriseId}
and other_chat_hm_id in
<foreach collection="chatHmIdList" item="item" separator="," index="index" close=")" open="(">
#{item}
</foreach>
</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