Commit be72f9cf by songyinghui

feat: 分片写

parent 739c5280
...@@ -34,6 +34,7 @@ import com.gic.wechat.api.dto.qywx.group.QywxGroupMsgSendResultDTO; ...@@ -34,6 +34,7 @@ import com.gic.wechat.api.dto.qywx.group.QywxGroupMsgSendResultDTO;
import com.gic.wechat.api.dto.qywx.group.QywxMomentRespDTO; import com.gic.wechat.api.dto.qywx.group.QywxMomentRespDTO;
import com.gic.wechat.api.dto.qywx.group.QywxMomentSendResultRespDTO; import com.gic.wechat.api.dto.qywx.group.QywxMomentSendResultRespDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -344,10 +345,13 @@ public class GroupMessageServiceImpl implements GroupMessageService { ...@@ -344,10 +345,13 @@ public class GroupMessageServiceImpl implements GroupMessageService {
log.info("处理导购群发朋友圈触达客户日志, 成员无好友. staffId:{}", clerkShareLogBo.getStaffId()); log.info("处理导购群发朋友圈触达客户日志, 成员无好友. staffId:{}", clerkShareLogBo.getStaffId());
return; return;
} }
List<TriggerCustomerDetailBO> customerDetailBos = externalUserIds.stream() List<List<String>> partition = Lists.partition(externalUserIds, 1000);
.map(item -> this.convertCustomerDetailLog(clerkShareLogBo, item)) for (List<String> userIds : partition) {
.collect(Collectors.toList()); List<TriggerCustomerDetailBO> customerDetailBos = userIds.stream()
triggerCustomerDetailService.batchSave(customerDetailBos); .map(item -> this.convertCustomerDetailLog(clerkShareLogBo, item))
.collect(Collectors.toList());
triggerCustomerDetailService.batchSave(customerDetailBos);
}
} }
} }
...@@ -551,11 +555,14 @@ public class GroupMessageServiceImpl implements GroupMessageService { ...@@ -551,11 +555,14 @@ public class GroupMessageServiceImpl implements GroupMessageService {
if (CollectionUtils.isEmpty(groupMsgSendResultInfos)) { if (CollectionUtils.isEmpty(groupMsgSendResultInfos)) {
return; return;
} }
List<TriggerCustomerDetailBO> customerDetailBos = groupMsgSendResultInfos List<List<QywxGroupMsgSendResultDTO.GroupMsgSendResultInfo>> partition = Lists.partition(groupMsgSendResultInfos, 1000);
.stream() for (List<QywxGroupMsgSendResultDTO.GroupMsgSendResultInfo> msgSendResultInfos : partition) {
.map(item -> this.convertCustomerDetailLog(clerkShareLogBO, item.getExternalUserId())) List<TriggerCustomerDetailBO> customerDetailBos = msgSendResultInfos
.collect(Collectors.toList()); .stream()
triggerCustomerDetailService.batchSave(customerDetailBos); .map(item -> this.convertCustomerDetailLog(clerkShareLogBO, item.getExternalUserId()))
.collect(Collectors.toList());
triggerCustomerDetailService.batchSave(customerDetailBos);
}
} }
/** /**
...@@ -569,11 +576,14 @@ public class GroupMessageServiceImpl implements GroupMessageService { ...@@ -569,11 +576,14 @@ public class GroupMessageServiceImpl implements GroupMessageService {
if (CollectionUtils.isEmpty(groupChatUserBos)) { if (CollectionUtils.isEmpty(groupChatUserBos)) {
return; return;
} }
List<TriggerCustomerDetailBO> customerDetailBos = groupChatUserBos List<List<GroupChatUserBO>> partition = Lists.partition(groupChatUserBos, 1000);
.stream() for (List<GroupChatUserBO> groupChatUserBOS : partition) {
.map(item -> this.convertCustomerDetailLog(clerkShareLogBO, item.getUserId())) List<TriggerCustomerDetailBO> customerDetailBos = groupChatUserBOS
.collect(Collectors.toList()); .stream()
triggerCustomerDetailService.batchSave(customerDetailBos); .map(item -> this.convertCustomerDetailLog(clerkShareLogBO, item.getUserId()))
.collect(Collectors.toList());
triggerCustomerDetailService.batchSave(customerDetailBos);
}
} }
private TriggerCustomerDetailBO convertCustomerDetailLog(ClerkShareLogBO clerkShareLogBO, String externalUserId) { private TriggerCustomerDetailBO convertCustomerDetailLog(ClerkShareLogBO clerkShareLogBO, String externalUserId) {
......
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