fix:修复因地理信息确实导致无法审批的问题
This commit is contained in:
parent
38a66b1037
commit
546a07f008
|
@ -5,6 +5,7 @@ import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.exceptions.CommandException;
|
import com.chint.domain.exceptions.CommandException;
|
||||||
import com.chint.domain.repository.ApprovalRecordRepository;
|
import com.chint.domain.repository.ApprovalRecordRepository;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
|
import com.chint.domain.service.LegDomainService;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
@ -31,6 +32,9 @@ public class ApprovalSubmit implements ApplicationListener<ApplicationReadyEvent
|
||||||
@Autowired
|
@Autowired
|
||||||
private RouteRepository routeRepository;
|
private RouteRepository routeRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LegDomainService legDomainService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(@NotNull ApplicationReadyEvent event) {
|
public void onApplicationEvent(@NotNull ApplicationReadyEvent event) {
|
||||||
|
@ -90,6 +94,7 @@ public class ApprovalSubmit implements ApplicationListener<ApplicationReadyEvent
|
||||||
ApprovalRecord.successApprovalStatus() :
|
ApprovalRecord.successApprovalStatus() :
|
||||||
ApprovalRecord.rejectApprovalStatus());
|
ApprovalRecord.rejectApprovalStatus());
|
||||||
approvalRecord.setApprovalResponseDate(LocalDateTime.now());
|
approvalRecord.setApprovalResponseDate(LocalDateTime.now());
|
||||||
|
legDomainService.queryLocation(routeOrder.getLegItems());
|
||||||
routeRepository.save(routeOrder);
|
routeRepository.save(routeOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -166,7 +167,9 @@ public class LegDomainService {
|
||||||
locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
|
locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
|
||||||
}
|
}
|
||||||
List<Location> locationList = legExtensionField.getLocationList();
|
List<Location> locationList = legExtensionField.getLocationList();
|
||||||
if (locationList == null || locationList.size() != locationIdsAsLong.size()) {
|
|
||||||
|
if (locationList == null || locationList.size() != locationIdsAsLong.size() ||
|
||||||
|
checkIfSameLocationList(locationList, locationIdsAsLong)) {
|
||||||
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
|
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
|
||||||
legExtensionField.setLocationList(byNameList);
|
legExtensionField.setLocationList(byNameList);
|
||||||
}
|
}
|
||||||
|
@ -184,6 +187,12 @@ public class LegDomainService {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkIfSameLocationList(List<Location> locationList, List<Long> locationIdsAsLong) {
|
||||||
|
List<Long> inIds = locationList.stream().map(Location::getLocationId).toList();
|
||||||
|
// 检查两个列表是否相互包含
|
||||||
|
return new HashSet<>(locationIdsAsLong).containsAll(inIds) && new HashSet<>(inIds).containsAll(locationIdsAsLong);
|
||||||
|
}
|
||||||
|
|
||||||
public List<LegItinerary> queryLocationByLeg(List<LegItinerary> list) {
|
public List<LegItinerary> queryLocationByLeg(List<LegItinerary> list) {
|
||||||
list.forEach(leg -> {
|
list.forEach(leg -> {
|
||||||
LegExtensionField legExtensionField = leg.getLegExtensionField();
|
LegExtensionField legExtensionField = leg.getLegExtensionField();
|
||||||
|
|
Loading…
Reference in New Issue