Commit 022f553a by 徐高华

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