public Map<String, Object> getDataByBatch(List<String> reUserIds) {
if (CollectionUtils.isEmpty(reUserIds)) {
return new HashMap<>();
}
log.error("大小:{}", reUserIds.size());
int size = reUserIds.size();
Map<String, Object> userInfos = new HashMap<>();
if (size <= 100) {
//批量请求
try {
//封装数据
} catch (Exception e) {
// 继续运行下去
log.error("获取用户信息失败", e);
}
} else {
//循环调次数
int sr = size / 100;
//余数
int ss = size % 100;
for (int i1 = 0; i1 < sr + 1; i1++) {
List<String> subUserIds = new ArrayList<>();
if (i1 == sr) {
subUserIds = reUserIds.subList(i1 * 100, i1 * 100 + ss);
} else {
subUserIds = reUserIds.subList(i1 * 100, (i1 + 1) * 100 - 1);
}
//批量请求
try {
//封装数据
} catch (Exception e) {
// 继续运行下去
log.error("获取用户信息失败", e);
}
}
}
return userInfos;
}
批量操作工具类
猜你喜欢
转载自blog.csdn.net/linyiwwy/article/details/126423672
今日推荐
周排行