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; int index = 0;
List<CompletableFuture<String>> completableFutureList = Lists.newArrayList(); List<List<MdmGmfxxtbReqBO>> partition = Lists.partition(reqBOList, 200);
for (MdmGmfxxtbReqBO reqBO : reqBOList) { for (List<MdmGmfxxtbReqBO> mdmGmfxxtbReqBOS : partition) {
CompletableFuture<String> voidCompletableFuture = CompletableFuture.supplyAsync(()->{ List<CompletableFuture<String>> completableFutureList = Lists.newArrayList();
String str = buyerMessageService(reqBO); for (MdmGmfxxtbReqBO reqBO : mdmGmfxxtbReqBOS) {
return str; CompletableFuture<String> voidCompletableFuture = CompletableFuture.supplyAsync(()->{
}, voucherTaskExecutor); String str = buyerMessageService(reqBO);
completableFutureList.add(voidCompletableFuture); 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",""); return R.ok().put("data","");
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);

Loading…
Cancel
Save