JAVA lambda 分组随笔琐记

Map<String, List<GoodsStockModel>> groupMap = goodsStockModelNew.getSkus_list().stream().
collect(Collectors.groupingBy(GoodsStockModel::getSkuid));

for (Map.Entry<String, List<GoodsStockModel>> map : groupMap.entrySet()) {
if (map.getValue().size() > 1) {
//处理业务
GoodsStockModelResponse response=new GoodsStockModelResponse();
System.out.println(map.getKey());
response.setSkuid(map.getKey());
response.setWarehouse_id("");
//response.setWarehouse_id(menu.getWarehouse_id());
response.setFail_info("商品编码不能重复,请检查参数中sku_id");
responseList.add(response);

System.out.println("------>" + map.getKey());
}
}
posted @ 2023-03-13 17:38  LowKeyC  阅读(42)  评论(0编辑  收藏  举报
有志者事竟成破釜沉舟百二秦关终属楚苦心人,天不负,卧薪尝胆,三千越甲可吞吴