feature 1.优化多线程逻辑

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

@ -166,8 +166,10 @@ public class GroupCommodityCodeController {
} }
int index = 0; int index = 0;
List<List<MdmGmfxxtbReqBO>> partition = Lists.partition(reqBOList, 200);
for (List<MdmGmfxxtbReqBO> mdmGmfxxtbReqBOS : partition) {
List<CompletableFuture<String>> completableFutureList = Lists.newArrayList(); List<CompletableFuture<String>> completableFutureList = Lists.newArrayList();
for (MdmGmfxxtbReqBO reqBO : reqBOList) { for (MdmGmfxxtbReqBO reqBO : mdmGmfxxtbReqBOS) {
CompletableFuture<String> voidCompletableFuture = CompletableFuture.supplyAsync(()->{ CompletableFuture<String> voidCompletableFuture = CompletableFuture.supplyAsync(()->{
String str = buyerMessageService(reqBO); String str = buyerMessageService(reqBO);
return str; return str;
@ -175,6 +177,7 @@ public class GroupCommodityCodeController {
completableFutureList.add(voidCompletableFuture); 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