From eaa76fbce32617ece51e97d161c812f960151d00 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Tue, 2 Jul 2024 10:56:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=A1=E6=89=B9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E9=87=8D=E6=9E=84-=E5=AE=89=E8=83=BD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=A1=8C=E7=A8=8B=E5=92=8C=E5=8F=98=E6=9B=B4=E8=A1=8C=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dtos/LegApprovalParam.java | 1 + .../application/dtos/response/LegRes.java | 7 +- .../dtos/response/RouteOrderPageRes.java | 3 + .../dtos/response/RouteOrderRes.java | 3 + .../chint/application/in/OrderController.java | 21 ++- .../application/in/OrderPublicController.java | 17 ++- .../application/out/OrderOutController.java | 6 +- .../application/queryies/OrderQuery.java | 5 + .../aggregates/approval/ApprovalData.java | 1 + .../aggregates/approval/ApprovalLegAdd.java | 11 +- .../ApprovalLegAddAndChangeBatch.java | 33 ++++- .../approval/ApprovalLegChange.java | 12 +- .../approval/ApprovalOrderChange.java | 11 +- .../approval/ApprovalOrderExpense.java | 11 +- .../approval/ApprovalOrderRefund.java | 13 +- .../aggregates/approval/ApprovalProcess.java | 73 ++++++++--- .../aggregates/approval/ApprovalRecord.java | 53 +++++++- .../approval/ApprovalResultData.java | 12 ++ .../aggregates/approval/ApprovalSubmit.java | 24 +++- .../aggregates/approval/ApprovalType.java | 10 ++ .../approval/platform/ApprovalPlatform.java | 16 ++- .../approval/platform/ApprovalPlatformAN.java | 6 +- .../approval/platform/ApprovalRecordBase.java | 8 ++ .../platform/ApprovalResultReceiver.java | 5 + .../aggregates/base/EventManageable.java | 6 +- .../aggregates/base/PermissionConfig.java | 39 ++++++ .../chint/domain/aggregates/order/Leg.java | 19 +++ .../aggregates/order/LegApprovalEvent.java | 5 +- .../domain/aggregates/order/RouteOrder.java | 3 + .../domain/aggregates/system/SystemCode.java | 15 ++- .../system/SystemCodeExtensionField.java | 2 - .../repository/ApprovalRecordRepository.java | 10 ++ .../PermissionConfigRepository.java | 13 ++ .../repository/SystemCodeRepository.java | 5 + .../domain/service/LegDomainService.java | 2 +- .../service/RouteApprovalDomainService.java | 122 ++++++++++++++++-- .../service/order_sync/SupplierOrderSync.java | 2 + .../value_object/enums/RoutePermission.java | 5 + .../ApprovalRecordRepositoryImpl.java | 28 ++++ .../PermissionConfigRepositoryImpl.java | 31 +++++ .../repository/RoleRepositoryImpl.java | 3 + .../repository/SystemCodeRepositoryImpl.java | 9 ++ .../jdbc/JdbcApprovalRecordRepository.java | 12 ++ .../jdbc/JdbcPermissionConfigRepository.java | 15 +++ .../jdbc/JdbcSystemCodeRepository.java | 7 +- .../infrastructure/util/DateTimeUtil.java | 5 + .../com/chint/infrastructure/util/Json.java | 6 +- .../chint/infrastructure/util/OrderNo.java | 27 ++-- src/test/java/com/chint/LYTest.java | 4 +- .../java/com/chint/RouteApplicationTests.java | 51 +++++++- 50 files changed, 696 insertions(+), 112 deletions(-) create mode 100644 src/main/java/com/chint/domain/aggregates/approval/ApprovalResultData.java create mode 100644 src/main/java/com/chint/domain/aggregates/approval/ApprovalType.java create mode 100644 src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalRecordBase.java create mode 100644 src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalResultReceiver.java create mode 100644 src/main/java/com/chint/domain/aggregates/base/PermissionConfig.java create mode 100644 src/main/java/com/chint/domain/repository/ApprovalRecordRepository.java create mode 100644 src/main/java/com/chint/domain/repository/PermissionConfigRepository.java create mode 100644 src/main/java/com/chint/domain/value_object/enums/RoutePermission.java create mode 100644 src/main/java/com/chint/infrastructure/repository/ApprovalRecordRepositoryImpl.java create mode 100644 src/main/java/com/chint/infrastructure/repository/PermissionConfigRepositoryImpl.java create mode 100644 src/main/java/com/chint/infrastructure/repository/jdbc/JdbcApprovalRecordRepository.java create mode 100644 src/main/java/com/chint/infrastructure/repository/jdbc/JdbcPermissionConfigRepository.java diff --git a/src/main/java/com/chint/application/dtos/LegApprovalParam.java b/src/main/java/com/chint/application/dtos/LegApprovalParam.java index db6c7b3b..5512f7ba 100644 --- a/src/main/java/com/chint/application/dtos/LegApprovalParam.java +++ b/src/main/java/com/chint/application/dtos/LegApprovalParam.java @@ -5,5 +5,6 @@ import lombok.Data; @Data public class LegApprovalParam { private Long routeId; + private String approvalReason; private String extension; } diff --git a/src/main/java/com/chint/application/dtos/response/LegRes.java b/src/main/java/com/chint/application/dtos/response/LegRes.java index 4b3369db..f35172fb 100644 --- a/src/main/java/com/chint/application/dtos/response/LegRes.java +++ b/src/main/java/com/chint/application/dtos/response/LegRes.java @@ -9,6 +9,7 @@ import com.chint.domain.aggregates.order.OrderDetail; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.data.annotation.Id; +import org.springframework.data.annotation.Transient; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -44,11 +45,11 @@ public class LegRes { private String destinationDescription; private List supplierList; private List supplierNameList; - private Integer legStatus; private String changeReason; - + private Integer legStatus; private String legStatusName; - + private Integer legApprovalStatus; + private String legApprovalStatusName; private String currencyType; private List otherLocationList; diff --git a/src/main/java/com/chint/application/dtos/response/RouteOrderPageRes.java b/src/main/java/com/chint/application/dtos/response/RouteOrderPageRes.java index 86cde824..4de27e02 100644 --- a/src/main/java/com/chint/application/dtos/response/RouteOrderPageRes.java +++ b/src/main/java/com/chint/application/dtos/response/RouteOrderPageRes.java @@ -2,6 +2,7 @@ package com.chint.application.dtos.response; import com.chint.domain.aggregates.order.ApproveOrderNo; +import com.chint.domain.value_object.enums.RoutePermission; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -11,6 +12,7 @@ import org.springframework.data.relational.core.mapping.Embedded; import java.time.LocalDateTime; import java.util.List; +import java.util.Set; @Data public class RouteOrderPageRes { @@ -48,4 +50,5 @@ public class RouteOrderPageRes { private String ifHaveCarLeg; @ApiModelProperty("是否能被确认结束, 0不能,1能") private String ifCanBeFinished; + private Set routePermissionSet; } diff --git a/src/main/java/com/chint/application/dtos/response/RouteOrderRes.java b/src/main/java/com/chint/application/dtos/response/RouteOrderRes.java index dac7e5ea..1d4814c0 100644 --- a/src/main/java/com/chint/application/dtos/response/RouteOrderRes.java +++ b/src/main/java/com/chint/application/dtos/response/RouteOrderRes.java @@ -3,6 +3,7 @@ package com.chint.application.dtos.response; import cn.hutool.core.bean.BeanUtil; import com.chint.domain.aggregates.order.ApproveOrderNo; import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.value_object.enums.RoutePermission; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -13,6 +14,7 @@ import org.springframework.data.relational.core.mapping.Embedded; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Set; import static com.chint.infrastructure.constant.RouteConstant.CAN_BE_FINISHED; import static com.chint.infrastructure.constant.RouteConstant.CAN_NOT_BE_FINISHED; @@ -52,6 +54,7 @@ public class RouteOrderRes { private List orderDetailRes; @ApiModelProperty("是否能被确认结束, 0不能,1能") private String ifCanBeFinished; + private Set routePermissionSet; public static RouteOrderRes copyFrom(RouteOrder routeOrder) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); diff --git a/src/main/java/com/chint/application/in/OrderController.java b/src/main/java/com/chint/application/in/OrderController.java index 3944499c..924cca21 100644 --- a/src/main/java/com/chint/application/in/OrderController.java +++ b/src/main/java/com/chint/application/in/OrderController.java @@ -1,13 +1,12 @@ package com.chint.application.in; -import com.chint.application.dtos.AddLegData; -import com.chint.application.dtos.DeleteLegData; -import com.chint.application.dtos.FinishOrderParam; +import com.chint.application.dtos.*; import com.chint.application.queryies.OrderQuery; import com.chint.application.services.OrderApplicationService; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.service.OrderDetailDomainService; import com.chint.domain.service.OrderDomainService; +import com.chint.domain.service.RouteApprovalDomainService; import com.chint.domain.service.RouteRequestDomainService; import com.chint.domain.value_object.OrderSaveData; import com.chint.domain.value_object.SyncLegData; @@ -42,6 +41,9 @@ public class OrderController { @Autowired private RouteRequestDomainService routeRequestDomainService; + @Autowired + private RouteApprovalDomainService routeApprovalDomainService; + @ApiOperation("保存行程规划单") @PostMapping("/save") @@ -62,12 +64,11 @@ public class OrderController { @ApiOperation("取消已同步的行程规划单") @PostMapping("/sync/cancel") - public Result syncOrderCancel(@RequestBody SyncLegData syncLegData) { + public Result approvalLegChangeAndAdd(@RequestBody SyncLegData syncLegData) { orderApplicationService.syncCancel(syncLegData); return Result.Success(SUCCESS); } - @ApiOperation("批量同步行程规划单到供应商") @PostMapping("/sync/batch") public Result syncOrderBatch(@RequestBody SyncLegData syncLegData) { @@ -96,7 +97,7 @@ public class OrderController { return Result.Success(SUCCESS); } - @Transactional + @ApiOperation("修改行程节点") @PostMapping("/leg/change") public Result changeLeg(@RequestBody AddLegData addLegData) { @@ -105,7 +106,6 @@ public class OrderController { } - @ApiOperation("删除行程节点") @PostMapping("/leg/delete") public Result deleteLeg(@RequestBody DeleteLegData deleteLegData) { @@ -135,4 +135,11 @@ public class OrderController { return Result.error(FAILURE); } } + + @ApiOperation("行程规划单——行程变更新增批量提交审批") + @PostMapping("/approval/legs") + public Result approvalLegChangeAndAdd(@RequestBody LegApprovalParam legApprovalParam) { + routeApprovalDomainService.approveRouteOfLegChangeAndAdd(legApprovalParam); + return Result.Success(SUCCESS); + } } diff --git a/src/main/java/com/chint/application/in/OrderPublicController.java b/src/main/java/com/chint/application/in/OrderPublicController.java index b2c353e8..1b274ac2 100644 --- a/src/main/java/com/chint/application/in/OrderPublicController.java +++ b/src/main/java/com/chint/application/in/OrderPublicController.java @@ -4,10 +4,12 @@ import com.chint.application.dtos.DeleteLegData; import com.chint.application.dtos.LegApprovalParam; import com.chint.application.queryies.OrderQuery; import com.chint.application.services.OrderApplicationService; +import com.chint.domain.aggregates.approval.ApprovalResultData; import com.chint.domain.aggregates.order.RouteOrder; 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.SystemDomainService; import com.chint.domain.value_object.ApproveCustomField; import com.chint.domain.value_object.ApproveRouteData; @@ -44,6 +46,8 @@ public class OrderPublicController { @Autowired private RouteRepository routeRepository; + @Autowired + private RouteApprovalDomainService routeApprovalDomainService; @ApiOperation("提交审批行程规划单") @PostMapping("/approve") @@ -54,12 +58,7 @@ public class OrderPublicController { return Result.Success(SUCCESS); } - @ApiOperation("提交需要审批的行程节点") - @PostMapping("/approve/leg") - public Result approveOrder(@RequestBody LegApprovalParam param) { - return Result.Success(SUCCESS); - } @ApiOperation("审批拒绝行程规划单") @@ -105,4 +104,12 @@ public class OrderPublicController { .toList(); return Result.Success(SUCCESS, approveCustomFieldList); } + + + @ApiOperation("提交需要审批的行程节点") + @PostMapping("/approve/response") + public Result approveOrder(@RequestBody ApprovalResultData data) { + routeApprovalDomainService.handlerApprovalResponse(data); + return Result.Success(SUCCESS); + } } diff --git a/src/main/java/com/chint/application/out/OrderOutController.java b/src/main/java/com/chint/application/out/OrderOutController.java index 6855982b..5e2c6c7d 100644 --- a/src/main/java/com/chint/application/out/OrderOutController.java +++ b/src/main/java/com/chint/application/out/OrderOutController.java @@ -55,8 +55,8 @@ public class OrderOutController { @Autowired private RouteRepository routeRepository; -// @Autowired -// private RouteApprovalDomainService routeApprovalDomainService; + @Autowired + private RouteApprovalDomainService routeApprovalDomainService; @ApiOperation("根据临时单号和系统编码查询订单") @PostMapping("/query/billcode") @@ -90,7 +90,7 @@ public class OrderOutController { routeOrder = routeOrderFromDB; } if (routeOrder != null) { -// routeApprovalDomainService.checkApprovalPermissions(routeOrder); + routeApprovalDomainService.checkApprovalPermissions(routeOrder); RouteOrderRes routeOrderRes = orderQuery.queryRouteRes(routeOrder); return Result.Success(SUCCESS, routeOrderRes); } else { diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 9eb9f4fd..5e9dc419 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -18,6 +18,7 @@ import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.*; import com.chint.domain.service.LegDomainService; import com.chint.domain.service.OrderDomainService; +import com.chint.domain.service.RouteApprovalDomainService; import com.chint.domain.service.amount_estimate.EstimateAdapter; import com.chint.domain.value_object.*; import com.chint.infrastructure.cache.RouteCacheService; @@ -93,6 +94,9 @@ public class OrderQuery { @Autowired private SupplierRepository supplierRepository; + @Autowired + private RouteApprovalDomainService routeApprovalDomainService; + public RouteOrder queryByOrderId(OrderQueryData queryData) { return routeRepository.queryById(queryData.getRouteId()).reloadStatus(); } @@ -154,6 +158,7 @@ public class OrderQuery { ); int total = routeOrders.size(); + routeApprovalDomainService.checkApprovalPermissions(routeOrders); List orders = routeOrders .stream() .sorted(statusComparator.thenComparing(RouteOrder::getUpdateTime).reversed()) diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalData.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalData.java index 9ba9adbd..a777bf48 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalData.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalData.java @@ -17,4 +17,5 @@ public class ApprovalData { private List addLegList; private List> changeLegList; private OrderDetail orderDetail; + private String approvalRecordNo; } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAdd.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAdd.java index e9c7c70a..bb92be80 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAdd.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAdd.java @@ -4,7 +4,8 @@ import com.chint.domain.aggregates.approval.platform.ApprovalPlatform; import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.RouteOrder; -import static com.chint.domain.aggregates.approval.ApprovalProcess.ApprovalType.LEG_ADD; +import static com.chint.domain.aggregates.approval.ApprovalType.LEG_ADD; + public class ApprovalLegAdd extends ApprovalProcess { @@ -34,7 +35,13 @@ public class ApprovalLegAdd extends ApprovalProcess { } @Override - public void submitToBpm() { + public ApprovalProcess doSubmitToBpm() { bpmPlatform.submitLegAddApproval(approvalData); + return this; + } + + @Override + public void handlerApprovalResultBefore(ApprovalResultData data) { + } } 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 943542a0..60731e69 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegAddAndChangeBatch.java @@ -1,18 +1,21 @@ package com.chint.domain.aggregates.approval; import com.chint.domain.aggregates.approval.platform.ApprovalPlatform; +import com.chint.domain.aggregates.base.BaseEvent; import com.chint.domain.aggregates.order.Leg; -import com.chint.domain.aggregates.order.OrderDetail; +import com.chint.domain.aggregates.order.LegApprovalEvent; import com.chint.domain.aggregates.order.RouteOrder; import com.google.gson.Gson; import org.springframework.data.util.Pair; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import static com.chint.domain.aggregates.approval.ApprovalProcess.ApprovalType.LEG_ADD_CHANGE_BATCH; +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; public class ApprovalLegAddAndChangeBatch extends ApprovalProcess { @@ -55,7 +58,31 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess { } @Override - public void submitToBpm() { + public ApprovalProcess doSubmitToBpm() { bpmPlatform.submitLegAddOrChangeApproval(approvalData); + return this; + } + + @Override + public void handlerApprovalResultBefore(ApprovalResultData data) { + String approvalRecordNo = data.getApprovalRecordNo(); + RouteOrder routeOrder = data.getRouteOrder(); + routeOrder.getLegItems().stream() + .filter(leg -> { + BaseEvent lastEvent = leg.getLastEvent(); + return lastEvent.getEventType().equals(LEG_APPROVAL_STATUS_SUBMIT) && + lastEvent.getExtension().equals(approvalRecordNo); + }).forEach(leg -> { + if (data.getApprovalStatus().equals(ApprovalRecord.successApprovalStatus())) { + leg.addEvent(LegApprovalEvent.success()); + } else { + leg.addEvent(LegApprovalEvent.reject());//如果行程被驳回 ,那么就要回滚到审批前的状态 + leg.getLegApprovalEventList() + .stream() + .filter(legApprovalEvent -> legApprovalEvent.getEventType().equals(LEG_APPROVAL_STATUS_PREPARE)) + .max(Comparator.comparing(LegApprovalEvent::getHappenTime)) + .ifPresent(it -> leg.restoreFromLegString(it.getExtension())); + } + }); } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegChange.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegChange.java index 3869a171..26ffd5a7 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegChange.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalLegChange.java @@ -4,8 +4,8 @@ package com.chint.domain.aggregates.approval; import com.chint.domain.aggregates.approval.platform.ApprovalPlatform; import com.chint.domain.aggregates.order.RouteOrder; -import static com.chint.domain.aggregates.approval.ApprovalProcess.ApprovalType.LEG_ADD; -import static com.chint.domain.aggregates.approval.ApprovalProcess.ApprovalType.LEG_CHANGE; +import static com.chint.domain.aggregates.approval.ApprovalType.LEG_CHANGE; + public class ApprovalLegChange extends ApprovalProcess{ @@ -30,7 +30,13 @@ public class ApprovalLegChange extends ApprovalProcess{ } @Override - public void submitToBpm() { + public ApprovalProcess doSubmitToBpm() { bpmPlatform.submitLegChangeApproval(approvalData); + return this; + } + + @Override + public void handlerApprovalResultBefore(ApprovalResultData data) { + } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderChange.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderChange.java index b36bb5b7..566093cc 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderChange.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderChange.java @@ -3,7 +3,8 @@ package com.chint.domain.aggregates.approval; import com.chint.domain.aggregates.approval.platform.ApprovalPlatform; import com.chint.domain.aggregates.order.RouteOrder; -import static com.chint.domain.aggregates.approval.ApprovalProcess.ApprovalType.LEG_CHANGE; +import static com.chint.domain.aggregates.approval.ApprovalType.LEG_CHANGE; + public class ApprovalOrderChange extends ApprovalProcess{ @@ -28,7 +29,13 @@ public class ApprovalOrderChange extends ApprovalProcess{ } @Override - public void submitToBpm() { + public ApprovalProcess doSubmitToBpm() { bpmPlatform.submitOrderChangeApproval(approvalData); + return this; + } + + @Override + public void handlerApprovalResultBefore(ApprovalResultData data) { + } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderExpense.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderExpense.java index 0a17a309..4a4721be 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderExpense.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderExpense.java @@ -3,7 +3,8 @@ package com.chint.domain.aggregates.approval; import com.chint.domain.aggregates.approval.platform.ApprovalPlatform; import com.chint.domain.aggregates.order.RouteOrder; -import static com.chint.domain.aggregates.approval.ApprovalProcess.ApprovalType.ORDER_EXPENSE; +import static com.chint.domain.aggregates.approval.ApprovalType.ORDER_EXPENSE; + public class ApprovalOrderExpense extends ApprovalProcess{ @@ -28,8 +29,14 @@ public class ApprovalOrderExpense extends ApprovalProcess{ } @Override - public void submitToBpm() { + public ApprovalProcess doSubmitToBpm() { bpmPlatform.submitOrderExpenseApproval(approvalData); + return this; + } + + @Override + public void handlerApprovalResultBefore(ApprovalResultData data) { + } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderRefund.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderRefund.java index 1c045b41..7ff8d3c9 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderRefund.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalOrderRefund.java @@ -3,9 +3,10 @@ package com.chint.domain.aggregates.approval; import com.chint.domain.aggregates.approval.platform.ApprovalPlatform; import com.chint.domain.aggregates.order.RouteOrder; -import static com.chint.domain.aggregates.approval.ApprovalProcess.ApprovalType.ORDER_REFUND; +import static com.chint.domain.aggregates.approval.ApprovalType.ORDER_REFUND; -public class ApprovalOrderRefund extends ApprovalProcess{ + +public class ApprovalOrderRefund extends ApprovalProcess { public ApprovalOrderRefund(ApprovalPlatform bpmPlatform) { super(bpmPlatform); @@ -28,8 +29,14 @@ public class ApprovalOrderRefund extends ApprovalProcess{ } @Override - public void submitToBpm() { + public ApprovalProcess doSubmitToBpm() { bpmPlatform.submitOrderRefundApproval(approvalData); + return this; + } + + @Override + public void handlerApprovalResultBefore(ApprovalResultData data) { + } } 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 0851411b..c85e19aa 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalProcess.java @@ -1,11 +1,17 @@ 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 lombok.Data; + +import java.util.function.Consumer; // 定义抽象类 ApprovalProcess +@Data public abstract class ApprovalProcess { protected ApprovalPlatform bpmPlatform; @@ -20,9 +26,11 @@ public abstract class ApprovalProcess { public ApprovalProcess approveData(RouteOrder routeOrder) { approvalData = new ApprovalData(); + approvalData.setRouteOrder(routeOrder); return this; } + public ApprovalProcess approveData(RouteOrder routeOrder, OrderDetail orderDetail) { ApprovalData approvalData = new ApprovalData(); approvalData.setRouteOrder(routeOrder); @@ -32,31 +40,66 @@ public abstract class ApprovalProcess { } // 审批流程的抽象方法 - public abstract boolean approve(); + public boolean approve() { + + + return false; + } + + + // 记录动作,将审批记录保存到数据库 + public ApprovalProcess record(Consumer consumer) { + RouteOrder routeOrder = approvalData.getRouteOrder(); + if (routeOrder != null) { + ApprovalRecord approvalRecord = ApprovalRecord.of(routeOrder, this); + approvalData.setApprovalRecordNo(approvalRecord.getApprovalRecordNo()); + consumer.accept(approvalRecord); // 使用传入的Consumer对象 + return this; + } else { + return null; + } + } + // 退回流程的抽象方法 - public abstract void reject(); + public void reject() { + + } + + // 退回流程的抽象方法 + public void success() { + + } // 通用的通知方法 public void notifyUser(String message) { - // 发送通知的逻辑 + // 发送通知的逻辑 System.out.println("Notify user: " + message); } // 提交审批到BPM平台的抽象方法 - public abstract void submitToBpm(); + public abstract ApprovalProcess doSubmitToBpm(); + + public ApprovalProcess beforeSubmitToBpm() { + //所有被提交审批的被加入审批事件 + approvalData.getAddLegList().forEach(leg -> leg.addEvent(LegApprovalEvent.submit())); + approvalData.getChangeLegList().forEach(it -> { + Leg newLeg = it.getFirst(); + newLeg.addEvent(LegApprovalEvent.submit()); + }); + return this; + } + + public ApprovalProcess submitToBpm() { + return beforeSubmitToBpm().doSubmitToBpm(); + } + + public void handlerApprovalResult(ApprovalResultData data) { + handlerApprovalResultBefore(data); + this.bpmPlatform.receiveApprovalResult(data); + } // 接收审批结果 - public void receiveApprovalResult(String resultData) { - bpmPlatform.receiveApprovalResult(resultData); - } + public abstract void handlerApprovalResultBefore(ApprovalResultData data); - public enum ApprovalType { - LEG_ADD, - LEG_CHANGE, - ORDER_EXPENSE, - ORDER_CHANGE, - ORDER_REFUND, - LEG_ADD_CHANGE_BATCH - } } \ No newline at end of file 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 415c3a26..bceaac3e 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecord.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalRecord.java @@ -1,21 +1,68 @@ package com.chint.domain.aggregates.approval; +import com.chint.domain.aggregates.order.ApproveOrderNo; +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.Table; import java.io.Serial; import java.io.Serializable; +import java.time.LocalDateTime; @Data @Table("approval_record") public class ApprovalRecord implements Serializable { @Serial private static final long serialVersionUID = 987769272351235112L; - @Id private Long id; private Long routeId; - private Long userId; - private String status; + private String employeeNo; + private String approvalRecordNo; + private String companyCode; + private String companyName; + private String sysCode; + private String approvalType; + private Integer approvalStatus; + private LocalDateTime approvalSubmitDate; + private LocalDateTime approvalResponseDate; + private String approvalPlatformMark; + private String approvalReason; + private String extension; + private String extensionSub; + + public static ApprovalRecord of(RouteOrder routeOrder, ApprovalProcess approvalProcess) { + ApprovalRecord approvalRecord = new ApprovalRecord(); + approvalRecord.routeId = routeOrder.getRouteId(); + approvalRecord.employeeNo = routeOrder.getUserId(); + approvalRecord.approvalRecordNo = OrderNo.generateApprovalNo(); + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + approvalRecord.companyCode = approveOrderNo.getAccountCompany(); + approvalRecord.companyName = approveOrderNo.getAccountCompanyName(); + approvalRecord.sysCode = approveOrderNo.getSysCode(); + approvalRecord.approvalType = approvalProcess.getApprovalType().name(); + approvalRecord.approvalStatus = prepareApprovalStatus(); + approvalRecord.approvalSubmitDate = LocalDateTime.now(); + approvalRecord.approvalPlatformMark = approvalProcess.getBpmPlatform().getApprovalPlatformName(); + return approvalRecord; + } + + public ApprovalRecord reason(String approvalReason) { + this.approvalReason = approvalReason; + return this; + } + + public static Integer prepareApprovalStatus() { + return 0; + } + + public static Integer successApprovalStatus() { + return 1; + } + + public static Integer rejectApprovalStatus() { + return -1; + } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalResultData.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalResultData.java new file mode 100644 index 00000000..a6dd98c8 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalResultData.java @@ -0,0 +1,12 @@ +package com.chint.domain.aggregates.approval; + +import com.chint.domain.aggregates.order.RouteOrder; +import lombok.Data; + +@Data +public class ApprovalResultData { + private String approvalRecordNo; + private Integer approvalStatus; + private String extension; + private RouteOrder routeOrder; +} 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 7de7f720..4c83e02b 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java @@ -1,6 +1,8 @@ package com.chint.domain.aggregates.approval; import com.chint.domain.aggregates.approval.platform.ApprovalPlatform; +import com.chint.domain.repository.ApprovalRecordRepository; +import com.chint.domain.repository.RouteRepository; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -12,11 +14,17 @@ import java.util.Map; import java.util.stream.Collectors; @Component -public class ApprovalSubmit implements ApplicationListener { +public class ApprovalSubmit implements ApplicationListener { @Autowired private ApplicationContext applicationContext; + @Autowired + private ApprovalRecordRepository approvalRecordRepository; + + @Autowired + private RouteRepository routeRepository; + @Override public void onApplicationEvent(@NotNull ApplicationReadyEvent event) { @@ -31,7 +39,7 @@ public class ApprovalSubmit implements ApplicationListener throw new IllegalArgumentException("Invalid approval type: " + type); }; } + + //用于处理审批结果 + public void handleApprovalResult(ApprovalResultData data) { + approvalRecordRepository.findByApprovalRecordNo(data.getApprovalRecordNo()) + .ifPresent(it -> { + data.setRouteOrder(routeRepository.queryById(it.getRouteId())); + ApprovalProcess approvalProcess = of(ApprovalType.valueOf(it.getApprovalType()), it.getApprovalPlatformMark()); + approvalProcess.handlerApprovalResult(data); + approvalRecordRepository.save(it); + routeRepository.save(data.getRouteOrder()); + }); + } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalType.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalType.java new file mode 100644 index 00000000..30fabc48 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalType.java @@ -0,0 +1,10 @@ +package com.chint.domain.aggregates.approval; + +public enum ApprovalType { + LEG_ADD, + LEG_CHANGE, + ORDER_EXPENSE, + ORDER_CHANGE, + ORDER_REFUND, + LEG_ADD_CHANGE_BATCH +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatform.java b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatform.java index 70f8b852..00d391be 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatform.java +++ b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatform.java @@ -1,16 +1,13 @@ package com.chint.domain.aggregates.approval.platform; import com.chint.domain.aggregates.approval.ApprovalData; -import com.chint.domain.aggregates.order.Leg; -import com.chint.domain.aggregates.order.OrderDetail; -import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.aggregates.approval.ApprovalResultData; public interface ApprovalPlatform { // 提交审批请求 void submitApproval(ApprovalData approvalData); - // 接收审批结果 - void receiveApprovalResult(String resultData); + String getApprovalPlatformName(); @@ -26,4 +23,13 @@ public interface ApprovalPlatform { void submitOrderRefundApproval(ApprovalData approvalData); void submitLegAddOrChangeApproval(ApprovalData approvalData); + + // 接收审批结果 + void receiveApprovalResultCustom(ApprovalResultData resultData); + + //这里引入模板模式对审批结果进行 + default void receiveApprovalResult(ApprovalResultData resultData){ + //这里所有的行程的审批结果进行 + this.receiveApprovalResultCustom(resultData); + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatformAN.java b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatformAN.java index 8b030fc6..8fe71fb4 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatformAN.java +++ b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalPlatformAN.java @@ -2,6 +2,7 @@ package com.chint.domain.aggregates.approval.platform; import com.chint.domain.aggregates.approval.ApprovalData; +import com.chint.domain.aggregates.approval.ApprovalResultData; import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.supplier.Supplier; import com.chint.domain.repository.ApprovalPlatformInfoRepository; @@ -54,7 +55,7 @@ public class ApprovalPlatformAN implements ApprovalPlatform { } @Override - public void receiveApprovalResult(String resultData) { + public void receiveApprovalResultCustom(ApprovalResultData resultData) { } @@ -103,6 +104,7 @@ public class ApprovalPlatformAN implements ApprovalPlatform { private ApprovalScheduleParam createApprovalScheduleParam(ApprovalData approvalData) { ApprovalScheduleParam approvalScheduleParam = new ApprovalScheduleParam(); + approvalScheduleParam.setApprovalRecordNo(approvalData.getApprovalRecordNo()); approvalScheduleParam.setSourceSystem(systemNum()); RouteOrder routeOrder = approvalData.getRouteOrder(); ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); @@ -279,7 +281,7 @@ public class ApprovalPlatformAN implements ApprovalPlatform { } @Data - private static class ApprovalScheduleParam { + private static class ApprovalScheduleParam extends ApprovalRecordBase { public String sourceSystem; public String sourceSystemNum; public String applicant; diff --git a/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalRecordBase.java b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalRecordBase.java new file mode 100644 index 00000000..0e14719a --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalRecordBase.java @@ -0,0 +1,8 @@ +package com.chint.domain.aggregates.approval.platform; + +import lombok.Data; + +@Data +public class ApprovalRecordBase { + private String approvalRecordNo; +} diff --git a/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalResultReceiver.java b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalResultReceiver.java new file mode 100644 index 00000000..daf3c505 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/approval/platform/ApprovalResultReceiver.java @@ -0,0 +1,5 @@ +package com.chint.domain.aggregates.approval.platform; + +public interface ApprovalResultReceiver { + void receiveApprovalResult(String resultData, String platformMark); +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/base/EventManageable.java b/src/main/java/com/chint/domain/aggregates/base/EventManageable.java index a8d2fc98..9f0662c6 100644 --- a/src/main/java/com/chint/domain/aggregates/base/EventManageable.java +++ b/src/main/java/com/chint/domain/aggregates/base/EventManageable.java @@ -3,6 +3,7 @@ package com.chint.domain.aggregates.base; import com.chint.domain.aggregates.order.LegApprovalEvent; import java.util.List; +import java.util.Objects; public interface EventManageable { @@ -12,7 +13,10 @@ public interface EventManageable { // 默认方法:添加事件 default void addEvent(BaseEvent event) { List events = (List) getEvents(); - events.add(event); + BaseEvent lastEvent = getLastEvent(); + if (!Objects.equals(lastEvent.getEventType(), event.getEventType())) { + events.add(event); + } } // 默认方法:获取最新的事件 diff --git a/src/main/java/com/chint/domain/aggregates/base/PermissionConfig.java b/src/main/java/com/chint/domain/aggregates/base/PermissionConfig.java new file mode 100644 index 00000000..8bde0f92 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/base/PermissionConfig.java @@ -0,0 +1,39 @@ +package com.chint.domain.aggregates.base; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +@Data +@Table("permission_config") +public class PermissionConfig implements Serializable { + + @Serial + private static final long serialVersionUID = 1098772936113573530L; + + @Id + private Long id; + + private String permissionName; + + private String permissionDescription; + + private String permissionType; + + private String permissionValue; + + private String extension; + + public List permissions() { + if (permissionValue == null || permissionValue.isEmpty()) { + return List.of(); + } + return Arrays.stream(permissionValue.split("&")).toList(); + } + +} diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index 87dddc3b..807cbce7 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -416,4 +416,23 @@ public class Leg implements Serializable, EventManageable { // this.createTime = LocalDateTime.parse(this.createTime.toString(), dateTimeFormatter); // return this; // } + + + public String generateLegString() { + return DateTimeUtil.timeToStrCommon(startTime) + "|" + + DateTimeUtil.timeToStrCommon(endTime) + "|" + + originId + "|" + destinationId; + } + + public void restoreFromLegString(String legString) { + String[] parts = legString.split("\\|"); + if (parts.length == 4) { + this.startTime = DateTimeUtil.strToTime(parts[0]); + this.endTime = DateTimeUtil.strToTime(parts[1]); + this.originId = Long.parseLong(parts[2]); + this.destinationId = Long.parseLong(parts[3]); + } else { + throw new IllegalArgumentException("Invalid legString format."); + } + } } \ No newline at end of file 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 40a7db2d..57fe4325 100644 --- a/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/LegApprovalEvent.java @@ -1,7 +1,7 @@ package com.chint.domain.aggregates.order; import com.chint.domain.aggregates.base.BaseEvent; -import com.google.gson.Gson; +import com.chint.infrastructure.util.Json; import lombok.Data; import org.springframework.data.annotation.Id; import org.springframework.data.relational.core.mapping.Column; @@ -41,10 +41,9 @@ public class LegApprovalEvent extends BaseEvent implements Serializable { } public static LegApprovalEvent prepare(Leg oldLeg) { - Gson gson = new Gson(); LegApprovalEvent event = new LegApprovalEvent(); event.setEventType(LEG_APPROVAL_STATUS_PREPARE); - event.extension(gson.toJson(oldLeg)); + event.extension(oldLeg.generateLegString()); 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 cccf0320..9ad56631 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -7,6 +7,7 @@ import com.chint.domain.service.LegDomainService; import com.chint.domain.service.amount_estimate.EstimateAdapter; import com.chint.domain.service.supplier.SupplierConstantUtil; import com.chint.domain.value_object.*; +import com.chint.domain.value_object.enums.RoutePermission; import com.chint.infrastructure.constant.LegConstant; import com.chint.infrastructure.constant.RouteConstant; import com.chint.infrastructure.echo_framework.command.Command; @@ -78,6 +79,8 @@ public class RouteOrder implements Serializable { private String orderStatusName; @Transient private String supplierCNName; + @Transient + private Set routePermissionSet; //共有的扩展字段 @MappedCollection(idColumn = "route_id") diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java index 586baeb6..fe359923 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java @@ -26,16 +26,23 @@ public class SystemCode implements Serializable { private List companyInfos; @MappedCollection(idColumn = "system_code_id") private SystemCodeUrl systemCodeUrl; - @Transient -// @MappedCollection(idColumn = "system_id", keyColumn = "system_key") + @MappedCollection(idColumn = "system_code_id", keyColumn = "system_code_key") private List systemCodeExtensionFieldList; public String getApprovalPlatformMark() { + return getExtensionValue("ApprovalPlatformMark"); + } + + public String getApprovalType() { + return getExtensionValue("ApprovalType"); + } + + private String getExtensionValue(String fieldName) { if (systemCodeExtensionFieldList == null || systemCodeExtensionFieldList.isEmpty()) { - return null; + return ""; } - return this.systemCodeExtensionFieldList.stream().filter(it -> it.getFieldName().equals("ApprovalPlatformMark")) + return this.systemCodeExtensionFieldList.stream().filter(it -> it.getFieldName().equals(fieldName)) .map(SystemCodeExtensionField::getFieldValue) .findFirst() .orElse(""); diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCodeExtensionField.java b/src/main/java/com/chint/domain/aggregates/system/SystemCodeExtensionField.java index 316ebd8c..fb91e015 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemCodeExtensionField.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCodeExtensionField.java @@ -30,7 +30,5 @@ public class SystemCodeExtensionField implements Serializable { public static SystemCodeExtensionField of(String fieldName, String fieldValue, String extension) { return new SystemCodeExtensionField(fieldName, fieldValue, extension); } - - } diff --git a/src/main/java/com/chint/domain/repository/ApprovalRecordRepository.java b/src/main/java/com/chint/domain/repository/ApprovalRecordRepository.java new file mode 100644 index 00000000..4ea94a13 --- /dev/null +++ b/src/main/java/com/chint/domain/repository/ApprovalRecordRepository.java @@ -0,0 +1,10 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.approval.ApprovalRecord; + +import java.util.Optional; + +public interface ApprovalRecordRepository { + ApprovalRecord save(ApprovalRecord record); + Optional findByApprovalRecordNo(String approvalRecordNo); +} diff --git a/src/main/java/com/chint/domain/repository/PermissionConfigRepository.java b/src/main/java/com/chint/domain/repository/PermissionConfigRepository.java new file mode 100644 index 00000000..f34aee7b --- /dev/null +++ b/src/main/java/com/chint/domain/repository/PermissionConfigRepository.java @@ -0,0 +1,13 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.base.PermissionConfig; + +import java.util.List; +import java.util.Optional; +import java.util.Set; + +public interface PermissionConfigRepository { + Optional findByPermissionName(String permissionName); + + List findByPermissionNameIn(Set approvalTypes); +} diff --git a/src/main/java/com/chint/domain/repository/SystemCodeRepository.java b/src/main/java/com/chint/domain/repository/SystemCodeRepository.java index eb8cb618..4d0ba74d 100644 --- a/src/main/java/com/chint/domain/repository/SystemCodeRepository.java +++ b/src/main/java/com/chint/domain/repository/SystemCodeRepository.java @@ -3,6 +3,10 @@ package com.chint.domain.repository; import com.chint.domain.aggregates.system.SystemCode; +import java.util.Collection; +import java.util.List; +import java.util.Set; + public interface SystemCodeRepository { SystemCode save(SystemCode systemCode); @@ -11,4 +15,5 @@ public interface SystemCodeRepository { SystemCode findById(Long id); + List findBySysCodeIn(Set sysCodes); } diff --git a/src/main/java/com/chint/domain/service/LegDomainService.java b/src/main/java/com/chint/domain/service/LegDomainService.java index 40489c30..8d6b7da6 100644 --- a/src/main/java/com/chint/domain/service/LegDomainService.java +++ b/src/main/java/com/chint/domain/service/LegDomainService.java @@ -228,7 +228,7 @@ public class LegDomainService { List filteredLegItems = legItems.stream() .filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal()) .peek(Leg::reloadStatus) - .filter(it -> it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_NOT)) + .filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT)) .toList(); // 根据供应商名称查找供应商并进行处理 diff --git a/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java b/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java index a1f468b5..5c652cc5 100644 --- a/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java +++ b/src/main/java/com/chint/domain/service/RouteApprovalDomainService.java @@ -1,17 +1,26 @@ package com.chint.domain.service; import com.chint.application.dtos.LegApprovalParam; +import com.chint.domain.aggregates.approval.ApprovalResultData; import com.chint.domain.aggregates.approval.ApprovalSubmit; +import com.chint.domain.aggregates.base.PermissionConfig; import com.chint.domain.aggregates.order.ApproveOrderNo; import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.aggregates.system.SystemCode; import com.chint.domain.aggregates.system.SystemOrganization; -import com.chint.domain.repository.RouteRepository; -import com.chint.domain.repository.SystemCodeRepository; -import com.chint.domain.repository.SystemOrganizationRepository; +import com.chint.domain.repository.*; +import com.chint.domain.value_object.enums.RoutePermission; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import static com.chint.domain.aggregates.approval.ApprovalProcess.ApprovalType.LEG_ADD_CHANGE_BATCH; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static com.chint.domain.aggregates.approval.ApprovalType.LEG_ADD_CHANGE_BATCH; + @Service public class RouteApprovalDomainService { @@ -25,30 +34,119 @@ public class RouteApprovalDomainService { @Autowired private SystemOrganizationRepository systemOrganizationRepository; + @Autowired + private PermissionConfigRepository permissionConfigRepository; - public void legApprovalResponse(){ + @Autowired + private ApprovalRecordRepository approvalRecordRepository; + + private ApprovalSubmit approvalSubmit; + + public void legApprovalResponse() { } - public void orderDetailResponse(){ + public void orderDetailResponse() { } + public void handlerApprovalResponse(ApprovalResultData data) { + approvalSubmit.handleApprovalResult(data); + } + public void approveRouteOfLegChangeAndAdd(LegApprovalParam param) { RouteOrder routeOrder = routeRepository.queryById(param.getRouteId()); String approvalPlatformMark = getApprovalPlatformMark(routeOrder); - ApprovalSubmit.of(LEG_ADD_CHANGE_BATCH,approvalPlatformMark) + ApprovalSubmit.of(LEG_ADD_CHANGE_BATCH, approvalPlatformMark) .approveData(routeOrder) + .record(record -> { + record.setApprovalReason(param.getApprovalReason()); + approvalRecordRepository.save(record); + }) .submitToBpm(); + routeRepository.save(routeOrder); + } + + public List checkApprovalPermissions(List routeOrderList) { + // 提取所有 approveOrderNo 和 sysCode + Set accountCompanyCodes = routeOrderList.stream() + .map(routeOrder -> routeOrder.getApproveOrderNo().getAccountCompany()) + .collect(Collectors.toSet()); + + Set sysCodes = routeOrderList.stream() + .map(routeOrder -> routeOrder.getApproveOrderNo().getSysCode()) + .collect(Collectors.toSet()); + + // 批量查询 systemOrganizationRepository 和 systemCodeRepository + Map accountCompanyToApprovalType = systemOrganizationRepository.findByOrgCodeIn(accountCompanyCodes) + .stream() + .filter(it -> it.getApprovalType() != null && !it.getApprovalType().isEmpty()) + .collect(Collectors.toMap(SystemOrganization::getOrgCode, SystemOrganization::getApprovalType)); + + Map sysCodeToApprovalType = systemCodeRepository.findBySysCodeIn(sysCodes) + .stream() + .filter(it -> it.getApprovalType() != null && !it.getApprovalType().isEmpty()) + .collect(Collectors.toMap(SystemCode::getSystemCode, SystemCode::getApprovalType)); + + // 获取所有审批类型 + Set approvalTypes = routeOrderList.stream() + .map(routeOrder -> { + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + String accountCompany = approveOrderNo.getAccountCompany(); + return accountCompanyToApprovalType.getOrDefault(accountCompany, sysCodeToApprovalType.get(approveOrderNo.getSysCode())); + }) + .collect(Collectors.toSet()); + + // 批量查询 permissionConfigRepository + Map> approvalTypeToPermissions = permissionConfigRepository + .findByPermissionNameIn(approvalTypes) + .stream() + .collect(Collectors.toMap(PermissionConfig::getPermissionName, PermissionConfig::permissions)); + + // 将权限映射为枚举 + Map> approvalTypeToPermissionSet = approvalTypeToPermissions.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().stream() + .distinct() + .map(permission -> Enum.valueOf(RoutePermission.class, permission)) + .collect(Collectors.toSet()))); + + // 更新每个 RouteOrder 的 routePermissionSet + for (RouteOrder routeOrder : routeOrderList) { + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + String approvalType = accountCompanyToApprovalType.getOrDefault(approveOrderNo.getAccountCompany(), + sysCodeToApprovalType.get(approveOrderNo.getSysCode())); + Set routePermissionSet = approvalTypeToPermissionSet + .getOrDefault(approvalType, Collections.emptySet()); + routeOrder.setRoutePermissionSet(routePermissionSet); + } + return routeOrderList; + } + + public RouteOrder checkApprovalPermissions(RouteOrder routeOrder) { + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + String approvalType = systemOrganizationRepository.findByOrgCodeContainingOrOrgNameContaining(approveOrderNo.getAccountCompany(), + approveOrderNo.getAccountCompany()).map(SystemOrganization::getApprovalType).orElseGet( + () -> systemCodeRepository.findBySysCode(approveOrderNo.getSysCode()).getApprovalType()); + routeOrder.setRoutePermissionSet( + permissionConfigRepository.findByPermissionName(approvalType) + .map(permissionConfig -> { + List permissions = permissionConfig.permissions(); + return permissions.stream() + .distinct() + .map(permission -> Enum.valueOf(RoutePermission.class, permission)) + .collect(Collectors.toSet()); + }).orElseGet(Set::of) + ); + return routeOrder; } - private String getApprovalPlatformMark(RouteOrder routeOrder){ + private String getApprovalPlatformMark(RouteOrder routeOrder) { ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); //先查寻公司是否有关联的BPM,如果没有的话,查询sysCode关联的BPM - return systemOrganizationRepository.findByOrgCodeContainingOrOrgNameContaining(approveOrderNo.getAccountCompany(), - approveOrderNo.getAccountCompany()).map(SystemOrganization::getApprovalPlatformMark).orElseGet( - () -> systemCodeRepository.findBySysCode(approveOrderNo.getSysCode()).getApprovalPlatformMark() - ); + return systemOrganizationRepository.findByOrgCode(approveOrderNo.getAccountCompany()) + .map(SystemOrganization::getApprovalPlatformMark).orElseGet( + () -> systemCodeRepository.findBySysCode(approveOrderNo.getSysCode()).getApprovalPlatformMark() + ); } } diff --git a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java index 9c762d2f..de615165 100644 --- a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java +++ b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java @@ -44,6 +44,8 @@ public interface SupplierOrderSync extends SupplierAdapter { List legList = routeRequest.getRouteRequestLegList() .stream() .map(RouteRequestLeg::getLeg) + .peek(Leg::reloadStatus) + .filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT)) .toList(); // Legs can not be empty 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 new file mode 100644 index 00000000..fcec9b06 --- /dev/null +++ b/src/main/java/com/chint/domain/value_object/enums/RoutePermission.java @@ -0,0 +1,5 @@ +package com.chint.domain.value_object.enums; + +public enum RoutePermission { + APPROVAL_BUTTON +} diff --git a/src/main/java/com/chint/infrastructure/repository/ApprovalRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/ApprovalRecordRepositoryImpl.java new file mode 100644 index 00000000..5daab9de --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/ApprovalRecordRepositoryImpl.java @@ -0,0 +1,28 @@ +package com.chint.infrastructure.repository; + +import com.chint.domain.aggregates.approval.ApprovalRecord; +import com.chint.domain.repository.ApprovalRecordRepository; +import com.chint.infrastructure.repository.jdbc.JdbcApprovalRecordRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public class ApprovalRecordRepositoryImpl implements ApprovalRecordRepository { + + + + @Autowired + private JdbcApprovalRecordRepository jdbcApprovalRecordRepository; + + @Override + public ApprovalRecord save(ApprovalRecord record) { + return jdbcApprovalRecordRepository.save(record); + } + + @Override + public Optional findByApprovalRecordNo(String approvalRecordNo) { + return jdbcApprovalRecordRepository.findByApprovalRecordNo(approvalRecordNo).stream().findFirst(); + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/PermissionConfigRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/PermissionConfigRepositoryImpl.java new file mode 100644 index 00000000..411f5b52 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/PermissionConfigRepositoryImpl.java @@ -0,0 +1,31 @@ +package com.chint.infrastructure.repository; + +import com.chint.domain.aggregates.base.PermissionConfig; +import com.chint.domain.repository.PermissionConfigRepository; +import com.chint.infrastructure.repository.jdbc.JdbcPermissionConfigRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +@Repository +public class PermissionConfigRepositoryImpl implements PermissionConfigRepository { + + @Autowired + private JdbcPermissionConfigRepository jdbcPermissionConfigRepository; + + @Cacheable(value = "PermissionConfig", key = "#permissionName") + @Override + public Optional findByPermissionName(String permissionName) { + return jdbcPermissionConfigRepository.findByPermissionName(permissionName).stream().findFirst(); + } + + @Override + public List findByPermissionNameIn(Set approvalTypes) { + return jdbcPermissionConfigRepository.findByPermissionNameIn(approvalTypes.stream().filter(Objects::nonNull).toList()); + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/RoleRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RoleRepositoryImpl.java index 57dfbec7..467b64e6 100644 --- a/src/main/java/com/chint/infrastructure/repository/RoleRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RoleRepositoryImpl.java @@ -1,7 +1,9 @@ package com.chint.infrastructure.repository; import com.chint.application.dtos.system.RoleOrgParam; +import com.chint.domain.aggregates.system.SystemOrganization; import com.chint.domain.aggregates.user.Role; +import com.chint.domain.aggregates.user.RoleOrganization; import com.chint.domain.aggregates.user.RoleUser; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.RoleRepository; @@ -103,6 +105,7 @@ public class RoleRepositoryImpl implements RoleRepository { } user.setRoleOrgCodeList(orgCodeList); + // List orgCodeList = cacheRoleRepository // .roleOrgCodeList(userId, null); // List systemOrganizationVOList = cacheRoleRepository diff --git a/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java index 54543c8f..316f8879 100644 --- a/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java @@ -8,6 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Repository; +import java.util.List; +import java.util.Objects; +import java.util.Set; + @Repository public class SystemCodeRepositoryImpl implements SystemCodeRepository { @@ -29,4 +33,9 @@ public class SystemCodeRepositoryImpl implements SystemCodeRepository { public SystemCode findById(Long id) { return jdbcSystemCodeRepository.findById(id).orElseThrow(() -> new NotFoundException("该产业公司不在实施范围内")); } + + @Override + public List findBySysCodeIn(Set sysCodes) { + return jdbcSystemCodeRepository.findBySystemCodeIn(sysCodes.stream().filter(Objects::nonNull).toList()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcApprovalRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcApprovalRecordRepository.java new file mode 100644 index 00000000..7da6815a --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcApprovalRecordRepository.java @@ -0,0 +1,12 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.approval.ApprovalRecord; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface JdbcApprovalRecordRepository extends CrudRepository { + List findByApprovalRecordNo(String approvalRecordNo); +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcPermissionConfigRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcPermissionConfigRepository.java new file mode 100644 index 00000000..822d70ec --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcPermissionConfigRepository.java @@ -0,0 +1,15 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.base.PermissionConfig; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface JdbcPermissionConfigRepository extends CrudRepository { + + List findByPermissionName(String permissionName); + + List findByPermissionNameIn(List permissionNames); +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemCodeRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemCodeRepository.java index 4585c0a9..ea78ba64 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemCodeRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemCodeRepository.java @@ -1,12 +1,15 @@ package com.chint.infrastructure.repository.jdbc; -import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.system.SystemCode; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository -public interface JdbcSystemCodeRepository extends CrudRepository { +public interface JdbcSystemCodeRepository extends CrudRepository { SystemCode findBySystemCode(String systemCode); + + List findBySystemCodeIn(List systemCodes); } diff --git a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java index ff187dcb..2bb7542a 100644 --- a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java +++ b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java @@ -11,6 +11,7 @@ public class DateTimeUtil { public final static DateTimeFormatter formatterDate = DateTimeFormatter.ofPattern("yyyy-MM-dd"); public final static DateTimeFormatter formatterDateYYYYMM = DateTimeFormatter.ofPattern("yyyyMM"); public final static DateTimeFormatter formatterDateYYYYMMDD = DateTimeFormatter.ofPattern("yyyyMMdd"); + public final static DateTimeFormatter formatterMinSS = DateTimeFormatter.ofPattern("yyMMddHHmmss"); public static String timeFromInstant(Long instant) { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(instant), ZoneId.systemDefault()); @@ -21,6 +22,9 @@ public class DateTimeUtil { return formatter.format(time); } + public static String timeToMinSS(LocalDateTime time) { + return formatterMinSS.format(time); + } public static String timeToStr(LocalDateTime input) { return input.format(formatterDate); @@ -79,6 +83,7 @@ public class DateTimeUtil { LocalDate parse = LocalDate.parse(date, formatterDate); return LocalDateTime.of(parse, LocalTime.MIN); } + public static LocalDateTime endOfDay(String date) { LocalDate parse = LocalDate.parse(date, formatterDate); return LocalDateTime.of(parse, LocalTime.MAX); diff --git a/src/main/java/com/chint/infrastructure/util/Json.java b/src/main/java/com/chint/infrastructure/util/Json.java index 2592c3bb..71231ec7 100644 --- a/src/main/java/com/chint/infrastructure/util/Json.java +++ b/src/main/java/com/chint/infrastructure/util/Json.java @@ -5,10 +5,8 @@ import org.springframework.stereotype.Component; @Component public class Json { - - private final Gson gson = new Gson(); - - public Gson gson() { + private static final Gson gson = new Gson(); + public static Gson gson() { return gson; } } diff --git a/src/main/java/com/chint/infrastructure/util/OrderNo.java b/src/main/java/com/chint/infrastructure/util/OrderNo.java index 31019c65..b24c13f3 100644 --- a/src/main/java/com/chint/infrastructure/util/OrderNo.java +++ b/src/main/java/com/chint/infrastructure/util/OrderNo.java @@ -1,7 +1,6 @@ package com.chint.infrastructure.util; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.Random; public class OrderNo { @@ -10,15 +9,7 @@ public class OrderNo { private static final String numbers = "0123456789"; public static String generate() { - // 获取当前时间 - LocalDateTime now = LocalDateTime.now(); - // 格式化日期和时间部分 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMddHHmmss"); - String datePart = now.format(formatter); - // 生成随机序列部分 - int randomPart = new Random().nextInt(9000) + 1000; // 生成1000到9999之间的随机数 - // 拼接最终的订单号 - return "R" + datePart + randomPart; + return "R" + generateNum(); } public static String generate(String sysCode, String billCode) { @@ -27,15 +18,19 @@ public class OrderNo { } public static String generateLegNo() { - // 获取当前时间 - LocalDateTime now = LocalDateTime.now(); + return "L" + generateNum(); + } + + public static String generateApprovalNo() { + return "A" + generateNum(); + } + + private static String generateNum() { // 格式化日期和时间部分 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMddHHmmss"); - String datePart = now.format(formatter); + String datePart = DateTimeUtil.timeToMinSS(LocalDateTime.now()); // 生成随机序列部分 int randomPart = new Random().nextInt(9000) + 1000; // 生成1000到9999之间的随机数 - // 拼接最终的订单号 - return "L" + datePart + randomPart; + return datePart + randomPart; } public static String generateRouteRequestNo(String routeOrderNo) { diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 6f2273a5..06c3ec3b 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("DT24062278179087557"); + TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24051673807741786"); Gson gson = new Gson(); String json = gson.toJson(trainOrderDetail); System.out.println(json); @@ -829,7 +829,7 @@ public class LYTest { @Test void searchHotel() { - HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240406120100189791"); + HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240321143500052669"); Gson gson = new Gson(); String json = gson.toJson(hotelOrderDetail); System.out.println(json); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index a847e029..5240eeda 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -24,6 +24,7 @@ import com.chint.infrastructure.repository.CTripOrderDetailImpl; import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.Digest; import com.chint.infrastructure.util.PinyinUtil; +import com.chint.infrastructure.util.Result; import com.chint.interfaces.rest.amap.dto.note.AmapNoteResponse; import com.chint.interfaces.rest.base.PostRequest; import com.chint.interfaces.rest.ctrip.CTripAirportRequest; @@ -57,6 +58,7 @@ import org.springframework.boot.test.context.SpringBootTest; import java.io.FileWriter; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Paths; import java.time.LocalDate; @@ -322,16 +324,56 @@ class RouteApplicationTests { @Test void loginSignProd() { - String sfno = "080301001"; - String syscode = "FSSC"; - String billcode = "CLSQ240620099999"; - String companycode = "正泰集团股份有限公司"; + String sfno = "210506025"; + String syscode = "ANFSSC"; + String billcode = "CLS24062700018"; + String companycode = "正泰安能数字能源(浙江)股份有限公司"; String timespan = "1708908662738"; String key = "ZhengTaiRoute"; String s = Digest.md5(sfno + syscode + billcode + companycode + key + timespan); System.out.println(s); } + + @Test + void testPushBatch() throws UnsupportedEncodingException { + List billcodeList = List.of("CLS24062500065", + "CLS24062400348", + "CLS24062500073", + "CLS24062500207"); + + List sfnoList = List.of( + "220915110", + "220719073", + "230627119", + "220802056" + ); + + System.out.println(billcodeList.size()); + System.out.println(sfnoList.size()); + + String sfno = "240227068"; + String syscode = "ANFSSC"; + String billcode = "CLS24062800068"; + String companycode = "正泰安能数字能源(浙江)股份有限公司"; + String timespan = "1708908662738"; + String key = "ZhengTaiRoute"; + + + for (int i = 0; i < billcodeList.size(); i++) { + billcode = billcodeList.get(i); + sfno = sfnoList.get(i); + String sign = Digest.md5(sfno + syscode + billcode + companycode + key + timespan); + String url = "https://trip.chint.com/api/public/login?sfno=" + sfno + + "&syscode=" + syscode + + "&billcode=" + billcode + + "×pan=" + timespan + + "&sign=" + sign + + "&companycode=" + java.net.URLEncoder.encode(companycode, "UTF-8"); + postRequest.get(url, Result.class); + } + } + // @Test void queryUserInfo() { User user2 = User.withEmployeeNo("180101001"); @@ -478,7 +520,6 @@ class RouteApplicationTests { } - CTripNoteResponse post = postRequest.post("https://trip.chint.com/api/public/CTrip/status", cTripStatusNotification, CTripNoteResponse.class); alreadyPost.add(cTripStatusNotification.getOrderId()); if (post.getErrorMessage() != null || !Objects.equals(post.getErrorCode(), "0")) {