修复变更行程bug
This commit is contained in:
parent
e12c5f4f0a
commit
49478aa83b
|
@ -86,13 +86,11 @@ public class OrderApplicationService {
|
||||||
RouteOrder order = Optional.ofNullable(routeRepository.queryById(addLegData.getRouteId()))
|
RouteOrder order = Optional.ofNullable(routeRepository.queryById(addLegData.getRouteId()))
|
||||||
.orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND));
|
.orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND));
|
||||||
order.reloadStatus();
|
order.reloadStatus();
|
||||||
|
|
||||||
checkLegDataTime(addLegData, order);
|
checkLegDataTime(addLegData, order);
|
||||||
|
|
||||||
LegData legData = addLegData.getLegData();
|
LegData legData = addLegData.getLegData();
|
||||||
List<Leg> legs = processLegData(legData, order);
|
List<Leg> legs = processLegData(legData, order);
|
||||||
orderDomainService.queryLocation(legs);
|
orderDomainService.queryLocation(legs);
|
||||||
RouteOrder routeOrder = orderDomainService.saveOrder(order);
|
|
||||||
legs.forEach(leg -> {
|
legs.forEach(leg -> {
|
||||||
leg.reloadStatus();
|
leg.reloadStatus();
|
||||||
legDomainService.addPreEvent(leg);
|
legDomainService.addPreEvent(leg);
|
||||||
|
@ -108,14 +106,14 @@ public class OrderApplicationService {
|
||||||
leg = legDomainService.addApproveEvent(leg);
|
leg = legDomainService.addApproveEvent(leg);
|
||||||
}
|
}
|
||||||
|
|
||||||
legRepository.save(leg);
|
order.addLeg(leg);
|
||||||
|
|
||||||
if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
|
if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
|
||||||
Command.of(BPMLegChangeCommand.class).routeOrder(order).newleg(leg.reloadStatus()).routeId(routeOrder.getRouteId()).changeType(0).sendToQueue();
|
Command.of(BPMLegChangeCommand.class).routeOrder(order).newleg(leg.reloadStatus()).routeId(order.getRouteId()).changeType(0).sendToQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次
|
//异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次
|
||||||
// if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) {
|
// if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) {
|
||||||
// CompletableFuture.runAsync(() -> {
|
// CompletableFuture.runAsync(() -> {
|
||||||
|
@ -125,7 +123,7 @@ public class OrderApplicationService {
|
||||||
// .sendToQueue();
|
// .sendToQueue();
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
return routeOrder; // 仅在所有操作完成后保存一次
|
return orderDomainService.saveOrder(order); // 仅在所有操作完成后保存一次
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -118,9 +118,7 @@ public class Leg {
|
||||||
this.legStatus = LegConstant.LEG_STATUS_PREPARE;
|
this.legStatus = LegConstant.LEG_STATUS_PREPARE;
|
||||||
} else {
|
} else {
|
||||||
// Find the latest event based on the maximum id
|
// Find the latest event based on the maximum id
|
||||||
LegEvent latestEvent = this.eventList.stream()
|
LegEvent latestEvent = this.getLastLegEvent();
|
||||||
.max(Comparator.comparingLong(LegEvent::getLegEventId))
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
// Set the legStatus based on the type of the latest event
|
// Set the legStatus based on the type of the latest event
|
||||||
this.legStatus = latestEvent.getEventType();
|
this.legStatus = latestEvent.getEventType();
|
||||||
|
|
Loading…
Reference in New Issue