@Override
public List<CustomsClearanceOutputDto> exportVehicleDerailList(CustomsClearanceInputDto dto, HttpServletResponse response) {
List<CustomsClearanceOutputDto> list = repository.queryCustomListDetail(dto);
Map<String, List<CustomsClearanceOutputDto>> map = list.stream().collect(Collectors.groupingBy(data -> format("{0}#{1}", data.getModel(), data.getType())));
return null;
}
public static String format(String value, Object... paras) {
return MessageFormat.format(value, paras);
}
多字段分组
Map<String, List<DfwlBuCheckEntity>> groupMap = list.stream()
.collect(Collectors.groupingBy(entity ->
String.format("%s_%s_%s_%s_%s",
entity.getWarehouseCode() != null ? entity.getWarehouseCode() : "",
entity.getAreaCode() != null ? entity.getAreaCode() : "",
entity.getPlaceCode() != null ? entity.getPlaceCode() : "",
entity.getPartNo() != null ? entity.getPartNo() : "",
entity.getSupplierCode() != null ? entity.getSupplierCode() : ""
)
));