Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
79dc530024
7
pom.xml
7
pom.xml
|
@ -106,4 +106,11 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>新正泰集团公共仓库</name>
|
||||
<url>https://newmaven.chint.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
|
|
@ -26,8 +26,9 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.ORDER_STATUS_ERROR;
|
||||
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_NOT_ORDERED;
|
||||
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE;
|
||||
|
||||
@Service
|
||||
|
@ -73,12 +74,20 @@ public class OrderApplicationService {
|
|||
RouteOrder order = Optional.ofNullable(routeRepository.queryById(addLegData.getRouteId()))
|
||||
.orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND));
|
||||
order.reloadStatus();
|
||||
// if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
|
||||
// throw new OrderException(ORDER_STATUS_ERROR);
|
||||
// }
|
||||
|
||||
List<Leg> legs = processLegData(addLegData.getLegData(), order);
|
||||
RouteOrder routeOrder = orderDomainService.saveOrder(order);
|
||||
legs.forEach(leg -> Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue());
|
||||
|
||||
//异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次
|
||||
if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Command
|
||||
.of(LegSyncCommand.class)
|
||||
.data(SyncLegData.of(routeOrder.getRouteId(), routeOrder.getSupplierName()))
|
||||
.sendToQueue();
|
||||
});
|
||||
}
|
||||
return routeOrder; // 仅在所有操作完成后保存一次
|
||||
}
|
||||
|
||||
|
@ -94,6 +103,19 @@ public class OrderApplicationService {
|
|||
byLegId.setOriginId(legData.getOriginId());
|
||||
byLegId.setDestinationId(legData.getDestinationId());
|
||||
legRepository.save(byLegId);
|
||||
|
||||
//异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Long routeId = byLegId.getRouteId();
|
||||
RouteOrder order = Optional.ofNullable(routeRepository.queryById(routeId))
|
||||
.orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)).reloadStatus();
|
||||
if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) {
|
||||
Command
|
||||
.of(LegSyncCommand.class)
|
||||
.data(SyncLegData.of(order.getRouteId(), order.getSupplierName()))
|
||||
.sendToQueue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<Leg> processLegData(LegData legData, RouteOrder order) {
|
||||
|
|
|
@ -9,4 +9,10 @@ public class SyncLegData {
|
|||
private Long routeId;
|
||||
private List<Long> routeIds;
|
||||
private String supplierName;
|
||||
public static SyncLegData of( Long routeId,String supplierName){
|
||||
SyncLegData syncLegData = new SyncLegData();
|
||||
syncLegData.setSupplierName(supplierName);
|
||||
syncLegData.setRouteId(routeId);
|
||||
return syncLegData;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue