|
@@ -9,32 +9,22 @@ import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @description 过滤车型
|
|
|
|
|
* @author wenks
|
|
* @author wenks
|
|
|
|
|
+ * @description 过滤车型
|
|
|
* @date 2023/8/22 9:54
|
|
* @date 2023/8/22 9:54
|
|
|
**/
|
|
**/
|
|
|
public final class CarModelsFilterUtils {
|
|
public final class CarModelsFilterUtils {
|
|
|
|
|
|
|
|
public static <T extends CarModelsFilter> T to(List<T> carModelsFilterList, CarInfoVo carInfo) {
|
|
public static <T extends CarModelsFilter> T to(List<T> carModelsFilterList, CarInfoVo carInfo) {
|
|
|
- if (carModelsFilterList.isEmpty()) {
|
|
|
|
|
|
|
+ if (carModelsFilterList == null) {
|
|
|
throw new SystemException("核心查询车型失败 请联系业务人员处理");
|
|
throw new SystemException("核心查询车型失败 请联系业务人员处理");
|
|
|
}
|
|
}
|
|
|
List<T> stadarCarDTOS = new ArrayList<>();
|
|
List<T> stadarCarDTOS = new ArrayList<>();
|
|
|
if (!StringUtils.isEmpty(carInfo.getCarYear())) {
|
|
if (!StringUtils.isEmpty(carInfo.getCarYear())) {
|
|
|
- stadarCarDTOS = carModelsFilterList
|
|
|
|
|
- .stream()
|
|
|
|
|
- .filter(car -> carInfo
|
|
|
|
|
- .getCarYear()
|
|
|
|
|
- .equals(car.getCarYear()))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
|
+ stadarCarDTOS = carModelsFilterList.stream().filter(car -> carInfo.getCarYear().equals(car.getCarYear())).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
if (!StringUtils.isEmpty(carInfo.getSeatCount())) {
|
|
if (!StringUtils.isEmpty(carInfo.getSeatCount())) {
|
|
|
- stadarCarDTOS = stadarCarDTOS
|
|
|
|
|
- .stream()
|
|
|
|
|
- .filter(car -> carInfo
|
|
|
|
|
- .getSeatCount()
|
|
|
|
|
- .equals(car.getSeatCount()))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
|
+ stadarCarDTOS = stadarCarDTOS.stream().filter(car -> carInfo.getSeatCount().equals(car.getSeatCount())).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!stadarCarDTOS.isEmpty()) {
|
|
if (!stadarCarDTOS.isEmpty()) {
|
|
@@ -43,12 +33,7 @@ public final class CarModelsFilterUtils {
|
|
|
stadarCarDTOS = carModelsFilterList;
|
|
stadarCarDTOS = carModelsFilterList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- carModelsFilterList = carModelsFilterList
|
|
|
|
|
- .stream()
|
|
|
|
|
- .filter(car -> carInfo
|
|
|
|
|
- .getPurchasePrice()
|
|
|
|
|
- .equals(String.valueOf(car.getPurchasePrice())))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
|
+ carModelsFilterList = carModelsFilterList.stream().filter(car -> carInfo.getPurchasePrice().equals(String.valueOf(car.getPurchasePrice()))).collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (carModelsFilterList.isEmpty()) {
|
|
if (carModelsFilterList.isEmpty()) {
|
|
|
return stadarCarDTOS.get(0);
|
|
return stadarCarDTOS.get(0);
|