// 从一个List<object>中获得每个object的对象的id组成一个list:
List<Long> ids = workStepPos.stream().map(WorkStepPo :: getId).collect(Collectors.toList());
// 数组里边有空,去空操作:
String[] strings = Arrays.stream(materialIds).filter(s -> !"".equals(s)).toArray(String[] ::new);
//根据id获得List中对象:
Cart cart = cartlist.stream().filter(item -> item.getProductId().equals(1L)).findFirst().get()
//list转换为imap
Map<String, WorkOrderProcessNumberVo> maps = workOrderProcessNumberVos.stream().collect(Collectors.toMap(WorkOrderProcessNumberVo::getProcessName, Function.identity()));
//去除辅料 num=0的为辅料 再分组计算
return bomVoList.stream().filter(e -> e.getNum() != 0).collect(Collectors.groupingBy(BomVo :: getInventoryCode, Collectors.summingInt(BomVo :: getNum)));
//选择type为1的对象的id
List<Long> productProcessIdList=qiProcessRouteNumberList.stream().filter(e->e.getType()==1).map(WorkOrderProcessNumberVo::getProcessId).collect(Collectors.toList());
//过滤对象,修改某些对象值
list.stream() .filter(dog -> dog.getAge()<50) .forEach(dog -> dog.setAge(26));
//list<object> Object对象包含一个id值,想查看里边的id包含什么
先转换为map形式,id为key
List<CVenCode> cVenCodeList = labelPrintRecordMapper.getCVenCodeBo(inventoryCodeList);
Map<String, CVenCode> maps = cVenCodeList.stream().collect(Collectors.toMap(CVenCode::getInventoryCode, Function.identity()));
for (String inventoryCode : inventoryCodeList) {
if (!maps.containsKey(inventoryCode)) {
CVenCode cVenCode = new CVenCode(inventoryCode, "999999");
cVenCodeList.add(cVenCode);
}
}
//字段为空
List<MaterialVo> result = list.stream().filter(s->StringUtils.isNoneBlank(s.getInventoryType())).filter(materialVo -> !materialVo.getInventoryType().equals("30")).collect(Collectors.toList());
List<BomPo> bomPoList = bomMapper.selectByExample(example);
List<ProductingVo> productingVos = bomPoList.stream().map(bomPo -> {
ProductingVo productingVo = new ProductingVo();
productingVo.setId(bomPo.getId());
return productingVo;
}).collect(Collectors.toList());
List转换为String
String cVenCode = cVenCodeList.stream().map(c -> c.toString()).collect(Collectors.joining("|"));
List<String>转换为List<Long>:
List<String> idList = Arrays.asList(strings);
return idList.stream().map(Long :: valueOf).collect(Collectors.toList());