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