1.1.16 审批已通过且合同未激活可重新发起流程逻辑

dev
yinq 3 months ago
parent 96f1a1b4d7
commit fdc2d4e205

@ -697,18 +697,23 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService {
@Override
@GlobalTransactional(rollbackFor = Exception.class)
public ErpContractInfoVo contractSubmitAndFlowStart(ErpContractInfoBo bo) {
// 统一补齐并落库flowCode/variables/bizExt/contractStatus/flowStatus
fillContractOacParams(bo);
ErpContractInfo add = MapstructUtils.convert(bo, ErpContractInfo.class);
// 重新发起须删旧实例后再 startWorkFlow
boolean clearedFinishedFlow = resetFinishedContractFlowForResubmit(bo);
if (clearedFinishedFlow) {
bo.setContractStatus(OAStatusEnum.APPROVING.getStatus());
bo.setFlowStatus(BusinessStatusEnum.WAITING.getStatus());
}
if (StringUtils.isNull(bo.getContractId())) {
this.insertByBo(bo);
} else {
this.updateByBo(bo);
}
// 后端发起需要忽略权限
Map<String, Object> vars = bo.getVariables();
vars.put("ignore", true);
bo.setVariables(vars);
if (vars != null) {
vars.put("ignore", true);
bo.setVariables(vars);
}
RemoteStartProcess startProcess = new RemoteStartProcess();
startProcess.setBusinessId(bo.getContractId().toString());
startProcess.setFlowCode(bo.getFlowCode());
@ -719,7 +724,32 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService {
if (!flagOne) {
throw new ServiceException("流程发起异常");
}
return MapstructUtils.convert(add, ErpContractInfoVo.class);
return queryById(bo.getContractId());
}
/**
* 便
*/
private boolean resetFinishedContractFlowForResubmit(ErpContractInfoBo bo) {
if (bo == null || bo.getContractId() == null) {
return false;
}
ErpContractInfoVo current = queryById(bo.getContractId());
if (current == null) {
return false;
}
if (!OAStatusEnum.COMPLETED.getStatus().equals(current.getContractStatus())) {
return false;
}
String wfStatus = remoteWorkflowService.getBusinessStatus(String.valueOf(bo.getContractId()));
if (!BusinessStatusEnum.FINISH.getStatus().equals(wfStatus)) {
return false;
}
log.info("合同[{}]重新发起审批:删除已结束流程实例后重新发起", bo.getContractId());
remoteWorkflowService.deleteInstance(Collections.singletonList(bo.getContractId()));
bo.setContractStatus(null);
bo.setFlowStatus(null);
return true;
}
/**
@ -729,6 +759,9 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService {
if (bo == null) {
return;
}
if (bo.getVariables() == null) {
bo.setVariables(new HashMap<>());
}
if (StringUtils.isBlank(bo.getFlowCode())) {
bo.setFlowCode(FLOW_CODE_CONTRACT);
}

Loading…
Cancel
Save