fix:修复高德打车地点无法映射行程的问题

This commit is contained in:
lulz1 2024-05-30 10:15:03 +08:00
parent 54022987a4
commit 52897065ec
5 changed files with 9 additions and 11 deletions

View File

@ -59,5 +59,5 @@ public interface LocationRepository {
List<Location> findNotChintCityByLevel(String locationNames, Integer level); List<Location> findNotChintCityByLevel(String locationNames, Integer level);
List<Location> findByLocationNameContainingAndIfInternal(String locationName,Integer ifInternal); List<Location> findByLocationNameContainingAndIfInternalAndLocationType(String locationName, Integer ifInternal, Integer locationType);
} }

View File

@ -61,11 +61,11 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
} }
Optional<Long> startLocationId = locationRepository Optional<Long> startLocationId = locationRepository
.findByLocationNameContainingAndIfInternal(handlerLocationName(data.getStartCity()), 1).stream().findFirst() .findByLocationNameContainingAndIfInternalAndLocationType(handlerLocationName(data.getStartCity()), 1, 4).stream().findFirst()
.flatMap(it -> Optional.ofNullable(it.getLocationId())); .flatMap(it -> Optional.ofNullable(it.getLocationId()));
Optional<Long> endCityLocationId = locationRepository Optional<Long> endCityLocationId = locationRepository
.findByLocationNameContainingAndIfInternal(handlerLocationName(data.getEndCity()), 1).stream().findFirst() .findByLocationNameContainingAndIfInternalAndLocationType(handlerLocationName(data.getEndCity()), 1, 4).stream().findFirst()
.flatMap(it -> Optional.ofNullable(it.getLocationId())); .flatMap(it -> Optional.ofNullable(it.getLocationId()));
return Optional.of( return Optional.of(
@ -86,7 +86,7 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
.destinationName(data.getEndName()) .destinationName(data.getEndName())
.supplierName(SUPPLIER_AMAP) .supplierName(SUPPLIER_AMAP)
.originId(startLocationId.orElse(null)) .originId(startLocationId.orElse(null))
.originId(endCityLocationId.orElse(null)) .destinationId(endCityLocationId.orElse(null))
.build()); .build());
} }
@ -122,7 +122,7 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
} }
//如果最后一位是市去掉最后一位 //如果最后一位是市去掉最后一位
if (locationName.endsWith("")) { if (locationName.endsWith("")) {
return locationName.substring(0, locationName.length() - 2); return locationName.substring(0, locationName.length() - 1);
} }
return locationName; return locationName;
} }

View File

@ -215,8 +215,8 @@ public class LocationRepositoryImpl implements LocationRepository {
} }
@Override @Override
public List<Location> findByLocationNameContainingAndIfInternal(String locationName, Integer ifInternal) { public List<Location> findByLocationNameContainingAndIfInternalAndLocationType(String locationName, Integer ifInternal, Integer locationType) {
return jdbcLocationRepository.findByLocationNameContainingAndIsInternal(locationName, ifInternal); return jdbcLocationRepository.findByLocationNameContainingAndIsInternalAndLocationType(locationName, ifInternal, locationType);
} }

View File

@ -70,5 +70,5 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
List<Location> findByLevelAndIsInternal(Integer level, Integer isInternal); List<Location> findByLevelAndIsInternal(Integer level, Integer isInternal);
List<Location> findByLocationNameContainingAndIsInternal(String locationName, Integer isInternal); List<Location> findByLocationNameContainingAndIsInternalAndLocationType(String locationName, Integer isInternal, Integer locationType);
} }

View File

@ -1127,9 +1127,7 @@ class RouteApplicationTests {
@Test @Test
void deleteByOrderId() { void deleteByOrderId() {
orderDetailRepository.deleteById(3138L);
orderDetailRepository.deleteById(3105L);
orderDetailRepository.deleteById(3106L);
} }
// @Test // @Test