1 List<EntityBaseWorkshopVO> list = workshopDao.getList(pageparams); 2 List<EntityBaseWorkshopArea> arealist=workshopAreaDao.getList(null); 3 Map<String,List<EntityBaseWorkshopArea>> areaMap=arealist.stream().collect(Collectors.groupingBy(EntityBaseWorkshopArea::getWorkshopid)); 4 for (EntityBaseWorkshopVO workshop : list) { 5 if(areaMap.get(workshop.getWorkshopid())!=null) { 6 workshop.setWorkshoparealist(areaMap.get(workshop.getWorkshopid())); 7 } 8 }
Map<String,List<EncodeProduct>> encodeMap=list.stream().collect(Collectors.groupingBy(EncodeProduct::getGroupno)); for (String key : encodeMap.keySet()) { ProductNoVO novo=new ProductNoVO(); List<String> prono=new ArrayList<String>(); for (int i = 0; i < encodeMap.get(key).size(); i++) { prono.add(encodeMap.get(key).get(i).getProductno()); } novo.setProductnolist(prono); novo.setGroupno(key); lst.add(novo); }