From cac28a3d578b52bbdc2f0f7f8ca58a4ce8d5b954 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Mon, 7 Apr 2025 12:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E4=B8=AD=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=90=AF=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/modules/gen/crud/service.xml | 28 ++++++++++++++++--- .../templates/modules/gen/view/viewForm.html | 6 ++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/resources/templates/modules/gen/crud/service.xml b/modules/core/src/main/resources/templates/modules/gen/crud/service.xml index 8bd4111f..b1e87204 100644 --- a/modules/core/src/main/resources/templates/modules/gen/crud/service.xml +++ b/modules/core/src/main/resources/templates/modules/gen/crud/service.xml @@ -131,6 +131,13 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv if (${ClassName}.STATUS_NORMAL.equals(${className}.getStatus())){ throw new ServiceException(text("非法操作,前端数据被劫持!")); } + + // 如果是重启流程操作,则恢复审核状态,并标记重启状态 + boolean isRestart = false; + if (${ClassName}.STATUS_RESTART.equals(${className}.getStatus())) { + ${className}.setStatus(${ClassName}.STATUS_AUDIT); + isRestart = true; + } // 如果状态为草稿或审核状态,才可以保存业务数据 if (${ClassName}.STATUS_DRAFT.equals(${className}.getStatus()) @@ -140,15 +147,28 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv // 如果为审核状态,则进行审批流操作 if (${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){ - + + // 流程定义中的表单Key,不是流程Key + String formKey = "${table.optionMap['bpmFormKey']}"; + // 指定流程变量,作为流程条件,决定流转方向 Map variables = MapUtils.newHashMap(); //variables.put("leaveDays", ${className}.getLeaveDays()); + + // 如果是流程重启,则先检查流程状态 + if (isRestart) { + if (BpmUtils.getRunProcIns(${className}, formKey) != null) { + throw new ServiceException(text("重启失败,流程已经启动!")); + } + if (StringUtils.isNotBlank(${className}.getBpm().getProcInsId())) { + variables.put("parentProcInsId", ${className}.getBpm().getProcInsId()); + } + } // 如果流程实例为空,任务编号也为空,则:启动流程 - if (StringUtils.isBlank(${className}.getBpm().getProcInsId()) - && StringUtils.isBlank(${className}.getBpm().getTaskId())){ - BpmUtils.start(${className}, "${table.optionMap['bpmFormKey']}", variables, null); + if (isRestart || (StringUtils.isBlank(${className}.getBpm().getProcInsId()) + && StringUtils.isBlank(${className}.getBpm().getTaskId()))){ + BpmUtils.start(${className}, formKey, variables, null); } // 如果有任务信息,则:提交任务 else{ diff --git a/modules/core/src/main/resources/templates/modules/gen/view/viewForm.html b/modules/core/src/main/resources/templates/modules/gen/view/viewForm.html index dc93d941..065198c0 100644 --- a/modules/core/src/main/resources/templates/modules/gen/view/viewForm.html +++ b/modules/core/src/main/resources/templates/modules/gen/view/viewForm.html @@ -95,6 +95,12 @@ BpmButton.init = function(task){ BpmButton.complete = function($this, task){ $('#status').val(Global.STATUS_AUDIT); }; +BpmButton.restart = function($this, task){ + js.confirm('\${text("确认要重启流程吗?")}', function(){ + $('#status').val("6"); + $('#inputForm').submit(); + }); +}; // 表单验证提交事件 <% } %> $('#inputForm').validate({