| | |
| | | @Log(title = "任务管理", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping("/startWorkFlow") |
| | | public R<Map<String, Object>> startWorkFlow(@RequestBody StartProcessBo startProcessBo) { |
| | | public R<Map<String, Object>> startWorkFlow(@Validated(AddGroup.class) @RequestBody StartProcessBo startProcessBo) { |
| | | Map<String, Object> map = actTaskService.startWorkFlow(startProcessBo); |
| | | return R.ok("提交成功", map); |
| | | } |
| | |
| | | */ |
| | | @GetMapping("/getByDefId/{definitionId}") |
| | | public R<WfDefinitionConfigVo> getByDefId(@NotBlank(message = "流程定义ID不能为空") |
| | | @PathVariable String definitionId) { |
| | | @PathVariable String definitionId) { |
| | | return R.ok(wfDefinitionConfigService.getByDefId(definitionId)); |
| | | } |
| | | |
| | |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(wfDefinitionConfigService.deleteByIds(List.of(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 查询流程定义配置排除当前查询的流程定义 |
| | | * |
| | | * @param tableName 表名 |
| | | * @param definitionId 流程定义id |
| | | */ |
| | | @GetMapping("/getByTableNameNotDefId/{tableName}/{definitionId}") |
| | | public R<List<WfDefinitionConfigVo>> getByTableNameNotDefId(@NotBlank(message = "表名不能为空") @PathVariable String tableName, |
| | | @NotBlank(message = "流程定义ID不能为空") @PathVariable String definitionId) { |
| | | return R.ok(wfDefinitionConfigService.getByTableNameNotDefId(tableName, definitionId)); |
| | | } |
| | | |
| | | } |
| | |
| | | private Long id; |
| | | |
| | | /** |
| | | * 表单ID |
| | | * 表名 |
| | | */ |
| | | private Long formId; |
| | | private String tableName; |
| | | |
| | | /** |
| | | * 流程定义ID |
| | |
| | | private String processKey; |
| | | |
| | | /** |
| | | * 流程版本 |
| | | */ |
| | | private Integer version; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | |
| | | package org.dromara.workflow.domain.bo; |
| | | |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | |
| | | /** |
| | | * 业务唯一值id |
| | | */ |
| | | @NotBlank(message = "业务ID不能为空", groups = {AddGroup.class}) |
| | | private String businessKey; |
| | | |
| | | /** |
| | | * 流程执行key |
| | | * 表名 |
| | | */ |
| | | private String processKey; |
| | | @NotBlank(message = "表名不能为空", groups = {AddGroup.class}) |
| | | private String tableName; |
| | | |
| | | /** |
| | | * 流程变量,前端会提交一个元素{'entity': {业务详情数据对象}} |
| | |
| | | private Long id; |
| | | |
| | | /** |
| | | * 表单ID |
| | | * 表名 |
| | | */ |
| | | @NotNull(message = "表单ID不能为空", groups = {AddGroup.class}) |
| | | private Long formId; |
| | | @NotBlank(message = "表名不能为空", groups = {AddGroup.class}) |
| | | private String tableName; |
| | | |
| | | /** |
| | | * 流程定义ID |
| | |
| | | private String processKey; |
| | | |
| | | /** |
| | | * 流程版本 |
| | | */ |
| | | @NotNull(message = "流程版本不能为空", groups = {AddGroup.class}) |
| | | private Integer version; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | |
| | | private Long id; |
| | | |
| | | /** |
| | | * 表单ID |
| | | * 表名 |
| | | */ |
| | | @ExcelProperty(value = "表单ID") |
| | | private Long formId; |
| | | @ExcelProperty(value = "表名") |
| | | private String tableName; |
| | | |
| | | /** |
| | | * 流程定义ID |
| | |
| | | @ExcelProperty(value = "流程KEY") |
| | | private String processKey; |
| | | |
| | | |
| | | /** |
| | | * 流程版本 |
| | | */ |
| | | @ExcelProperty(value = "流程版本") |
| | | private Integer version; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | |
| | | WfDefinitionConfigVo getByDefId(String definitionId); |
| | | |
| | | /** |
| | | * 查询流程定义配置 |
| | | * |
| | | * @param tableName 表名 |
| | | * @return 结果 |
| | | */ |
| | | WfDefinitionConfigVo getByTableNameLastVersion(String tableName); |
| | | |
| | | /** |
| | | * 查询流程定义配置 |
| | | * |
| | | * @param definitionId 流程定义id |
| | | * @param tableName 表名 |
| | | * @return 结果 |
| | | */ |
| | | WfDefinitionConfigVo getByDefIdAndTableName(String definitionId, String tableName); |
| | | |
| | | /** |
| | | * 查询流程定义配置排除当前查询的流程定义 |
| | | * |
| | | * @param definitionId 流程定义id |
| | | * @param tableName 表名 |
| | | * @return 结果 |
| | | */ |
| | | List<WfDefinitionConfigVo> getByTableNameNotDefId(String tableName, String definitionId); |
| | | |
| | | /** |
| | | * 查询流程定义配置列表 |
| | | * |
| | | * @param definitionIds 流程定义id |
| | |
| | | import org.dromara.workflow.mapper.ActHiTaskinstMapper; |
| | | import org.dromara.workflow.mapper.ActTaskMapper; |
| | | import org.dromara.workflow.service.IActTaskService; |
| | | import org.dromara.workflow.service.IWfDefinitionConfigService; |
| | | import org.dromara.workflow.service.IWfNodeConfigService; |
| | | import org.dromara.workflow.service.IWfTaskBackNodeService; |
| | | import org.dromara.workflow.utils.ModelUtils; |
| | |
| | | private final IWfTaskBackNodeService iWfTaskBackNodeService; |
| | | private final ActHiTaskinstMapper actHiTaskinstMapper; |
| | | private final IWfNodeConfigService iWfNodeConfigService; |
| | | private final IWfDefinitionConfigService iWfDefinitionConfigService; |
| | | |
| | | /** |
| | | * 启动任务 |
| | |
| | | map.put("taskId", taskResult.get(0).getId()); |
| | | return map; |
| | | } |
| | | WfDefinitionConfigVo wfDefinitionConfigVo = iWfDefinitionConfigService.getByTableNameLastVersion(startProcessBo.getTableName()); |
| | | if (wfDefinitionConfigVo == null) { |
| | | throw new ServiceException("请到流程定义绑定业务表名与流程KEY!"); |
| | | } |
| | | // 设置启动人 |
| | | identityService.setAuthenticatedUserId(String.valueOf(LoginHelper.getUserId())); |
| | | Authentication.setAuthenticatedUserId(String.valueOf(LoginHelper.getUserId())); |
| | |
| | | ProcessInstance pi; |
| | | try { |
| | | if (TenantHelper.isEnable()) { |
| | | pi = runtimeService.startProcessInstanceByKeyAndTenantId(startProcessBo.getProcessKey(), startProcessBo.getBusinessKey(), variables, TenantHelper.getTenantId()); |
| | | pi = runtimeService.startProcessInstanceByKeyAndTenantId(wfDefinitionConfigVo.getProcessKey(), startProcessBo.getBusinessKey(), variables, TenantHelper.getTenantId()); |
| | | } else { |
| | | pi = runtimeService.startProcessInstanceByKey(startProcessBo.getProcessKey(), startProcessBo.getBusinessKey(), variables); |
| | | pi = runtimeService.startProcessInstanceByKey(wfDefinitionConfigVo.getProcessKey(), startProcessBo.getBusinessKey(), variables); |
| | | } |
| | | } catch (FlowableObjectNotFoundException e) { |
| | | throw new ServiceException("找不到当前【" + startProcessBo.getProcessKey() + "】流程定义!"); |
| | | throw new ServiceException("找不到当前【" + wfDefinitionConfigVo.getProcessKey() + "】流程定义!"); |
| | | } |
| | | // 将流程定义名称 作为 流程实例名称 |
| | | runtimeService.setProcessInstanceName(pi.getProcessInstanceId(), pi.getProcessDefinitionName()); |
| | |
| | | package org.dromara.workflow.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询流程定义配置 |
| | | * |
| | | * @param tableName 表名 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public WfDefinitionConfigVo getByTableNameLastVersion(String tableName) { |
| | | List<WfDefinitionConfigVo> wfDefinitionConfigVos = baseMapper.selectVoList( |
| | | new LambdaQueryWrapper<WfDefinitionConfig>().eq(WfDefinitionConfig::getTableName, tableName).orderByDesc(WfDefinitionConfig::getVersion)); |
| | | if (CollUtil.isNotEmpty(wfDefinitionConfigVos)) { |
| | | return wfDefinitionConfigVos.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 查询流程定义配置 |
| | | * |
| | | * @param definitionId 流程定义id |
| | | * @param tableName 表名 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public WfDefinitionConfigVo getByDefIdAndTableName(String definitionId, String tableName) { |
| | | return baseMapper.selectVoOne(new LambdaQueryWrapper<WfDefinitionConfig>() |
| | | .eq(WfDefinitionConfig::getDefinitionId, definitionId) |
| | | .eq(WfDefinitionConfig::getTableName, tableName)); |
| | | } |
| | | |
| | | /** |
| | | * 查询流程定义配置排除当前查询的流程定义 |
| | | * |
| | | * @param tableName 表名 |
| | | * @param definitionId 流程定义id |
| | | */ |
| | | @Override |
| | | public List<WfDefinitionConfigVo> getByTableNameNotDefId(String tableName, String definitionId) { |
| | | return baseMapper.selectVoList(new LambdaQueryWrapper<WfDefinitionConfig>() |
| | | .eq(WfDefinitionConfig::getTableName, tableName) |
| | | .ne(WfDefinitionConfig::getDefinitionId, definitionId)); |
| | | } |
| | | |
| | | /** |
| | | * 查询流程定义配置列表 |
| | | */ |
| | | @Override |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean saveOrUpdate(WfDefinitionConfigBo bo) { |
| | | WfDefinitionConfig add = MapstructUtils.convert(bo, WfDefinitionConfig.class); |
| | | baseMapper.delete(new LambdaQueryWrapper<WfDefinitionConfig>().eq(WfDefinitionConfig::getTableName, bo.getTableName())); |
| | | add.setTableName(add.getTableName().toLowerCase()); |
| | | boolean flag = baseMapper.insertOrUpdate(add); |
| | | if (baseMapper.insertOrUpdate(add)) { |
| | | bo.setId(add.getId()); |
| | |
| | | ( |
| | | id bigint not null comment '主键' |
| | | primary key, |
| | | form_id bigint not null comment '表单ID', |
| | | table_name varchar(255) not null comment '表名', |
| | | definition_id varchar(255) not null comment '流程定义ID', |
| | | process_key varchar(255) not null comment '流程KEY', |
| | | version int(10) not null comment '流程版本', |
| | | create_dept bigint null comment '创建部门', |
| | | create_by bigint null comment '创建者', |
| | | create_time datetime null comment '创建时间', |
| | |
| | | ID NUMBER(20) NOT NULL |
| | | CONSTRAINT PK_WF_DEFINITION_CONFIG |
| | | PRIMARY KEY, |
| | | FORM_ID NUMBER(20) NOT NULL, |
| | | TABLE_NAME VARCHAR2(255) NOT NULL, |
| | | DEFINITION_ID VARCHAR2(255) NOT NULL, |
| | | PROCESS_KEY VARCHAR2(255) NOT NULL, |
| | | PROCESS_KEY VARCHAR2(255) NOT NULL, |
| | | VERSION NUMBER(10) NOT NULL, |
| | | TENANT_ID VARCHAR2(20), |
| | | CREATE_DEPT NUMBER(20), |
| | | CREATE_BY NUMBER(20), |
| | |
| | | ); |
| | | comment on table WF_DEFINITION_CONFIG is '流程定义配置' |
| | | comment on column WF_DEFINITION_CONFIG.ID is '主键' |
| | | comment on column WF_DEFINITION_CONFIG.FORM_ID is '表单ID' |
| | | comment on column WF_DEFINITION_CONFIG.TABLE_NAME is '表名' |
| | | comment on column WF_DEFINITION_CONFIG.DEFINITION_ID is '流程定义ID' |
| | | comment on column WF_DEFINITION_CONFIG.PROCESS_KEY is '流程KEY' |
| | | comment on column WF_DEFINITION_CONFIG.VERSION is '流程版本' |
| | | comment on column WF_DEFINITION_CONFIG.TENANT_ID is '租户编号' |
| | | comment on column WF_DEFINITION_CONFIG.CREATE_DEPT is '创建部门' |
| | | comment on column WF_DEFINITION_CONFIG.CREATE_BY is '创建者' |
| | |
| | | id bigint not null |
| | | constraint pk_wf_definition_config |
| | | primary key, |
| | | form_id bigint(20) not null, |
| | | table_name varchar(255) not null, |
| | | definition_id varchar(255) not null, |
| | | process_key varchar(255) not null, |
| | | process_key varchar(255) not null, |
| | | version bigint not null, |
| | | tenant_id varchar(20), |
| | | create_dept bigint, |
| | | create_by bigint, |
| | |
| | | |
| | | comment on column wf_definition_config.id is '主键'; |
| | | |
| | | comment on column wf_definition_config.form_id is '表单ID'; |
| | | comment on column wf_definition_config.table_name is '表名'; |
| | | |
| | | comment on column wf_definition_config.definition_id is '流程定义ID'; |
| | | |
| | | comment on column wf_definition_config.process_key is '流程KEY'; |
| | | |
| | | comment on column wf_definition_config.version is '流程版本'; |
| | | |
| | | comment on column wf_definition_config.tenant_id is '租户id'; |
| | | |
| | | comment on column wf_definition_config.create_dept is '创建部门'; |
| | |
| | | create table wf_definition_config |
| | | ( |
| | | id bigint not null primary key, |
| | | form_id bigint not null, |
| | | definition_id nvarchar(255) |
| | | table_name nvarchar(255) not null, |
| | | definition_id nvarchar(255) not null |
| | | constraint uni_definition_id |
| | | unique, |
| | | process_key nvarchar(255) not null, |
| | | version bigint not null, |
| | | tenant_id nvarchar(20), |
| | | create_dept bigint, |
| | | create_by bigint, |
| | |
| | | exec sp_addextendedproperty 'MS_Description', N'主键', 'SCHEMA', 'dbo', 'TABLE', 'wf_definition_config', 'COLUMN', 'id' |
| | | go |
| | | |
| | | exec sp_addextendedproperty 'MS_Description', N'表单ID', 'SCHEMA', 'dbo', 'TABLE', 'wf_definition_config', 'COLUMN', |
| | | 'form_id' |
| | | exec sp_addextendedproperty 'MS_Description', N'表名', 'SCHEMA', 'dbo', 'TABLE', 'wf_definition_config', 'COLUMN', |
| | | 'table_name' |
| | | go |
| | | |
| | | exec sp_addextendedproperty 'MS_Description', N'流程定义ID', 'SCHEMA', 'dbo', 'TABLE', 'wf_definition_config', 'COLUMN', |
| | |
| | | 'process_key' |
| | | go |
| | | |
| | | exec sp_addextendedproperty 'MS_Description', N'流程版本', 'SCHEMA', 'dbo', 'TABLE', 'wf_definition_config', 'COLUMN', |
| | | 'version' |
| | | go |
| | | |
| | | exec sp_addextendedproperty 'MS_Description', N'租户编号', 'SCHEMA', 'dbo', 'TABLE', 'wf_definition_config', 'COLUMN', |
| | | 'tenant_id' |
| | | go |