修改查询已同步行程节点的接口查询逻辑

This commit is contained in:
lulz1 2024-04-09 16:13:41 +08:00
parent 7269918196
commit 13678aea14
4 changed files with 42 additions and 3 deletions

View File

@ -42,6 +42,8 @@ public class LegRes {
private String originDescription; private String originDescription;
@ApiModelProperty("目的地详细") @ApiModelProperty("目的地详细")
private String destinationDescription; private String destinationDescription;
private String supplier;
private String supplierName;
private Integer legStatus; private Integer legStatus;
private String changeReason; private String changeReason;

View File

@ -123,6 +123,7 @@ public class OrderOutController {
List<LegRes> legResList = legDomainService List<LegRes> legResList = legDomainService
.queryLegsCanSync(routeOrder, queryData.getSupplierName()).stream().map(LegRes::copyFrom).toList(); .queryLegsCanSync(routeOrder, queryData.getSupplierName()).stream().map(LegRes::copyFrom).toList();
legResList.forEach(it -> it.setUserName(userRepository.findByUserEmployeeNo(routeOrder.getUserId()).getName())); legResList.forEach(it -> it.setUserName(userRepository.findByUserEmployeeNo(routeOrder.getUserId()).getName()));
legDomainService.getSupplierName(legResList,routeOrder);
return Result.Success(SUCCESS, legResList); return Result.Success(SUCCESS, legResList);
} }

View File

@ -2,6 +2,7 @@ package com.chint.domain.aggregates.order;
import com.chint.domain.aggregates.base.BaseEvent; import com.chint.domain.aggregates.base.BaseEvent;
import com.chint.domain.aggregates.base.EventManageable; import com.chint.domain.aggregates.base.EventManageable;
import com.chint.infrastructure.constant.SupplierNameConstant;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -18,6 +19,8 @@ import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.chint.infrastructure.constant.SupplierNameConstant.*;
@Data @Data
@Table("route_request") @Table("route_request")
public class RouteRequest implements Serializable, EventManageable { public class RouteRequest implements Serializable, EventManageable {
@ -48,6 +51,8 @@ public class RouteRequest implements Serializable, EventManageable {
private Integer status; private Integer status;
@Transient @Transient
private String statusName; private String statusName;
@Transient
private String supplierName;
@CreatedDate @CreatedDate
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
@ -61,7 +66,7 @@ public class RouteRequest implements Serializable, EventManageable {
@Override @Override
public List<RouteRequestEvent> getEvents() { public List<RouteRequestEvent> getEvents() {
if( this.eventList == null){ if (this.eventList == null) {
this.eventList = new ArrayList<>(); this.eventList = new ArrayList<>();
} }
return this.eventList; return this.eventList;
@ -71,6 +76,7 @@ public class RouteRequest implements Serializable, EventManageable {
BaseEvent lastEvent = this.getLastEvent().reloadStatus(); BaseEvent lastEvent = this.getLastEvent().reloadStatus();
this.status = lastEvent.getEventType(); this.status = lastEvent.getEventType();
this.statusName = lastEvent.getEventName(); this.statusName = lastEvent.getEventName();
this.setSupplierName(translateSupplierName(this.supplier));
return this; return this;
} }
@ -79,4 +85,12 @@ public class RouteRequest implements Serializable, EventManageable {
this.setRouteRequestLegList(routeRequestLegs); this.setRouteRequestLegList(routeRequestLegs);
return this; 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 -> "未知供应商";
};
}
} }

View File

@ -1,5 +1,6 @@
package com.chint.domain.service; package com.chint.domain.service;
import com.chint.application.dtos.response.LegRes;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.exceptions.LegEventException; import com.chint.domain.exceptions.LegEventException;
import com.chint.domain.factoriy.leg_event.LegEventFactory; 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.APPROVAL_EVENT_PREPARE;
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_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;
import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_SYNC_NAME;
@Service @Service
public class LegDomainService { public class LegDomainService {
@ -161,13 +161,14 @@ public class LegDomainService {
public List<Leg> queryLegsCanSync(RouteOrder routeOrder, String supplierName) { public List<Leg> queryLegsCanSync(RouteOrder routeOrder, String supplierName) {
List<Leg> legItems = routeOrder.getLegItems(); List<Leg> legItems = routeOrder.getLegItems();
legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList(); legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList();
if (supplierName.equals("CTrip")) { if (supplierName.equals("CTrip")) {
legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_TRAIN)).toList(); legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_TRAIN)).toList();
} }
List<Long> alreadySyncLegs = routeOrder.getRouteRequestList() List<Long> alreadySyncLegs = routeOrder.getRouteRequestList()
.stream() .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)) .flatMap(it -> it.getRouteRequestLegList().stream().map(RouteRequestLeg::getLegId))
.toList(); .toList();
@ -193,4 +194,25 @@ public class LegDomainService {
queryLocation(res); queryLocation(res);
return res; return res;
} }
public List<LegRes> getSupplierName(List<LegRes> legResList, RouteOrder routeOrder) {
List<RouteRequest> routeRequestList = routeOrder.getRouteRequestList()
.stream()
.filter(it -> it.reloadStatus().getStatus().equals(ROUTE_REQUEST_STATUS_SYNC))
.toList();
for (LegRes legRes : legResList) {
for (RouteRequest routeRequest : routeRequestList) {
List<Long> legIds = routeRequest
.getRouteRequestLegList()
.stream()
.map(RouteRequestLeg::getLegId)
.toList();
if (legIds.contains(legRes.getLegId())) {
legRes.setSupplier(routeRequest.getSupplier());
legRes.setSupplierName(routeRequest.getSupplierName());
}
}
}
return legResList;
}
} }