From 546a07f008b6a52add5372ee982e629ad5c4b9a1 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Thu, 4 Jul 2024 17:03:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=9B=A0=E5=9C=B0?= =?UTF-8?q?=E7=90=86=E4=BF=A1=E6=81=AF=E7=A1=AE=E5=AE=9E=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=AE=A1=E6=89=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/aggregates/approval/ApprovalSubmit.java | 5 +++++ .../com/chint/domain/service/LegDomainService.java | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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();