1. 新增流程定义的列表 API

2. 新增流程创建的界面,暂未实现完全
This commit is contained in:
YunaiV 2022-01-08 23:11:09 +08:00
parent 2630ad8eaa
commit 749cb5d762
14 changed files with 250 additions and 104 deletions

View File

@ -0,0 +1,4 @@
### 请求 /bpm/process-definition/list 接口 => 成功
GET {{baseUrl}}/bpm/process-definition/list?suspensionState=1
tenant-id: 1
Authorization: Bearer {{token}}

View File

@ -1,7 +1,9 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition; package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionListReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -17,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Api(tags = "流程定义") @Api(tags = "流程定义")
@ -36,6 +40,13 @@ public class BpmProcessDefinitionController {
return success(bpmDefinitionService.getProcessDefinitionPage(pageReqVO)); return success(bpmDefinitionService.getProcessDefinitionPage(pageReqVO));
} }
@GetMapping ("/list")
@ApiOperation(value = "获得流程定义列表")
public CommonResult<List<BpmProcessDefinitionRespVO>> getProcessDefinitionList(
BpmProcessDefinitionListReqVO listReqVO) {
return success(bpmDefinitionService.getProcessDefinitionList(listReqVO));
}
@GetMapping ("/get-bpmn-xml") @GetMapping ("/get-bpmn-xml")
@ApiOperation(value = "获得流程定义的 BPMN XML") @ApiOperation(value = "获得流程定义的 BPMN XML")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("流程定义列表 Request VO")
public class BpmProcessDefinitionListReqVO extends PageParam {
@ApiModelProperty(value = "中断状态", example = "1", notes = "参见 SuspensionState 枚举")
private Integer suspensionState;
}

View File

@ -20,5 +20,4 @@ public class BpmProcessDefinitionPageItemRespVO extends BpmProcessDefinitionResp
@ApiModelProperty(value = "部署时间", required = true) @ApiModelProperty(value = "部署时间", required = true)
private Date deploymentTime; private Date deploymentTime;
} }

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition; package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
@ -9,6 +10,9 @@ import org.activiti.engine.impl.persistence.entity.SuspensionState;
import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.repository.ProcessDefinition;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.List; import java.util.List;
@ -55,4 +59,17 @@ public interface BpmDefinitionConvert {
BpmProcessDefinitionExtDO convert2(BpmDefinitionCreateReqDTO bean); BpmProcessDefinitionExtDO convert2(BpmDefinitionCreateReqDTO bean);
@Named("convertList3")
List<BpmProcessDefinitionRespVO> convertList3(List<ProcessDefinition> list);
@Named("convert3")
@Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState")
BpmProcessDefinitionRespVO convert3(ProcessDefinition bean);
@Named("convertSuspendedToSuspensionState")
default Integer convertSuspendedToSuspensionState(boolean suspended) {
return suspended ? SuspensionState.SUSPENDED.getStateCode() :
SuspensionState.ACTIVE.getStateCode();
}
} }

View File

@ -1,7 +1,9 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition; package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionListReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
@ -30,6 +32,14 @@ public interface BpmProcessDefinitionService {
*/ */
PageResult<BpmProcessDefinitionPageItemRespVO> getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO); PageResult<BpmProcessDefinitionPageItemRespVO> getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO);
/**
* 获得流程定义列表
*
* @param listReqVO 列表入参
* @return 流程定义列表
*/
List<BpmProcessDefinitionRespVO> getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO);
/** /**
* 获得流程定义对应的 BPMN XML * 获得流程定义对应的 BPMN XML
* *

View File

@ -2,8 +2,10 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionListReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmDefinitionConvert; import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmDefinitionConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
@ -93,6 +95,19 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
processDefinitionDOMap, formMap), definitionCount); processDefinitionDOMap, formMap), definitionCount);
} }
@Override
public List<BpmProcessDefinitionRespVO> getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO) {
// 拼接查询条件
ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();
if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), listReqVO.getSuspensionState())) {
definitionQuery.suspended();
} else if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), listReqVO.getSuspensionState())) {
definitionQuery.active();
}
// 执行查询并返回
return BpmDefinitionConvert.INSTANCE.convertList3(definitionQuery.list());
}
@Override @Override
public String getProcessDefinitionBpmnXML(String id) { public String getProcessDefinitionBpmnXML(String id) {
BpmnModel bpmnModel = repositoryService.getBpmnModel(id); BpmnModel bpmnModel = repositoryService.getBpmnModel(id);

View File

@ -9,7 +9,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* 工作任务 Service 接口 * 流程任务 Service 接口
* *
* @author jason * @author jason
* @author 芋道源码 * @author 芋道源码

View File

@ -135,6 +135,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
if (instance == null) { if (instance == null) {
throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS);
} }
// TODO 芋艿只能自己取消流程
// 通过删除流程实例实现流程实例的取消 // 通过删除流程实例实现流程实例的取消
runtimeService.deleteProcessInstance(cancelReqVO.getId(), cancelReqVO.getReason()); runtimeService.deleteProcessInstance(cancelReqVO.getId(), cancelReqVO.getReason());

View File

@ -45,6 +45,12 @@ import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstan
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
/**
* 流程任务 Service 实现类
*
* @author jason
* @author 芋道源码
*/
@Slf4j @Slf4j
@Service @Service
public class BpmTaskServiceImpl implements BpmTaskService { public class BpmTaskServiceImpl implements BpmTaskService {

View File

@ -188,6 +188,18 @@ export const constantRoutes = [
meta: { title: '流程定义' } meta: { title: '流程定义' }
} }
] ]
}, {
path: '/bpm',
component: Layout,
hidden: true,
children: [
{
path: 'process-instance/create',
component: (resolve) => require(['@/views/bpm/processInstance/create'], resolve),
name: '发起流程',
meta: { title: '发起流程' }
}
]
}, },
] ]

View File

@ -0,0 +1,152 @@
<template>
<div class="app-container">
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
<el-table-column label="定义编号" align="center" prop="id" width="400" />
<el-table-column label="定义名称" align="center" prop="name" width="100">
<template slot-scope="scope">
<el-button type="text" @click="handleBpmnDetail(scope.row)">
<span>{{ scope.row.name }}</span>
</el-button>
</template>
</el-table-column>
<el-table-column label="定义分类" align="center" prop="category" width="100">
<template slot-scope="scope">
<span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
</template>
</el-table-column>
<el-table-column label="表单信息" align="center" prop="formId">
<template slot-scope="scope">
<el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)">
<span>{{ scope.row.formName }}</span>
</el-button>
<label v-else>暂无表单</label>
</template>
</el-table-column>
<el-table-column label="流程版本" align="center" prop="processDefinition.version" width="80">
<template slot-scope="scope">
<el-tag size="medium" v-if="scope.row">v{{ scope.row.version }}</el-tag>
<el-tag size="medium" type="warning" v-else>未部署</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="version" width="80">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.suspensionState === 1">激活</el-tag>
<el-tag type="warning" v-if="scope.row.suspensionState === 2">挂起</el-tag>
</template>
</el-table-column>
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.deploymentTime) }}</span>
</template>
</el-table-column>
<el-table-column label="定义描述" align="center" prop="description" width="300" show-overflow-tooltip />
</el-table>
<!-- 流程表单配置详情 -->
<el-dialog title="表单详情" :visible.sync="detailOpen" width="50%" append-to-body>
<parser :key="new Date().getTime()" :form-conf="detailForm" />
</el-dialog>
<!-- 流程模型图的预览 -->
<el-dialog title="流程图" :visible.sync="showBpmnOpen" width="80%" append-to-body>
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
</el-dialog>
<!-- 分页组件 -->
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
</div>
</template>
<script>
import {getProcessDefinitionBpmnXML, getProcessDefinitionPage} from "@/api/bpm/definition";
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import {getForm} from "@/api/bpm/form";
import {decodeFields} from "@/utils/formGenerator";
import Parser from '@/components/parser/Parser'
export default {
name: "processDefinition",
components: {
Parser
},
data() {
return {
//
loading: true,
//
total: 0,
//
list: [],
//
queryParams: {
pageNo: 1,
pageSize: 10
},
//
detailOpen: false,
detailForm: {
fields: []
},
// BPMN
showBpmnOpen: false,
bpmnXML: null,
bpmnControlForm: {
prefix: "activiti"
},
//
categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
};
},
created() {
const key = this.$route.query && this.$route.query.key
if (key) {
this.queryParams['key'] = key
}
this.getList();
},
methods: {
/** 查询流程定义列表 */
getList() {
this.loading = true;
getProcessDefinitionPage(this.queryParams).then(response => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
}
);
},
/** 流程表单的详情按钮操作 */
handleFormDetail(row) {
getForm(row.formId).then(response => {
//
const data = response.data
this.detailForm = {
...JSON.parse(data.conf),
fields: decodeFields(data.fields)
}
//
this.detailOpen = true
})
},
/** 流程图的详情按钮操作 */
handleBpmnDetail(row) {
getProcessDefinitionBpmnXML(row.id).then(response => {
this.bpmnXML = response.data
//
this.showBpmnOpen = true
})
},
}
};
</script>
<style lang="scss">
.my-process-designer {
height: calc(100vh - 200px);
}
</style>

View File

@ -113,45 +113,6 @@
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/> @pagination="getList"/>
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="发起流程的用户编号" prop="userId">
<el-input v-model="form.userId" placeholder="请输入发起流程的用户编号" />
</el-form-item>
<el-form-item label="流程实例的名字" prop="name">
<el-input v-model="form.name" placeholder="请输入流程实例的名字" />
</el-form-item>
<el-form-item label="流程实例的编号" prop="processInstanceId">
<el-input v-model="form.processInstanceId" placeholder="请输入流程实例的编号" />
</el-form-item>
<el-form-item label="流程定义的编号" prop="processDefinitionId">
<el-input v-model="form.processDefinitionId" placeholder="请输入流程定义的编号" />
</el-form-item>
<el-form-item label="流程分类" prop="category">
<el-select v-model="form.category" placeholder="请选择流程分类">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY)"
:key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="流程实例的名字" prop="status">
<el-select v-model="form.status" placeholder="请选择流程实例的名字">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
<el-form-item label="流程实例的结果" prop="result">
<el-select v-model="form.result" placeholder="请选择流程实例的结果">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -181,10 +142,7 @@ export default {
total: 0, total: 0,
// //
list: [], list: [],
//
title: "",
// //
open: false,
dateRangeCreateTime: [], dateRangeCreateTime: [],
// //
queryParams: { queryParams: {
@ -195,18 +153,6 @@ export default {
category: null, category: null,
status: null, status: null,
result: null, result: null,
},
//
form: {},
//
rules: {
userId: [{ required: true, message: "发起流程的用户编号不能为空", trigger: "blur" }],
name: [{ required: true, message: "流程实例的名字不能为空", trigger: "blur" }],
processInstanceId: [{ required: true, message: "流程实例的编号不能为空", trigger: "blur" }],
processDefinitionId: [{ required: true, message: "流程定义的编号不能为空", trigger: "blur" }],
category: [{ required: true, message: "流程分类不能为空", trigger: "change" }],
status: [{ required: true, message: "流程实例的名字不能为空", trigger: "change" }],
result: [{ required: true, message: "流程实例的结果不能为空", trigger: "change" }],
} }
}; };
}, },
@ -227,25 +173,6 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: undefined,
userId: undefined,
name: undefined,
processInstanceId: undefined,
processDefinitionId: undefined,
category: undefined,
status: undefined,
result: undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
@ -257,34 +184,9 @@ export default {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
/** 新增按钮操作 */ /** 新增按钮操作 **/
handleAdd() { handleAdd() {
this.reset(); this.$router.push({ path: "/bpm/process-instance/create"})
this.open = true;
this.title = "添加工作流的流程实例的拓展";
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (!valid) {
return;
}
//
if (this.form.id != null) {
updateProcessInstanceExt(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
return;
}
//
createProcessInstanceExt(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
});
}, },
/** 取消按钮操作 */ /** 取消按钮操作 */
handleCancel(row) { handleCancel(row) {

View File

@ -16,8 +16,6 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="任务编号" align="center" prop="id" width="300" /> <el-table-column label="任务编号" align="center" prop="id" width="300" />