Commit 50e3e303 by 徐高华

其他链接保存逻辑

parent 9545c8cf
...@@ -5,7 +5,6 @@ import java.util.List; ...@@ -5,7 +5,6 @@ import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO;
import com.gic.haoban.manage.service.entity.hm.TabHmLink; import com.gic.haoban.manage.service.entity.hm.TabHmLink;
/** /**
...@@ -65,7 +64,4 @@ public interface HmLinkMapper { ...@@ -65,7 +64,4 @@ public interface HmLinkMapper {
public List<TabHmLink> queryPageRelationList(@Param("pageId") Long pageId, public List<TabHmLink> queryPageRelationList(@Param("pageId") Long pageId,
@Param("enterpriseId") String enterpriseId, @Param("searchText") String searchText); @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
...@@ -30,8 +30,17 @@ public class TabHmLinkChat implements Serializable{ ...@@ -30,8 +30,17 @@ public class TabHmLinkChat implements Serializable{
private java.util.Date updateTime; private java.util.Date updateTime;
private Integer deleteFlag; private Integer deleteFlag;
private Long linkId ; private Long linkId ;
private Integer otherFlag = 0 ;
public Long getLinkId() { public Integer getOtherFlag() {
return otherFlag;
}
public void setOtherFlag(Integer otherFlag) {
this.otherFlag = otherFlag;
}
public Long getLinkId() {
return linkId; return linkId;
} }
......
...@@ -386,35 +386,14 @@ public class GroupChatHmServiceImpl implements GroupChatHmService { ...@@ -386,35 +386,14 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
Set<Long> set = new HashSet<>(chatHmIdList); Set<Long> set = new HashSet<>(chatHmIdList);
List<HmLinkChatDTO> linkGroup = this.hmLinkChatService.getLinkCountForHm(wxEnterpriseId, List<HmLinkChatDTO> linkGroup = this.hmLinkChatService.getLinkCountForHm(wxEnterpriseId,
new ArrayList<>(set)); new ArrayList<>(set));
List<Long> allList = linkGroup.stream().map(dto -> dto.getLinkChatId()).collect(Collectors.toList());
List<String> otherIdList = new ArrayList<>(); linkGroup.forEach(dto -> {
if (CollectionUtils.isNotEmpty(linkGroup)) { Long hmId = dto.getChatHmId();
for (HmLinkChatDTO item : linkGroup) { int count = dto.getLinkCount();
otherIdList.add(item.getChatHmId() + "_" + item.getLinkId()); this.groupChatHmMapper.updateLinkCount(hmId, count);
} });
} for (Long id : chatHmIdList) {
List<HmLinkChatDTO> otherList = this.hmLinkMapper.getLinkCountForHm(wxEnterpriseId, chatHmIdList); if (!allList.contains(id)) {
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); this.groupChatHmMapper.updateLinkCount(id, 0);
} }
} }
......
package com.gic.haoban.manage.service.service.hm.impl; package com.gic.haoban.manage.service.service.hm.impl;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -82,13 +83,32 @@ public class HmLinkChatServiceImpl implements HmLinkChatService { ...@@ -82,13 +83,32 @@ public class HmLinkChatServiceImpl implements HmLinkChatService {
// 更新其他链接 // 更新其他链接
List<Long> idList = list.stream().map(dto -> dto.getChatHmId()).collect(Collectors.toList()); List<Long> idList = list.stream().map(dto -> dto.getChatHmId()).collect(Collectors.toList());
idList.add(otherHmId); idList.add(otherHmId);
boolean addOther = false;
if (null != link) { if (null != link) {
idList.add(link.getOtherChatHmId()); idList.add(link.getOtherChatHmId());
if (otherHmId.equals(link.getOtherChatHmId())) {
this.hmLinkChatMapper.delete(linkId, Arrays.asList(link.getOtherChatHmId()));
addOther = true;
}
} else {
addOther = true;
}
if (addOther) {
TabHmLinkChat other = new TabHmLinkChat();
other.setOtherFlag(1);
other.setWxEnterpriseId(wxEnterpriseId);
other.setEnterpriseId(enterpriseId);
other.setLinkId(linkId);
other.setLinkChatId(UniqueIdUtils.uniqueLong());
this.hmLinkChatMapper.insert(other);
} }
// 统计活码关联的链接数量 // 统计活码关联的链接数量
for (HmLinkChatDTO old : oldList) { for (HmLinkChatDTO old : oldList) {
idList.add(old.getChatHmId()); idList.add(old.getChatHmId());
} }
this.groupChatHmService.updateLinkCount(wxEnterpriseId, idList); this.groupChatHmService.updateLinkCount(wxEnterpriseId, idList);
return 0; return 0;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<result column="update_time" property="updateTime" /> <result column="update_time" property="updateTime" />
<result column="delete_flag" property="deleteFlag" /> <result column="delete_flag" property="deleteFlag" />
<result column="link_id" property="linkId" /> <result column="link_id" property="linkId" />
<result column="other_flag" property="otherFlag"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
link_chat_id, link_chat_id,
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
sort_num, sort_num,
create_time, create_time,
update_time, update_time,
delete_flag , link_id delete_flag , link_id , other_flag
</sql> </sql>
<!-- ===================== 新增 ======================== --> <!-- ===================== 新增 ======================== -->
<insert id="insert" <insert id="insert"
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
sort_num, sort_num,
create_time, create_time,
update_time, update_time,
delete_flag , link_id delete_flag , link_id , other_flag
)VALUES( )VALUES(
#{linkChatId}, #{linkChatId},
#{wxEnterpriseId}, #{wxEnterpriseId},
...@@ -53,7 +54,7 @@ ...@@ -53,7 +54,7 @@
now(), now(),
now(), now(),
0 , 0 ,
#{linkId} #{linkId} , #{otherFlag}
) )
]]> ]]>
</insert> </insert>
...@@ -90,17 +91,17 @@ ...@@ -90,17 +91,17 @@
filter_json filterJson , filter_json filterJson ,
chat_hm_id chatHmId, chat_hm_id chatHmId,
member_type memberType member_type memberType
from tab_haoban_hm_link_chat where link_id = #{linkId} and wx_enterprise_id = #{wxEnterpriseId} and enterprise_id = #{enterpriseId} from tab_haoban_hm_link_chat where link_id = #{linkId} and wx_enterprise_id = #{wxEnterpriseId} and enterprise_id = #{enterpriseId} and other_flag = 0
</select> </select>
<select id="getLinkCountForHm" resultType="com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO"> <select id="getLinkCountForHm" resultType="com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO">
select chat_hm_id chatHmId, link_id linkId , COUNT(*) linkCount from tab_haoban_hm_link_chat where wx_enterprise_id = #{wxEnterpriseId} select chat_hm_id chatHmId, COUNT(DISTINCT(link_id)) linkCount linkCount from tab_haoban_hm_link_chat where wx_enterprise_id = #{wxEnterpriseId}
and chat_hm_id in and chat_hm_id in
<foreach collection="chatHmIdList" item="item" separator="," index="index" close=")" open="("> <foreach collection="chatHmIdList" item="item" separator="," index="index" close=")" open="(">
#{item} #{item}
</foreach> </foreach>
and delete_flag = 0 group by chat_hm_id , link_id and delete_flag = 0 group by chat_hm_id
</select> </select>
......
...@@ -164,14 +164,5 @@ ...@@ -164,14 +164,5 @@
and ( link_code = #{searchText} or name like CONCAT('%', #{searchText},'%')) and ( link_code = #{searchText} or name like CONCAT('%', #{searchText},'%'))
</if> </if>
</select> </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> </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