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; + } }