From 4342b3133737835a71eec0bb048c3ce9680d773b Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 28 Jun 2024 17:32:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=A1=8C=E7=A8=8B=E8=A7=84=E5=88=92?= =?UTF-8?q?=E5=8D=95=E6=A0=B9=E6=8D=AE=E5=BD=92=E5=B1=9E=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=85=AC=E5=8F=B8=E7=BC=96=E7=A0=81=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/leg_event/LegEventHandler.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index d05a9a47..317f6b54 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -3,6 +3,7 @@ package com.chint.domain.service.leg_event; import com.chint.application.commands.*; import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.system.SystemCode; +import com.chint.domain.aggregates.system.SystemOrganization; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.CommandException; import com.chint.domain.exceptions.LegEventException; @@ -135,7 +136,7 @@ public class LegEventHandler implements LegEventService { routeOrder.reloadStatus(); //如果是已经提交审批了,就直接退出 - if(routeOrder.getApproveOrderNo().getActualOrderNo() != null){ + if (routeOrder.getApproveOrderNo().getActualOrderNo() != null) { return; } @@ -145,6 +146,8 @@ public class LegEventHandler implements LegEventService { //保存提交审批所提供的资料 routeOrder.updateApprovalData(data); + updateApprovalData(data, routeOrder); + //这里order所有的leg触发approve事件 routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( @@ -173,6 +176,34 @@ public class LegEventHandler implements LegEventService { Command.of(RouteAutoSyncCommand.class).route(save).async().sendToQueue(); } + public void updateApprovalData(ApproveRouteData data,RouteOrder routeOrder) { + // 保存提交审批所提供的资料 + routeOrder.updateApprovalData(data); + RouterOrderExtensionField routerOrderExtensionField = routeOrder.getRouterOrderExtensionField(); + if (routerOrderExtensionField != null && routerOrderExtensionField.getBelongDeptCode() != null) { + String belongDeptCode = routerOrderExtensionField.getBelongDeptCode(); + systemOrganizationRepository.findByOrgCodeContaining(belongDeptCode) + .ifPresent(org -> { + Long currentParentId = org.getParentId(); + List parentOrganizations; + while (currentParentId != null) { + parentOrganizations = systemOrganizationRepository.findByIdIn(List.of(currentParentId)); + if (!parentOrganizations.isEmpty()) { + SystemOrganization organization = parentOrganizations.get(0); + if (organization.getOrgLevel() == null || organization.getOrgLevel().isEmpty()) { + routerOrderExtensionField.setCompanyCode(organization.getOrgShortCode()); + break; + } else { + currentParentId = organization.getParentId(); + } + } else { + break; // Parent organization not found + } + } + }); + } + } + @Transactional @Override public void syncLeg(LegSyncCommand command) {