美文网首页
java8-在项目中的使用示例

java8-在项目中的使用示例

作者: lesline | 来源:发表于2018-10-14 23:41 被阅读23次
//车源信息
CompletableFuture<CarSourceHttpAdapter.CarSourceInfo> carSourceInfoFuture = CompletableFuture.supplyAsync(() -> carSourceHttpAdapter.getCarInfoByClueId(claimCases.getClueId()));

CarSourceHttpAdapter.CarSourceInfo carSourceInfo = getResult(carSourceInfoFuture);

public static <T> T getResult(Future<T> future) {
    T result = null;
    try {
        result = future.get(1000, TimeUnit.MILLISECONDS);
    } catch (Exception e) {
        log.error("调用第三方接口异常", e);
    }
    return result;
}
//复检师信息
        //复检师id
        CompletableFuture<Integer> evaluatorIdFuture = CompletableFuture.supplyAsync(() -> evaluateHttpAdapter.getEvaluatorIdByClueId(clueId));
        //根据复检师id获取复检师详情
        CompletableFuture<StaffHttpAdapter.StaffInfo> evaluatorFuture = evaluatorIdFuture.thenApplyAsync(evaluatorId -> staffHttpAdapter.getStaffInfoById(evaluatorId));
Map<Integer, Integer> requestMap = orderDetailList.stream().filter(detailParam -> detailParam.getOrderContentDetailId() != null).
        collect(Collectors.*groupingBy*(BusinessOrderDetailParam::getOrderContentDetailId, Collectors.*summingInt*(BusinessOrderDetailParam::getUseNum)));

相关文章

网友评论

      本文标题:java8-在项目中的使用示例

      本文链接:https://www.haomeiwen.com/subject/gzkxzftx.html