From a25cb67e7bc6b7f7b5a51b07a1a44391471b205c Mon Sep 17 00:00:00 2001 From: lulz1 Date: Sat, 1 Jun 2024 15:47:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E5=B7=AE=E6=97=85=E7=94=B3=E8=AF=B7=E5=8D=95=E5=9C=B0=E7=82=B9?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=90=8C=E6=AD=A5bug=EF=BC=8C=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E6=B7=B1=E6=8B=B7=E8=B4=9D=E6=96=B9?= =?UTF-8?q?=E6=B3=95bug=EF=BC=8C=E4=BB=A5=E5=8F=8A=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/aggregates/order/OrderDetail.java | 54 ++++++++++++------- .../domain/aggregates/order/RouteOrder.java | 5 +- .../aggregates/order/RouteRequestEvent.java | 1 - .../domain/service/LegDomainService.java | 3 ++ .../order_sync/AmapOrderSyncAdapter.java | 15 ++++-- .../java/com/chint/RouteApplicationTests.java | 4 +- 6 files changed, 51 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java index 393c5865..db72f6ef 100644 --- a/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java @@ -230,34 +230,48 @@ public class OrderDetail implements Serializable { copyOrderDetail.setOtherOrderDetail(copiedOtherOrderDetail); // 深拷贝 orderEventList - List copiedOrderEventList = this.orderEventList.stream() - .map(event -> BeanUtil.copyProperties(event, OrderEvent.class)) - .collect(Collectors.toList()); - copyOrderDetail.setOrderEventList(copiedOrderEventList); + if(this.orderEventList != null && !this.orderEventList.isEmpty()) { + List copiedOrderEventList = this.orderEventList.stream() + .map(event -> BeanUtil.copyProperties(event, OrderEvent.class)) + .collect(Collectors.toList()); + copyOrderDetail.setOrderEventList(copiedOrderEventList); + } + // 深拷贝 orderCarRecordList - List copiedOrderCarRecordList = this.orderCarRecordList.stream() - .map(record -> BeanUtil.copyProperties(record, OrderCarRecord.class)) - .collect(Collectors.toList()); - copyOrderDetail.setOrderCarRecordList(copiedOrderCarRecordList); + if (this.orderCarRecordList != null && !this.orderCarRecordList.isEmpty()) { + List copiedOrderCarRecordList = this.orderCarRecordList.stream() + .map(record -> BeanUtil.copyProperties(record, OrderCarRecord.class)) + .collect(Collectors.toList()); + copyOrderDetail.setOrderCarRecordList(copiedOrderCarRecordList); + } + // 深拷贝 orderFlightRecordList - List copiedOrderFlightRecordList = this.orderFlightRecordList.stream() - .map(record -> BeanUtil.copyProperties(record, OrderFlightRecord.class)) - .collect(Collectors.toList()); - copyOrderDetail.setOrderFlightRecordList(copiedOrderFlightRecordList); + if (this.orderFlightRecordList != null && !this.orderFlightRecordList.isEmpty()) { + List copiedOrderFlightRecordList = this.orderFlightRecordList.stream() + .map(record -> BeanUtil.copyProperties(record, OrderFlightRecord.class)) + .collect(Collectors.toList()); + copyOrderDetail.setOrderFlightRecordList(copiedOrderFlightRecordList); + } + // 深拷贝 orderHotelRecordList - List copiedOrderHotelRecordList = this.orderHotelRecordList.stream() - .map(record -> BeanUtil.copyProperties(record, OrderHotelRecord.class)) - .collect(Collectors.toList()); - copyOrderDetail.setOrderHotelRecordList(copiedOrderHotelRecordList); + if (this.orderHotelRecordList != null && !this.orderHotelRecordList.isEmpty()) { + List copiedOrderHotelRecordList = this.orderHotelRecordList.stream() + .map(record -> BeanUtil.copyProperties(record, OrderHotelRecord.class)) + .collect(Collectors.toList()); + copyOrderDetail.setOrderHotelRecordList(copiedOrderHotelRecordList); + } + // 深拷贝 orderTrainRecordList - List copiedOrderTrainRecordList = this.orderTrainRecordList.stream() - .map(record -> BeanUtil.copyProperties(record, OrderTrainRecord.class)) - .collect(Collectors.toList()); - copyOrderDetail.setOrderTrainRecordList(copiedOrderTrainRecordList); + if (this.orderTrainRecordList != null && !this.orderTrainRecordList.isEmpty()) { + List copiedOrderTrainRecordList = this.orderTrainRecordList.stream() + .map(record -> BeanUtil.copyProperties(record, OrderTrainRecord.class)) + .collect(Collectors.toList()); + copyOrderDetail.setOrderTrainRecordList(copiedOrderTrainRecordList); + } return copyOrderDetail; } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index 50514519..06c5d5db 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -31,8 +31,7 @@ import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; -import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI; -import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TRAIN; +import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.RouteConstant.*; import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; import static com.chint.infrastructure.constant.UtilConstant.RESULT_ORDER_DETAIL; @@ -541,7 +540,7 @@ public class RouteOrder implements Serializable { List potentialMatches = this.legItems.stream() .filter(leg -> { // Skip taxi legs already handled - if (leg.getLegType().equals(LEG_TYPE_TAXI)) { + if (leg.getLegType().equals(LEG_TYPE_TAXI) || leg.getLegType().equals(LEG_TYPE_OTHER)) { return false; } diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteRequestEvent.java b/src/main/java/com/chint/domain/aggregates/order/RouteRequestEvent.java index c5026ab3..a09c237a 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteRequestEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteRequestEvent.java @@ -22,7 +22,6 @@ public class RouteRequestEvent extends BaseEvent implements Serializable { private Long routeRequestId; - private Long routeRequestKey; @Override protected Map getStatusMappings() { diff --git a/src/main/java/com/chint/domain/service/LegDomainService.java b/src/main/java/com/chint/domain/service/LegDomainService.java index df59af84..4386a644 100644 --- a/src/main/java/com/chint/domain/service/LegDomainService.java +++ b/src/main/java/com/chint/domain/service/LegDomainService.java @@ -90,6 +90,9 @@ public class LegDomainService { public void deleteByLegNo(String legNo) { Leg byLegNo = legRepository.findByLegNo(legNo); + if(byLegNo == null){ + return; + } RouteOrder routeOrder = routeRepository.queryById(byLegNo.getRouteId()).reloadStatus(); if (routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE)) { legRepository.deleteById(byLegNo); diff --git a/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java index ce47bfe3..7604363d 100644 --- a/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java @@ -7,10 +7,7 @@ import com.chint.domain.aggregates.supplier.SupplierProductStandardLevel; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.AuthException; import com.chint.domain.exceptions.CommandException; -import com.chint.domain.repository.AmapPolicyRepository; -import com.chint.domain.repository.AmapRouteRelationshipRepository; -import com.chint.domain.repository.SupplierRepository; -import com.chint.domain.repository.UserRepository; +import com.chint.domain.repository.*; import com.chint.domain.service.LegDomainService; import com.chint.infrastructure.util.DateTimeUtil; import com.chint.interfaces.rest.amap.AmapLocationRequest; @@ -30,6 +27,7 @@ import java.util.List; import java.util.Optional; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI; +import static com.chint.infrastructure.constant.LocationConstant.LOCATION_TYPE_CITY; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; @Slf4j @@ -57,6 +55,7 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync { @Autowired private SupplierRepository supplierRepository; + private Gson gson = new Gson(); @Override @@ -142,7 +141,13 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync { } List areaCodes = new ArrayList<>(); for (Location location : locationList) { - areaCodes.add(amapLocationRequest.getACodeByLocationName(location.getLocationName())); + if(location.getLocationType() != LOCATION_TYPE_CITY){ + //如果类型不是地级市,那么就从地区路径获取地级市信息 + String[] split = location.getLocationPathName().split("_"); + areaCodes.add(amapLocationRequest.getACodeByLocationName(split[3])); + } else { + areaCodes.add(amapLocationRequest.getACodeByLocationName(location.getLocationName())); + } } processContent.setValidCityList(areaCodes); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 2fe1dd85..c2914043 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -302,7 +302,7 @@ class RouteApplicationTests { @Test void loginSign() { - String sfno = "230615020"; + String sfno = "230207110"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司"; @@ -359,7 +359,7 @@ class RouteApplicationTests { @Test void deleteOrderDetail() { - orderDetailRepository.deleteById(3128L); + orderDetailRepository.deleteById(3157L); } // @Test