From 708226b3c8bdcae1b7c038914803d13b886df191 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Tue, 2 Jul 2024 14:23:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=AE=A1=E6=89=B9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E9=87=8D=E6=9E=84-=E5=AE=89=E8=83=BD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=A1=8C=E7=A8=8B=E5=92=8C=E5=8F=98=E6=9B=B4=E8=A1=8C=E7=A8=8B?= =?UTF-8?q?-=E7=BB=86=E8=8A=82=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/in/OrderPublicController.java | 3 +- .../ApprovalLegAddAndChangeBatch.java | 45 ++++++++++++------- .../aggregates/approval/ApprovalProcess.java | 19 ++++++-- .../aggregates/approval/ApprovalSubmit.java | 30 +++++++++---- .../approval/platform/ApprovalPlatformAN.java | 2 +- .../aggregates/base/EventManageable.java | 2 +- .../chint/domain/aggregates/order/Leg.java | 8 ++-- .../aggregates/order/LegApprovalEvent.java | 8 +++- .../domain/aggregates/order/RouteOrder.java | 13 ++++++ .../domain/aggregates/system/SystemCode.java | 2 +- .../aggregates/system/SystemOrganization.java | 2 +- .../domain/service/LegDomainService.java | 3 +- .../service/RouteApprovalDomainService.java | 16 +++++-- .../service/order_sync/SupplierOrderSync.java | 3 +- .../repository/RouteRepositoryImpl.java | 10 ++++- .../infrastructure/util/DelayDispatch.java | 2 +- 16 files changed, 122 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/chint/application/in/OrderPublicController.java b/src/main/java/com/chint/application/in/OrderPublicController.java index 1b274ac2..e28a7055 100644 --- a/src/main/java/com/chint/application/in/OrderPublicController.java +++ b/src/main/java/com/chint/application/in/OrderPublicController.java @@ -60,7 +60,6 @@ public class OrderPublicController { - @ApiOperation("审批拒绝行程规划单") @PostMapping("/reject") public Result rejectOrder(@RequestBody ApproveRouteData approveRouteData) { @@ -106,7 +105,7 @@ public class OrderPublicController { } - @ApiOperation("提交需要审批的行程节点") + @ApiOperation("处理审批结果回复") @PostMapping("/approve/response") public Result approveOrder(@RequestBody ApprovalResultData data) { routeApprovalDomainService.handlerApprovalResponse(data); diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java index 60731e69..c4ad5d3e 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java @@ -5,7 +5,6 @@ import com.chint.domain.aggregates.base.BaseEvent; import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.LegApprovalEvent; import com.chint.domain.aggregates.order.RouteOrder; -import com.google.gson.Gson; import org.springframework.data.util.Pair; import java.util.Comparator; @@ -36,9 +35,8 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess { approvalData.setAddLegList(legMap.get(true)); List> pairList = legMap.get(false).stream() .map(leg -> { - Gson gson = new Gson(); String extension = leg.getLastEvent().getExtension(); - Leg oldLeg = gson.fromJson(extension, Leg.class); + Leg oldLeg = leg.deepClone().restoreFromLegString(extension); return Pair.of(leg, oldLeg); }).toList(); approvalData.setChangeLegList(pairList); @@ -67,22 +65,37 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess { public void handlerApprovalResultBefore(ApprovalResultData data) { String approvalRecordNo = data.getApprovalRecordNo(); RouteOrder routeOrder = data.getRouteOrder(); + routeOrder.getLegItems().stream() - .filter(leg -> { - BaseEvent lastEvent = leg.getLastEvent(); - return lastEvent.getEventType().equals(LEG_APPROVAL_STATUS_SUBMIT) && - lastEvent.getExtension().equals(approvalRecordNo); - }).forEach(leg -> { - if (data.getApprovalStatus().equals(ApprovalRecord.successApprovalStatus())) { - leg.addEvent(LegApprovalEvent.success()); + .filter(leg -> isLegApprovalPending(leg, approvalRecordNo)) + .forEach(leg -> handleLegApprovalResult(data, routeOrder, leg)); + } + private boolean isLegApprovalPending(Leg leg, String approvalRecordNo) { + BaseEvent lastEvent = leg.getLastEvent(); + return lastEvent.getEventType().equals(LEG_APPROVAL_STATUS_SUBMIT) && + lastEvent.getExtension().equals(approvalRecordNo); + } + private void handleLegApprovalResult(ApprovalResultData data, RouteOrder routeOrder, Leg leg) { + if (data.getApprovalStatus().equals(ApprovalRecord.successApprovalStatus())) { + leg.addEvent(LegApprovalEvent.success()); + } else { + leg.addEvent(LegApprovalEvent.reject()); + rollbackLegState(routeOrder, leg); + } + } + private void rollbackLegState(RouteOrder routeOrder, Leg leg) { + leg.getLegApprovalEventList().stream() + .filter(event -> event.getEventType().equals(LEG_APPROVAL_STATUS_PREPARE)) + .max(Comparator.comparing(LegApprovalEvent::getHappenTime)) + .ifPresent(lastPrepareEvent -> { + if (isRollbackToOriginalLeg(lastPrepareEvent)) { + routeOrder.deleteLeg(leg.getLegNo()); } else { - leg.addEvent(LegApprovalEvent.reject());//如果行程被驳回 ,那么就要回滚到审批前的状态 - leg.getLegApprovalEventList() - .stream() - .filter(legApprovalEvent -> legApprovalEvent.getEventType().equals(LEG_APPROVAL_STATUS_PREPARE)) - .max(Comparator.comparing(LegApprovalEvent::getHappenTime)) - .ifPresent(it -> leg.restoreFromLegString(it.getExtension())); + leg.restoreFromLegString(lastPrepareEvent.getExtension()); } }); } + private boolean isRollbackToOriginalLeg(LegApprovalEvent lastPrepareEvent) { + return lastPrepareEvent.getExtension() == null || lastPrepareEvent.getExtension().isEmpty(); + } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java index c85e19aa..4964687c 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java @@ -5,10 +5,14 @@ import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.LegApprovalEvent; import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.exceptions.CommandException; import lombok.Data; +import java.util.List; import java.util.function.Consumer; +import static com.chint.infrastructure.constant.LegConstant.LEG_APPROVAL_STATUS_PREPARE; + // 定义抽象类 ApprovalProcess @Data @@ -52,8 +56,16 @@ public abstract class ApprovalProcess { RouteOrder routeOrder = approvalData.getRouteOrder(); if (routeOrder != null) { ApprovalRecord approvalRecord = ApprovalRecord.of(routeOrder, this); + List legs = routeOrder.getLegItems() + .stream() + .filter(legItem -> legItem.getLastEvent().getEventType().equals(LEG_APPROVAL_STATUS_PREPARE)) + .toList(); + if (legs.isEmpty()) { + throw new CommandException("不存在需要审批的行程"); + } approvalData.setApprovalRecordNo(approvalRecord.getApprovalRecordNo()); - consumer.accept(approvalRecord); // 使用传入的Consumer对象 + routeOrder.addApprovalRecord(approvalRecord); + consumer.accept(approvalRecord); return this; } else { return null; @@ -82,10 +94,11 @@ public abstract class ApprovalProcess { public ApprovalProcess beforeSubmitToBpm() { //所有被提交审批的被加入审批事件 - approvalData.getAddLegList().forEach(leg -> leg.addEvent(LegApprovalEvent.submit())); + String approvalRecordNo = approvalData.getApprovalRecordNo(); + approvalData.getAddLegList().forEach(leg -> leg.addEvent(LegApprovalEvent.submit(approvalRecordNo))); approvalData.getChangeLegList().forEach(it -> { Leg newLeg = it.getFirst(); - newLeg.addEvent(LegApprovalEvent.submit()); + newLeg.addEvent(LegApprovalEvent.submit(approvalRecordNo)); }); return this; } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java index 4c83e02b..0f1cef93 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java @@ -1,6 +1,7 @@ package com.chint.domain.aggregates.approval; import com.chint.domain.aggregates.approval.platform.ApprovalPlatform; +import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.repository.ApprovalRecordRepository; import com.chint.domain.repository.RouteRepository; import org.jetbrains.annotations.NotNull; @@ -9,8 +10,10 @@ import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; @Component @@ -57,14 +60,25 @@ public class ApprovalSubmit implements ApplicationListener { - data.setRouteOrder(routeRepository.queryById(it.getRouteId())); - ApprovalProcess approvalProcess = of(ApprovalType.valueOf(it.getApprovalType()), it.getApprovalPlatformMark()); - approvalProcess.handlerApprovalResult(data); - approvalRecordRepository.save(it); - routeRepository.save(data.getRouteOrder()); - }); + Optional optionalApprovalRecord = approvalRecordRepository.findByApprovalRecordNo(data.getApprovalRecordNo()); + if (optionalApprovalRecord.isPresent()) { + ApprovalRecord approvalRecord = optionalApprovalRecord.get(); + RouteOrder routeOrder = routeRepository.queryById(approvalRecord.getRouteId()); + data.setRouteOrder(routeOrder); + Optional matchingApprovalRecord = routeOrder.getApprovalRecordList().stream() + .filter(record -> record.getApprovalRecordNo().equals(data.getApprovalRecordNo())) + .findFirst(); + matchingApprovalRecord.ifPresent(record -> processHandleApprovalResult(data, routeOrder, record)); + } + } + + private void processHandleApprovalResult(ApprovalResultData data, RouteOrder routeOrder, ApprovalRecord approvalRecord) { + ApprovalProcess approvalProcess = of(ApprovalType.valueOf(approvalRecord.getApprovalType()), + approvalRecord.getApprovalPlatformMark()); + approvalProcess.handlerApprovalResult(data); + approvalRecord.setApprovalStatus(data.getApprovalStatus()); + routeRepository.save(routeOrder); } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatformAN.java b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatformAN.java index 8fe71fb4..3ceac25f 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatformAN.java +++ b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatformAN.java @@ -46,7 +46,7 @@ public class ApprovalPlatformAN implements ApprovalPlatform { @PostConstruct void init() { approvalPlatformInfoRepository.findByPlatformMark(platformMark) - .ifPresent(approvalPlatformInfo -> approvalPlatformInfo.setPlatformMark(platformMark)); + .ifPresent(approvalPlatformInfo -> this.approvalPlatformInfo = approvalPlatformInfo); } @Override diff --git a/src/main/java/com/chint/domain/aggregates/base/EventManageable.java b/src/main/java/com/chint/domain/aggregates/base/EventManageable.java index 9f0662c6..06744d95 100644 --- a/src/main/java/com/chint/domain/aggregates/base/EventManageable.java +++ b/src/main/java/com/chint/domain/aggregates/base/EventManageable.java @@ -14,7 +14,7 @@ public interface EventManageable { default void addEvent(BaseEvent event) { List events = (List) getEvents(); BaseEvent lastEvent = getLastEvent(); - if (!Objects.equals(lastEvent.getEventType(), event.getEventType())) { + if (lastEvent == null || !Objects.equals(lastEvent.getEventType(), event.getEventType())) { events.add(event); } } diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index 807cbce7..4d637b0e 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -421,18 +421,20 @@ public class Leg implements Serializable, EventManageable { public String generateLegString() { return DateTimeUtil.timeToStrCommon(startTime) + "|" + DateTimeUtil.timeToStrCommon(endTime) + "|" + - originId + "|" + destinationId; + originId + "|" + destinationId + "|" + estimateAmount; } - public void restoreFromLegString(String legString) { + public Leg restoreFromLegString(String legString) { String[] parts = legString.split("\\|"); - if (parts.length == 4) { + if (parts.length == 5) { this.startTime = DateTimeUtil.strToTime(parts[0]); this.endTime = DateTimeUtil.strToTime(parts[1]); this.originId = Long.parseLong(parts[2]); this.destinationId = Long.parseLong(parts[3]); + this.estimateAmount = parts[4]; } else { throw new IllegalArgumentException("Invalid legString format."); } + return this; } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java b/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java index 57fe4325..f6df2f14 100644 --- a/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java @@ -1,7 +1,6 @@ package com.chint.domain.aggregates.order; import com.chint.domain.aggregates.base.BaseEvent; -import com.chint.infrastructure.util.Json; import lombok.Data; import org.springframework.data.annotation.Id; import org.springframework.data.relational.core.mapping.Column; @@ -53,6 +52,13 @@ public class LegApprovalEvent extends BaseEvent implements Serializable { return event; } + public static LegApprovalEvent submit(String extension) { + LegApprovalEvent event = new LegApprovalEvent(); + event.setEventType(LEG_APPROVAL_STATUS_SUBMIT); + event.setExtension(extension); + return event; + } + public static LegApprovalEvent success() { LegApprovalEvent event = new LegApprovalEvent(); event.setEventType(LEG_APPROVAL_STATUS_SUCCESS); diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index 9ad56631..a3f64144 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -2,6 +2,7 @@ package com.chint.domain.aggregates.order; import com.chint.application.commands.LegOrderedCommand; +import com.chint.domain.aggregates.approval.ApprovalRecord; import com.chint.domain.factoriy.leg.LegFactory; import com.chint.domain.service.LegDomainService; import com.chint.domain.service.amount_estimate.EstimateAdapter; @@ -102,6 +103,9 @@ public class RouteOrder implements Serializable { @MappedCollection(idColumn = "route_id", keyColumn = "route_order_key") private List routeRequestList; + @MappedCollection(idColumn = "route_id", keyColumn = "route_order_key") + private List approvalRecordList; + @ApiModelProperty("启用状态,1启动,0禁用") public Integer status = 1; @@ -224,6 +228,15 @@ public class RouteOrder implements Serializable { return this; } + public RouteOrder addApprovalRecord(ApprovalRecord approvalRecord) { + if (this.approvalRecordList == null) { + this.approvalRecordList = new ArrayList<>(); + } + this.approvalRecordList = new ArrayList<>(this.approvalRecordList); + this.approvalRecordList.add(approvalRecord); + return this; + } + public RouteOrder addRouteRequest(RouteRequest routeRequest) { if (this.routeRequestList == null) { this.routeRequestList = new ArrayList<>(); diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java index fe359923..8db9b025 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java @@ -40,7 +40,7 @@ public class SystemCode implements Serializable { private String getExtensionValue(String fieldName) { if (systemCodeExtensionFieldList == null || systemCodeExtensionFieldList.isEmpty()) { - return ""; + return null; } return this.systemCodeExtensionFieldList.stream().filter(it -> it.getFieldName().equals(fieldName)) .map(SystemCodeExtensionField::getFieldValue) diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java b/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java index 89bd504c..1207239c 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java @@ -104,7 +104,7 @@ public class SystemOrganization implements Serializable { private String getExtensionValue(String fieldName) { if (systemOrganizationExtensionList == null || systemOrganizationExtensionList.isEmpty()) { - return ""; + return null; } return this.systemOrganizationExtensionList.stream().filter(it -> it.getFieldName().equals(fieldName)) .map(SystemOrganizationExtension::getFieldValue) diff --git a/src/main/java/com/chint/domain/service/LegDomainService.java b/src/main/java/com/chint/domain/service/LegDomainService.java index 8d6b7da6..5051af23 100644 --- a/src/main/java/com/chint/domain/service/LegDomainService.java +++ b/src/main/java/com/chint/domain/service/LegDomainService.java @@ -228,7 +228,8 @@ public class LegDomainService { List filteredLegItems = legItems.stream() .filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal()) .peek(Leg::reloadStatus) - .filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT)) + .filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT) && + !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_PREPARE)) .toList(); // 根据供应商名称查找供应商并进行处理 diff --git a/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java b/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java index 5c652cc5..682d568d 100644 --- a/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java +++ b/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java @@ -5,6 +5,7 @@ import com.chint.domain.aggregates.approval.ApprovalResultData; import com.chint.domain.aggregates.approval.ApprovalSubmit; import com.chint.domain.aggregates.base.PermissionConfig; import com.chint.domain.aggregates.order.ApproveOrderNo; +import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.system.SystemCode; import com.chint.domain.aggregates.system.SystemOrganization; @@ -12,6 +13,7 @@ import com.chint.domain.repository.*; import com.chint.domain.value_object.enums.RoutePermission; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Collections; import java.util.List; @@ -40,6 +42,10 @@ public class RouteApprovalDomainService { @Autowired private ApprovalRecordRepository approvalRecordRepository; + @Autowired + private LegDomainService legDomainService; + + @Autowired private ApprovalSubmit approvalSubmit; public void legApprovalResponse() { @@ -54,15 +60,17 @@ public class RouteApprovalDomainService { approvalSubmit.handleApprovalResult(data); } + @Transactional public void approveRouteOfLegChangeAndAdd(LegApprovalParam param) { RouteOrder routeOrder = routeRepository.queryById(param.getRouteId()); + List legItems = routeOrder.getLegItems(); + if (legItems != null && !legItems.isEmpty() && legItems.get(0).getOriginLocation() == null) { + legDomainService.queryLocation(legItems); + } String approvalPlatformMark = getApprovalPlatformMark(routeOrder); ApprovalSubmit.of(LEG_ADD_CHANGE_BATCH, approvalPlatformMark) .approveData(routeOrder) - .record(record -> { - record.setApprovalReason(param.getApprovalReason()); - approvalRecordRepository.save(record); - }) + .record(it -> it.setApprovalReason(param.getApprovalReason())) .submitToBpm(); routeRepository.save(routeOrder); } diff --git a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java index de615165..60260152 100644 --- a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java +++ b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java @@ -45,7 +45,8 @@ public interface SupplierOrderSync extends SupplierAdapter { .stream() .map(RouteRequestLeg::getLeg) .peek(Leg::reloadStatus) - .filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT)) + .filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT) && + !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_PREPARE)) .toList(); // Legs can not be empty diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java index f9466f19..9b004a13 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java @@ -1,8 +1,10 @@ package com.chint.infrastructure.repository; import com.chint.domain.aggregates.order.ApproveOrderNo; +import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.repository.RouteRepository; +import com.chint.domain.service.LegDomainService; import com.chint.domain.value_object.OrderQueryData; import com.chint.infrastructure.cache.RouteCacheService; import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository; @@ -32,10 +34,14 @@ public class RouteRepositoryImpl implements RouteRepository { @Autowired private RedisTemplate redisTemplate; + @Override public RouteOrder queryById(Long orderId) { -// jdbcRouteRepository.findByRouteId(orderId); - return routeCacheService.getRouteById(orderId); + RouteOrder routeOrder = routeCacheService.getRouteById(orderId); + if (routeOrder != null && routeOrder.getOrderStatus() == null) { + routeOrder.reloadStatus(); + } + return routeOrder; } @Override diff --git a/src/main/java/com/chint/infrastructure/util/DelayDispatch.java b/src/main/java/com/chint/infrastructure/util/DelayDispatch.java index dccf9af4..fa499f43 100644 --- a/src/main/java/com/chint/infrastructure/util/DelayDispatch.java +++ b/src/main/java/com/chint/infrastructure/util/DelayDispatch.java @@ -11,7 +11,7 @@ public class DelayDispatch { if (attempt >= 5) { return; } - boolean success = requestSupplier.get(); // 使用Supplier获取请求成功与否的状态 + boolean success = requestSupplier != null && requestSupplier.get() != null && requestSupplier.get(); // 使用Supplier获取请求成功与否的状态 if (!success) { ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.schedule(() -> {