递归查:

    @Override
public List<PromotionOrgInfoPO> queryOrgInfo() {
List<PromotionOrgInfoPO> promotionOrgInfoPOS = pointExchangeDAO.queryOrgInfo();
List<PromotionOrgInfoPO> rootInfo = new ArrayList<>();
if (CollectionUtils.isNotEmpty(promotionOrgInfoPOS)) {
promotionOrgInfoPOS.forEach(promotionOrgInfoPO -> {
if (Objects.isNull(promotionOrgInfoPO.getParentId())) {
rootInfo.add(promotionOrgInfoPO);
}
});
rootInfo.forEach(menu -> {
List<PromotionOrgInfoPO> childList = getChildMenu(menu.getId(), promotionOrgInfoPOS);
menu.setChildOrgInfos(childList);
});
}
return rootInfo;
} private List<PromotionOrgInfoPO> getChildMenu(Long id, List<PromotionOrgInfoPO> allMenu) {
//子菜单
List<PromotionOrgInfoPO> childList = new ArrayList<>();
allMenu.forEach(all -> {
// 遍历所有节点,将所有的父id与传过来的根节点的id比较
if (all.getParentId().equals(id)) {
childList.add(all);
}
});
//递归
childList.forEach(child -> child.setChildOrgInfos(getChildMenu(child.getId(), allMenu)));
//如果节点下没有子节点,返回一个空List(递归退出)
if (childList.size() == 0) {
return new ArrayList<>();
}
return childList;
}

常用求和:

Map<String, BigDecimal> currencyCard = paymentVOS.stream().distinct().collect(Collectors.groupingBy(InternalPaymentVO::getDeductCardNo,
Collectors.mapping(InternalPaymentVO::getDeductAmount,
Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
    int points = internalPaymentVOS.stream().filter(v -> v.getType().equals(92)).mapToInt(InternalPaymentVO::getPmUsedPoints).sum();

                BigDecimal pointsMoney = internalPaymentVOS.stream().filter(v -> v.getType().equals(92)).map(InternalPaymentVO::getPmUsedMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
paymentVOS = internalPaymentVOS.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InternalPaymentVO::getType))), ArrayList::new));

最新文章

  1. NOIP模板整理计划
  2. Thinkphp3.2.3使用Ajax一定注意 数据返回
  3. android 下载文件,file的读写应用
  4. xlat指令...
  5. Js杂谈-DOM
  6. Java api 入门教程 之 JAVA的文件操作
  7. 用jackson封装的JSON工具类
  8. matlab实现分水岭算法处理图像分割
  9. 容器--Collection和AbstractCollection
  10. php:mysqli扩展
  11. css3 动画 执行一次
  12. 【转】【iOS系列】-iOS查看沙盒文件图文教程(真机+模拟器)
  13. Map集合案例
  14. Rust 学习 0
  15. Hyper-V 测试
  16. yii 使用renderPartial调用另外一个控制器的视图
  17. 使用 Windows Media Center 远程控制
  18. [Angular Tutorial] 9 -Routing &amp; Multiple Views
  19. JFinal 极速开发框架的优点和不足的地方
  20. PHP常见错误汇总

热门文章

  1. Linux内核机制—smp_hotplug_thread
  2. CPU 相关知识
  3. redis相关入门知识
  4. 第三周day3
  5. 检测到远端rexec服务正在运行中
  6. PMP学习笔记 (一)
  7. kubectl的vistor模式
  8. 我和Java这些年的故事(三)
  9. c语言学习--静态函数
  10. Java方法之可变参数