From 2adb2f203eb8a55dd9bdbf3b4dab115a17fa67e1 Mon Sep 17 00:00:00 2001 From: yuchen Date: Wed, 8 Apr 2026 12:08:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E5=BC=95=E6=93=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/workflow/WfNodeDefinitionDao.java | 13 + .../dao/workflow/WfProcessDefinitionDao.java | 13 + .../dao/workflow/WfProcessInstanceDao.java | 13 + .../com/sipai/dao/workflow/WfTaskDao.java | 13 + .../sipai/dao/workflow/WfTransitionDao.java | 13 + .../entity/workflow/WfNodeDefinition.java | 70 +++ .../entity/workflow/WfProcessDefinition.java | 79 +++ .../entity/workflow/WfProcessInstance.java | 88 ++++ .../com/sipai/entity/workflow/WfTask.java | 106 ++++ .../sipai/entity/workflow/WfTransition.java | 70 +++ .../workflow/WfNodeDefinitionMapper.xml | 61 +++ .../workflow/WfProcessDefinitionMapper.xml | 61 +++ .../workflow/WfProcessInstanceMapper.xml | 64 +++ .../sipai/mapper/workflow/WfTaskMapper.xml | 72 +++ .../mapper/workflow/WfTransitionMapper.xml | 61 +++ .../service/activiti/WorkflowService.java | 57 ++- .../com/sipai/workflow/IWorkflowEngine.java | 151 ++++++ .../sipai/workflow/WorkflowEngineConfig.java | 35 ++ .../activiti/ActivitiWorkflowEngine.java | 299 +++++++++++ .../workflow/simple/SimpleWorkflowEngine.java | 465 ++++++++++++++++++ src/main/resources/sql/wf_tables.sql | 90 ++++ .../专项安全检查(safety_check_special).sql | 40 ++ .../workflow_init/丢失申请(Lose_Apply).sql | 40 ++ .../临时任务(Administration_Temporary).sql | 40 ++ .../保养工单(Workorder_Maintain).sql | 40 ++ .../workflow_init/保养计划(Maintain_Plan).sql | 40 ++ .../sql/workflow_init/入库管理(In_Stock).sql | 40 ++ .../公司运维(Business_Maintenance).sql | 40 ++ .../公司采购(Business_Purchase).sql | 40 ++ .../内部作业会签(safety_job_inside).sql | 40 ++ .../workflow_init/出售申请(Sale_Apply).sql | 40 ++ .../sql/workflow_init/出库管理(Out_Stock).sql | 40 ++ .../化验管理(TestManagement).sql | 40 ++ .../workflow_init/参观申请(Visit_Apply).sql | 40 ++ .../参观登记(Visit_Register).sql | 40 ++ .../合同管理(Business_Contract).sql | 40 ++ .../合理化建议(Reasonable_Advice).sql | 40 ++ .../sql/workflow_init/吐槽内容(Roast).sql | 40 ++ .../周期常规任务(Routine_Work).sql | 40 ++ .../处级物资领用(Scetion_Stock).sql | 40 ++ .../workflow_init/大修计划(Overhaul_PLAN).sql | 40 ++ .../sql/workflow_init/大修项目(Overhaul).sql | 40 ++ .../workflow_init/安装调试(Install_Debug).sql | 40 ++ .../客户运维(System_Maintenance).sql | 77 +++ .../巡检计划确认(Patrol_Record).sql | 40 ++ .../工艺调整(Process_Adjustment).sql | 40 ++ .../workflow_init/库存盘点(Stock_Check).sql | 40 ++ ...上报-设备(Workorder_Abnormity_Equipment).sql | 40 ++ ...报-设施(Workorder_Abnormity_Facilities).sql | 40 ++ ...异常上报-运行(Workorder_Abnormity_Run).sql | 40 ++ .../workflow_init/报废申请(Scrap_Apply).sql | 40 ++ .../workflow_init/报表审核(Report_Check).sql | 40 ++ .../workflow_init/招标比价(Bidding_Price).sql | 40 ++ .../指标控制(Administration_IndexWork).sql | 40 ++ .../方案编制(Programme_Write).sql | 40 ++ .../日常安全检查(safety_check_dayly).sql | 40 ++ .../workflow_init/水质化验(Water_Test).sql | 40 ++ .../组织工作(Administration_Organization).sql | 40 ++ .../绩效方案审核(KPI_MAKE_PLAN).sql | 40 ++ .../维修工单(Workorder_Repair).sql | 40 ++ .../维修流程(Maintenance_Repair).sql | 40 ++ .../workflow_init/维修计划(Repair_Plan).sql | 40 ++ ...合安全检查(safety_check_comprehensive).sql | 40 ++ .../workflow_init/考核项目评分(KPI_MARK).sql | 40 ++ .../workflow_init/药剂管理(Raw_Material).sql | 40 ++ .../设备停用申请(EquipmentStop_Apply).sql | 40 ++ .../请假补假(Administration_Leave).sql | 64 +++ .../调拨申请(Transfers_Apply).sql | 40 ++ .../workflow_init/车辆维保(Maintain_Car).sql | 40 ++ .../workflow_init/车辆维修(Repair_Car).sql | 40 ++ .../workflow_init/项目验收(Project_Check).sql | 40 ++ .../预案工作(Administration_Reserve).sql | 40 ++ .../验收申请(Acceptance_Apply).sql | 40 ++ src/main/resources/workflow.properties | 2 + src/main/webapp/WEB-INF/spring-mybatis.xml | 1 + 75 files changed, 4018 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/sipai/dao/workflow/WfNodeDefinitionDao.java create mode 100644 src/main/java/com/sipai/dao/workflow/WfProcessDefinitionDao.java create mode 100644 src/main/java/com/sipai/dao/workflow/WfProcessInstanceDao.java create mode 100644 src/main/java/com/sipai/dao/workflow/WfTaskDao.java create mode 100644 src/main/java/com/sipai/dao/workflow/WfTransitionDao.java create mode 100644 src/main/java/com/sipai/entity/workflow/WfNodeDefinition.java create mode 100644 src/main/java/com/sipai/entity/workflow/WfProcessDefinition.java create mode 100644 src/main/java/com/sipai/entity/workflow/WfProcessInstance.java create mode 100644 src/main/java/com/sipai/entity/workflow/WfTask.java create mode 100644 src/main/java/com/sipai/entity/workflow/WfTransition.java create mode 100644 src/main/java/com/sipai/mapper/workflow/WfNodeDefinitionMapper.xml create mode 100644 src/main/java/com/sipai/mapper/workflow/WfProcessDefinitionMapper.xml create mode 100644 src/main/java/com/sipai/mapper/workflow/WfProcessInstanceMapper.xml create mode 100644 src/main/java/com/sipai/mapper/workflow/WfTaskMapper.xml create mode 100644 src/main/java/com/sipai/mapper/workflow/WfTransitionMapper.xml create mode 100644 src/main/java/com/sipai/workflow/IWorkflowEngine.java create mode 100644 src/main/java/com/sipai/workflow/WorkflowEngineConfig.java create mode 100644 src/main/java/com/sipai/workflow/activiti/ActivitiWorkflowEngine.java create mode 100644 src/main/java/com/sipai/workflow/simple/SimpleWorkflowEngine.java create mode 100644 src/main/resources/sql/wf_tables.sql create mode 100644 src/main/resources/sql/workflow_init/专项安全检查(safety_check_special).sql create mode 100644 src/main/resources/sql/workflow_init/丢失申请(Lose_Apply).sql create mode 100644 src/main/resources/sql/workflow_init/临时任务(Administration_Temporary).sql create mode 100644 src/main/resources/sql/workflow_init/保养工单(Workorder_Maintain).sql create mode 100644 src/main/resources/sql/workflow_init/保养计划(Maintain_Plan).sql create mode 100644 src/main/resources/sql/workflow_init/入库管理(In_Stock).sql create mode 100644 src/main/resources/sql/workflow_init/公司运维(Business_Maintenance).sql create mode 100644 src/main/resources/sql/workflow_init/公司采购(Business_Purchase).sql create mode 100644 src/main/resources/sql/workflow_init/内部作业会签(safety_job_inside).sql create mode 100644 src/main/resources/sql/workflow_init/出售申请(Sale_Apply).sql create mode 100644 src/main/resources/sql/workflow_init/出库管理(Out_Stock).sql create mode 100644 src/main/resources/sql/workflow_init/化验管理(TestManagement).sql create mode 100644 src/main/resources/sql/workflow_init/参观申请(Visit_Apply).sql create mode 100644 src/main/resources/sql/workflow_init/参观登记(Visit_Register).sql create mode 100644 src/main/resources/sql/workflow_init/合同管理(Business_Contract).sql create mode 100644 src/main/resources/sql/workflow_init/合理化建议(Reasonable_Advice).sql create mode 100644 src/main/resources/sql/workflow_init/吐槽内容(Roast).sql create mode 100644 src/main/resources/sql/workflow_init/周期常规任务(Routine_Work).sql create mode 100644 src/main/resources/sql/workflow_init/处级物资领用(Scetion_Stock).sql create mode 100644 src/main/resources/sql/workflow_init/大修计划(Overhaul_PLAN).sql create mode 100644 src/main/resources/sql/workflow_init/大修项目(Overhaul).sql create mode 100644 src/main/resources/sql/workflow_init/安装调试(Install_Debug).sql create mode 100644 src/main/resources/sql/workflow_init/客户运维(System_Maintenance).sql create mode 100644 src/main/resources/sql/workflow_init/巡检计划确认(Patrol_Record).sql create mode 100644 src/main/resources/sql/workflow_init/工艺调整(Process_Adjustment).sql create mode 100644 src/main/resources/sql/workflow_init/库存盘点(Stock_Check).sql create mode 100644 src/main/resources/sql/workflow_init/异常上报-设备(Workorder_Abnormity_Equipment).sql create mode 100644 src/main/resources/sql/workflow_init/异常上报-设施(Workorder_Abnormity_Facilities).sql create mode 100644 src/main/resources/sql/workflow_init/异常上报-运行(Workorder_Abnormity_Run).sql create mode 100644 src/main/resources/sql/workflow_init/报废申请(Scrap_Apply).sql create mode 100644 src/main/resources/sql/workflow_init/报表审核(Report_Check).sql create mode 100644 src/main/resources/sql/workflow_init/招标比价(Bidding_Price).sql create mode 100644 src/main/resources/sql/workflow_init/指标控制(Administration_IndexWork).sql create mode 100644 src/main/resources/sql/workflow_init/方案编制(Programme_Write).sql create mode 100644 src/main/resources/sql/workflow_init/日常安全检查(safety_check_dayly).sql create mode 100644 src/main/resources/sql/workflow_init/水质化验(Water_Test).sql create mode 100644 src/main/resources/sql/workflow_init/组织工作(Administration_Organization).sql create mode 100644 src/main/resources/sql/workflow_init/绩效方案审核(KPI_MAKE_PLAN).sql create mode 100644 src/main/resources/sql/workflow_init/维修工单(Workorder_Repair).sql create mode 100644 src/main/resources/sql/workflow_init/维修流程(Maintenance_Repair).sql create mode 100644 src/main/resources/sql/workflow_init/维修计划(Repair_Plan).sql create mode 100644 src/main/resources/sql/workflow_init/综合安全检查(safety_check_comprehensive).sql create mode 100644 src/main/resources/sql/workflow_init/考核项目评分(KPI_MARK).sql create mode 100644 src/main/resources/sql/workflow_init/药剂管理(Raw_Material).sql create mode 100644 src/main/resources/sql/workflow_init/设备停用申请(EquipmentStop_Apply).sql create mode 100644 src/main/resources/sql/workflow_init/请假补假(Administration_Leave).sql create mode 100644 src/main/resources/sql/workflow_init/调拨申请(Transfers_Apply).sql create mode 100644 src/main/resources/sql/workflow_init/车辆维保(Maintain_Car).sql create mode 100644 src/main/resources/sql/workflow_init/车辆维修(Repair_Car).sql create mode 100644 src/main/resources/sql/workflow_init/项目验收(Project_Check).sql create mode 100644 src/main/resources/sql/workflow_init/预案工作(Administration_Reserve).sql create mode 100644 src/main/resources/sql/workflow_init/验收申请(Acceptance_Apply).sql create mode 100644 src/main/resources/workflow.properties diff --git a/src/main/java/com/sipai/dao/workflow/WfNodeDefinitionDao.java b/src/main/java/com/sipai/dao/workflow/WfNodeDefinitionDao.java new file mode 100644 index 00000000..dfea9238 --- /dev/null +++ b/src/main/java/com/sipai/dao/workflow/WfNodeDefinitionDao.java @@ -0,0 +1,13 @@ +package com.sipai.dao.workflow; + +import com.sipai.dao.base.CommDaoImpl; +import com.sipai.entity.workflow.WfNodeDefinition; +import org.springframework.stereotype.Repository; + +@Repository +public class WfNodeDefinitionDao extends CommDaoImpl { + public WfNodeDefinitionDao() { + super(); + this.setMappernamespace("workflow.WfNodeDefinitionMapper"); + } +} diff --git a/src/main/java/com/sipai/dao/workflow/WfProcessDefinitionDao.java b/src/main/java/com/sipai/dao/workflow/WfProcessDefinitionDao.java new file mode 100644 index 00000000..ad938179 --- /dev/null +++ b/src/main/java/com/sipai/dao/workflow/WfProcessDefinitionDao.java @@ -0,0 +1,13 @@ +package com.sipai.dao.workflow; + +import com.sipai.dao.base.CommDaoImpl; +import com.sipai.entity.workflow.WfProcessDefinition; +import org.springframework.stereotype.Repository; + +@Repository +public class WfProcessDefinitionDao extends CommDaoImpl { + public WfProcessDefinitionDao() { + super(); + this.setMappernamespace("workflow.WfProcessDefinitionMapper"); + } +} diff --git a/src/main/java/com/sipai/dao/workflow/WfProcessInstanceDao.java b/src/main/java/com/sipai/dao/workflow/WfProcessInstanceDao.java new file mode 100644 index 00000000..a3c1a7a2 --- /dev/null +++ b/src/main/java/com/sipai/dao/workflow/WfProcessInstanceDao.java @@ -0,0 +1,13 @@ +package com.sipai.dao.workflow; + +import com.sipai.dao.base.CommDaoImpl; +import com.sipai.entity.workflow.WfProcessInstance; +import org.springframework.stereotype.Repository; + +@Repository +public class WfProcessInstanceDao extends CommDaoImpl { + public WfProcessInstanceDao() { + super(); + this.setMappernamespace("workflow.WfProcessInstanceMapper"); + } +} diff --git a/src/main/java/com/sipai/dao/workflow/WfTaskDao.java b/src/main/java/com/sipai/dao/workflow/WfTaskDao.java new file mode 100644 index 00000000..6b354bf6 --- /dev/null +++ b/src/main/java/com/sipai/dao/workflow/WfTaskDao.java @@ -0,0 +1,13 @@ +package com.sipai.dao.workflow; + +import com.sipai.dao.base.CommDaoImpl; +import com.sipai.entity.workflow.WfTask; +import org.springframework.stereotype.Repository; + +@Repository +public class WfTaskDao extends CommDaoImpl { + public WfTaskDao() { + super(); + this.setMappernamespace("workflow.WfTaskMapper"); + } +} diff --git a/src/main/java/com/sipai/dao/workflow/WfTransitionDao.java b/src/main/java/com/sipai/dao/workflow/WfTransitionDao.java new file mode 100644 index 00000000..30a67ca4 --- /dev/null +++ b/src/main/java/com/sipai/dao/workflow/WfTransitionDao.java @@ -0,0 +1,13 @@ +package com.sipai.dao.workflow; + +import com.sipai.dao.base.CommDaoImpl; +import com.sipai.entity.workflow.WfTransition; +import org.springframework.stereotype.Repository; + +@Repository +public class WfTransitionDao extends CommDaoImpl { + public WfTransitionDao() { + super(); + this.setMappernamespace("workflow.WfTransitionMapper"); + } +} diff --git a/src/main/java/com/sipai/entity/workflow/WfNodeDefinition.java b/src/main/java/com/sipai/entity/workflow/WfNodeDefinition.java new file mode 100644 index 00000000..da842277 --- /dev/null +++ b/src/main/java/com/sipai/entity/workflow/WfNodeDefinition.java @@ -0,0 +1,70 @@ +package com.sipai.entity.workflow; + +import com.sipai.entity.base.SQLAdapter; + +public class WfNodeDefinition extends SQLAdapter { + + private Long id; + private Long processDefId; + private String nodeKey; + private String nodeName; + private String nodeType; + private Integer sortOrder; + private String description; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getProcessDefId() { + return processDefId; + } + + public void setProcessDefId(Long processDefId) { + this.processDefId = processDefId; + } + + public String getNodeKey() { + return nodeKey; + } + + public void setNodeKey(String nodeKey) { + this.nodeKey = nodeKey; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public String getNodeType() { + return nodeType; + } + + public void setNodeType(String nodeType) { + this.nodeType = nodeType; + } + + public Integer getSortOrder() { + return sortOrder; + } + + public void setSortOrder(Integer sortOrder) { + this.sortOrder = sortOrder; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/sipai/entity/workflow/WfProcessDefinition.java b/src/main/java/com/sipai/entity/workflow/WfProcessDefinition.java new file mode 100644 index 00000000..58b3cdd3 --- /dev/null +++ b/src/main/java/com/sipai/entity/workflow/WfProcessDefinition.java @@ -0,0 +1,79 @@ +package com.sipai.entity.workflow; + +import com.sipai.entity.base.SQLAdapter; + +public class WfProcessDefinition extends SQLAdapter { + + private Long id; + private String processKey; + private String processName; + private String description; + private Integer version; + private String status; + private String createTime; + private String updateTime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getProcessKey() { + return processKey; + } + + public void setProcessKey(String processKey) { + this.processKey = processKey; + } + + public String getProcessName() { + return processName; + } + + public void setProcessName(String processName) { + this.processName = processName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version = version; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } +} diff --git a/src/main/java/com/sipai/entity/workflow/WfProcessInstance.java b/src/main/java/com/sipai/entity/workflow/WfProcessInstance.java new file mode 100644 index 00000000..21a4a006 --- /dev/null +++ b/src/main/java/com/sipai/entity/workflow/WfProcessInstance.java @@ -0,0 +1,88 @@ +package com.sipai.entity.workflow; + +import com.sipai.entity.base.SQLAdapter; + +public class WfProcessInstance extends SQLAdapter { + + private Long id; + private Long processDefId; + private String processKey; + private String businessKey; + private String starter; + private String status; + private Long currentNodeId; + private String createTime; + private String endTime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getProcessDefId() { + return processDefId; + } + + public void setProcessDefId(Long processDefId) { + this.processDefId = processDefId; + } + + public String getProcessKey() { + return processKey; + } + + public void setProcessKey(String processKey) { + this.processKey = processKey; + } + + public String getBusinessKey() { + return businessKey; + } + + public void setBusinessKey(String businessKey) { + this.businessKey = businessKey; + } + + public String getStarter() { + return starter; + } + + public void setStarter(String starter) { + this.starter = starter; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Long getCurrentNodeId() { + return currentNodeId; + } + + public void setCurrentNodeId(Long currentNodeId) { + this.currentNodeId = currentNodeId; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } +} diff --git a/src/main/java/com/sipai/entity/workflow/WfTask.java b/src/main/java/com/sipai/entity/workflow/WfTask.java new file mode 100644 index 00000000..8d60d6d6 --- /dev/null +++ b/src/main/java/com/sipai/entity/workflow/WfTask.java @@ -0,0 +1,106 @@ +package com.sipai.entity.workflow; + +import com.sipai.entity.base.SQLAdapter; + +public class WfTask extends SQLAdapter { + + private Long id; + private Long processInstanceId; + private Long nodeDefId; + private String nodeName; + private String assignee; + private String candidateUsers; + private String status; + private String result; + private String comment; + private String createTime; + private String completeTime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getProcessInstanceId() { + return processInstanceId; + } + + public void setProcessInstanceId(Long processInstanceId) { + this.processInstanceId = processInstanceId; + } + + public Long getNodeDefId() { + return nodeDefId; + } + + public void setNodeDefId(Long nodeDefId) { + this.nodeDefId = nodeDefId; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public String getAssignee() { + return assignee; + } + + public void setAssignee(String assignee) { + this.assignee = assignee; + } + + public String getCandidateUsers() { + return candidateUsers; + } + + public void setCandidateUsers(String candidateUsers) { + this.candidateUsers = candidateUsers; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCompleteTime() { + return completeTime; + } + + public void setCompleteTime(String completeTime) { + this.completeTime = completeTime; + } +} diff --git a/src/main/java/com/sipai/entity/workflow/WfTransition.java b/src/main/java/com/sipai/entity/workflow/WfTransition.java new file mode 100644 index 00000000..268d6ee4 --- /dev/null +++ b/src/main/java/com/sipai/entity/workflow/WfTransition.java @@ -0,0 +1,70 @@ +package com.sipai.entity.workflow; + +import com.sipai.entity.base.SQLAdapter; + +public class WfTransition extends SQLAdapter { + + private Long id; + private Long processDefId; + private Long sourceNodeId; + private Long targetNodeId; + private String conditionExpr; + private String transitionName; + private Integer sortOrder; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getProcessDefId() { + return processDefId; + } + + public void setProcessDefId(Long processDefId) { + this.processDefId = processDefId; + } + + public Long getSourceNodeId() { + return sourceNodeId; + } + + public void setSourceNodeId(Long sourceNodeId) { + this.sourceNodeId = sourceNodeId; + } + + public Long getTargetNodeId() { + return targetNodeId; + } + + public void setTargetNodeId(Long targetNodeId) { + this.targetNodeId = targetNodeId; + } + + public String getConditionExpr() { + return conditionExpr; + } + + public void setConditionExpr(String conditionExpr) { + this.conditionExpr = conditionExpr; + } + + public String getTransitionName() { + return transitionName; + } + + public void setTransitionName(String transitionName) { + this.transitionName = transitionName; + } + + public Integer getSortOrder() { + return sortOrder; + } + + public void setSortOrder(Integer sortOrder) { + this.sortOrder = sortOrder; + } +} diff --git a/src/main/java/com/sipai/mapper/workflow/WfNodeDefinitionMapper.xml b/src/main/java/com/sipai/mapper/workflow/WfNodeDefinitionMapper.xml new file mode 100644 index 00000000..9af98cc5 --- /dev/null +++ b/src/main/java/com/sipai/mapper/workflow/WfNodeDefinitionMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + id, process_def_id, node_key, node_name, node_type, sort_order, description + + + + + insert into [OA_ELM].[dbo].wf_node_definition + + process_def_id, + node_key, + node_name, + node_type, + sort_order, + description, + + + #{processDefId,jdbcType=BIGINT}, + #{nodeKey,jdbcType=VARCHAR}, + #{nodeName,jdbcType=NVARCHAR}, + #{nodeType,jdbcType=VARCHAR}, + #{sortOrder,jdbcType=INTEGER}, + #{description,jdbcType=NVARCHAR}, + + + + update [OA_ELM].[dbo].wf_node_definition + + process_def_id = #{processDefId,jdbcType=BIGINT}, + node_key = #{nodeKey,jdbcType=VARCHAR}, + node_name = #{nodeName,jdbcType=NVARCHAR}, + node_type = #{nodeType,jdbcType=VARCHAR}, + sort_order = #{sortOrder,jdbcType=INTEGER}, + description = #{description,jdbcType=NVARCHAR}, + + where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_node_definition where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_node_definition ${where} + + diff --git a/src/main/java/com/sipai/mapper/workflow/WfProcessDefinitionMapper.xml b/src/main/java/com/sipai/mapper/workflow/WfProcessDefinitionMapper.xml new file mode 100644 index 00000000..1c16577d --- /dev/null +++ b/src/main/java/com/sipai/mapper/workflow/WfProcessDefinitionMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + id, process_key, process_name, description, version, status, create_time, update_time + + + + + insert into [OA_ELM].[dbo].wf_process_definition + + process_key, + process_name, + description, + version, + status, + + + #{processKey,jdbcType=VARCHAR}, + #{processName,jdbcType=NVARCHAR}, + #{description,jdbcType=NVARCHAR}, + #{version,jdbcType=INTEGER}, + #{status,jdbcType=VARCHAR}, + + + + update [OA_ELM].[dbo].wf_process_definition + + process_key = #{processKey,jdbcType=VARCHAR}, + process_name = #{processName,jdbcType=NVARCHAR}, + description = #{description,jdbcType=NVARCHAR}, + version = #{version,jdbcType=INTEGER}, + status = #{status,jdbcType=VARCHAR}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_process_definition where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_process_definition ${where} + + diff --git a/src/main/java/com/sipai/mapper/workflow/WfProcessInstanceMapper.xml b/src/main/java/com/sipai/mapper/workflow/WfProcessInstanceMapper.xml new file mode 100644 index 00000000..5feb58db --- /dev/null +++ b/src/main/java/com/sipai/mapper/workflow/WfProcessInstanceMapper.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + id, process_def_id, process_key, business_key, starter, status, current_node_id, create_time, end_time + + + + + insert into [OA_ELM].[dbo].wf_process_instance + + process_def_id, + process_key, + business_key, + starter, + status, + current_node_id, + + + #{processDefId,jdbcType=BIGINT}, + #{processKey,jdbcType=VARCHAR}, + #{businessKey,jdbcType=VARCHAR}, + #{starter,jdbcType=VARCHAR}, + #{status,jdbcType=VARCHAR}, + #{currentNodeId,jdbcType=BIGINT}, + + + + update [OA_ELM].[dbo].wf_process_instance + + process_def_id = #{processDefId,jdbcType=BIGINT}, + process_key = #{processKey,jdbcType=VARCHAR}, + business_key = #{businessKey,jdbcType=VARCHAR}, + starter = #{starter,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + current_node_id = #{currentNodeId,jdbcType=BIGINT}, + end_time = #{endTime,jdbcType=TIMESTAMP}, + + where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_process_instance where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_process_instance ${where} + + diff --git a/src/main/java/com/sipai/mapper/workflow/WfTaskMapper.xml b/src/main/java/com/sipai/mapper/workflow/WfTaskMapper.xml new file mode 100644 index 00000000..52355cb3 --- /dev/null +++ b/src/main/java/com/sipai/mapper/workflow/WfTaskMapper.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + id, process_instance_id, node_def_id, node_name, assignee, candidate_users, status, result, comment, create_time, complete_time + + + + + insert into [OA_ELM].[dbo].wf_task + + process_instance_id, + node_def_id, + node_name, + assignee, + candidate_users, + status, + result, + comment, + + + #{processInstanceId,jdbcType=BIGINT}, + #{nodeDefId,jdbcType=BIGINT}, + #{nodeName,jdbcType=NVARCHAR}, + #{assignee,jdbcType=VARCHAR}, + #{candidateUsers,jdbcType=VARCHAR}, + #{status,jdbcType=VARCHAR}, + #{result,jdbcType=VARCHAR}, + #{comment,jdbcType=NVARCHAR}, + + + + update [OA_ELM].[dbo].wf_task + + process_instance_id = #{processInstanceId,jdbcType=BIGINT}, + node_def_id = #{nodeDefId,jdbcType=BIGINT}, + node_name = #{nodeName,jdbcType=NVARCHAR}, + assignee = #{assignee,jdbcType=VARCHAR}, + candidate_users = #{candidateUsers,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + result = #{result,jdbcType=VARCHAR}, + comment = #{comment,jdbcType=NVARCHAR}, + complete_time = #{completeTime,jdbcType=TIMESTAMP}, + + where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_task where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_task ${where} + + diff --git a/src/main/java/com/sipai/mapper/workflow/WfTransitionMapper.xml b/src/main/java/com/sipai/mapper/workflow/WfTransitionMapper.xml new file mode 100644 index 00000000..a9e932f1 --- /dev/null +++ b/src/main/java/com/sipai/mapper/workflow/WfTransitionMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + id, process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order + + + + + insert into [OA_ELM].[dbo].wf_transition + + process_def_id, + source_node_id, + target_node_id, + condition_expr, + transition_name, + sort_order, + + + #{processDefId,jdbcType=BIGINT}, + #{sourceNodeId,jdbcType=BIGINT}, + #{targetNodeId,jdbcType=BIGINT}, + #{conditionExpr,jdbcType=VARCHAR}, + #{transitionName,jdbcType=NVARCHAR}, + #{sortOrder,jdbcType=INTEGER}, + + + + update [OA_ELM].[dbo].wf_transition + + process_def_id = #{processDefId,jdbcType=BIGINT}, + source_node_id = #{sourceNodeId,jdbcType=BIGINT}, + target_node_id = #{targetNodeId,jdbcType=BIGINT}, + condition_expr = #{conditionExpr,jdbcType=VARCHAR}, + transition_name = #{transitionName,jdbcType=NVARCHAR}, + sort_order = #{sortOrder,jdbcType=INTEGER}, + + where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_transition where id = #{id,jdbcType=BIGINT} + + + delete from [OA_ELM].[dbo].wf_transition ${where} + + diff --git a/src/main/java/com/sipai/service/activiti/WorkflowService.java b/src/main/java/com/sipai/service/activiti/WorkflowService.java index ba9297a4..62df89b2 100644 --- a/src/main/java/com/sipai/service/activiti/WorkflowService.java +++ b/src/main/java/com/sipai/service/activiti/WorkflowService.java @@ -60,6 +60,8 @@ import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.sipai.workflow.IWorkflowEngine; + import javax.annotation.Resource; import java.text.SimpleDateFormat; import java.util.*; @@ -71,6 +73,8 @@ public class WorkflowService { private static Logger logger = LoggerFactory.getLogger(WorkflowService.class); + @Resource + private IWorkflowEngine workflowEngine; private RuntimeService runtimeService; @@ -154,38 +158,51 @@ public class WorkflowService { @Resource private OverhaulService overhaulService; - //启动流程 - public ProcessInstance startWorkflow(String businessKey, String userId, String processDefKey, Map variables) { - ProcessInstance processInstance = null; - try { - ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery() - .processDefinitionKey(processDefKey).orderByProcessDefinitionVersion().desc(); -// ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefID); - List processDefinitionList = processDefinitionQuery.list(); - if (processDefinitionList != null && processDefinitionList.size() > 0) { - // 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中 - identityService.setAuthenticatedUserId(userId); - processInstance = runtimeService.startProcessInstanceById(processDefinitionList.get(0).getId(), businessKey, variables); - } + /** + * 获取工作流引擎实例(供外部需要直接访问引擎的场景使用) + */ + public IWorkflowEngine getWorkflowEngine() { + return workflowEngine; + } - } finally { - identityService.setAuthenticatedUserId(null); + //启动流程(委托给IWorkflowEngine) + public ProcessInstance startWorkflow(String businessKey, String userId, String processDefKey, Map variables) { + // 通过统一引擎接口启动流程 + String processInstanceId = workflowEngine.startProcess(businessKey, userId, processDefKey, variables); + if (processInstanceId != null) { + // activiti模式下通过runtimeService查询返回原始ProcessInstance对象 + // simple模式下runtimeService可能为null,返回null(Controller只需要getId(),可通过processInstanceId获取) + try { + if (runtimeService != null) { + return runtimeService.createProcessInstanceQuery() + .processInstanceId(processInstanceId).singleResult(); + } + } catch (Exception e) { + logger.warn("查询ProcessInstance失败,processInstanceId={}", processInstanceId); + } } - return processInstance; + return null; } /** - * 删除运行中流程 + * 启动流程(返回流程实例ID,推荐新代码使用此方法) + */ + public String startWorkflowReturnId(String businessKey, String userId, String processDefKey, Map variables) { + return workflowEngine.startProcess(businessKey, userId, processDefKey, variables); + } + + /** + * 删除运行中流程(委托给IWorkflowEngine) */ public void delProcessInstance(String processInstanceId) { - runtimeService.deleteProcessInstance(processInstanceId, ""); + workflowEngine.deleteProcessInstance(processInstanceId); } /** - * 删除历史流程 + * 删除历史流程(委托给IWorkflowEngine) */ public void delHistoryInstance(String processInstanceId) { - historyService.deleteHistoricProcessInstance(processInstanceId); + workflowEngine.deleteHistoricInstance(processInstanceId); } /** diff --git a/src/main/java/com/sipai/workflow/IWorkflowEngine.java b/src/main/java/com/sipai/workflow/IWorkflowEngine.java new file mode 100644 index 00000000..7f650b1c --- /dev/null +++ b/src/main/java/com/sipai/workflow/IWorkflowEngine.java @@ -0,0 +1,151 @@ +package com.sipai.workflow; + +import java.util.List; +import java.util.Map; + +/** + * 工作流引擎统一接口 + * 抽象核心流程操作,支持 Activiti 和自研引擎切换 + */ +public interface IWorkflowEngine { + + /** + * 启动流程 + * + * @param businessKey 业务数据主键 + * @param userId 发起人ID + * @param processDefKey 流程定义key(对应ProcessType.id) + * @param variables 流程变量 + * @return 流程实例ID + */ + String startProcess(String businessKey, String userId, String processDefKey, Map variables); + + /** + * 完成任务(审批通过/驳回/作废) + * + * @param taskId 任务ID + * @param variables 流程变量(pass、route、userIds等) + */ + void completeTask(String taskId, Map variables); + + /** + * 删除运行中流程实例 + * + * @param processInstanceId 流程实例ID + */ + void deleteProcessInstance(String processInstanceId); + + /** + * 删除历史流程实例 + * + * @param processInstanceId 流程实例ID + */ + void deleteHistoricInstance(String processInstanceId); + + /** + * 查询上一个审批节点的历史任务信息 + * + * @param taskId 当前任务ID + * @return 上一节点信息 Map(包含 id、name、assignee、processInstanceId、taskDefinitionKey 等) + */ + Map queryUpOneNode(String taskId); + + /** + * 获取流程实例当前活跃的节点ID列表 + * + * @param processInstanceId 流程实例ID + * @return 活跃节点ID列表 + */ + List getActiveActivityIds(String processInstanceId); + + /** + * 根据流程实例ID查询当前活跃任务信息 + * + * @param processInstanceId 流程实例ID + * @return 任务信息 Map(包含 id、name、assignee、candidateUsers、processInstanceId、createTime 等) + */ + Map getActiveTask(String processInstanceId); + + /** + * 根据任务ID获取任务信息 + * + * @param taskId 任务ID + * @return 任务信息 Map + */ + Map getTask(String taskId); + + /** + * 根据任务ID获取流程变量 + * + * @param taskId 任务ID + * @return 流程变量 + */ + Map getTaskVariables(String taskId); + + /** + * 根据用户ID和流程定义key查询待办任务列表 + * + * @param userId 用户ID + * @param modelKey 流程定义key + * @return 待办任务列表,每个元素包含任务信息Map + */ + List> findTodoTasksByUser(String userId, String modelKey); + + /** + * 根据用户ID查询待办任务列表(不限流程类型) + * + * @param userId 用户ID + * @return 待办任务列表 + */ + List> findTodoTasksByUser(String userId); + + /** + * 查询用户已办任务列表 + * + * @param assignee 用户ID + * @param modelKey 流程定义key + * @return 已办任务列表 + */ + List> findDoneTasks(String assignee, String modelKey); + + /** + * 查询已完成的流程实例 + * + * @return 已完成流程实例列表 + */ + List> findFinishedProcessInstances(); + + /** + * 查询运行中的流程实例 + * + * @param processDefinitionKey 流程定义key(可为null查全部) + * @param offset 分页偏移 + * @param limit 分页大小 + * @return 运行中流程实例列表 + */ + List> findRunningProcessInstances(String processDefinitionKey, int offset, int limit); + + /** + * 获取流程实例信息 + * + * @param processInstanceId 流程实例ID + * @return 流程实例信息 Map(包含 id、businessKey、processDefinitionId、processDefinitionKey、suspended 等) + */ + Map getProcessInstance(String processInstanceId); + + /** + * 获取流程定义信息 + * + * @param processDefinitionId 流程定义ID + * @return 流程定义信息 Map(包含 id、key、name、version、deploymentId 等) + */ + Map getProcessDefinition(String processDefinitionId); + + /** + * 签收任务 + * + * @param taskId 任务ID + * @param userId 签收人ID + */ + void claimTask(String taskId, String userId); +} diff --git a/src/main/java/com/sipai/workflow/WorkflowEngineConfig.java b/src/main/java/com/sipai/workflow/WorkflowEngineConfig.java new file mode 100644 index 00000000..a7171cde --- /dev/null +++ b/src/main/java/com/sipai/workflow/WorkflowEngineConfig.java @@ -0,0 +1,35 @@ +package com.sipai.workflow; + +import com.sipai.workflow.activiti.ActivitiWorkflowEngine; +import com.sipai.workflow.simple.SimpleWorkflowEngine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 工作流引擎配置类 + * 根据 workflow.engine 配置值注入对应的 IWorkflowEngine 实现 + * activiti = 使用Activiti引擎(默认) + * simple = 使用自研轻量级引擎 + */ +@Configuration +public class WorkflowEngineConfig { + + private static Logger logger = LoggerFactory.getLogger(WorkflowEngineConfig.class); + + @Value("${workflow.engine:activiti}") + private String engineType; + + @Bean + public IWorkflowEngine workflowEngine() { + if ("simple".equalsIgnoreCase(engineType)) { + logger.info("========== 工作流引擎: 自研SimpleWorkflowEngine =========="); + return new SimpleWorkflowEngine(); + } else { + logger.info("========== 工作流引擎: ActivitiWorkflowEngine =========="); + return new ActivitiWorkflowEngine(); + } + } +} diff --git a/src/main/java/com/sipai/workflow/activiti/ActivitiWorkflowEngine.java b/src/main/java/com/sipai/workflow/activiti/ActivitiWorkflowEngine.java new file mode 100644 index 00000000..abf93a53 --- /dev/null +++ b/src/main/java/com/sipai/workflow/activiti/ActivitiWorkflowEngine.java @@ -0,0 +1,299 @@ +package com.sipai.workflow.activiti; + +import com.sipai.workflow.IWorkflowEngine; +import org.activiti.engine.*; +import org.activiti.engine.history.HistoricProcessInstance; +import org.activiti.engine.history.HistoricTaskInstance; +import org.activiti.engine.repository.ProcessDefinition; +import org.activiti.engine.runtime.ProcessInstance; +import org.activiti.engine.task.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Activiti引擎适配器 + * 将现有Activiti调用逻辑包装为IWorkflowEngine接口实现 + */ +public class ActivitiWorkflowEngine implements IWorkflowEngine { + + private static Logger logger = LoggerFactory.getLogger(ActivitiWorkflowEngine.class); + + @Autowired + private RuntimeService runtimeService; + @Autowired + private TaskService taskService; + @Autowired + private HistoryService historyService; + @Autowired + private RepositoryService repositoryService; + @Autowired + private IdentityService identityService; + + @Override + public String startProcess(String businessKey, String userId, String processDefKey, Map variables) { + try { + List processDefinitionList = repositoryService.createProcessDefinitionQuery() + .processDefinitionKey(processDefKey).orderByProcessDefinitionVersion().desc().list(); + if (processDefinitionList != null && processDefinitionList.size() > 0) { + identityService.setAuthenticatedUserId(userId); + ProcessInstance processInstance = runtimeService.startProcessInstanceById( + processDefinitionList.get(0).getId(), businessKey, variables); + return processInstance.getId(); + } + } finally { + identityService.setAuthenticatedUserId(null); + } + return null; + } + + @Override + public void completeTask(String taskId, Map variables) { + taskService.complete(taskId, variables); + } + + @Override + public void deleteProcessInstance(String processInstanceId) { + runtimeService.deleteProcessInstance(processInstanceId, ""); + } + + @Override + public void deleteHistoricInstance(String processInstanceId) { + historyService.deleteHistoricProcessInstance(processInstanceId); + } + + @Override + public Map queryUpOneNode(String taskId) { + List list = historyService + .createHistoricTaskInstanceQuery() + .taskId(taskId) + .list(); + if (list != null && list.size() > 0) { + HistoricTaskInstance hti = list.get(0); + // 查询同一流程实例中,在当前任务之前完成的最近一个任务 + List upList = historyService + .createHistoricTaskInstanceQuery() + .processInstanceId(hti.getProcessInstanceId()) + .finished() + .orderByHistoricTaskInstanceEndTime().desc() + .list(); + if (upList != null && upList.size() > 0) { + HistoricTaskInstance upTask = upList.get(0); + return historicTaskToMap(upTask); + } + } + return null; + } + + @Override + public List getActiveActivityIds(String processInstanceId) { + return runtimeService.getActiveActivityIds(processInstanceId); + } + + @Override + public Map getActiveTask(String processInstanceId) { + Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult(); + if (task == null) { + return null; + } + return taskToMap(task); + } + + @Override + public Map getTask(String taskId) { + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + if (task == null) { + return null; + } + return taskToMap(task); + } + + @Override + public Map getTaskVariables(String taskId) { + return taskService.getVariables(taskId); + } + + @Override + public List> findTodoTasksByUser(String userId, String modelKey) { + List tasks = taskService.createTaskQuery() + .taskCandidateOrAssigned(userId) + .processDefinitionKey(modelKey) + .list(); + List> result = new ArrayList<>(); + for (Task task : tasks) { + Map map = taskToMap(task); + // 补充流程实例信息 + ProcessInstance pi = runtimeService.createProcessInstanceQuery() + .processInstanceId(task.getProcessInstanceId()).singleResult(); + if (pi != null) { + map.put("businessKey", pi.getBusinessKey()); + map.put("processDefinitionKey", pi.getProcessDefinitionKey()); + map.put("suspended", pi.isSuspended()); + } + result.add(map); + } + return result; + } + + @Override + public List> findTodoTasksByUser(String userId) { + List tasks = taskService.createTaskQuery() + .taskCandidateOrAssigned(userId) + .list(); + List> result = new ArrayList<>(); + for (Task task : tasks) { + Map map = taskToMap(task); + ProcessInstance pi = runtimeService.createProcessInstanceQuery() + .processInstanceId(task.getProcessInstanceId()).singleResult(); + if (pi != null) { + map.put("businessKey", pi.getBusinessKey()); + map.put("processDefinitionKey", pi.getProcessDefinitionKey()); + map.put("suspended", pi.isSuspended()); + } + result.add(map); + } + return result; + } + + @Override + public List> findDoneTasks(String assignee, String modelKey) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + List taskList = historyService.createHistoricTaskInstanceQuery() + .taskAssignee(assignee) + .finished().processDefinitionKey(modelKey) + .list(); + List> result = new ArrayList<>(); + for (HistoricTaskInstance task : taskList) { + Map map = historicTaskToMap(task); + HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery() + .processInstanceId(task.getProcessInstanceId()).singleResult(); + if (hpi != null) { + map.put("businessKey", hpi.getBusinessKey()); + } + result.add(map); + } + return result; + } + + @Override + public List> findFinishedProcessInstances() { + List list = historyService.createHistoricProcessInstanceQuery() + .finished().orderByProcessInstanceEndTime().desc().list(); + List> result = new ArrayList<>(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for (HistoricProcessInstance hpi : list) { + Map map = new HashMap<>(); + map.put("id", hpi.getId()); + map.put("businessKey", hpi.getBusinessKey()); + map.put("processDefinitionId", hpi.getProcessDefinitionId()); + map.put("processDefinitionKey", hpi.getProcessDefinitionKey()); + map.put("startTime", hpi.getStartTime() != null ? sdf.format(hpi.getStartTime()) : null); + map.put("endTime", hpi.getEndTime() != null ? sdf.format(hpi.getEndTime()) : null); + map.put("startActivityId", hpi.getStartActivityId()); + result.add(map); + } + return result; + } + + @Override + public List> findRunningProcessInstances(String processDefinitionKey, int offset, int limit) { + List list; + if (processDefinitionKey != null && !processDefinitionKey.isEmpty()) { + list = runtimeService.createProcessInstanceQuery() + .processDefinitionKey(processDefinitionKey) + .orderByProcessInstanceId().desc() + .listPage(offset, limit); + } else { + list = runtimeService.createProcessInstanceQuery() + .orderByProcessInstanceId().desc() + .listPage(offset, limit); + } + List> result = new ArrayList<>(); + for (ProcessInstance pi : list) { + Map map = new HashMap<>(); + map.put("id", pi.getId()); + map.put("businessKey", pi.getBusinessKey()); + map.put("processDefinitionId", pi.getProcessDefinitionId()); + map.put("processDefinitionKey", pi.getProcessDefinitionKey()); + map.put("suspended", pi.isSuspended()); + result.add(map); + } + return result; + } + + @Override + public Map getProcessInstance(String processInstanceId) { + ProcessInstance pi = runtimeService.createProcessInstanceQuery() + .processInstanceId(processInstanceId).singleResult(); + if (pi == null) { + return null; + } + Map map = new HashMap<>(); + map.put("id", pi.getId()); + map.put("businessKey", pi.getBusinessKey()); + map.put("processDefinitionId", pi.getProcessDefinitionId()); + map.put("processDefinitionKey", pi.getProcessDefinitionKey()); + map.put("suspended", pi.isSuspended()); + map.put("activityId", pi.getActivityId()); + return map; + } + + @Override + public Map getProcessDefinition(String processDefinitionId) { + ProcessDefinition pd = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(processDefinitionId).singleResult(); + if (pd == null) { + return null; + } + Map map = new HashMap<>(); + map.put("id", pd.getId()); + map.put("key", pd.getKey()); + map.put("name", pd.getName()); + map.put("version", pd.getVersion()); + map.put("deploymentId", pd.getDeploymentId()); + map.put("description", pd.getDescription()); + map.put("resourceName", pd.getResourceName()); + return map; + } + + @Override + public void claimTask(String taskId, String userId) { + taskService.claim(taskId, userId); + } + + // ========== 私有工具方法 ========== + + private Map taskToMap(Task task) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Map map = new HashMap<>(); + map.put("id", task.getId()); + map.put("name", task.getName()); + map.put("assignee", task.getAssignee()); + map.put("processInstanceId", task.getProcessInstanceId()); + map.put("processDefinitionId", task.getProcessDefinitionId()); + map.put("executionId", task.getExecutionId()); + map.put("taskDefinitionKey", task.getTaskDefinitionKey()); + map.put("createTime", task.getCreateTime() != null ? sdf.format(task.getCreateTime()) : null); + map.put("description", task.getDescription()); + return map; + } + + private Map historicTaskToMap(HistoricTaskInstance task) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Map map = new HashMap<>(); + map.put("id", task.getId()); + map.put("name", task.getName()); + map.put("assignee", task.getAssignee()); + map.put("processInstanceId", task.getProcessInstanceId()); + map.put("processDefinitionId", task.getProcessDefinitionId()); + map.put("executionId", task.getExecutionId()); + map.put("taskDefinitionKey", task.getTaskDefinitionKey()); + map.put("startTime", task.getStartTime() != null ? sdf.format(task.getStartTime()) : null); + map.put("endTime", task.getEndTime() != null ? sdf.format(task.getEndTime()) : null); + map.put("description", task.getDescription()); + return map; + } +} diff --git a/src/main/java/com/sipai/workflow/simple/SimpleWorkflowEngine.java b/src/main/java/com/sipai/workflow/simple/SimpleWorkflowEngine.java new file mode 100644 index 00000000..0a3b4601 --- /dev/null +++ b/src/main/java/com/sipai/workflow/simple/SimpleWorkflowEngine.java @@ -0,0 +1,465 @@ +package com.sipai.workflow.simple; + +import com.sipai.dao.workflow.*; +import com.sipai.entity.workflow.*; +import com.sipai.workflow.IWorkflowEngine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 自研轻量级工作流引擎 + * 基于 wf_process_definition / wf_node_definition / wf_transition / wf_process_instance / wf_task 五张表实现 + */ +public class SimpleWorkflowEngine implements IWorkflowEngine { + + private static Logger logger = LoggerFactory.getLogger(SimpleWorkflowEngine.class); + + @Resource + private WfProcessDefinitionDao wfProcessDefinitionDao; + @Resource + private WfNodeDefinitionDao wfNodeDefinitionDao; + @Resource + private WfTransitionDao wfTransitionDao; + @Resource + private WfProcessInstanceDao wfProcessInstanceDao; + @Resource + private WfTaskDao wfTaskDao; + + @Override + public String startProcess(String businessKey, String userId, String processDefKey, Map variables) { + // 1. 查找流程定义(最新版本) + WfProcessDefinition queryDef = new WfProcessDefinition(); + queryDef.setWhere("WHERE process_key = '" + processDefKey + "' AND status = 'ACTIVE' ORDER BY version DESC"); + List defList = wfProcessDefinitionDao.selectListByWhere(queryDef); + if (defList == null || defList.isEmpty()) { + logger.error("未找到流程定义: {}", processDefKey); + return null; + } + WfProcessDefinition processDef = defList.get(0); + + // 2. 查找起始节点 + WfNodeDefinition queryNode = new WfNodeDefinition(); + queryNode.setWhere("WHERE process_def_id = " + processDef.getId() + " AND node_type = 'START'"); + List startNodes = wfNodeDefinitionDao.selectListByWhere(queryNode); + if (startNodes == null || startNodes.isEmpty()) { + logger.error("流程定义 {} 未配置START节点", processDefKey); + return null; + } + WfNodeDefinition startNode = startNodes.get(0); + + // 3. 查找START节点的下一个节点(第一个UserTask) + WfTransition queryTrans = new WfTransition(); + queryTrans.setWhere("WHERE source_node_id = " + startNode.getId()); + List transitions = wfTransitionDao.selectListByWhere(queryTrans); + if (transitions == null || transitions.isEmpty()) { + logger.error("START节点 {} 无出口连线", startNode.getId()); + return null; + } + WfNodeDefinition firstTaskNode = wfNodeDefinitionDao.selectByPrimaryKey(transitions.get(0).getTargetNodeId()); + + // 4. 创建流程实例 + WfProcessInstance instance = new WfProcessInstance(); + instance.setProcessDefId(processDef.getId()); + instance.setProcessKey(processDefKey); + instance.setBusinessKey(businessKey); + instance.setStarter(userId); + instance.setStatus("RUNNING"); + instance.setCurrentNodeId(firstTaskNode.getId()); + wfProcessInstanceDao.insertSelective(instance); + + // 5. 创建第一个任务 + WfTask task = new WfTask(); + task.setProcessInstanceId(instance.getId()); + task.setNodeDefId(firstTaskNode.getId()); + task.setNodeName(firstTaskNode.getNodeName()); + task.setStatus("PENDING"); + // 从变量中获取候选人 + if (variables != null) { + Object userIds = variables.get("userIds"); + if (userIds != null) { + task.setCandidateUsers(userIds.toString()); + } + Object assignee = variables.get("applicantId"); + if (assignee != null) { + task.setAssignee(assignee.toString()); + } + } + wfTaskDao.insertSelective(task); + + return String.valueOf(instance.getId()); + } + + @Override + public void completeTask(String taskId, Map variables) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + // 1. 获取当前任务 + WfTask currentTask = wfTaskDao.selectByPrimaryKey(Long.parseLong(taskId)); + if (currentTask == null) { + logger.error("任务不存在: {}", taskId); + return; + } + + // 2. 解析变量 + boolean pass = true; + int route = 0; + String candidateUsers = null; + if (variables != null) { + Object passObj = variables.get("pass"); + if (passObj != null) { + pass = Boolean.parseBoolean(passObj.toString()); + } + Object routeObj = variables.get("route"); + if (routeObj != null) { + route = Integer.parseInt(routeObj.toString()); + } + Object userIdsObj = variables.get("userIds"); + if (userIdsObj != null) { + candidateUsers = userIdsObj.toString(); + } + } + + // 3. 更新当前任务状态 + currentTask.setStatus(pass ? "COMPLETED" : "REJECTED"); + currentTask.setResult(pass ? "PASS" : "REJECT"); + currentTask.setCompleteTime(sdf.format(new Date())); + wfTaskDao.updateByPrimaryKeySelective(currentTask); + + // 4. 获取流程实例 + WfProcessInstance instance = wfProcessInstanceDao.selectByPrimaryKey(currentTask.getProcessInstanceId()); + + // 5. 根据 pass/route 查找匹配的 transition + WfTransition queryTrans = new WfTransition(); + queryTrans.setWhere("WHERE source_node_id = " + currentTask.getNodeDefId() + " ORDER BY sort_order"); + List transitions = wfTransitionDao.selectListByWhere(queryTrans); + + WfTransition matchedTransition = null; + for (WfTransition t : transitions) { + if (evaluateCondition(t.getConditionExpr(), pass, route)) { + matchedTransition = t; + break; + } + } + // 如果没有匹配的条件,取无条件的默认连线 + if (matchedTransition == null) { + for (WfTransition t : transitions) { + if (t.getConditionExpr() == null || t.getConditionExpr().trim().isEmpty()) { + matchedTransition = t; + break; + } + } + } + + if (matchedTransition == null) { + logger.error("节点 {} 无匹配的出口连线, pass={}, route={}", currentTask.getNodeDefId(), pass, route); + return; + } + + // 6. 获取目标节点 + WfNodeDefinition targetNode = wfNodeDefinitionDao.selectByPrimaryKey(matchedTransition.getTargetNodeId()); + + if ("END".equals(targetNode.getNodeType())) { + // 流程结束 + instance.setStatus(pass ? "COMPLETED" : "CANCELLED"); + instance.setCurrentNodeId(targetNode.getId()); + instance.setEndTime(sdf.format(new Date())); + wfProcessInstanceDao.updateByPrimaryKeySelective(instance); + } else { + // 创建下一个任务 + instance.setCurrentNodeId(targetNode.getId()); + wfProcessInstanceDao.updateByPrimaryKeySelective(instance); + + WfTask nextTask = new WfTask(); + nextTask.setProcessInstanceId(instance.getId()); + nextTask.setNodeDefId(targetNode.getId()); + nextTask.setNodeName(targetNode.getNodeName()); + nextTask.setStatus("PENDING"); + if (candidateUsers != null) { + nextTask.setCandidateUsers(candidateUsers); + } + Object assignee = variables != null ? variables.get("applicantId") : null; + if (assignee != null) { + nextTask.setAssignee(assignee.toString()); + } + wfTaskDao.insertSelective(nextTask); + } + } + + @Override + public void deleteProcessInstance(String processInstanceId) { + Long instId = Long.parseLong(processInstanceId); + // 删除关联任务 + WfTask queryTask = new WfTask(); + queryTask.setWhere("WHERE process_instance_id = " + instId); + wfTaskDao.deleteByWhere(queryTask); + // 删除流程实例 + wfProcessInstanceDao.deleteByPrimaryKey(instId); + } + + @Override + public void deleteHistoricInstance(String processInstanceId) { + // 自研引擎中历史和运行时在同一张表,直接删除 + deleteProcessInstance(processInstanceId); + } + + @Override + public Map queryUpOneNode(String taskId) { + WfTask currentTask = wfTaskDao.selectByPrimaryKey(Long.parseLong(taskId)); + if (currentTask == null) { + return null; + } + // 查询同一流程实例中,在当前任务之前完成的最近一个任务 + WfTask queryTask = new WfTask(); + queryTask.setWhere("WHERE process_instance_id = " + currentTask.getProcessInstanceId() + + " AND status != 'PENDING' AND id < " + taskId + " ORDER BY complete_time DESC"); + List list = wfTaskDao.selectListByWhere(queryTask); + if (list != null && !list.isEmpty()) { + return wfTaskToMap(list.get(0)); + } + return null; + } + + @Override + public List getActiveActivityIds(String processInstanceId) { + Long instId = Long.parseLong(processInstanceId); + WfProcessInstance instance = wfProcessInstanceDao.selectByPrimaryKey(instId); + if (instance == null || instance.getCurrentNodeId() == null) { + return new ArrayList<>(); + } + WfNodeDefinition node = wfNodeDefinitionDao.selectByPrimaryKey(instance.getCurrentNodeId()); + List result = new ArrayList<>(); + if (node != null) { + result.add(node.getNodeKey()); + } + return result; + } + + @Override + public Map getActiveTask(String processInstanceId) { + WfTask queryTask = new WfTask(); + queryTask.setWhere("WHERE process_instance_id = " + processInstanceId + " AND status = 'PENDING'"); + List list = wfTaskDao.selectListByWhere(queryTask); + if (list != null && !list.isEmpty()) { + return wfTaskToMap(list.get(0)); + } + return null; + } + + @Override + public Map getTask(String taskId) { + WfTask task = wfTaskDao.selectByPrimaryKey(Long.parseLong(taskId)); + if (task == null) { + return null; + } + return wfTaskToMap(task); + } + + @Override + public Map getTaskVariables(String taskId) { + // 自研引擎不持久化变量,返回基本信息 + WfTask task = wfTaskDao.selectByPrimaryKey(Long.parseLong(taskId)); + if (task == null) { + return new HashMap<>(); + } + Map vars = new HashMap<>(); + WfProcessInstance instance = wfProcessInstanceDao.selectByPrimaryKey(task.getProcessInstanceId()); + if (instance != null) { + vars.put("businessKey", instance.getBusinessKey()); + } + if (task.getCandidateUsers() != null) { + vars.put("userIds", task.getCandidateUsers()); + } + if (task.getAssignee() != null) { + vars.put("applicantId", task.getAssignee()); + } + return vars; + } + + @Override + public List> findTodoTasksByUser(String userId, String modelKey) { + WfTask queryTask = new WfTask(); + queryTask.setWhere("WHERE status = 'PENDING' AND (assignee = '" + userId + + "' OR candidate_users LIKE '%" + userId + "%') AND process_instance_id IN " + + "(SELECT id FROM [OA_ELM].[dbo].wf_process_instance WHERE process_key = '" + modelKey + "' AND status = 'RUNNING')"); + List tasks = wfTaskDao.selectListByWhere(queryTask); + return buildTodoTaskResult(tasks); + } + + @Override + public List> findTodoTasksByUser(String userId) { + WfTask queryTask = new WfTask(); + queryTask.setWhere("WHERE status = 'PENDING' AND (assignee = '" + userId + + "' OR candidate_users LIKE '%" + userId + "%')"); + List tasks = wfTaskDao.selectListByWhere(queryTask); + return buildTodoTaskResult(tasks); + } + + @Override + public List> findDoneTasks(String assignee, String modelKey) { + WfTask queryTask = new WfTask(); + queryTask.setWhere("WHERE status != 'PENDING' AND assignee = '" + assignee + + "' AND process_instance_id IN " + + "(SELECT id FROM [OA_ELM].[dbo].wf_process_instance WHERE process_key = '" + modelKey + "')"); + List tasks = wfTaskDao.selectListByWhere(queryTask); + List> result = new ArrayList<>(); + for (WfTask task : tasks) { + Map map = wfTaskToMap(task); + WfProcessInstance instance = wfProcessInstanceDao.selectByPrimaryKey(task.getProcessInstanceId()); + if (instance != null) { + map.put("businessKey", instance.getBusinessKey()); + } + result.add(map); + } + return result; + } + + @Override + public List> findFinishedProcessInstances() { + WfProcessInstance query = new WfProcessInstance(); + query.setWhere("WHERE status IN ('COMPLETED','CANCELLED') ORDER BY end_time DESC"); + List list = wfProcessInstanceDao.selectListByWhere(query); + List> result = new ArrayList<>(); + for (WfProcessInstance inst : list) { + result.add(wfProcessInstanceToMap(inst)); + } + return result; + } + + @Override + public List> findRunningProcessInstances(String processDefinitionKey, int offset, int limit) { + WfProcessInstance query = new WfProcessInstance(); + String where = "WHERE status = 'RUNNING'"; + if (processDefinitionKey != null && !processDefinitionKey.isEmpty()) { + where += " AND process_key = '" + processDefinitionKey + "'"; + } + where += " ORDER BY id DESC OFFSET " + offset + " ROWS FETCH NEXT " + limit + " ROWS ONLY"; + query.setWhere(where); + List list = wfProcessInstanceDao.selectListByWhere(query); + List> result = new ArrayList<>(); + for (WfProcessInstance inst : list) { + result.add(wfProcessInstanceToMap(inst)); + } + return result; + } + + @Override + public Map getProcessInstance(String processInstanceId) { + WfProcessInstance instance = wfProcessInstanceDao.selectByPrimaryKey(Long.parseLong(processInstanceId)); + if (instance == null) { + return null; + } + return wfProcessInstanceToMap(instance); + } + + @Override + public Map getProcessDefinition(String processDefinitionId) { + WfProcessDefinition def = wfProcessDefinitionDao.selectByPrimaryKey(Long.parseLong(processDefinitionId)); + if (def == null) { + return null; + } + Map map = new HashMap<>(); + map.put("id", String.valueOf(def.getId())); + map.put("key", def.getProcessKey()); + map.put("name", def.getProcessName()); + map.put("version", def.getVersion()); + map.put("deploymentId", null); + map.put("description", def.getDescription()); + map.put("resourceName", null); + return map; + } + + @Override + public void claimTask(String taskId, String userId) { + WfTask task = wfTaskDao.selectByPrimaryKey(Long.parseLong(taskId)); + if (task != null) { + task.setAssignee(userId); + wfTaskDao.updateByPrimaryKeySelective(task); + } + } + + // ========== 私有工具方法 ========== + + /** + * 评估条件表达式 + * 支持格式:pass==true, pass==false, route==N + */ + private boolean evaluateCondition(String expr, boolean pass, int route) { + if (expr == null || expr.trim().isEmpty()) { + return true; // 无条件,默认匹配 + } + expr = expr.trim(); + if ("pass==true".equals(expr)) { + return pass; + } + if ("pass==false".equals(expr)) { + return !pass; + } + if (expr.startsWith("route==")) { + try { + int expected = Integer.parseInt(expr.substring("route==".length()).trim()); + return route == expected; + } catch (NumberFormatException e) { + logger.error("无法解析route条件: {}", expr); + return false; + } + } + logger.warn("未识别的条件表达式: {}", expr); + return false; + } + + private List> buildTodoTaskResult(List tasks) { + List> result = new ArrayList<>(); + if (tasks == null) return result; + for (WfTask task : tasks) { + Map map = wfTaskToMap(task); + WfProcessInstance instance = wfProcessInstanceDao.selectByPrimaryKey(task.getProcessInstanceId()); + if (instance != null) { + map.put("businessKey", instance.getBusinessKey()); + map.put("processDefinitionKey", instance.getProcessKey()); + map.put("suspended", false); + map.put("processDefinitionId", String.valueOf(instance.getProcessDefId())); + } + result.add(map); + } + return result; + } + + private Map wfTaskToMap(WfTask task) { + Map map = new HashMap<>(); + map.put("id", String.valueOf(task.getId())); + map.put("name", task.getNodeName()); + map.put("assignee", task.getAssignee()); + map.put("processInstanceId", String.valueOf(task.getProcessInstanceId())); + map.put("executionId", String.valueOf(task.getProcessInstanceId())); + map.put("taskDefinitionKey", task.getNodeDefId() != null ? String.valueOf(task.getNodeDefId()) : null); + map.put("createTime", task.getCreateTime()); + map.put("description", task.getStatus()); + map.put("candidateUsers", task.getCandidateUsers()); + map.put("startTime", task.getCreateTime()); + map.put("endTime", task.getCompleteTime()); + // 补充processDefinitionId + WfProcessInstance instance = wfProcessInstanceDao.selectByPrimaryKey(task.getProcessInstanceId()); + if (instance != null) { + map.put("processDefinitionId", String.valueOf(instance.getProcessDefId())); + } + return map; + } + + private Map wfProcessInstanceToMap(WfProcessInstance inst) { + Map map = new HashMap<>(); + map.put("id", String.valueOf(inst.getId())); + map.put("businessKey", inst.getBusinessKey()); + map.put("processDefinitionId", String.valueOf(inst.getProcessDefId())); + map.put("processDefinitionKey", inst.getProcessKey()); + map.put("suspended", false); + map.put("activityId", inst.getCurrentNodeId() != null ? String.valueOf(inst.getCurrentNodeId()) : null); + map.put("startTime", inst.getCreateTime()); + map.put("endTime", inst.getEndTime()); + map.put("startActivityId", null); + return map; + } +} diff --git a/src/main/resources/sql/wf_tables.sql b/src/main/resources/sql/wf_tables.sql new file mode 100644 index 00000000..983336d9 --- /dev/null +++ b/src/main/resources/sql/wf_tables.sql @@ -0,0 +1,90 @@ +-- ============================================================ +-- 自研工作流引擎建表脚本(SQL Server) +-- 共5张表:wf_process_definition、wf_node_definition、 +-- wf_transition、wf_process_instance、wf_task +-- ============================================================ + +-- 1. 流程定义表 +CREATE TABLE wf_process_definition ( + id BIGINT IDENTITY(1,1) PRIMARY KEY, + process_key VARCHAR(100) NOT NULL, -- 流程标识,对应 ProcessType.id + process_name NVARCHAR(200) NOT NULL, -- 流程名称,对应 ProcessType.name + description NVARCHAR(500) NULL, -- 描述 + version INT NOT NULL DEFAULT 1, -- 版本号 + status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE', -- ACTIVE / DISABLED + create_time DATETIME NOT NULL DEFAULT GETDATE(), + update_time DATETIME NULL +); + +CREATE UNIQUE INDEX idx_wf_procdef_key_ver ON wf_process_definition(process_key, version); + +-- 2. 流程节点定义表 +CREATE TABLE wf_node_definition ( + id BIGINT IDENTITY(1,1) PRIMARY KEY, + process_def_id BIGINT NOT NULL, -- 所属流程定义ID + node_key VARCHAR(100) NOT NULL, -- 节点标识 + node_name NVARCHAR(200) NOT NULL, -- 节点名称 + node_type VARCHAR(20) NOT NULL, -- START / USER_TASK / END + sort_order INT NOT NULL DEFAULT 0, -- 排序 + description NVARCHAR(500) NULL, + CONSTRAINT fk_wf_node_procdef FOREIGN KEY (process_def_id) REFERENCES wf_process_definition(id) +); + +CREATE INDEX idx_wf_nodedef_procdef ON wf_node_definition(process_def_id); + +-- 3. 节点连线/路由表 +CREATE TABLE wf_transition ( + id BIGINT IDENTITY(1,1) PRIMARY KEY, + process_def_id BIGINT NOT NULL, -- 所属流程定义ID + source_node_id BIGINT NOT NULL, -- 源节点ID + target_node_id BIGINT NOT NULL, -- 目标节点ID + condition_expr VARCHAR(200) NULL, -- 条件表达式,如 pass==true, route==1 + transition_name NVARCHAR(200) NULL, -- 连线名称(通过/驳回/作废) + sort_order INT NOT NULL DEFAULT 0, + CONSTRAINT fk_wf_trans_procdef FOREIGN KEY (process_def_id) REFERENCES wf_process_definition(id), + CONSTRAINT fk_wf_trans_source FOREIGN KEY (source_node_id) REFERENCES wf_node_definition(id), + CONSTRAINT fk_wf_trans_target FOREIGN KEY (target_node_id) REFERENCES wf_node_definition(id) +); + +CREATE INDEX idx_wf_trans_procdef ON wf_transition(process_def_id); +CREATE INDEX idx_wf_trans_source ON wf_transition(source_node_id); + +-- 4. 流程实例表 +CREATE TABLE wf_process_instance ( + id BIGINT IDENTITY(1,1) PRIMARY KEY, + process_def_id BIGINT NOT NULL, -- 流程定义ID + process_key VARCHAR(100) NOT NULL, -- 冗余:流程标识 + business_key VARCHAR(100) NOT NULL, -- 业务数据主键 + starter VARCHAR(100) NOT NULL, -- 发起人 + status VARCHAR(20) NOT NULL DEFAULT 'RUNNING', -- RUNNING / COMPLETED / CANCELLED + current_node_id BIGINT NULL, -- 当前节点ID + create_time DATETIME NOT NULL DEFAULT GETDATE(), + end_time DATETIME NULL, + CONSTRAINT fk_wf_inst_procdef FOREIGN KEY (process_def_id) REFERENCES wf_process_definition(id) +); + +CREATE INDEX idx_wf_inst_bizkey ON wf_process_instance(business_key); +CREATE INDEX idx_wf_inst_starter ON wf_process_instance(starter); +CREATE INDEX idx_wf_inst_status ON wf_process_instance(status); +CREATE INDEX idx_wf_inst_prockey ON wf_process_instance(process_key); + +-- 5. 任务表(合并待办+历史) +CREATE TABLE wf_task ( + id BIGINT IDENTITY(1,1) PRIMARY KEY, + process_instance_id BIGINT NOT NULL, -- 流程实例ID + node_def_id BIGINT NOT NULL, -- 节点定义ID + node_name NVARCHAR(200) NULL, -- 冗余:节点名称 + assignee VARCHAR(100) NULL, -- 处理人 + candidate_users VARCHAR(500) NULL, -- 候选人(逗号分隔) + status VARCHAR(20) NOT NULL DEFAULT 'PENDING', -- PENDING / COMPLETED / REJECTED / CANCELLED + result VARCHAR(20) NULL, -- 处理结果 + comment NVARCHAR(1000) NULL, -- 审批意见 + create_time DATETIME NOT NULL DEFAULT GETDATE(), + complete_time DATETIME NULL, + CONSTRAINT fk_wf_task_inst FOREIGN KEY (process_instance_id) REFERENCES wf_process_instance(id), + CONSTRAINT fk_wf_task_node FOREIGN KEY (node_def_id) REFERENCES wf_node_definition(id) +); + +CREATE INDEX idx_wf_task_inst ON wf_task(process_instance_id); +CREATE INDEX idx_wf_task_status_assignee ON wf_task(status, assignee); +CREATE INDEX idx_wf_task_status_candidate ON wf_task(status, candidate_users); diff --git a/src/main/resources/sql/workflow_init/专项安全检查(safety_check_special).sql b/src/main/resources/sql/workflow_init/专项安全检查(safety_check_special).sql new file mode 100644 index 00000000..5d16bc4c --- /dev/null +++ b/src/main/resources/sql/workflow_init/专项安全检查(safety_check_special).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 专项安全检查 (safety_check_special) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('safety_check_special', N'专项安全检查', N'专项安全检查流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/丢失申请(Lose_Apply).sql b/src/main/resources/sql/workflow_init/丢失申请(Lose_Apply).sql new file mode 100644 index 00000000..439b5431 --- /dev/null +++ b/src/main/resources/sql/workflow_init/丢失申请(Lose_Apply).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 丢失申请 (Lose_Apply) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Lose_Apply', N'丢失申请', N'丢失申请流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/临时任务(Administration_Temporary).sql b/src/main/resources/sql/workflow_init/临时任务(Administration_Temporary).sql new file mode 100644 index 00000000..12427500 --- /dev/null +++ b/src/main/resources/sql/workflow_init/临时任务(Administration_Temporary).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 临时任务 (Administration_Temporary) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Administration_Temporary', N'临时任务', N'临时任务流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/保养工单(Workorder_Maintain).sql b/src/main/resources/sql/workflow_init/保养工单(Workorder_Maintain).sql new file mode 100644 index 00000000..d4b50b98 --- /dev/null +++ b/src/main/resources/sql/workflow_init/保养工单(Workorder_Maintain).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 保养工单 (Workorder_Maintain) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Workorder_Maintain', N'保养工单', N'保养工单流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/保养计划(Maintain_Plan).sql b/src/main/resources/sql/workflow_init/保养计划(Maintain_Plan).sql new file mode 100644 index 00000000..101bc430 --- /dev/null +++ b/src/main/resources/sql/workflow_init/保养计划(Maintain_Plan).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 保养计划 (Maintain_Plan) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Maintain_Plan', N'保养计划', N'保养计划流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/入库管理(In_Stock).sql b/src/main/resources/sql/workflow_init/入库管理(In_Stock).sql new file mode 100644 index 00000000..22d94656 --- /dev/null +++ b/src/main/resources/sql/workflow_init/入库管理(In_Stock).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 入库管理 (In_Stock) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('In_Stock', N'入库管理', N'入库管理流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/公司运维(Business_Maintenance).sql b/src/main/resources/sql/workflow_init/公司运维(Business_Maintenance).sql new file mode 100644 index 00000000..2b823bf8 --- /dev/null +++ b/src/main/resources/sql/workflow_init/公司运维(Business_Maintenance).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 公司运维 (Business_Maintenance) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Business_Maintenance', N'公司运维', N'公司运维流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/公司采购(Business_Purchase).sql b/src/main/resources/sql/workflow_init/公司采购(Business_Purchase).sql new file mode 100644 index 00000000..91e317bd --- /dev/null +++ b/src/main/resources/sql/workflow_init/公司采购(Business_Purchase).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 公司采购 (Business_Purchase) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Business_Purchase', N'公司采购', N'公司采购流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/内部作业会签(safety_job_inside).sql b/src/main/resources/sql/workflow_init/内部作业会签(safety_job_inside).sql new file mode 100644 index 00000000..26707179 --- /dev/null +++ b/src/main/resources/sql/workflow_init/内部作业会签(safety_job_inside).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 内部作业会签 (safety_job_inside) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('safety_job_inside', N'内部作业会签', N'内部作业会签流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/出售申请(Sale_Apply).sql b/src/main/resources/sql/workflow_init/出售申请(Sale_Apply).sql new file mode 100644 index 00000000..b8717023 --- /dev/null +++ b/src/main/resources/sql/workflow_init/出售申请(Sale_Apply).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 出售申请 (Sale_Apply) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Sale_Apply', N'出售申请', N'出售申请流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/出库管理(Out_Stock).sql b/src/main/resources/sql/workflow_init/出库管理(Out_Stock).sql new file mode 100644 index 00000000..f22445d1 --- /dev/null +++ b/src/main/resources/sql/workflow_init/出库管理(Out_Stock).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 出库管理 (Out_Stock) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Out_Stock', N'出库管理', N'出库管理流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/化验管理(TestManagement).sql b/src/main/resources/sql/workflow_init/化验管理(TestManagement).sql new file mode 100644 index 00000000..b5bee88a --- /dev/null +++ b/src/main/resources/sql/workflow_init/化验管理(TestManagement).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 化验管理 (TestManagement) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('TestManagement', N'化验管理', N'化验管理流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/参观申请(Visit_Apply).sql b/src/main/resources/sql/workflow_init/参观申请(Visit_Apply).sql new file mode 100644 index 00000000..3bd11df4 --- /dev/null +++ b/src/main/resources/sql/workflow_init/参观申请(Visit_Apply).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 参观申请 (Visit_Apply) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Visit_Apply', N'参观申请', N'参观申请流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/参观登记(Visit_Register).sql b/src/main/resources/sql/workflow_init/参观登记(Visit_Register).sql new file mode 100644 index 00000000..21726bb9 --- /dev/null +++ b/src/main/resources/sql/workflow_init/参观登记(Visit_Register).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 参观登记 (Visit_Register) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Visit_Register', N'参观登记', N'参观登记流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/合同管理(Business_Contract).sql b/src/main/resources/sql/workflow_init/合同管理(Business_Contract).sql new file mode 100644 index 00000000..3c9ab97c --- /dev/null +++ b/src/main/resources/sql/workflow_init/合同管理(Business_Contract).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 合同管理 (Business_Contract) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Business_Contract', N'合同管理', N'合同管理流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/合理化建议(Reasonable_Advice).sql b/src/main/resources/sql/workflow_init/合理化建议(Reasonable_Advice).sql new file mode 100644 index 00000000..3540a300 --- /dev/null +++ b/src/main/resources/sql/workflow_init/合理化建议(Reasonable_Advice).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 合理化建议 (Reasonable_Advice) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Reasonable_Advice', N'合理化建议', N'合理化建议流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/吐槽内容(Roast).sql b/src/main/resources/sql/workflow_init/吐槽内容(Roast).sql new file mode 100644 index 00000000..cbb6f1bc --- /dev/null +++ b/src/main/resources/sql/workflow_init/吐槽内容(Roast).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 吐槽内容 (Roast) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Roast', N'吐槽内容', N'吐槽内容流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/周期常规任务(Routine_Work).sql b/src/main/resources/sql/workflow_init/周期常规任务(Routine_Work).sql new file mode 100644 index 00000000..8beb8c3a --- /dev/null +++ b/src/main/resources/sql/workflow_init/周期常规任务(Routine_Work).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 周期常规任务 (Routine_Work) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Routine_Work', N'周期常规任务', N'周期常规任务流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/处级物资领用(Scetion_Stock).sql b/src/main/resources/sql/workflow_init/处级物资领用(Scetion_Stock).sql new file mode 100644 index 00000000..20ed081d --- /dev/null +++ b/src/main/resources/sql/workflow_init/处级物资领用(Scetion_Stock).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 处级物资领用 (Scetion_Stock) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Scetion_Stock', N'处级物资领用', N'处级物资领用流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/大修计划(Overhaul_PLAN).sql b/src/main/resources/sql/workflow_init/大修计划(Overhaul_PLAN).sql new file mode 100644 index 00000000..83cfb941 --- /dev/null +++ b/src/main/resources/sql/workflow_init/大修计划(Overhaul_PLAN).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 大修计划 (Overhaul_PLAN) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Overhaul_PLAN', N'大修计划', N'大修计划流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/大修项目(Overhaul).sql b/src/main/resources/sql/workflow_init/大修项目(Overhaul).sql new file mode 100644 index 00000000..fc839727 --- /dev/null +++ b/src/main/resources/sql/workflow_init/大修项目(Overhaul).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 大修项目 (Overhaul) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Overhaul', N'大修项目', N'大修项目流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/安装调试(Install_Debug).sql b/src/main/resources/sql/workflow_init/安装调试(Install_Debug).sql new file mode 100644 index 00000000..9289e8dd --- /dev/null +++ b/src/main/resources/sql/workflow_init/安装调试(Install_Debug).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 安装调试 (Install_Debug) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Install_Debug', N'安装调试', N'安装调试流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/客户运维(System_Maintenance).sql b/src/main/resources/sql/workflow_init/客户运维(System_Maintenance).sql new file mode 100644 index 00000000..7dc0f6ee --- /dev/null +++ b/src/main/resources/sql/workflow_init/客户运维(System_Maintenance).sql @@ -0,0 +1,77 @@ +-- ============================================================ +-- 客户运维 (System_Maintenance) 工作流初始化数据 +-- 流程:开始 → 负责人审核发布 → [同意/驳回/作废] → 运维商接单确认 +-- → 运维商执行 → [完成提交/退回] → 负责人完成确认 → [确认完成/退回] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('System_Maintenance', N'客户运维', N'客户运维流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'ApplicantSubmit', N'负责人审核发布', 'USER_TASK', 2); +DECLARE @n_applicant_submit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'LaunchProblem', N'问题调整', 'USER_TASK', 3); +DECLARE @n_launch_problem BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'MaintainerConfirm', N'运维商接单确认', 'USER_TASK', 4); +DECLARE @n_maintainer_confirm BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'MaintainerSubmit', N'运维商执行', 'USER_TASK', 5); +DECLARE @n_maintainer_submit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'ApplicantFinish', N'负责人完成确认', 'USER_TASK', 6); +DECLARE @n_applicant_finish BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 7); +DECLARE @n_end1 BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 8); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 负责人审核发布 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_applicant_submit, NULL, NULL, 1); + +-- 负责人审核发布 → 运维商接单确认(同意 target==1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_applicant_submit, @n_maintainer_confirm, 'target==1', N'同意', 2); + +-- 负责人审核发布 → 问题调整(驳回 target==0) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_applicant_submit, @n_launch_problem, 'target==0', N'驳回', 3); + +-- 负责人审核发布 → 结束(作废)(作废 target==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_applicant_submit, @n_end2, 'target==-1', N'作废', 4); + +-- 问题调整 → 负责人审核发布 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_launch_problem, @n_applicant_submit, NULL, NULL, 5); + +-- 运维商接单确认 → 运维商执行 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_maintainer_confirm, @n_maintainer_submit, NULL, NULL, 6); + +-- 运维商执行 → 负责人完成确认(完成提交 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_maintainer_submit, @n_applicant_finish, 'pass==true', N'完成提交', 7); + +-- 运维商执行 → 负责人审核发布(退回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_maintainer_submit, @n_applicant_submit, 'pass==false', N'退回', 8); + +-- 负责人完成确认 → 结束(确认完成 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_applicant_finish, @n_end1, 'pass==true', N'确认完成', 9); + +-- 负责人完成确认 → 运维商执行(退回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_applicant_finish, @n_maintainer_submit, 'pass==false', N'退回', 10); diff --git a/src/main/resources/sql/workflow_init/巡检计划确认(Patrol_Record).sql b/src/main/resources/sql/workflow_init/巡检计划确认(Patrol_Record).sql new file mode 100644 index 00000000..4f93b83b --- /dev/null +++ b/src/main/resources/sql/workflow_init/巡检计划确认(Patrol_Record).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 巡检计划确认 (Patrol_Record) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Patrol_Record', N'巡检计划确认', N'巡检计划确认流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/工艺调整(Process_Adjustment).sql b/src/main/resources/sql/workflow_init/工艺调整(Process_Adjustment).sql new file mode 100644 index 00000000..74143d14 --- /dev/null +++ b/src/main/resources/sql/workflow_init/工艺调整(Process_Adjustment).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 工艺调整 (Process_Adjustment) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Process_Adjustment', N'工艺调整', N'工艺调整流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/库存盘点(Stock_Check).sql b/src/main/resources/sql/workflow_init/库存盘点(Stock_Check).sql new file mode 100644 index 00000000..8a45117e --- /dev/null +++ b/src/main/resources/sql/workflow_init/库存盘点(Stock_Check).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 库存盘点 (Stock_Check) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Stock_Check', N'库存盘点', N'库存盘点流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/异常上报-设备(Workorder_Abnormity_Equipment).sql b/src/main/resources/sql/workflow_init/异常上报-设备(Workorder_Abnormity_Equipment).sql new file mode 100644 index 00000000..ab976722 --- /dev/null +++ b/src/main/resources/sql/workflow_init/异常上报-设备(Workorder_Abnormity_Equipment).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 异常上报-设备 (Workorder_Abnormity_Equipment) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Workorder_Abnormity_Equipment', N'异常上报-设备', N'异常上报(设备)流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/异常上报-设施(Workorder_Abnormity_Facilities).sql b/src/main/resources/sql/workflow_init/异常上报-设施(Workorder_Abnormity_Facilities).sql new file mode 100644 index 00000000..db27d3cc --- /dev/null +++ b/src/main/resources/sql/workflow_init/异常上报-设施(Workorder_Abnormity_Facilities).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 异常上报-设施 (Workorder_Abnormity_Facilities) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Workorder_Abnormity_Facilities', N'异常上报-设施', N'异常上报(设施)流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/异常上报-运行(Workorder_Abnormity_Run).sql b/src/main/resources/sql/workflow_init/异常上报-运行(Workorder_Abnormity_Run).sql new file mode 100644 index 00000000..d4f67be8 --- /dev/null +++ b/src/main/resources/sql/workflow_init/异常上报-运行(Workorder_Abnormity_Run).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 异常上报-运行 (Workorder_Abnormity_Run) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Workorder_Abnormity_Run', N'异常上报-运行', N'异常上报(运行)流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/报废申请(Scrap_Apply).sql b/src/main/resources/sql/workflow_init/报废申请(Scrap_Apply).sql new file mode 100644 index 00000000..ae5d5725 --- /dev/null +++ b/src/main/resources/sql/workflow_init/报废申请(Scrap_Apply).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 报废申请 (Scrap_Apply) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Scrap_Apply', N'报废申请', N'报废申请流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/报表审核(Report_Check).sql b/src/main/resources/sql/workflow_init/报表审核(Report_Check).sql new file mode 100644 index 00000000..99f92b4c --- /dev/null +++ b/src/main/resources/sql/workflow_init/报表审核(Report_Check).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 报表审核 (Report_Check) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Report_Check', N'报表审核', N'报表审核流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/招标比价(Bidding_Price).sql b/src/main/resources/sql/workflow_init/招标比价(Bidding_Price).sql new file mode 100644 index 00000000..2f83f82f --- /dev/null +++ b/src/main/resources/sql/workflow_init/招标比价(Bidding_Price).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 招标比价 (Bidding_Price) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Bidding_Price', N'招标比价', N'招标比价流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/指标控制(Administration_IndexWork).sql b/src/main/resources/sql/workflow_init/指标控制(Administration_IndexWork).sql new file mode 100644 index 00000000..64fc5750 --- /dev/null +++ b/src/main/resources/sql/workflow_init/指标控制(Administration_IndexWork).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 指标控制 (Administration_IndexWork) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Administration_IndexWork', N'指标控制', N'指标控制流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/方案编制(Programme_Write).sql b/src/main/resources/sql/workflow_init/方案编制(Programme_Write).sql new file mode 100644 index 00000000..2b02912d --- /dev/null +++ b/src/main/resources/sql/workflow_init/方案编制(Programme_Write).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 方案编制 (Programme_Write) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Programme_Write', N'方案编制', N'方案编制流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/日常安全检查(safety_check_dayly).sql b/src/main/resources/sql/workflow_init/日常安全检查(safety_check_dayly).sql new file mode 100644 index 00000000..8d063200 --- /dev/null +++ b/src/main/resources/sql/workflow_init/日常安全检查(safety_check_dayly).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 日常安全检查 (safety_check_dayly) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('safety_check_dayly', N'日常安全检查', N'日常安全检查流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/水质化验(Water_Test).sql b/src/main/resources/sql/workflow_init/水质化验(Water_Test).sql new file mode 100644 index 00000000..ab9c37cd --- /dev/null +++ b/src/main/resources/sql/workflow_init/水质化验(Water_Test).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 水质化验 (Water_Test) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Water_Test', N'水质化验', N'水质化验流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/组织工作(Administration_Organization).sql b/src/main/resources/sql/workflow_init/组织工作(Administration_Organization).sql new file mode 100644 index 00000000..4dbdcbbf --- /dev/null +++ b/src/main/resources/sql/workflow_init/组织工作(Administration_Organization).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 组织工作 (Administration_Organization) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Administration_Organization', N'组织工作', N'组织工作流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/绩效方案审核(KPI_MAKE_PLAN).sql b/src/main/resources/sql/workflow_init/绩效方案审核(KPI_MAKE_PLAN).sql new file mode 100644 index 00000000..5e5ca68d --- /dev/null +++ b/src/main/resources/sql/workflow_init/绩效方案审核(KPI_MAKE_PLAN).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 绩效方案审核 (KPI_MAKE_PLAN) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('KPI_MAKE_PLAN', N'绩效方案审核', N'绩效考核:绩效方案审核流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/维修工单(Workorder_Repair).sql b/src/main/resources/sql/workflow_init/维修工单(Workorder_Repair).sql new file mode 100644 index 00000000..fa803a8a --- /dev/null +++ b/src/main/resources/sql/workflow_init/维修工单(Workorder_Repair).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 维修工单 (Workorder_Repair) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Workorder_Repair', N'维修工单', N'维修工单流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/维修流程(Maintenance_Repair).sql b/src/main/resources/sql/workflow_init/维修流程(Maintenance_Repair).sql new file mode 100644 index 00000000..f23a89c9 --- /dev/null +++ b/src/main/resources/sql/workflow_init/维修流程(Maintenance_Repair).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 维修流程 (Maintenance_Repair) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Maintenance_Repair', N'维修流程', N'维修流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/维修计划(Repair_Plan).sql b/src/main/resources/sql/workflow_init/维修计划(Repair_Plan).sql new file mode 100644 index 00000000..a0b2a4cb --- /dev/null +++ b/src/main/resources/sql/workflow_init/维修计划(Repair_Plan).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 维修计划 (Repair_Plan) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Repair_Plan', N'维修计划', N'维修计划流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/综合安全检查(safety_check_comprehensive).sql b/src/main/resources/sql/workflow_init/综合安全检查(safety_check_comprehensive).sql new file mode 100644 index 00000000..450c8b01 --- /dev/null +++ b/src/main/resources/sql/workflow_init/综合安全检查(safety_check_comprehensive).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 综合安全检查 (safety_check_comprehensive) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('safety_check_comprehensive', N'综合安全检查', N'综合安全检查流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/考核项目评分(KPI_MARK).sql b/src/main/resources/sql/workflow_init/考核项目评分(KPI_MARK).sql new file mode 100644 index 00000000..d323ef15 --- /dev/null +++ b/src/main/resources/sql/workflow_init/考核项目评分(KPI_MARK).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 考核项目评分 (KPI_MARK) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('KPI_MARK', N'考核项目评分', N'绩效考核:考核项目评分流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/药剂管理(Raw_Material).sql b/src/main/resources/sql/workflow_init/药剂管理(Raw_Material).sql new file mode 100644 index 00000000..d94e5b2c --- /dev/null +++ b/src/main/resources/sql/workflow_init/药剂管理(Raw_Material).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 药剂管理 (Raw_Material) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Raw_Material', N'药剂管理', N'药剂管理流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/设备停用申请(EquipmentStop_Apply).sql b/src/main/resources/sql/workflow_init/设备停用申请(EquipmentStop_Apply).sql new file mode 100644 index 00000000..1cd4ff96 --- /dev/null +++ b/src/main/resources/sql/workflow_init/设备停用申请(EquipmentStop_Apply).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 设备停用申请 (EquipmentStop_Apply) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('EquipmentStop_Apply', N'设备停用申请', N'设备停用申请流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/请假补假(Administration_Leave).sql b/src/main/resources/sql/workflow_init/请假补假(Administration_Leave).sql new file mode 100644 index 00000000..19bfd31b --- /dev/null +++ b/src/main/resources/sql/workflow_init/请假补假(Administration_Leave).sql @@ -0,0 +1,64 @@ +-- ============================================================ +-- 请假补假 (Administration_Leave) 工作流初始化数据 +-- 流程:开始 → 科长/副科长审批 → [通过/驳回] → 分管经理审批 +-- → [通过/驳回] → 总经理审批 → [通过/驳回] → 结束 +-- 驳回统一退回到"退回修改"节点,修改后重新提交到科长审批 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Administration_Leave', N'请假补假', N'请假补假流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'sectionChiefAudit', N'科长/副科长审批', 'USER_TASK', 2); +DECLARE @n_section BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'managerAudit', N'分管经理审批', 'USER_TASK', 3); +DECLARE @n_manager BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'generalManagerAudit', N'总经理审批', 'USER_TASK', 4); +DECLARE @n_general BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'modifyApply', N'退回修改', 'USER_TASK', 5); +DECLARE @n_modify BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 6); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 科长/副科长审批 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_section, NULL, NULL, 1); + +-- 科长/副科长审批 → 分管经理审批(通过) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_section, @n_manager, 'pass==true&&route==1', N'通过', 2); + +-- 科长/副科长审批 → 退回修改(驳回) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_section, @n_modify, 'pass==false&&route==0', N'驳回', 3); + +-- 分管经理审批 → 总经理审批(通过) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_manager, @n_general, 'pass==true&&route==1', N'通过', 4); + +-- 分管经理审批 → 退回修改(驳回) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_manager, @n_modify, 'pass==false&&route==0', N'驳回', 5); + +-- 总经理审批 → 结束(通过) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_general, @n_end, 'pass==true&&route==1', N'通过', 6); + +-- 总经理审批 → 退回修改(驳回) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_general, @n_modify, 'pass==false&&route==0', N'驳回', 7); + +-- 退回修改 → 科长/副科长审批(重新提交) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_modify, @n_section, NULL, N'重新提交', 8); diff --git a/src/main/resources/sql/workflow_init/调拨申请(Transfers_Apply).sql b/src/main/resources/sql/workflow_init/调拨申请(Transfers_Apply).sql new file mode 100644 index 00000000..98ab5cc0 --- /dev/null +++ b/src/main/resources/sql/workflow_init/调拨申请(Transfers_Apply).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 调拨申请 (Transfers_Apply) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Transfers_Apply', N'调拨申请', N'调拨申请流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/车辆维保(Maintain_Car).sql b/src/main/resources/sql/workflow_init/车辆维保(Maintain_Car).sql new file mode 100644 index 00000000..4158c83d --- /dev/null +++ b/src/main/resources/sql/workflow_init/车辆维保(Maintain_Car).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 车辆维保 (Maintain_Car) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Maintain_Car', N'车辆维保', N'车辆维保流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/车辆维修(Repair_Car).sql b/src/main/resources/sql/workflow_init/车辆维修(Repair_Car).sql new file mode 100644 index 00000000..d6b0545c --- /dev/null +++ b/src/main/resources/sql/workflow_init/车辆维修(Repair_Car).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 车辆维修 (Repair_Car) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Repair_Car', N'车辆维修', N'车辆维修流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/项目验收(Project_Check).sql b/src/main/resources/sql/workflow_init/项目验收(Project_Check).sql new file mode 100644 index 00000000..7a817cc6 --- /dev/null +++ b/src/main/resources/sql/workflow_init/项目验收(Project_Check).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 项目验收 (Project_Check) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Project_Check', N'项目验收', N'项目验收流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/预案工作(Administration_Reserve).sql b/src/main/resources/sql/workflow_init/预案工作(Administration_Reserve).sql new file mode 100644 index 00000000..7aebe49d --- /dev/null +++ b/src/main/resources/sql/workflow_init/预案工作(Administration_Reserve).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 预案工作 (Administration_Reserve) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Administration_Reserve', N'预案工作', N'预案工作流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/sql/workflow_init/验收申请(Acceptance_Apply).sql b/src/main/resources/sql/workflow_init/验收申请(Acceptance_Apply).sql new file mode 100644 index 00000000..2f7d1ad2 --- /dev/null +++ b/src/main/resources/sql/workflow_init/验收申请(Acceptance_Apply).sql @@ -0,0 +1,40 @@ +-- ============================================================ +-- 验收申请 (Acceptance_Apply) 工作流初始化数据 +-- 流程:开始 → 提交审核 → [通过/驳回/作废] → 结束 +-- ============================================================ + +-- 1. 流程定义 +INSERT INTO wf_process_definition (process_key, process_name, description, version, status) +VALUES ('Acceptance_Apply', N'验收申请', N'验收申请流程', 1, 'ACTIVE'); + +DECLARE @pd_id BIGINT = SCOPE_IDENTITY(); + +-- 2. 节点定义 +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'startevent1', N'开始', 'START', 1); +DECLARE @n_start BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'audit', N'提交审核', 'USER_TASK', 2); +DECLARE @n_audit BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent1', N'结束', 'END', 3); +DECLARE @n_end BIGINT = SCOPE_IDENTITY(); + +INSERT INTO wf_node_definition (process_def_id, node_key, node_name, node_type, sort_order) VALUES (@pd_id, 'endevent2', N'结束(作废)', 'END', 4); +DECLARE @n_end2 BIGINT = SCOPE_IDENTITY(); + +-- 3. 路由/连线 +-- 开始 → 提交审核 +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_start, @n_audit, NULL, NULL, 1); + +-- 提交审核 → 结束(通过 pass==true) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==true', N'通过', 2); + +-- 提交审核 → 结束(驳回 pass==false) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end, 'pass==false', N'驳回', 3); + +-- 提交审核 → 结束(作废)(作废 route==-1) +INSERT INTO wf_transition (process_def_id, source_node_id, target_node_id, condition_expr, transition_name, sort_order) +VALUES (@pd_id, @n_audit, @n_end2, 'route==-1', N'作废', 4); diff --git a/src/main/resources/workflow.properties b/src/main/resources/workflow.properties new file mode 100644 index 00000000..c0a13e73 --- /dev/null +++ b/src/main/resources/workflow.properties @@ -0,0 +1,2 @@ +#工作流引擎切换配置 activiti:使用Activiti引擎 simple:使用自研引擎 +workflow.engine=activiti diff --git a/src/main/webapp/WEB-INF/spring-mybatis.xml b/src/main/webapp/WEB-INF/spring-mybatis.xml index c71c5828..9bdee5df 100644 --- a/src/main/webapp/WEB-INF/spring-mybatis.xml +++ b/src/main/webapp/WEB-INF/spring-mybatis.xml @@ -32,6 +32,7 @@ classpath:library.properties classpath:thirdRequest.properties classpath:xxl-job-executor.properties + classpath:workflow.properties