fix:行程规划单根据归属部门补充公司编码字段

This commit is contained in:
lulz1 2024-06-28 17:32:34 +08:00
parent 3939cc2c91
commit 4342b31337
1 changed files with 32 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package com.chint.domain.service.leg_event;
import com.chint.application.commands.*; import com.chint.application.commands.*;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.system.SystemCode; 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.aggregates.user.User;
import com.chint.domain.exceptions.CommandException; import com.chint.domain.exceptions.CommandException;
import com.chint.domain.exceptions.LegEventException; import com.chint.domain.exceptions.LegEventException;
@ -135,7 +136,7 @@ public class LegEventHandler implements LegEventService {
routeOrder.reloadStatus(); routeOrder.reloadStatus();
//如果是已经提交审批了就直接退出 //如果是已经提交审批了就直接退出
if(routeOrder.getApproveOrderNo().getActualOrderNo() != null){ if (routeOrder.getApproveOrderNo().getActualOrderNo() != null) {
return; return;
} }
@ -145,6 +146,8 @@ public class LegEventHandler implements LegEventService {
//保存提交审批所提供的资料 //保存提交审批所提供的资料
routeOrder.updateApprovalData(data); routeOrder.updateApprovalData(data);
updateApprovalData(data, routeOrder);
//这里order所有的leg触发approve事件 //这里order所有的leg触发approve事件
routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( routeOrder.getLegItems().forEach(leg -> leg.getEventList().add(
@ -173,6 +176,34 @@ public class LegEventHandler implements LegEventService {
Command.of(RouteAutoSyncCommand.class).route(save).async().sendToQueue(); 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<SystemOrganization> 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 @Transactional
@Override @Override
public void syncLeg(LegSyncCommand command) { public void syncLeg(LegSyncCommand command) {