From 52897065ec6ebd73463bad2413aeaa8ad5c9130e Mon Sep 17 00:00:00 2001 From: lulz1 Date: Thu, 30 May 2024 10:15:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=AB=98=E5=BE=B7?= =?UTF-8?q?=E6=89=93=E8=BD=A6=E5=9C=B0=E7=82=B9=E6=97=A0=E6=B3=95=E6=98=A0?= =?UTF-8?q?=E5=B0=84=E8=A1=8C=E7=A8=8B=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chint/domain/repository/LocationRepository.java | 2 +- .../domain/service/supplier/AmapOrderDataAdapter.java | 8 ++++---- .../infrastructure/repository/LocationRepositoryImpl.java | 4 ++-- .../repository/jdbc/JdbcLocationRepository.java | 2 +- src/test/java/com/chint/RouteApplicationTests.java | 4 +--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/chint/domain/repository/LocationRepository.java b/src/main/java/com/chint/domain/repository/LocationRepository.java index e870013e..387c817a 100644 --- a/src/main/java/com/chint/domain/repository/LocationRepository.java +++ b/src/main/java/com/chint/domain/repository/LocationRepository.java @@ -59,5 +59,5 @@ public interface LocationRepository { List findNotChintCityByLevel(String locationNames, Integer level); - List findByLocationNameContainingAndIfInternal(String locationName,Integer ifInternal); + List findByLocationNameContainingAndIfInternalAndLocationType(String locationName, Integer ifInternal, Integer locationType); } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java index 7e91af4f..9c271790 100644 --- a/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java @@ -61,11 +61,11 @@ public class AmapOrderDataAdapter implements OrderDataAdapter { } Optional startLocationId = locationRepository - .findByLocationNameContainingAndIfInternal(handlerLocationName(data.getStartCity()), 1).stream().findFirst() + .findByLocationNameContainingAndIfInternalAndLocationType(handlerLocationName(data.getStartCity()), 1, 4).stream().findFirst() .flatMap(it -> Optional.ofNullable(it.getLocationId())); Optional endCityLocationId = locationRepository - .findByLocationNameContainingAndIfInternal(handlerLocationName(data.getEndCity()), 1).stream().findFirst() + .findByLocationNameContainingAndIfInternalAndLocationType(handlerLocationName(data.getEndCity()), 1, 4).stream().findFirst() .flatMap(it -> Optional.ofNullable(it.getLocationId())); return Optional.of( @@ -86,7 +86,7 @@ public class AmapOrderDataAdapter implements OrderDataAdapter { .destinationName(data.getEndName()) .supplierName(SUPPLIER_AMAP) .originId(startLocationId.orElse(null)) - .originId(endCityLocationId.orElse(null)) + .destinationId(endCityLocationId.orElse(null)) .build()); } @@ -122,7 +122,7 @@ public class AmapOrderDataAdapter implements OrderDataAdapter { } //如果最后一位是市,去掉最后一位 if (locationName.endsWith("市")) { - return locationName.substring(0, locationName.length() - 2); + return locationName.substring(0, locationName.length() - 1); } return locationName; } diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index 4bcec56e..cd073189 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -215,8 +215,8 @@ public class LocationRepositoryImpl implements LocationRepository { } @Override - public List findByLocationNameContainingAndIfInternal(String locationName, Integer ifInternal) { - return jdbcLocationRepository.findByLocationNameContainingAndIsInternal(locationName, ifInternal); + public List findByLocationNameContainingAndIfInternalAndLocationType(String locationName, Integer ifInternal, Integer locationType) { + return jdbcLocationRepository.findByLocationNameContainingAndIsInternalAndLocationType(locationName, ifInternal, locationType); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java index 0a833924..9fa61443 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java @@ -70,5 +70,5 @@ public interface JdbcLocationRepository extends CrudRepository { List findByLevelAndIsInternal(Integer level, Integer isInternal); - List findByLocationNameContainingAndIsInternal(String locationName, Integer isInternal); + List findByLocationNameContainingAndIsInternalAndLocationType(String locationName, Integer isInternal, Integer locationType); } diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 25e0436e..be39a89a 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -1127,9 +1127,7 @@ class RouteApplicationTests { @Test void deleteByOrderId() { - - orderDetailRepository.deleteById(3105L); - orderDetailRepository.deleteById(3106L); + orderDetailRepository.deleteById(3138L); } // @Test