Commit 3ece2262 by jinxin

离职继承数据量过大优化

parent 20127ca8
...@@ -120,5 +120,5 @@ public interface HandoverService { ...@@ -120,5 +120,5 @@ public interface HandoverService {
* @return * @return
*/ */
public List<HandoverStaffFriendCountDTO> listFriendCountByWxStaffIds(String wxEnterpriseId, List<String> staffIds); public List<HandoverStaffFriendCountDTO> listFriendCountByWxStaffIds(String wxEnterpriseId, List<String> staffIds);
TabHandoverStaff getHandoverStaff(String wxEnterpriseId, String wxUserId);
} }
...@@ -176,8 +176,8 @@ public class HandoverServiceImpl implements HandoverService { ...@@ -176,8 +176,8 @@ public class HandoverServiceImpl implements HandoverService {
staffClerkRelationService.cleanStaffClerk(handoverStaff.getWxEnterpriseId(), staffIds); staffClerkRelationService.cleanStaffClerk(handoverStaff.getWxEnterpriseId(), staffIds);
} }
} }
@Override
private TabHandoverStaff getHandoverStaff(String wxEnterpriseId, String wxUserId) { public TabHandoverStaff getHandoverStaff(String wxEnterpriseId, String wxUserId) {
TabHaobanStaff haobanStaff = staffMapper.getNoStatusByWxUserIds(wxEnterpriseId, wxUserId); TabHaobanStaff haobanStaff = staffMapper.getNoStatusByWxUserIds(wxEnterpriseId, wxUserId);
if (null == haobanStaff) { if (null == haobanStaff) {
logger.info("对应的staff不存在:{}", wxUserId); logger.info("对应的staff不存在:{}", wxUserId);
......
...@@ -99,15 +99,27 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -99,15 +99,27 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
*/ */
private List<QywxUnassignedInfoDTO> getAllQywxUnassigned(String wxEnterpriseId) { private List<QywxUnassignedInfoDTO> getAllQywxUnassigned(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
List<QywxUnassignedInfoDTO> ret = new ArrayList<>(); //这里改成LinkedList,避免使用ArrayList导致频繁扩容,从而减少内存的浪费
List<QywxUnassignedInfoDTO> ret = new LinkedList<>();
QywxGetUnassignedListDTO unassignedListDTO = null; QywxGetUnassignedListDTO unassignedListDTO = null;
String cursor = null; String cursor = null;
do { do {
//离职成员客户列表 //离职成员客户列表
unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), cursor , qwDTO.isSelf(),qwDTO.getUrlHost()); unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), cursor , qwDTO.isSelf(),qwDTO.getUrlHost());
cursor = unassignedListDTO.getNextCursor(); cursor = unassignedListDTO.getNextCursor();
if (CollectionUtils.isNotEmpty(unassignedListDTO.getInfo())) { List<QywxUnassignedInfoDTO> infoList = unassignedListDTO.getInfo();
ret.addAll(unassignedListDTO.getInfo()); if (CollectionUtils.isNotEmpty(infoList)) {
//这里过滤staff成员id,避免ret数组过大
ret.addAll(infoList);
//根据handoverUserid去重
List<QywxUnassignedInfoDTO> collect = infoList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(QywxUnassignedInfoDTO::getHandoverUserid))), ArrayList::new));
for (QywxUnassignedInfoDTO dto : collect){
String handoverUserid = dto.getHandoverUserid();
TabHandoverStaff handoverStaff = handoverService.getHandoverStaff(wxEnterpriseId, handoverUserid);
if (null == handoverStaff) {
ret = ret.stream().filter(d -> !d.getHandoverUserid().equals(handoverUserid)).collect(Collectors.toList());
}
}
} }
} while (StringUtils.isNotBlank(cursor) && unassignedListDTO.getErrcode() == 0); } while (StringUtils.isNotBlank(cursor) && unassignedListDTO.getErrcode() == 0);
if (CollectionUtils.isEmpty(ret)) { if (CollectionUtils.isEmpty(ret)) {
......
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