feature 1.优化多线程逻辑

release
zhenghaiyang@ele-cloud.com 2 years ago
parent 4315e789c7
commit 6df223494c
  1. 19
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/controller/GroupCommodityCodeController.java

@ -166,15 +166,18 @@ public class GroupCommodityCodeController {
}
int index = 0;
List<CompletableFuture<String>> completableFutureList = Lists.newArrayList();
for (MdmGmfxxtbReqBO reqBO : reqBOList) {
CompletableFuture<String> voidCompletableFuture = CompletableFuture.supplyAsync(()->{
String str = buyerMessageService(reqBO);
return str;
}, voucherTaskExecutor);
completableFutureList.add(voidCompletableFuture);
List<List<MdmGmfxxtbReqBO>> partition = Lists.partition(reqBOList, 200);
for (List<MdmGmfxxtbReqBO> mdmGmfxxtbReqBOS : partition) {
List<CompletableFuture<String>> completableFutureList = Lists.newArrayList();
for (MdmGmfxxtbReqBO reqBO : mdmGmfxxtbReqBOS) {
CompletableFuture<String> voidCompletableFuture = CompletableFuture.supplyAsync(()->{
String str = buyerMessageService(reqBO);
return str;
}, voucherTaskExecutor);
completableFutureList.add(voidCompletableFuture);
}
CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0])).join();
}
CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0])).join();
return R.ok().put("data","");
} catch (IOException e) {
throw new RuntimeException(e);

Loading…
Cancel
Save