fix:修复因地理信息确实导致无法审批的问题
This commit is contained in:
parent
d97da29c2f
commit
c166e430d5
|
@ -168,7 +168,9 @@ public class OrderQuery {
|
|||
.skip((long) (pageNum - 1) * pageSize)
|
||||
.limit(pageSize)
|
||||
.map(routeOrder -> {
|
||||
legDomainService.queryLocation(routeOrder.getLegItems());
|
||||
if (legDomainService.checkLocation(routeOrder.getLegItems())) {
|
||||
routeRepository.reloadRouteOrderInCache(routeOrder);
|
||||
}
|
||||
User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId());
|
||||
return getRouteOrderPageRes(routeOrder, user);
|
||||
})
|
||||
|
@ -179,7 +181,6 @@ public class OrderQuery {
|
|||
orderDomainService.finishOrder(it);
|
||||
}
|
||||
});
|
||||
|
||||
return new PageResult<>(total, orders);
|
||||
}
|
||||
|
||||
|
@ -535,7 +536,9 @@ public class OrderQuery {
|
|||
if (routeOrder.getApprovalStatusCode() != APPROVAL_EVENT_PREPARE) {
|
||||
legItems.forEach(leg -> legDomainService.legCheckOrder(leg));
|
||||
}
|
||||
legDomainService.queryLocation(legItems);
|
||||
if (legDomainService.checkLocation(legItems)) {
|
||||
routeRepository.reloadRouteOrderInCache(routeOrder);
|
||||
}
|
||||
List<LegRes> list = legItems.stream().map(LegRes::copyFrom).toList();
|
||||
routeOrderRes.setLegResList(list);
|
||||
}
|
||||
|
|
|
@ -429,14 +429,18 @@ public class Leg implements Serializable, EventManageable {
|
|||
|
||||
|
||||
public String generateLegString() {
|
||||
return DateTimeUtil.timeToStrCommon(startTime) + "|" +
|
||||
String generateStr = DateTimeUtil.timeToStrCommon(startTime) + "|" +
|
||||
DateTimeUtil.timeToStrCommon(endTime) + "|" +
|
||||
originId + "|" + destinationId + "|" + estimateAmount;
|
||||
if (this.legType.equals(LEG_TYPE_TAXI)) {
|
||||
return generateStr + "|" + this.getLegExtensionField().getLocationIds();
|
||||
}
|
||||
return generateStr;
|
||||
}
|
||||
|
||||
public Leg restoreFromLegString(String legString) {
|
||||
String[] parts = legString.split("\\|");
|
||||
if (parts.length == 5) {
|
||||
if (parts.length >= 5) {
|
||||
this.startTime = parts[0] != null && !"null".equals(parts[0]) ? DateTimeUtil.strToTime(parts[0]) : null;
|
||||
this.endTime = parts[1] != null && !"null".equals(parts[1]) ? DateTimeUtil.strToTime(parts[1]) : null;
|
||||
this.originId = parts[2] != null && !"null".equals(parts[2]) ? Long.parseLong(parts[2]) : null;
|
||||
|
@ -445,6 +449,9 @@ public class Leg implements Serializable, EventManageable {
|
|||
} else {
|
||||
throw new IllegalArgumentException("Invalid legString format.");
|
||||
}
|
||||
if (parts.length >= 6 && parts[5] != null && !parts[5].isEmpty() && !"null".equals(parts[5])) {
|
||||
this.getLegExtensionField().setLocationIds(parts[5]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ public interface RouteRepository {
|
|||
|
||||
RouteOrder queryById(Long orderId, boolean ifUpdateCache);
|
||||
|
||||
RouteOrder reloadRouteOrderInCache(RouteOrder routeOrder);
|
||||
|
||||
List<RouteOrder> queryByIdIn(List<Long> routeIds);
|
||||
|
||||
List<RouteOrder> queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end);
|
||||
|
|
|
@ -156,35 +156,55 @@ public class LegDomainService {
|
|||
return leg;
|
||||
}
|
||||
|
||||
|
||||
public List<Leg> queryLocation(List<Leg> list) {
|
||||
list.forEach(leg -> {
|
||||
list.forEach(this::updateLegLocation);
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean checkLocation(List<Leg> list) {
|
||||
boolean flag = false;
|
||||
for (Leg leg : list) {
|
||||
boolean updated = updateLegLocation(leg);
|
||||
if (updated) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean updateLegLocation(Leg leg) {
|
||||
boolean updated = false;
|
||||
LegExtensionField legExtensionField = leg.getLegExtensionField();
|
||||
if (legExtensionField != null && legExtensionField.getLocationIds() != null) {
|
||||
List<Long> locationIdsAsLong;
|
||||
if (legExtensionField.getLocationIds().startsWith("[")) {
|
||||
locationIdsAsLong = legExtensionField.getLocationIdsAsLongFromArray();
|
||||
} else {
|
||||
locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
|
||||
}
|
||||
List<Long> locationIdsAsLong = getLocationIdsAsLong(legExtensionField);
|
||||
List<Location> locationList = legExtensionField.getLocationList();
|
||||
|
||||
if (locationList == null || locationList.size() != locationIdsAsLong.size() ||
|
||||
checkIfSameLocationList(locationList, locationIdsAsLong)) {
|
||||
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
|
||||
legExtensionField.setLocationList(byNameList);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
if (leg.getOriginId() != null && (leg.getOriginLocation() == null ||
|
||||
!Objects.equals(leg.getOriginLocation().getLocationId(), leg.getOriginId()))) {
|
||||
leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId()));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (leg.getDestinationId() != null && (leg.getDestinationLocation() == null ||
|
||||
!Objects.equals(leg.getDestinationLocation().getLocationId(), leg.getDestinationId()))) {
|
||||
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
|
||||
updated = true;
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
private List<Long> getLocationIdsAsLong(LegExtensionField legExtensionField) {
|
||||
if (legExtensionField.getLocationIds().startsWith("[")) {
|
||||
return legExtensionField.getLocationIdsAsLongFromArray();
|
||||
} else {
|
||||
return legExtensionField.getLocationIdsAsLong();
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
private boolean checkIfSameLocationList(List<Location> locationList, List<Long> locationIdsAsLong) {
|
||||
|
@ -212,7 +232,6 @@ public class LegDomainService {
|
|||
if (leg.getOriginId() != null && leg.getOriginLocation() == null) {
|
||||
leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId()));
|
||||
}
|
||||
|
||||
if (leg.getDestinationId() != null && leg.getDestinationLocation() == null) {
|
||||
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
|
||||
}
|
||||
|
@ -245,10 +264,19 @@ public class LegDomainService {
|
|||
.toList();
|
||||
|
||||
|
||||
List<Leg> legs = new ArrayList<>();
|
||||
for (Leg leg : legItems) {
|
||||
if (!leg.getLegType().equals(LEG_TYPE_OTHER) && leg.legIsInternal()) {
|
||||
leg.reloadStatus();
|
||||
// 不再过滤LegApprovalStatus
|
||||
legs.add(leg);
|
||||
}
|
||||
}
|
||||
|
||||
// 根据供应商名称查找供应商并进行处理
|
||||
return supplierRepository.findBySupplierName(supplierName)
|
||||
.map(supplier -> {
|
||||
List<Leg> syncAbleLegItems = ifCanSync(filteredLegItems, routeOrder, supplier);
|
||||
List<Leg> syncAbleLegItems = ifCanSync(legs, routeOrder, supplier);
|
||||
syncAbleLegItems.forEach(Leg::reloadStatus);
|
||||
return syncAbleLegItems;
|
||||
})
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.chint.domain.service;
|
||||
|
||||
import com.chint.application.dtos.LegApprovalParam;
|
||||
import com.chint.domain.aggregates.approval.ApprovalData;
|
||||
import com.chint.domain.aggregates.approval.ApprovalProcess;
|
||||
import com.chint.domain.aggregates.approval.ApprovalResultData;
|
||||
import com.chint.domain.aggregates.approval.ApprovalSubmit;
|
||||
import com.chint.domain.aggregates.base.PermissionConfig;
|
||||
|
@ -13,6 +15,7 @@ import com.chint.domain.repository.*;
|
|||
import com.chint.domain.value_object.enums.RoutePermission;
|
||||
import com.chint.infrastructure.util.StringCheck;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -46,6 +49,7 @@ public class RouteApprovalDomainService {
|
|||
@Autowired
|
||||
private ApprovalSubmit approvalSubmit;
|
||||
|
||||
|
||||
public void legApprovalResponse() {
|
||||
|
||||
}
|
||||
|
@ -64,13 +68,41 @@ public class RouteApprovalDomainService {
|
|||
List<Leg> legItems = routeOrder.getLegItems();
|
||||
legDomainService.queryLocation(legItems);
|
||||
String approvalPlatformMark = getApprovalPlatformMark(routeOrder);
|
||||
ApprovalSubmit.of(LEG_ADD_CHANGE_BATCH, approvalPlatformMark)
|
||||
.approveData(routeOrder)
|
||||
.record(it -> it.setApprovalReason(param.getApprovalReason()))
|
||||
ApprovalProcess approvalProcess = ApprovalSubmit.of(LEG_ADD_CHANGE_BATCH, approvalPlatformMark)
|
||||
.approveData(routeOrder);
|
||||
checkApprovalData(approvalProcess.getApprovalData());
|
||||
approvalProcess.record(it -> it.setApprovalReason(param.getApprovalReason()))
|
||||
.submitToBpm();
|
||||
routeRepository.save(routeOrder);
|
||||
}
|
||||
|
||||
private void checkApprovalData(ApprovalData approvalData) {
|
||||
List<Leg> allLegs = new ArrayList<>();
|
||||
// 添加单个 leg 对象
|
||||
if (approvalData.getLeg() != null) {
|
||||
allLegs.add(approvalData.getLeg());
|
||||
}
|
||||
|
||||
// 添加单个 oldLeg 对象
|
||||
if (approvalData.getOldLeg() != null) {
|
||||
allLegs.add(approvalData.getOldLeg());
|
||||
}
|
||||
|
||||
// 添加 addLegList 中的 Leg 对象
|
||||
if (approvalData.getAddLegList() != null) {
|
||||
allLegs.addAll(approvalData.getAddLegList());
|
||||
}
|
||||
|
||||
// 添加 changeLegList 中的 Leg 对象
|
||||
if (approvalData.getChangeLegList() != null) {
|
||||
for (Pair<Leg, Leg> pair : approvalData.getChangeLegList()) {
|
||||
allLegs.add(pair.getFirst());
|
||||
allLegs.add(pair.getSecond());
|
||||
}
|
||||
}
|
||||
legDomainService.checkLocation(allLegs);
|
||||
}
|
||||
|
||||
public List<RouteOrder> checkApprovalPermissions(List<RouteOrder> routeOrderList) {
|
||||
// 提取所有 approveOrderNo 和 sysCode
|
||||
Set<String> accountCompanyCodes = routeOrderList.stream()
|
||||
|
@ -140,11 +172,13 @@ public class RouteApprovalDomainService {
|
|||
}
|
||||
return routeOrder;
|
||||
}
|
||||
|
||||
private String findApprovalType(ApproveOrderNo approveOrderNo) {
|
||||
return systemOrganizationRepository.findByOrgCodeContainingOrOrgNameContaining(approveOrderNo.getAccountCompany(), approveOrderNo.getAccountCompany())
|
||||
.map(SystemOrganization::getApprovalType)
|
||||
.orElseGet(() -> systemCodeRepository.findBySysCode(approveOrderNo.getSysCode()).getApprovalType());
|
||||
}
|
||||
|
||||
private Set<RoutePermission> findRoutePermissions(String approvalType) {
|
||||
return permissionConfigRepository.findByPermissionName(approvalType)
|
||||
.map(permissionConfig -> permissionConfig.permissions().stream()
|
||||
|
|
|
@ -50,6 +50,11 @@ public class RouteCacheService {
|
|||
return routeOrders;
|
||||
}
|
||||
|
||||
public RouteOrder reloadRouteOrderInCache(RouteOrder routeOrder) {
|
||||
routeCacheManage.invalidateRouteCache(routeOrder.getRouteId());
|
||||
routeCacheManage.cacheRouteOrder(routeOrder);
|
||||
return routeOrder;
|
||||
}
|
||||
|
||||
public List<RouteOrder> getUserRoutes(String employeeNo) {
|
||||
//获取当前用户所有的订单id
|
||||
|
|
|
@ -49,6 +49,11 @@ public class RouteRepositoryImpl implements RouteRepository {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouteOrder reloadRouteOrderInCache(RouteOrder routeOrder) {
|
||||
return routeCacheService.reloadRouteOrderInCache(routeOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RouteOrder> queryByIdIn(List<Long> routeIds) {
|
||||
List<RouteOrder> routeOrders = new java.util.ArrayList<>(routeCacheService.queryByIdIn(routeIds)
|
||||
|
|
Loading…
Reference in New Issue