From 99bd01fe7b97f9165850c95cae5f2e5c7ae01507 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 09:34:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dtos/response/LocationRes.java | 3 ++ .../application/queryies/OrderQuery.java | 36 +++++++++++-------- .../chint/domain/aggregates/order/Leg.java | 4 +-- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/chint/application/dtos/response/LocationRes.java b/src/main/java/com/chint/application/dtos/response/LocationRes.java index 18b331fd..15ec5d93 100644 --- a/src/main/java/com/chint/application/dtos/response/LocationRes.java +++ b/src/main/java/com/chint/application/dtos/response/LocationRes.java @@ -15,6 +15,9 @@ public class LocationRes { private String province; public static LocationRes copyFrom(Location location) { + if (location == null) { + return null; + } LocationRes locationRes = BeanUtil.copyProperties(location, LocationRes.class); String[] parts = location.getLocationPathName().split("_"); if (parts.length != 4) { diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index a2ac90e6..7d38946d 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -232,22 +232,28 @@ public class OrderQuery { CityEntity destinationCity; ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail.builder(); if (!leg.getLegType().equals(LegConstant.LEG_TYPE_OTHER)) { - originCity = cityEntities.stream().filter(cityEntity -> cityEntity - .getCityName() - .equals(leg.getOriginLocation().getLocationName())) - .findFirst().get(); - destinationCity = cityEntities.stream().filter(cityEntity -> cityEntity - .getCityName() - .equals(leg.getDestinationLocation().getLocationName())) - .findFirst().get(); - scheduleDetailBuilder - .startCity(originCity.getCityName()) - .startCityName(originCity.getCityName()) - .startCityEnName(originCity.getCityename()) - .endCityName(destinationCity.getCityName()) - .endCity(destinationCity.getCityName()) - .endCityEnName(destinationCity.getCityename()); + if (leg.getOriginLocation() != null) { + originCity = cityEntities.stream().filter(cityEntity -> cityEntity + .getCityName() + .equals(leg.getOriginLocation().getLocationName())) + .findFirst().get(); + scheduleDetailBuilder + .startCity(originCity.getCityName()) + .startCityName(originCity.getCityName()) + .startCityEnName(originCity.getCityename()); + } + + if (leg.getDestinationLocation() != null) { + destinationCity = cityEntities.stream().filter(cityEntity -> cityEntity + .getCityName() + .equals(leg.getDestinationLocation().getLocationName())) + .findFirst().get(); + scheduleDetailBuilder + .endCityName(destinationCity.getCityName()) + .endCity(destinationCity.getCityName()) + .endCityEnName(destinationCity.getCityename()); + } } if (leg.getCurrencyType() != null) { diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index 0bb6b3a8..b5e6a432 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -85,9 +85,7 @@ public class Leg { } public Leg queryEstimateAmount(EstimateAdapter estimateAdapter, String supplierName) { - if (this.getLegType().equals(LEG_TYPE_OTHER) || this.getLegType().equals(LEG_TYPE_TAXI)) { - - } else { + if (!this.getLegType().equals(LEG_TYPE_OTHER) && !this.getLegType().equals(LEG_TYPE_TAXI)) { this.estimateAmount = estimateAdapter.of(supplierName).amountEstimate(this); } return this;