java List<Map>流 转map

场景:近日需要将查询的数据返回结果重组成map,遍找了个方便的方法

  //查询昨日办结量
        List> zrBllList = tjYwCommonDao.selectYwbllByDate(map);
        Map zrBllListMap = zrBllList.stream().collect(Collectors.toMap(a -> a.get("QXDM"), b -> b.get("BJL")));
        //查询本月办结量
        List> byBllList = tjYwCommonDao.selectYwbBenyllByDate(map);
        Map byBllListMap = byBllList.stream().collect(Collectors.toMap(a -> a.get("QXDM"), b -> b.get("BJL")));
        //查询同比办理量
        List> tbBllList = tjYwCommonDao.selectYwTbbllByDate(map);
        Map tbBllListMap = tbBllList.stream().collect(Collectors.toMap(a -> a.get("QXDM"), b -> b.get("BJL")));
        //查询环比办理量
        List> hbBllList = tjYwCommonDao.selectYwHbbllByDate(map);
        Map hbBllListMap = hbBllList.stream().collect(Collectors.toMap(a -> a.get("QXDM"), b -> b.get("BJL")));

2.流分组,返回为以qxdm 为key

Map>> qxdm = mapList.stream().collect(Collectors.groupingBy(x -> x.get("QXDM").toString()));

你可能感兴趣的:(java List<Map>流 转map)