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 b3873af1..aba5fd64 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java @@ -5,6 +5,7 @@ import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.exceptions.CommandException; import com.chint.domain.repository.ApprovalRecordRepository; import com.chint.domain.repository.RouteRepository; +import com.chint.domain.service.LegDomainService; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -31,6 +32,9 @@ public class ApprovalSubmit implements ApplicationListener locationList = legExtensionField.getLocationList(); - if (locationList == null || locationList.size() != locationIdsAsLong.size()) { + + if (locationList == null || locationList.size() != locationIdsAsLong.size() || + checkIfSameLocationList(locationList, locationIdsAsLong)) { List byNameList = locationRepository.findByNameList(locationIdsAsLong); legExtensionField.setLocationList(byNameList); } @@ -184,6 +187,12 @@ public class LegDomainService { return list; } + private boolean checkIfSameLocationList(List locationList, List locationIdsAsLong) { + List inIds = locationList.stream().map(Location::getLocationId).toList(); + // 检查两个列表是否相互包含 + return new HashSet<>(locationIdsAsLong).containsAll(inIds) && new HashSet<>(inIds).containsAll(locationIdsAsLong); + } + public List queryLocationByLeg(List list) { list.forEach(leg -> { LegExtensionField legExtensionField = leg.getLegExtensionField();