diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index 5cb02b7c..8c2c5361 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -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,9 +150,11 @@ 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)) { //这里加入一个待审批事件, 变更加入旧行程数据, 用于回滚还原 - leg.addEvent(LegApprovalEvent.prepare(oldLeg)); + if (checkIfNeedApprove(routeOrder)) { + leg.addEvent(LegApprovalEvent.prepare(oldLeg)); + } } if (!routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE) && !approveOrderNo.getSysCode().equals("ANFSSC")) { sendLegChangeCommand(oldLeg, leg, @@ -160,6 +169,18 @@ public class OrderApplicationService { Command.of(RouteAutoSyncCommand.class).route(routeOrder).async().sendToQueue(); } + private boolean checkIfNeedApprove(RouteOrder routeOrder) { + Set 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,11 +203,12 @@ 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 ) { //这里加入一个待审批事件 - leg.addEvent(LegApprovalEvent.prepare()); + if (checkIfNeedApprove(routeOrder)) { + leg.addEvent(LegApprovalEvent.prepare()); + } } if (!routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE) && !approveOrderNo.getSysCode().equals("ANFSSC")) { @@ -216,7 +238,6 @@ public class OrderApplicationService { .sendToQueue(); } - private List processLegData(LegData legData, RouteOrder order) { if (legData.getCurrencyType() == null) { legData.setCurrencyType(CurrencyType.RENMINBI.getCode()); diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java index 199a05b0..1c2c7b8d 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java @@ -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; @@ -72,7 +73,7 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess { private boolean isExtensionNotNullOrEmpty(Leg leg) { Optional lastApprovalPrepareEvent = leg.getLastApprovalPrepareEvent(); - if(lastApprovalPrepareEvent.isEmpty()){ + if (lastApprovalPrepareEvent.isEmpty()) { return false; } String extension = lastApprovalPrepareEvent.get().getExtension(); @@ -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(); diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java index 0e53a266..104820f0 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java @@ -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; } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecord.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecord.java index e3e5d203..631b20ed 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecord.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecord.java @@ -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 ApprovalRecordLegList; + + @MappedCollection(idColumn = "approval_record_id", keyColumn = "approval_record_key") + private List 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; diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecordLeg.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecordLeg.java new file mode 100644 index 00000000..17fcf13c --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecordLeg.java @@ -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; + } +} diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecordOrder.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecordOrder.java new file mode 100644 index 00000000..3b200506 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecordOrder.java @@ -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; + } +} diff --git a/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java b/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java index f6df2f14..39514b88 100644 --- a/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java @@ -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; + } } diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index a3f64144..8cdf4cd8 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -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 routePermissionSet; + @Transient + private Set permissionConfigSet; //共有的扩展字段 @MappedCollection(idColumn = "route_id") diff --git a/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java b/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java index d8dda049..855a372b 100644 --- a/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java +++ b/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java @@ -68,6 +68,7 @@ public class RouteApprovalDomainService { List 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 checkApprovalPermissions(List routeOrderList) { // 提取所有 approveOrderNo 和 sysCode Set accountCompanyCodes = routeOrderList.stream() @@ -129,16 +131,23 @@ public class RouteApprovalDomainService { // 获取所有审批类型 Set 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 byPermissionNameIn = permissionConfigRepository + .findByPermissionNameIn(approvalTypes); // 批量查询 permissionConfigRepository - Map> approvalTypeToPermissions = permissionConfigRepository - .findByPermissionNameIn(approvalTypes) + Map> approvalTypeToPermissions = byPermissionNameIn .stream() .collect(Collectors.toMap(PermissionConfig::getPermissionName, PermissionConfig::permissions)); @@ -157,6 +166,14 @@ public class RouteApprovalDomainService { Set routePermissionSet = approvalTypeToPermissionSet .getOrDefault(approvalType, Collections.emptySet()); routeOrder.setRoutePermissionSet(routePermissionSet); + + if (approvalType != null && !approvalType.isEmpty()) { + List 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 permissions = findRoutePermissions(approvalType); + Set approvalTypeSet = Arrays.stream(approvalType.split("&")).collect(Collectors.toSet()); + Set 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 findRoutePermissions(String approvalType) { - return permissionConfigRepository.findByPermissionName(approvalType) - .map(permissionConfig -> permissionConfig.permissions().stream() + private Set findRoutePermissions(Set 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()); } diff --git a/src/main/java/com/chint/domain/value_object/enums/RoutePermission.java b/src/main/java/com/chint/domain/value_object/enums/RoutePermission.java index fcec9b06..5188c382 100644 --- a/src/main/java/com/chint/domain/value_object/enums/RoutePermission.java +++ b/src/main/java/com/chint/domain/value_object/enums/RoutePermission.java @@ -1,5 +1,5 @@ package com.chint.domain.value_object.enums; public enum RoutePermission { - APPROVAL_BUTTON + APPROVAL_BUTTON, LEG_NEED_APPROVAL, LEG_NEED_NOTIFY } diff --git a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java index 8ad20561..38170168 100644 --- a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java @@ -167,18 +167,18 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos @Override public Optional findByOrgCodeContainingOrOrgNameContaining(String orgCode, String orgName) { - return Stream.of( - jdbcSystemOrganizationRepository.findByOrgCode(orgCode).stream().findFirst(), - jdbcSystemOrganizationRepository.findByOrgName(orgName).stream().findFirst() - ) - .filter(Optional::isPresent) - .map(Optional::get) - .findFirst(); + 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()); } - - @Override public List queryOrgCodeListByUserId(Long userId) { return jdbcSystemOrganizationRepository.queryOrgCodeListByUserId(userId); diff --git a/src/main/java/com/chint/infrastructure/repository/cache/CacheSystemOrganizationRepository.java b/src/main/java/com/chint/infrastructure/repository/cache/CacheSystemOrganizationRepository.java index f70ac86f..5b7564e0 100644 --- a/src/main/java/com/chint/infrastructure/repository/cache/CacheSystemOrganizationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/cache/CacheSystemOrganizationRepository.java @@ -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) { } diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 04d9219a..9047bb0c 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -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);