public ResponseUtil getOrder(Map<String, Object>where){
//查询主数据列表
List<LastAppprovedProjInfo> list = lastAppprovedProjInfoMapper.list(where);
//补充办事处信息
Set<Long> officeIdSet = list.stream().map(LastAppprovedProjInfo::getOfficeId).collect(Collectors.toSet());
Map<Long, OfficeInfo> officeMAp = iOfficeInfoService.getMapByIds(officeIdSet);
//补充订单类型
//使用lambda表达式获取到主数据中外键set集合 filter(Objects::nonNull)放在map后 筛除为null的值 外键为string时需要 如果为int 默认值0不需要
Set<String> orderTypeSet = list.stream().map(LastAppprovedProjInfo::getOrderType).filter(Objects::nonNull).collect(Collectors.toSet());
Map<String, Object> orderTypeWhere = new HashMap<>();
orderTypeWhere.put("keys",orderTypeSet);
//外键set集合 in查询获取关联数据
List<DictInfo> orderTypeList = dictInfoMapper.list(orderTypeWhere);
//关联数据转为m
Java 使用lambda表达式进行联查 以及 lambda表达式过滤空值
最新推荐文章于 2024-05-03 16:35:22 发布