List<GroupSubCodeEntity> records = groupSubCode.getRecords();
CompletableFuture<GroupListingDTO>[] completableFutures = records.stream().map(e -> CompletableFuture.supplyAsync(() -> {
GroupListingDTO dto = new GroupListingDTO();
BeanUtil.copyProperties(e, dto);
JSONObject list = subCodeService.getList(e.getChatId());
int count = 1 ;
if (LinkeWechat.OK.equals(list.get(LinkeWechat.ERRMSG))) {
count = list.getJSONObject(LinkeWechat.GROUP_CHAT).getJSONArray(LinkeWechat.MEMBER_LIST).size();
}
dto.setNumber(count);
return dto;
},threadPoolBuilder.getThreadPoolExecutor())).toArray(CompletableFuture[]::new);
CompletableFuture.allOf(completableFutures).join();
List<GroupListingDTO> dtos = Arrays.stream(completableFutures).map(CompletableFuture::join).collect(Collectors.toList());