From fdc2d4e2050564e206ff301866bf5001841e4278 Mon Sep 17 00:00:00 2001 From: yinq Date: Mon, 13 Apr 2026 17:14:55 +0800 Subject: [PATCH] =?UTF-8?q?1.1.16=20=E5=AE=A1=E6=89=B9=E5=B7=B2=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E4=B8=94=E5=90=88=E5=90=8C=E6=9C=AA=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E5=8F=AF=E9=87=8D=E6=96=B0=E5=8F=91=E8=B5=B7=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ErpContractInfoServiceImpl.java | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpContractInfoServiceImpl.java b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpContractInfoServiceImpl.java index 7fc10c4a..6ee143b2 100644 --- a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpContractInfoServiceImpl.java +++ b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpContractInfoServiceImpl.java @@ -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 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); }