通过 workOrederNum
字段排序
1
| List<ProduceOrderDTO> collect = list.stream().sorted(Comparator.comparing(ProduceOrderDTO::getWorkOrderNum)).collect(Collectors.toList());
|
查出 InstructionPoDTO
中 InstructionDocNum
作为 list
1 2
| List<String> instructionDocNums = read.stream().map(InstructionPoDTO::getInstructionDocNum).distinct().collect(Collectors.toList());
|
筛选所有 instructionDocNum = 123
的对象
1 2
| List<InstructionPoDTO> instructionPoDTOS = read.stream().filter(instructionPoDTO -> instructionPoDTO.getInstructionDocNum().equals("123")).collect(Collectors.toList());
|
查询出第一个
1
| String instructionDocId = instructionDocs.stream().findFirst().get();
|
设置 typeCode
为 key, list
的对象为 value
1
| Map<String, MtGenType> typesMap = types.stream().collect(Collectors.toMap(t -> t.getTypeCode(), t -> t));
|
// 通过字段去重
1
| instructionSapStockDTOS.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()-> new TreeSet<>(Comparator.comparing(o -> o.getMaterial()+";"+o.getPlant()+";"+o.getStorage()+";"+o.getBatch()+";"+o.getSpecialStock()))), ArrayList::new));
|
GROUP BY
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Map<String, List<WmsIqcRecord>> map = records.stream().collect(Collectors.groupingBy(iqcRecord -> { if (StringUtils.equals("TO_DO", iqcRecord.getStatus())) { switch (iqcRecord.getDealMethod()) { case "RELEASE": return "TO_RELEASE"; case "FREEZE": return "TO_FREEZE"; case "RETURN": return "TO_RETURN"; default: return "TO_DO"; } } else if (StringUtils.equals("DONE", iqcRecord.getStatus())) { switch (iqcRecord.getDealMethod()) { case "RELEASE": return "RELEASE_DONE"; case "FREEZE": return "FREEZE_DONE"; case "RETURN": return "RETURN_DONE"; default: return "DONE"; } } else { return "DEAL"; } }));
|
1 2 3 4 5 6 7
| // List<LocalDate> collect = localDates.stream().sorted((var1, var2) -> { // if (var1.isBefore(var2)) { // return -1; // } // return 1; // }).collect(Collectors.toList()); // System.out.println(localDates.stream().sorted().collect(Collectors.toList()));
|