JAVA8新特性

1、sql聚合函数,将查询到的一列值拼接到一个字段

GROUP_CONCAT( rep.`wg_name` SEPARATOR ',' )

2、java8将list中以特定符号隔开

String result5 = listCust.stream().map(String::valueOf).collect(Collectors.joining(","));

3、获取某一项元素组成新的list

List<String> res = list.stream() // 将列表转换为Stream
                .map(WmsTblbarcodeScaned::getTblBarcode) // 提取每个人的名字
                .collect(Collectors.toList()); // 收集结果到新的列表
                ```
  1. // 使用Stream API遍历List,并检查每个对象的某个属性是否为null
List<MyObject> objectsWithNullProperty = myList.stream()
        .filter(obj -> obj.getProperty() == null)
        .collect(Collectors.toList());
  1. // 使用Stream根据指定字段分组后求和
Map<String, Integer> listSignMap = signList.stream()
                    .collect(Collectors.groupingBy(
                            WmsSignApplication::getCInvCode,
                            Collectors.summingInt(WmsSignApplication::getQty)
                    ));
  1. // 使用Stream API进行双层分组

        Map<String, Map<String, List<ErpSyncOutDTO>>> res = erpSyncOutDTOS.stream()
                .collect(Collectors.groupingBy(
                        ErpSyncOutDTO::getCCode,
                        Collectors.groupingBy(ErpSyncOutDTO::getSyncCode)
                ));
  1. // 根据元素过滤得到新的list
        List<UpdateWmsStockInDTO> scannedExist = tblBarcodeList.stream()
                .filter(dto -> !tblBarCodeStatusAll.contains(dto.getTblBarcode()))
                .collect(Collectors.toList());
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值