fix:行程规划单根据归属部门补充公司编码字段
This commit is contained in:
parent
3939cc2c91
commit
4342b31337
|
@ -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<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
|
||||
@Override
|
||||
public void syncLeg(LegSyncCommand command) {
|
||||
|
|
Loading…
Reference in New Issue