From 13678aea1424d9f80c333a6fb172922b5aa357c1 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Tue, 9 Apr 2024 16:13:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2=E5=B7=B2?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=A1=8C=E7=A8=8B=E8=8A=82=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dtos/response/LegRes.java | 2 ++ .../application/out/OrderOutController.java | 1 + .../domain/aggregates/order/RouteRequest.java | 16 +++++++++++- .../domain/service/LegDomainService.java | 26 +++++++++++++++++-- 4 files changed, 42 insertions(+), 3 deletions(-) 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 8c73349e..82f8206b 100644 --- a/src/main/java/com/chint/application/dtos/response/LegRes.java +++ b/src/main/java/com/chint/application/dtos/response/LegRes.java @@ -42,6 +42,8 @@ public class LegRes { private String originDescription; @ApiModelProperty("目的地详细") private String destinationDescription; + private String supplier; + private String supplierName; private Integer legStatus; private String changeReason; diff --git a/src/main/java/com/chint/application/out/OrderOutController.java b/src/main/java/com/chint/application/out/OrderOutController.java index cfc61a3c..bd5aab51 100644 --- a/src/main/java/com/chint/application/out/OrderOutController.java +++ b/src/main/java/com/chint/application/out/OrderOutController.java @@ -123,6 +123,7 @@ public class OrderOutController { List legResList = legDomainService .queryLegsCanSync(routeOrder, queryData.getSupplierName()).stream().map(LegRes::copyFrom).toList(); legResList.forEach(it -> it.setUserName(userRepository.findByUserEmployeeNo(routeOrder.getUserId()).getName())); + legDomainService.getSupplierName(legResList,routeOrder); return Result.Success(SUCCESS, legResList); } diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java b/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java index d64bf337..2ca34062 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java @@ -2,6 +2,7 @@ package com.chint.domain.aggregates.order; import com.chint.domain.aggregates.base.BaseEvent; import com.chint.domain.aggregates.base.EventManageable; +import com.chint.infrastructure.constant.SupplierNameConstant; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -18,6 +19,8 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import static com.chint.infrastructure.constant.SupplierNameConstant.*; + @Data @Table("route_request") public class RouteRequest implements Serializable, EventManageable { @@ -48,6 +51,8 @@ public class RouteRequest implements Serializable, EventManageable { private Integer status; @Transient private String statusName; + @Transient + private String supplierName; @CreatedDate @ApiModelProperty("创建时间") @@ -61,7 +66,7 @@ public class RouteRequest implements Serializable, EventManageable { @Override public List getEvents() { - if( this.eventList == null){ + if (this.eventList == null) { this.eventList = new ArrayList<>(); } return this.eventList; @@ -71,6 +76,7 @@ public class RouteRequest implements Serializable, EventManageable { BaseEvent lastEvent = this.getLastEvent().reloadStatus(); this.status = lastEvent.getEventType(); this.statusName = lastEvent.getEventName(); + this.setSupplierName(translateSupplierName(this.supplier)); return this; } @@ -79,4 +85,12 @@ public class RouteRequest implements Serializable, EventManageable { this.setRouteRequestLegList(routeRequestLegs); return this; } + + private String translateSupplierName(String supplier) { + return switch (supplier) { + case SUPPLIER_L_Y -> SUPPLIER_L_Y_CN_NAME; + case SUPPLIER_C_TRIP -> SUPPLIER_C_TRIP_CN_NAME; + default -> "未知供应商"; + }; + } } diff --git a/src/main/java/com/chint/domain/service/LegDomainService.java b/src/main/java/com/chint/domain/service/LegDomainService.java index 62f120c7..03b6024d 100644 --- a/src/main/java/com/chint/domain/service/LegDomainService.java +++ b/src/main/java/com/chint/domain/service/LegDomainService.java @@ -1,5 +1,6 @@ package com.chint.domain.service; +import com.chint.application.dtos.response.LegRes; import com.chint.domain.aggregates.order.*; import com.chint.domain.exceptions.LegEventException; import com.chint.domain.factoriy.leg_event.LegEventFactory; @@ -19,7 +20,6 @@ import static com.chint.infrastructure.constant.OrderConstant.*; import static com.chint.infrastructure.constant.RouteConstant.APPROVAL_EVENT_PREPARE; import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_SYNC; -import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_SYNC_NAME; @Service public class LegDomainService { @@ -161,13 +161,14 @@ public class LegDomainService { public List queryLegsCanSync(RouteOrder routeOrder, String supplierName) { List legItems = routeOrder.getLegItems(); legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList(); + if (supplierName.equals("CTrip")) { legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_TRAIN)).toList(); } List alreadySyncLegs = routeOrder.getRouteRequestList() .stream() - .filter(it->it.reloadStatus().getStatus().equals(ROUTE_REQUEST_STATUS_SYNC)) + .filter(it -> it.reloadStatus().getStatus().equals(ROUTE_REQUEST_STATUS_SYNC)) .flatMap(it -> it.getRouteRequestLegList().stream().map(RouteRequestLeg::getLegId)) .toList(); @@ -193,4 +194,25 @@ public class LegDomainService { queryLocation(res); return res; } + + public List getSupplierName(List legResList, RouteOrder routeOrder) { + List routeRequestList = routeOrder.getRouteRequestList() + .stream() + .filter(it -> it.reloadStatus().getStatus().equals(ROUTE_REQUEST_STATUS_SYNC)) + .toList(); + for (LegRes legRes : legResList) { + for (RouteRequest routeRequest : routeRequestList) { + List legIds = routeRequest + .getRouteRequestLegList() + .stream() + .map(RouteRequestLeg::getLegId) + .toList(); + if (legIds.contains(legRes.getLegId())) { + legRes.setSupplier(routeRequest.getSupplier()); + legRes.setSupplierName(routeRequest.getSupplierName()); + } + } + } + return legResList; + } }