fix:修改添加和修改行程的增加审批事件的逻辑
This commit is contained in:
parent
845099b282
commit
2c0924372a
|
@ -15,9 +15,11 @@ import com.chint.domain.repository.LegRepository;
|
|||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.service.LegDomainService;
|
||||
import com.chint.domain.service.OrderDomainService;
|
||||
import com.chint.domain.service.RouteApprovalDomainService;
|
||||
import com.chint.domain.service.order_sync.SyncAdapter;
|
||||
import com.chint.domain.value_object.*;
|
||||
import com.chint.domain.value_object.enums.CurrencyType;
|
||||
import com.chint.domain.value_object.enums.RoutePermission;
|
||||
import com.chint.infrastructure.constant.DataMessageConstant;
|
||||
import com.chint.infrastructure.constant.LegConstant;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
|
@ -31,7 +33,10 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.chint.domain.value_object.enums.RoutePermission.LEG_NEED_APPROVAL;
|
||||
import static com.chint.domain.value_object.enums.RoutePermission.LEG_NEED_NOTIFY;
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_TIME_ERROR;
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
|
||||
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_APPROVAL;
|
||||
|
@ -55,6 +60,8 @@ public class OrderApplicationService {
|
|||
@Autowired
|
||||
private LegRepository legRepository;
|
||||
|
||||
@Autowired
|
||||
private RouteApprovalDomainService routeApprovalDomainService;
|
||||
|
||||
@Autowired
|
||||
private LegDomainService legDomainService;
|
||||
|
@ -143,10 +150,12 @@ public class OrderApplicationService {
|
|||
|
||||
// 发送 BPM 保存结果
|
||||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||
if (!routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE) && approveOrderNo.getSysCode().equals("ANFSSC")) {
|
||||
if (!routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
|
||||
//这里加入一个待审批事件, 变更加入旧行程数据, 用于回滚还原
|
||||
if (checkIfNeedApprove(routeOrder)) {
|
||||
leg.addEvent(LegApprovalEvent.prepare(oldLeg));
|
||||
}
|
||||
}
|
||||
if (!routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE) && !approveOrderNo.getSysCode().equals("ANFSSC")) {
|
||||
sendLegChangeCommand(oldLeg, leg,
|
||||
routeOrder,
|
||||
|
@ -160,6 +169,18 @@ public class OrderApplicationService {
|
|||
Command.of(RouteAutoSyncCommand.class).route(routeOrder).async().sendToQueue();
|
||||
}
|
||||
|
||||
private boolean checkIfNeedApprove(RouteOrder routeOrder) {
|
||||
Set<RoutePermission> routePermissionSet = routeOrder.getRoutePermissionSet();
|
||||
if (routePermissionSet == null) {
|
||||
routeApprovalDomainService.checkApprovalPermissions(routeOrder);
|
||||
}
|
||||
if (routePermissionSet == null) {
|
||||
return false;
|
||||
}
|
||||
return routePermissionSet.contains(LEG_NEED_APPROVAL) || routePermissionSet.contains(LEG_NEED_NOTIFY);
|
||||
}
|
||||
|
||||
|
||||
private Leg handleLegChangeEvent(Leg leg, LegData legData, RouteOrder routeOrder) {
|
||||
// 保存变更事件理由
|
||||
legDomainService.addChangeEvent(leg, legData.getChangeReason());
|
||||
|
@ -182,12 +203,13 @@ public class OrderApplicationService {
|
|||
|
||||
leg.setRouteId(routeOrder.getRouteId());
|
||||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||
if (!routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE) && approveOrderNo.getSysCode().equals("ANFSSC") &&
|
||||
addLegData.getIfApprove() == 1
|
||||
if (!routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE) && addLegData.getIfApprove() == 1
|
||||
) {
|
||||
//这里加入一个待审批事件
|
||||
if (checkIfNeedApprove(routeOrder)) {
|
||||
leg.addEvent(LegApprovalEvent.prepare());
|
||||
}
|
||||
}
|
||||
|
||||
if (!routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE) && !approveOrderNo.getSysCode().equals("ANFSSC")) {
|
||||
leg.reloadStatus();
|
||||
|
@ -216,7 +238,6 @@ public class OrderApplicationService {
|
|||
.sendToQueue();
|
||||
}
|
||||
|
||||
|
||||
private List<Leg> processLegData(LegData legData, RouteOrder order) {
|
||||
if (legData.getCurrencyType() == null) {
|
||||
legData.setCurrencyType(CurrencyType.RENMINBI.getCode());
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.chint.domain.aggregates.approval.ApprovalMethod.NOTIFY;
|
||||
import static com.chint.domain.aggregates.approval.ApprovalType.LEG_ADD_CHANGE_BATCH;
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_APPROVAL_STATUS_PREPARE;
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_APPROVAL_STATUS_SUBMIT;
|
||||
|
@ -96,8 +97,6 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean approve() {
|
||||
return false;
|
||||
|
@ -110,10 +109,34 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess {
|
|||
|
||||
@Override
|
||||
public ApprovalProcess doSubmitToBpm() {
|
||||
//按照审批类型为行程加入不同的审批事件
|
||||
if (this.getApprovalMethod().equals(NOTIFY)) {
|
||||
//所有被提交审批的被加入知会事件
|
||||
String approvalRecordNo = approvalData.getApprovalRecordNo();
|
||||
addApprovalEventAndRecord(LegApprovalEvent.notifyEvent(approvalRecordNo));
|
||||
} else {
|
||||
//所有被提交审批的被加入审批事件
|
||||
String approvalRecordNo = approvalData.getApprovalRecordNo();
|
||||
addApprovalEventAndRecord(LegApprovalEvent.submit(approvalRecordNo));
|
||||
}
|
||||
bpmPlatform.submitLegAddOrChangeApproval(approvalData);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void addApprovalEventAndRecord(LegApprovalEvent event) {
|
||||
ApprovalRecord approvalRecord = this.getApprovalRecord();
|
||||
approvalData.getAddLegList().forEach(leg -> {
|
||||
leg.addEvent(event);
|
||||
approvalRecord.addLeg(leg);
|
||||
});
|
||||
approvalData.getChangeLegList().forEach(it -> {
|
||||
Leg newLeg = it.getFirst();
|
||||
newLeg.addEvent(event);
|
||||
approvalRecord.addLeg(newLeg);
|
||||
});
|
||||
bpmPlatform.submitLegAddOrChangeApproval(approvalData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerApprovalResultBefore(ApprovalResultData data) {
|
||||
String approvalRecordNo = data.getApprovalRecordNo();
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.chint.domain.aggregates.approval;
|
|||
|
||||
import com.chint.domain.aggregates.approval.platform.ApprovalPlatform;
|
||||
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;
|
||||
|
@ -26,6 +25,8 @@ public abstract class ApprovalProcess {
|
|||
|
||||
private ApprovalMethod approvalMethod;
|
||||
|
||||
private ApprovalRecord approvalRecord;
|
||||
|
||||
public ApprovalProcess(ApprovalPlatform bpmPlatform) {
|
||||
this.bpmPlatform = bpmPlatform;
|
||||
}
|
||||
|
@ -81,6 +82,7 @@ public abstract class ApprovalProcess {
|
|||
}
|
||||
approvalData.setApprovalRecordNo(approvalRecord.getApprovalRecordNo());
|
||||
routeOrder.addApprovalRecord(approvalRecord);
|
||||
this.approvalRecord = approvalRecord;
|
||||
consumer.accept(approvalRecord);
|
||||
return this;
|
||||
} else {
|
||||
|
@ -108,13 +110,6 @@ public abstract class ApprovalProcess {
|
|||
public abstract ApprovalProcess doSubmitToBpm();
|
||||
|
||||
public ApprovalProcess beforeSubmitToBpm() {
|
||||
//所有被提交审批的被加入审批事件
|
||||
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(approvalRecordNo));
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package com.chint.domain.aggregates.approval;
|
||||
|
||||
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.infrastructure.util.OrderNo;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
|
@ -33,6 +38,11 @@ public class ApprovalRecord implements Serializable {
|
|||
private String approvalReason;
|
||||
private String extension;
|
||||
private String extensionSub;
|
||||
@MappedCollection(idColumn = "approval_record_id", keyColumn = "approval_record_key")
|
||||
private List<ApprovalRecordLeg> ApprovalRecordLegList;
|
||||
|
||||
@MappedCollection(idColumn = "approval_record_id", keyColumn = "approval_record_key")
|
||||
private List<ApprovalRecordOrder> ApprovalRecordOrderList;
|
||||
|
||||
public static ApprovalRecord of(RouteOrder routeOrder, ApprovalProcess approvalProcess) {
|
||||
ApprovalRecord approvalRecord = new ApprovalRecord();
|
||||
|
@ -50,6 +60,24 @@ public class ApprovalRecord implements Serializable {
|
|||
return approvalRecord;
|
||||
}
|
||||
|
||||
public ApprovalRecord addLeg(Leg leg) {
|
||||
if (ApprovalRecordLegList == null) {
|
||||
ApprovalRecordLegList = new ArrayList<>();
|
||||
}
|
||||
ApprovalRecordLegList = new ArrayList<>(ApprovalRecordLegList);
|
||||
ApprovalRecordLegList.add(ApprovalRecordLeg.of(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApprovalRecord addOrderDetail(OrderDetail orderDetail) {
|
||||
if (ApprovalRecordOrderList == null) {
|
||||
ApprovalRecordOrderList = new ArrayList<>();
|
||||
}
|
||||
ApprovalRecordOrderList = new ArrayList<>(ApprovalRecordOrderList);
|
||||
ApprovalRecordOrderList.add(ApprovalRecordOrder.of(orderDetail));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApprovalRecord reason(String approvalReason) {
|
||||
this.approvalReason = approvalReason;
|
||||
return this;
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.chint.domain.aggregates.approval;
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Table("approval_record_leg")
|
||||
public class ApprovalRecordLeg implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 976619376459713654L;
|
||||
@Id
|
||||
private Long id;
|
||||
private Long ApprovalRecordId;
|
||||
private Long legId;
|
||||
@Transient
|
||||
private Leg leg;
|
||||
|
||||
public static ApprovalRecordLeg of(Leg leg) {
|
||||
ApprovalRecordLeg approvalRecordLeg = of(leg.getLegId());
|
||||
approvalRecordLeg.setLeg(leg);
|
||||
return approvalRecordLeg;
|
||||
}
|
||||
|
||||
public static ApprovalRecordLeg of(Long id) {
|
||||
ApprovalRecordLeg approvalRecordLeg = new ApprovalRecordLeg();
|
||||
approvalRecordLeg.setLegId(id);
|
||||
return approvalRecordLeg;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.chint.domain.aggregates.approval;
|
||||
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Table("approval_record_order")
|
||||
public class ApprovalRecordOrder implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 8651937409123544654L;
|
||||
@Id
|
||||
private Long id;
|
||||
private Long ApprovalRecordId;
|
||||
private Long orderId;
|
||||
@Transient
|
||||
private OrderDetail orderDetail;
|
||||
|
||||
public static ApprovalRecordOrder of(OrderDetail orderDetail) {
|
||||
ApprovalRecordOrder approvalRecordOrder = of(orderDetail.getOrderId());
|
||||
approvalRecordOrder.setOrderDetail(orderDetail);
|
||||
return approvalRecordOrder;
|
||||
}
|
||||
|
||||
public static ApprovalRecordOrder of(Long orderId) {
|
||||
ApprovalRecordOrder approvalRecordOrder = new ApprovalRecordOrder();
|
||||
approvalRecordOrder.setOrderId(orderId);
|
||||
return approvalRecordOrder;
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ public class LegApprovalEvent extends BaseEvent implements Serializable {
|
|||
LEG_APPROVAL_STATUS_PREPARE, LEG_APPROVAL_STATUS_PREPARE_NAME,
|
||||
LEG_APPROVAL_STATUS_SUBMIT, LEG_APPROVAL_STATUS_SUBMIT_NAME,
|
||||
LEG_APPROVAL_STATUS_SUCCESS, LEG_APPROVAL_STATUS_SUCCESS_NAME,
|
||||
LEG_APPROVAL_STATUS_NOTIFY, LEG_APPROVAL_STATUS_NOTIFY_NAME,
|
||||
LEG_APPROVAL_STATUS_REJECT, LEG_APPROVAL_STATUS_REJECT_NAME);
|
||||
}
|
||||
|
||||
|
@ -70,4 +71,17 @@ public class LegApprovalEvent extends BaseEvent implements Serializable {
|
|||
event.setEventType(LEG_APPROVAL_STATUS_REJECT);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static LegApprovalEvent notifyEvent() {
|
||||
LegApprovalEvent event = new LegApprovalEvent();
|
||||
event.setEventType(LEG_APPROVAL_STATUS_NOTIFY);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static LegApprovalEvent notifyEvent(String extension) {
|
||||
LegApprovalEvent event = new LegApprovalEvent();
|
||||
event.setEventType(LEG_APPROVAL_STATUS_NOTIFY);
|
||||
event.setExtension(extension);
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.chint.domain.aggregates.order;
|
|||
|
||||
import com.chint.application.commands.LegOrderedCommand;
|
||||
import com.chint.domain.aggregates.approval.ApprovalRecord;
|
||||
import com.chint.domain.aggregates.base.PermissionConfig;
|
||||
import com.chint.domain.factoriy.leg.LegFactory;
|
||||
import com.chint.domain.service.LegDomainService;
|
||||
import com.chint.domain.service.amount_estimate.EstimateAdapter;
|
||||
|
@ -82,6 +83,8 @@ public class RouteOrder implements Serializable {
|
|||
private String supplierCNName;
|
||||
@Transient
|
||||
private Set<RoutePermission> routePermissionSet;
|
||||
@Transient
|
||||
private Set<PermissionConfig> permissionConfigSet;
|
||||
|
||||
//共有的扩展字段
|
||||
@MappedCollection(idColumn = "route_id")
|
||||
|
|
|
@ -68,6 +68,7 @@ public class RouteApprovalDomainService {
|
|||
List<Leg> legItems = routeOrder.getLegItems();
|
||||
legDomainService.queryLocation(legItems);
|
||||
String approvalPlatformMark = getApprovalPlatformMark(routeOrder);
|
||||
checkApprovalPermissions(List.of(routeOrder));
|
||||
ApprovalProcess approvalProcess = ApprovalSubmit.of(LEG_ADD_CHANGE_BATCH, approvalPlatformMark)
|
||||
.approveData(routeOrder);
|
||||
checkApprovalData(approvalProcess.getApprovalData());
|
||||
|
@ -103,6 +104,7 @@ public class RouteApprovalDomainService {
|
|||
legDomainService.checkLocation(allLegs);
|
||||
}
|
||||
|
||||
|
||||
public List<RouteOrder> checkApprovalPermissions(List<RouteOrder> routeOrderList) {
|
||||
// 提取所有 approveOrderNo 和 sysCode
|
||||
Set<String> accountCompanyCodes = routeOrderList.stream()
|
||||
|
@ -129,16 +131,23 @@ public class RouteApprovalDomainService {
|
|||
|
||||
// 获取所有审批类型
|
||||
Set<String> approvalTypes = routeOrderList.stream()
|
||||
.map(routeOrder -> {
|
||||
.flatMap(routeOrder -> {
|
||||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||
String accountCompany = approveOrderNo.getAccountCompany();
|
||||
return accountCompanyToApprovalType.getOrDefault(accountCompany, sysCodeToApprovalType.get(approveOrderNo.getSysCode()));
|
||||
String orDefault = accountCompanyToApprovalType.getOrDefault(accountCompany, sysCodeToApprovalType.get(approveOrderNo.getSysCode()));
|
||||
if (orDefault != null && !orDefault.isEmpty()) {
|
||||
return Arrays.stream(orDefault.split("&"));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<PermissionConfig> byPermissionNameIn = permissionConfigRepository
|
||||
.findByPermissionNameIn(approvalTypes);
|
||||
// 批量查询 permissionConfigRepository
|
||||
Map<String, List<String>> approvalTypeToPermissions = permissionConfigRepository
|
||||
.findByPermissionNameIn(approvalTypes)
|
||||
Map<String, List<String>> approvalTypeToPermissions = byPermissionNameIn
|
||||
.stream()
|
||||
.collect(Collectors.toMap(PermissionConfig::getPermissionName, PermissionConfig::permissions));
|
||||
|
||||
|
@ -157,6 +166,14 @@ public class RouteApprovalDomainService {
|
|||
Set<RoutePermission> routePermissionSet = approvalTypeToPermissionSet
|
||||
.getOrDefault(approvalType, Collections.emptySet());
|
||||
routeOrder.setRoutePermissionSet(routePermissionSet);
|
||||
|
||||
if (approvalType != null && !approvalType.isEmpty()) {
|
||||
List<String> list = Arrays.stream(approvalType.split("&")).distinct().toList();
|
||||
routeOrder.setPermissionConfigSet(byPermissionNameIn
|
||||
.stream()
|
||||
.filter(it -> list.contains(it.getPermissionName()))
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
return routeOrderList;
|
||||
}
|
||||
|
@ -165,7 +182,8 @@ public class RouteApprovalDomainService {
|
|||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||
String approvalType = findApprovalType(approveOrderNo);
|
||||
if (approvalType != null) {
|
||||
Set<RoutePermission> permissions = findRoutePermissions(approvalType);
|
||||
Set<String> approvalTypeSet = Arrays.stream(approvalType.split("&")).collect(Collectors.toSet());
|
||||
Set<RoutePermission> permissions = findRoutePermissions(approvalTypeSet);
|
||||
routeOrder.setRoutePermissionSet(permissions);
|
||||
} else {
|
||||
routeOrder.setRoutePermissionSet(Collections.emptySet());
|
||||
|
@ -179,13 +197,13 @@ public class RouteApprovalDomainService {
|
|||
.orElseGet(() -> systemCodeRepository.findBySysCode(approveOrderNo.getSysCode()).getApprovalType());
|
||||
}
|
||||
|
||||
private Set<RoutePermission> findRoutePermissions(String approvalType) {
|
||||
return permissionConfigRepository.findByPermissionName(approvalType)
|
||||
.map(permissionConfig -> permissionConfig.permissions().stream()
|
||||
private Set<RoutePermission> findRoutePermissions(Set<String> approvalTypeSet) {
|
||||
return permissionConfigRepository.findByPermissionNameIn(approvalTypeSet)
|
||||
.stream()
|
||||
.flatMap(permissionConfig -> permissionConfig.permissions().stream()
|
||||
.distinct()
|
||||
.map(permission -> Enum.valueOf(RoutePermission.class, permission))
|
||||
.collect(Collectors.toSet()))
|
||||
.orElseGet(Collections::emptySet);
|
||||
.map(permission -> Enum.valueOf(RoutePermission.class, permission)))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package com.chint.domain.value_object.enums;
|
||||
|
||||
public enum RoutePermission {
|
||||
APPROVAL_BUTTON
|
||||
APPROVAL_BUTTON, LEG_NEED_APPROVAL, LEG_NEED_NOTIFY
|
||||
}
|
||||
|
|
|
@ -167,18 +167,18 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos
|
|||
|
||||
@Override
|
||||
public Optional<SystemOrganization> findByOrgCodeContainingOrOrgNameContaining(String orgCode, String orgName) {
|
||||
return Stream.of(
|
||||
return Optional.ofNullable(cacheSystemOrganizationRepository.cacheOrgCodeById(orgCode, null))
|
||||
.flatMap(id -> Optional.ofNullable(cacheSystemOrganizationRepository.cacheById(id, null)))
|
||||
.or(() -> Stream.of(
|
||||
jdbcSystemOrganizationRepository.findByOrgCode(orgCode).stream().findFirst(),
|
||||
jdbcSystemOrganizationRepository.findByOrgName(orgName).stream().findFirst()
|
||||
)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.findFirst();
|
||||
.findFirst());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> queryOrgCodeListByUserId(Long userId) {
|
||||
return jdbcSystemOrganizationRepository.queryOrgCodeListByUserId(userId);
|
||||
|
|
|
@ -26,11 +26,17 @@ public class CacheSystemOrganizationRepository {
|
|||
return Objects.requireNonNullElseGet(systemOrganizationList, List::of);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(value = "SystemOrganization", key = "#systemOrganization.id")
|
||||
public SystemOrganization cache(SystemOrganization systemOrganization) {
|
||||
return systemOrganization;
|
||||
}
|
||||
|
||||
@Cacheable(value = "SystemOrganization", key = "#id")
|
||||
public SystemOrganization cacheById(Long id, SystemOrganization systemOrganization) {
|
||||
return systemOrganization;
|
||||
}
|
||||
|
||||
@CacheEvict(value = "SystemOrganization", key = "#systemOrganization.id")
|
||||
public void cacheEvict(SystemOrganization systemOrganization) {
|
||||
}
|
||||
|
|
|
@ -821,7 +821,7 @@ public class LYTest {
|
|||
|
||||
@Test
|
||||
void searchTrain() {
|
||||
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24060375930947862");
|
||||
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24062077869838419");
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(trainOrderDetail);
|
||||
System.out.println(json);
|
||||
|
|
Loading…
Reference in New Issue