fix:总订单明细表,高德打车增加目的地和出发地字段

This commit is contained in:
lulz1 2024-05-30 09:21:34 +08:00
parent 57c284fa95
commit 54022987a4
6 changed files with 58 additions and 20 deletions

View File

@ -519,26 +519,28 @@ public class RouteOrder implements Serializable {
public Long matchOrderWithLegId(OrderDetail orderDetail) {
if (this.legItems.isEmpty()) {
if (this.legItems == null || this.legItems.isEmpty()) {
return null;
}
// 定义时间容差例如1天
long tolerance = Duration.ofDays(2).toMillis();
List<Leg> potentialMatches = this.legItems.stream()
.filter(leg -> {
// Handle taxi legs separately
for (Leg leg : this.legItems) {
if (leg.getLegType().equals(LEG_TYPE_TAXI) && orderDetail.getProductType().equals(LEG_TYPE_TAXI)) {
if (leg.getLegExtensionField() != null && leg.getLegExtensionField().getLocationIdsAsLong() != null) {
if (leg.getLegExtensionField().getLocationIdsAsLong().contains(orderDetail.getOriginId()) ||
leg.getLegExtensionField().getLocationIdsAsLong().contains(orderDetail.getDestinationId())) {
orderDetail.setLegId(leg.getLegId());
return false;
return leg.getLegId();
}
}
} else {
return false;
}
}
// Define time tolerance (e.g., 2 days)
long tolerance = Duration.ofDays(2).toMillis();
List<Leg> potentialMatches = this.legItems.stream()
.filter(leg -> {
// Skip taxi legs already handled
if (leg.getLegType().equals(LEG_TYPE_TAXI)) {
return false;
}
@ -547,14 +549,17 @@ public class RouteOrder implements Serializable {
Location destinationLocation = leg.getDestinationLocation();
Long orderDetailOriginId = orderDetail.getOriginId();
Long orderDetailDestinationId = orderDetail.getDestinationId();
return leg.getLegType().equals(orderDetail.getProductType()) &&
(originLocation.getLocationId().equals(orderDetailOriginId) ||
boolean typeMatches = leg.getLegType().equals(orderDetail.getProductType());
boolean locationMatches = (originLocation.getLocationId().equals(orderDetailOriginId) ||
originLocation.getParentLocationId().equals(orderDetailOriginId) ||
originLocation.getLocationPath().contains(String.valueOf(orderDetailOriginId)))
&&
(destinationLocation.getLocationId().equals(orderDetailDestinationId) ||
destinationLocation.getParentLocationId().equals(orderDetailDestinationId) ||
destinationLocation.getLocationPath().contains(String.valueOf(orderDetailDestinationId)));
return typeMatches && locationMatches;
})
.toList();

View File

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

View File

@ -40,6 +40,7 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
@Autowired
private AmapOrderDetailRequest orderDetailRequest;
@Override
public Optional<OrderLegData> adapt(SupplierCallbackData supplierData) {
AmapOrderDetailResponse amapOrderDetailResponse = (AmapOrderDetailResponse) supplierData.getData();
@ -58,6 +59,15 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
Integer personAmount = data.getPersonAmount();
price = String.valueOf((enterpriseAmount == null ? 0 : enterpriseAmount) + (personAmount == null ? 0 : personAmount));
}
Optional<Long> startLocationId = locationRepository
.findByLocationNameContainingAndIfInternal(handlerLocationName(data.getStartCity()), 1).stream().findFirst()
.flatMap(it -> Optional.ofNullable(it.getLocationId()));
Optional<Long> endCityLocationId = locationRepository
.findByLocationNameContainingAndIfInternal(handlerLocationName(data.getEndCity()), 1).stream().findFirst()
.flatMap(it -> Optional.ofNullable(it.getLocationId()));
return Optional.of(
OrderLegData.builder()
.productType(LEG_TYPE_TAXI)
@ -75,6 +85,8 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
.originOrderStatus(supplierData.getOutOrderStatus())
.destinationName(data.getEndName())
.supplierName(SUPPLIER_AMAP)
.originId(startLocationId.orElse(null))
.originId(endCityLocationId.orElse(null))
.build());
}
@ -104,6 +116,17 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
}
private String handlerLocationName(String locationName) {
if (locationName == null) {
return null;
}
//如果最后一位是市去掉最后一位
if (locationName.endsWith("")) {
return locationName.substring(0, locationName.length() - 2);
}
return locationName;
}
// AmapOrderDetailResponse response = amapOrderDetailRequest.queryOrderDetail(amapNoteParam.getAmapOrderId());
// AmapOrderDetailResponse.Data data = response.getData();
//

View File

@ -214,5 +214,10 @@ public class LocationRepositoryImpl implements LocationRepository {
return hotCities;
}
@Override
public List<Location> findByLocationNameContainingAndIfInternal(String locationName, Integer ifInternal) {
return jdbcLocationRepository.findByLocationNameContainingAndIsInternal(locationName, ifInternal);
}
}

View File

@ -13,9 +13,11 @@ import java.util.List;
public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
Location findByCityIdAndLocationShortName(Long cityId, String locationShortName);
List<Location> findByLocationType(Integer locationType);
List<Location> findByCityIdAndLocationType(Long cityId, Integer locationType);
List<Location> findByCityId(Long cityId);
Location findByLocationId(Long locationId);
@ -68,4 +70,5 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
List<Location> findByLevelAndIsInternal(Integer level, Integer isInternal);
List<Location> findByLocationNameContainingAndIsInternal(String locationName, Integer isInternal);
}

View File

@ -95,8 +95,9 @@ public class AmapTest {
*/
@Test
public void queryorderDetail() {
AmapOrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
System.out.println("orderDetailResponse = " + orderDetailResponse);
Gson gson = new Gson();
AmapOrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40184156001340013649231865");
System.out.println(gson.toJson(orderDetailResponse));
}
/**