diff --git a/src/main/java/com/chint/application/dtos/response/LegRes.java b/src/main/java/com/chint/application/dtos/response/LegRes.java index 786e0654..618a48e0 100644 --- a/src/main/java/com/chint/application/dtos/response/LegRes.java +++ b/src/main/java/com/chint/application/dtos/response/LegRes.java @@ -4,12 +4,14 @@ package com.chint.application.dtos.response; import cn.hutool.core.bean.BeanUtil; import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.LegExtensionField; +import com.chint.domain.aggregates.order.Location; import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.value_object.enums.CurrencyType; import lombok.Data; import org.springframework.data.annotation.Id; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; @Data @@ -37,6 +39,8 @@ public class LegRes { private CurrencyType currencyType; + private List otherLocationList; + private List orderDetails; //这个属性不做持久化保存 ,根据下单事件进行获取 public static LegRes copyFrom(Leg leg) { @@ -50,9 +54,19 @@ public class LegRes { legRes.setAmountType(legExtensionField.getAmountType()); legRes.setAmountTypeName(legExtensionField.getAmountTypeName()); legRes.setAmountTypeEnName(legExtensionField.getAmountTypeEnName()); + + if (legExtensionField.getLocationIds() != null) { + List locationResList = new ArrayList<>(); + List locationList = legExtensionField.getLocationList(); + for (Location location : locationList) { + locationResList.add(LocationRes.copyFrom(location)); + } + legRes.setOtherLocationList(locationResList); + } } legRes.setOriginLocation(LocationRes.copyFrom(leg.getOriginLocation())); legRes.setDestinationLocation(LocationRes.copyFrom(leg.getDestinationLocation())); + return legRes; } } diff --git a/src/main/java/com/chint/application/dtos/response/RouteOrderPageRes.java b/src/main/java/com/chint/application/dtos/response/RouteOrderPageRes.java index b8d9b9af..4b4b7a09 100644 --- a/src/main/java/com/chint/application/dtos/response/RouteOrderPageRes.java +++ b/src/main/java/com/chint/application/dtos/response/RouteOrderPageRes.java @@ -34,7 +34,7 @@ public class RouteOrderPageRes { private String amount; private String estimateAmount; private Integer orderStatus; - private String approvalStatusCode; + private Integer approvalStatusCode; private String approvalStatus; private String orderStatusName; private String startTime; diff --git a/src/main/java/com/chint/domain/aggregates/order/LegExtensionField.java b/src/main/java/com/chint/domain/aggregates/order/LegExtensionField.java index f62a8413..e8e1fdbe 100644 --- a/src/main/java/com/chint/domain/aggregates/order/LegExtensionField.java +++ b/src/main/java/com/chint/domain/aggregates/order/LegExtensionField.java @@ -6,6 +6,8 @@ import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Transient; import org.springframework.data.relational.core.mapping.Table; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; @Data @@ -28,6 +30,26 @@ public class LegExtensionField { private String estimatedAmount; + public LegExtensionField addLocationIdsAsString(List locationIds) { + this.locationIds = Arrays.toString(locationIds.toArray()); + return this; + } + + public List getLocationIdsAsLong() { + // 去除字符串开头和结尾的方括号 + this.locationIds = this.locationIds.substring(1, this.locationIds.length() - 1); + // 根据逗号分割字符串 + String[] items = this.locationIds.split(","); + // 创建一个Long类型的列表 + List result = new ArrayList<>(); + // 将每个分割后的字符串转换为Long并添加到列表中 + for (String item : items) { + result.add(Long.parseLong(item.trim())); + } + return result; + } + + public LegExtensionField reloadStatus() { this.amountTypeName = translateLegOtherAmountTypeToChineseName(this.amountType); this.amountTypeEnName = translateLegOtherAmountTypeToEnglishName(this.amountType); diff --git a/src/main/java/com/chint/domain/aggregates/standards/CityTag.java b/src/main/java/com/chint/domain/aggregates/standards/CityTag.java index 7d195c71..3ca7e0f0 100644 --- a/src/main/java/com/chint/domain/aggregates/standards/CityTag.java +++ b/src/main/java/com/chint/domain/aggregates/standards/CityTag.java @@ -3,7 +3,6 @@ package com.chint.domain.aggregates.standards; import java.util.HashMap; public class CityTag { - public static final HashMap cityMap; static { diff --git a/src/main/java/com/chint/domain/factoriy/leg/RouteLegFactory.java b/src/main/java/com/chint/domain/factoriy/leg/RouteLegFactory.java index d15a1d69..9afb0c7e 100644 --- a/src/main/java/com/chint/domain/factoriy/leg/RouteLegFactory.java +++ b/src/main/java/com/chint/domain/factoriy/leg/RouteLegFactory.java @@ -126,6 +126,10 @@ public class RouteLegFactory implements LegFactory { private static LegExtensionField getLegExtensionField(LegData data) { LegExtensionFieldData legExtensionFieldData = data.getLegExtensionFieldData(); - return BeanUtil.copyProperties(legExtensionFieldData, LegExtensionField.class); + LegExtensionField legExtensionField = BeanUtil.copyProperties(legExtensionFieldData, LegExtensionField.class); + if (legExtensionFieldData.getLocationIds() != null && !legExtensionFieldData.getLocationIds().isEmpty()) { + legExtensionField.addLocationIdsAsString(legExtensionFieldData.getLocationIds()); + } + return legExtensionField; } } diff --git a/src/main/java/com/chint/domain/repository/LocationRepository.java b/src/main/java/com/chint/domain/repository/LocationRepository.java index c8034d09..a45e5d59 100644 --- a/src/main/java/com/chint/domain/repository/LocationRepository.java +++ b/src/main/java/com/chint/domain/repository/LocationRepository.java @@ -22,4 +22,6 @@ public interface LocationRepository { List findByName(String localName); String locationPathByName(String localName); + + List findByNameList(List locationIds); } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index 8d5ca9d8..1d2ef3c3 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -68,6 +68,12 @@ public class OrderDomainService { public List queryLocation(List list) { list.forEach(leg -> { + LegExtensionField legExtensionField = leg.getLegExtensionField(); + if (legExtensionField != null && legExtensionField.getLocationIds() != null) { + List locationIdsAsLong = legExtensionField.getLocationIdsAsLong(); + List byNameList = locationRepository.findByNameList(locationIdsAsLong); + legExtensionField.setLocationList(byNameList); + } leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId())); leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId())); }); @@ -122,7 +128,8 @@ public class OrderDomainService { .productType(orderDetail.getProductType()) .extensionData(orderDetail.getExtensionDataByProductType()) .sendToQueue(); - }; + } + ; } @ListenTo(command = "BPMAuditCommand", order = 0) diff --git a/src/main/java/com/chint/domain/value_object/LegExtensionFieldData.java b/src/main/java/com/chint/domain/value_object/LegExtensionFieldData.java index 1d8a3991..c404989d 100644 --- a/src/main/java/com/chint/domain/value_object/LegExtensionFieldData.java +++ b/src/main/java/com/chint/domain/value_object/LegExtensionFieldData.java @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.data.annotation.Transient; +import java.util.List; + @Data public class LegExtensionFieldData { @ApiModelProperty("其他费用类型") @@ -16,4 +18,6 @@ public class LegExtensionFieldData { private String destinationDescription; @ApiModelProperty("预估金额") private String estimatedAmount; + @ApiModelProperty("地理位置id列表") + private List locationIds; } diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index 3e6ab08c..65418e05 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -76,4 +76,9 @@ public class LocationRepositoryImpl implements LocationRepository { Location byLocationName = jdbcLocationRepository.findByLocationName(localName); return byLocationName.getLocationPathName().replace("_", "、"); } + + @Override + public List findByNameList(List locationIds) { + return jdbcLocationRepository.findByLocationIdIn(locationIds); + } } 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 4695cc40..7a1a4841 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java @@ -25,4 +25,7 @@ public interface JdbcLocationRepository extends CrudRepository { Location findByLocationName(String locationName); + List findByLocationNameIn(Collection locationName); + + List findByLocationIdIn(Collection locationId); } diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 05d230ab..4a5bec2e 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -17,6 +17,7 @@ import org.springframework.boot.test.context.SpringBootTest; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Arrays; import java.util.List; @Slf4j @@ -124,4 +125,11 @@ class RouteApplicationTests { String login = pailaLoginStrategy.login("OC-5909-zRqrWjZGNThNXJiAV1kA7dPXTojGzVxK3nE"); System.out.println(login); } + + @Test + void arrayToStr(){ + List ids = List.of(1L,2L,3L,4L); + System.out.println(Arrays.toString(ids.toArray())); + + } }