Commit d202f3c0 by 徐高华

代码优化

parent c0157cc7
......@@ -25,4 +25,7 @@ public class Manage3Constants {
* 企微最大分页
*/
public static final Integer QW_LIMIT = 1000;
// 群群发统计
public static final Integer CHAT_PLAN_PAGE_SIZE = 1 ;
}
......@@ -56,25 +56,26 @@ public interface GroupChatApiService {
/**
*
* @Title: refreshChatInfo
* @Description: 刷新群信息
* @Description: 刷新群
* @author xugh
* @param groupChatId
* @return
* @throws
*/
public ServiceResponse<Void> refreshChatInfo(Long groupChatId);
public ServiceResponse<Void> refreshChatInfoFromMQ(String params);
/**
*
* @Title: refreshChatInfo
* @Description: 刷新群信息,从队列获取
* @Title: refreshChatStatus
* @Description: 刷新群的状态
* @author xugh
* @param groupChatId
* @param params
* @return
* @throws
*/
public ServiceResponse<Void> refreshChatInfoFromMQ(String params);
public ServiceResponse<Void> refreshChatStatusFromMQ(String params) ;
/**
*
* @Title: updateChatEnterpriseId
......
......@@ -21,6 +21,8 @@ public interface GroupChatUserMapper {
public int insert(TabGroupChatUser tabHaobanGroupChatUser);
public int batchInsert(@Param("list")List<TabGroupChatUser> userList);
public int dismiss(@Param("idList") List<Long> chatUserIdList, @Param("ownerId") String ownerId);
public int update(TabGroupChatUser tabHaobanGroupChatUser);
......
......@@ -39,7 +39,17 @@ public interface GroupChatService {
* @param chatHmId
* @throws
*/
public void refreshChatInfo(Long chatHmId);
public void refreshChatInfo(Long groupChatId);
/**
*
* @Title: refreshChatStatus
* @Description: 刷新群的状态
* @author xugh
* @param groupChatId
* @throws
*/
public void refreshChatStatus(Long groupChatId);
/**
*
......
......@@ -111,6 +111,9 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
@Override
public void batchAdd(String staffIdList, TabGroupChatPlan entity) {
if (StringUtils.isBlank(staffIdList)) {
return;
}
String[] arr = staffIdList.split(",");
List<TabGroupChatPlanOwnerLog> logList = new ArrayList<>();
for (int i = 0; i < arr.length; i++) {
......@@ -132,7 +135,7 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
@Override
public void update(TabGroupChatPlanOwnerLog entity) {
String staffId = entity.getStaffId() ;
String staffId = entity.getStaffId();
TabHaobanClerkMainStoreRelated mainStore = this.clerkMainStoreRelatedService.getMainStoreByStaffId(staffId,
entity.getWxEnterpriseId());
if (null == mainStore) {
......@@ -159,8 +162,14 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
@Override
public void deleteByStaffIds(Long planId, String delStaffIds) {
if (StringUtils.isBlank(delStaffIds)) {
return;
}
String[] arr = delStaffIds.split(",");
List<String> delStaffIdList = Arrays.asList(arr);
if (CollectionUtils.isEmpty(delStaffIdList)) {
return;
}
this.groupChatPlanOwnerLogMapper.deleteByStaffIds(planId, delStaffIdList);
}
......
......@@ -31,6 +31,7 @@ import com.gic.dubbo.entity.ProviderLocalTag;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.common.utils.DingUtils;
import com.gic.haoban.manage.api.constants.Manage3Constants;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatPlanDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatPlanLogDTO;
......@@ -101,7 +102,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
// 发送队列
private void putMQForSend(Long id) {
try {
mqClient.sendCommonMessage("haobanCommonRouter", id + "",
mqClient.sendCommonMessage("haobanChatMQ", id + "",
"com.gic.haoban.manage.api.service.chat.GroupChatPlanApiService", "doPlanTimer");
} catch (Exception e) {
logger.error("发送MQ异常");
......@@ -112,7 +113,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
// 统计队列
private void putMQForData(Long id) {
try {
mqClient.sendCommonMessage("haobanCommonRouter", id + "",
mqClient.sendCommonMessage("haobanChatMQ", id + "",
"com.gic.haoban.manage.api.service.chat.GroupChatPlanApiService", "doPlanSendInfoTimer");
} catch (Exception e) {
logger.error("发送MQ异常");
......@@ -145,20 +146,16 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
} else {
this.groupChatPlanMapper.updateById(entity);
// 删除本次删除的
String delStaffIdList = dto.getDelStaffIdList();
if (StringUtils.isNotBlank(delStaffIdList)) {
this.groupChatPlanOwnerLogService.deleteByStaffIds(planId, delStaffIdList);
}
this.groupChatPlanOwnerLogService.deleteByStaffIds(planId, dto.getDelStaffIdList());
// 新增本次新增的
if (StringUtils.isNotBlank(staffIdList)) {
this.groupChatPlanOwnerLogService.batchAdd(staffIdList, entity);
}
this.groupChatPlanOwnerLogService.batchAdd(staffIdList, entity);
}
// 立即发送
if (entity.getSendType() == 1) {
this.putMQForSend(entity.getPlanId());
this.addOrDelTimer(planId, entity.getSendTime(), 0);
this.putMQForSend(planId);
} else {
this.addOrDelTimer(entity.getPlanId(), entity.getSendTime(), 1);
this.addOrDelTimer(planId, entity.getSendTime(), 1);
}
}
......@@ -200,7 +197,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
madidList.add(json.getString("relation_id"));
}
int pageNum = 0;
int pageSize = 1;
int pageSize = Manage3Constants.CHAT_PLAN_PAGE_SIZE;
List<TabGroupChatPlanOwnerLog> ownerList = null;
while (true) {
ownerList = this.groupChatPlanOwnerLogMapper.listForDoPlan(planId, pageNum * pageSize, pageSize);
......
......@@ -165,12 +165,6 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
}
@Override
public ServiceResponse<Void> refreshChatInfo(Long chatHmId) {
this.groupChatService.refreshChatInfo(chatHmId);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> updateChatEnterpriseId(String wxEnterpriseId, String enterpriseId,
List<Long> groupChatIdList) {
this.groupChatService.updateChatEnterpriseId(wxEnterpriseId, enterpriseId, groupChatIdList);
......@@ -232,7 +226,17 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
JSONObject json = JSONObject.parseObject(params);
List<Long> arr = JSONObject.parseArray(json.getString("groupChatIdList"), Long.class);
for (Long id : arr) {
this.refreshChatInfo(id);
this.groupChatService.refreshChatInfo(id);
}
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> refreshChatStatusFromMQ(String params) {
JSONObject json = JSONObject.parseObject(params);
List<Long> arr = JSONObject.parseArray(json.getString("groupChatIdList"), Long.class);
for (Long id : arr) {
this.groupChatService.refreshChatStatus(id);
}
return ServiceResponse.success();
}
......
......@@ -756,10 +756,6 @@
</update>
<select id="getMemberForExternalId" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related where wx_enterprise_id = #{wxEnterpriseId}
and self_external_userid = #{externalUserId} and status_flag in (1,3,4) and member_id <![CDATA[ <> '']]>
union
select <include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related where wx_enterprise_id = #{wxEnterpriseId}
and external_user_id = #{externalUserId} and status_flag in (1,3,4) and member_id <![CDATA[ <> '' ]]>
......
......@@ -103,8 +103,60 @@
)
]]>
</insert>
<insert id="batchInsert">
INSERT INTO tab_haoban_group_chat_user(
chat_user_id,
wx_enterprise_id,
enterprise_id,
user_type,
join_time,
user_name,
nick_name,
user_id,
unionid,
member_id,
invitor_user_id,
create_time,
update_time,
delete_flag,
group_chat_id,
status_flag,
user_quit_time,
quit_scene,
join_scene,
join_remark,
join_state , invitor_user_name , admin_flag
)VALUES
<foreach collection="list" item="item" separator="," >
( #{item.chatUserId},
#{item.wxEnterpriseId},
#{item.enterpriseId},
#{item.userType},
#{item.joinTime},
#{item.userName},
#{item.nickName},
#{item.userId},
#{item.unionid},
#{item.memberId},
#{item.invitorUserId},
#{item.createTime},
#{item.updateTime},
#{item.deleteFlag},
#{item.groupChatId},
#{item.statusFlag},
#{item.userQuitTime},
#{item.quitScene},
#{item.joinScene},
#{item.joinRemark},
#{item.joinState} , #{item.invitorUserName} , #{item.adminFlag}
)
</foreach>
</insert>
<!-- =====================删除==================== -->
<!-- =====================废弃群==================== -->
<update id="dismiss">
UPDATE tab_haoban_group_chat_user SET status_flag = 2 , update_time=now() , user_quit_time = now() , quit_scene = 0 , quit_staff_id = #{ownerId} WHERE chat_user_id in
<foreach collection="idList" close=")" open="(" index="index" item="id" separator=",">
......
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