From 749cb5d762075f7a3ba739d8f14a4bafeec0153c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 8 Jan 2022 23:11:09 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=96=B0=E5=A2=9E=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=9A=84=E5=88=97=E8=A1=A8=20API=202.=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=81=E7=A8=8B=E5=88=9B=E5=BB=BA=E7=9A=84?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=EF=BC=8C=E6=9A=82=E6=9C=AA=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=AE=8C=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BpmProcessDefinitionController.http | 4 + .../BpmProcessDefinitionController.java | 11 ++ .../vo/BpmProcessDefinitionListReqVO.java | 19 +++ .../BpmProcessDefinitionPageItemRespVO.java | 1 - .../definition/BpmDefinitionConvert.java | 17 ++ .../BpmProcessDefinitionService.java | 10 ++ .../impl/BpmProcessDefinitionServiceImpl.java | 15 ++ .../bpm/service/task/BpmTaskService.java | 2 +- .../impl/BpmProcessInstanceServiceImpl.java | 1 + .../service/task/impl/BpmTaskServiceImpl.java | 6 + yudao-admin-ui/src/router/index.js | 12 ++ .../src/views/bpm/processInstance/create.vue | 152 ++++++++++++++++++ .../src/views/bpm/processInstance/index.vue | 102 +----------- yudao-admin-ui/src/views/bpm/task/todo.vue | 2 - 14 files changed, 250 insertions(+), 104 deletions(-) create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.http create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionListReqVO.java create mode 100644 yudao-admin-ui/src/views/bpm/processInstance/create.vue diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.http b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.http new file mode 100644 index 0000000000..492960ed5f --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.http @@ -0,0 +1,4 @@ +### 请求 /bpm/process-definition/list 接口 => 成功 +GET {{baseUrl}}/bpm/process-definition/list?suspensionState=1 +tenant-id: 1 +Authorization: Bearer {{token}} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.java index 678b88d2ca..ba76cf431a 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.java @@ -1,7 +1,9 @@ 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.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.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -17,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.List; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Api(tags = "流程定义") @@ -36,6 +40,13 @@ public class BpmProcessDefinitionController { return success(bpmDefinitionService.getProcessDefinitionPage(pageReqVO)); } + @GetMapping ("/list") + @ApiOperation(value = "获得流程定义列表") + public CommonResult> getProcessDefinitionList( + BpmProcessDefinitionListReqVO listReqVO) { + return success(bpmDefinitionService.getProcessDefinitionList(listReqVO)); + } + @GetMapping ("/get-bpmn-xml") @ApiOperation(value = "获得流程定义的 BPMN XML") @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionListReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionListReqVO.java new file mode 100644 index 0000000000..0b87daa322 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionListReqVO.java @@ -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; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionPageItemRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionPageItemRespVO.java index 7ed489da12..2e74f07695 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionPageItemRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionPageItemRespVO.java @@ -20,5 +20,4 @@ public class BpmProcessDefinitionPageItemRespVO extends BpmProcessDefinitionResp @ApiModelProperty(value = "部署时间", required = true) private Date deploymentTime; - } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmDefinitionConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmDefinitionConvert.java index 895f410d02..8dab681656 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmDefinitionConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmDefinitionConvert.java @@ -1,6 +1,7 @@ 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.BpmProcessDefinitionRespVO; 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.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.ProcessDefinition; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; +import org.mapstruct.Named; import org.mapstruct.factory.Mappers; import java.util.List; @@ -55,4 +59,17 @@ public interface BpmDefinitionConvert { BpmProcessDefinitionExtDO convert2(BpmDefinitionCreateReqDTO bean); + @Named("convertList3") + List convertList3(List 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(); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmProcessDefinitionService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmProcessDefinitionService.java index deb8625be2..89198a9c5e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmProcessDefinitionService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmProcessDefinitionService.java @@ -1,7 +1,9 @@ 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.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.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; @@ -30,6 +32,14 @@ public interface BpmProcessDefinitionService { */ PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO); + /** + * 获得流程定义列表 + * + * @param listReqVO 列表入参 + * @return 流程定义列表 + */ + List getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO); + /** * 获得流程定义对应的 BPMN XML * diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java index 4fe4bef304..b47b32477b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java @@ -2,8 +2,10 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl; import cn.hutool.core.collection.CollUtil; 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.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.dal.dataobject.definition.BpmProcessDefinitionExtDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; @@ -93,6 +95,19 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ processDefinitionDOMap, formMap), definitionCount); } + @Override + public List 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 public String getProcessDefinitionBpmnXML(String id) { BpmnModel bpmnModel = repositoryService.getBpmnModel(id); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java index fefdecd7dd..d3f7d3a4b8 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Map; /** - * 工作任务 Service 接口 + * 流程任务 Service 接口 * * @author jason * @author 芋道源码 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java index 9228ab139f..1552fd9cbf 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java @@ -135,6 +135,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService if (instance == null) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); } + // TODO 芋艿:只能自己取消流程 // 通过删除流程实例,实现流程实例的取消 runtimeService.deleteProcessInstance(cancelReqVO.getId(), cancelReqVO.getReason()); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java index 0cd7df96c0..dbc728072b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java @@ -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.util.collection.CollectionUtils.convertSet; +/** + * 流程任务 Service 实现类 + * + * @author jason + * @author 芋道源码 + */ @Slf4j @Service public class BpmTaskServiceImpl implements BpmTaskService { diff --git a/yudao-admin-ui/src/router/index.js b/yudao-admin-ui/src/router/index.js index dcac36f4dc..be4e46296b 100644 --- a/yudao-admin-ui/src/router/index.js +++ b/yudao-admin-ui/src/router/index.js @@ -188,6 +188,18 @@ export const constantRoutes = [ meta: { title: '流程定义' } } ] + }, { + path: '/bpm', + component: Layout, + hidden: true, + children: [ + { + path: 'process-instance/create', + component: (resolve) => require(['@/views/bpm/processInstance/create'], resolve), + name: '发起流程', + meta: { title: '发起流程' } + } + ] }, ] diff --git a/yudao-admin-ui/src/views/bpm/processInstance/create.vue b/yudao-admin-ui/src/views/bpm/processInstance/create.vue new file mode 100644 index 0000000000..b613f46a3e --- /dev/null +++ b/yudao-admin-ui/src/views/bpm/processInstance/create.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/yudao-admin-ui/src/views/bpm/processInstance/index.vue b/yudao-admin-ui/src/views/bpm/processInstance/index.vue index 79c705d7b1..1ae521a15d 100644 --- a/yudao-admin-ui/src/views/bpm/processInstance/index.vue +++ b/yudao-admin-ui/src/views/bpm/processInstance/index.vue @@ -113,45 +113,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -181,10 +142,7 @@ export default { total: 0, // 工作流的流程实例的拓展列表 list: [], - // 弹出层标题 - title: "", // 是否显示弹出层 - open: false, dateRangeCreateTime: [], // 查询参数 queryParams: { @@ -195,18 +153,6 @@ export default { category: null, status: 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; }); }, - /** 取消按钮 */ - 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() { this.queryParams.pageNo = 1; @@ -257,34 +184,9 @@ export default { this.resetForm("queryForm"); this.handleQuery(); }, - /** 新增按钮操作 */ + /** 新增按钮操作 **/ handleAdd() { - this.reset(); - 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(); - }); - }); + this.$router.push({ path: "/bpm/process-instance/create"}) }, /** 取消按钮操作 */ handleCancel(row) { diff --git a/yudao-admin-ui/src/views/bpm/task/todo.vue b/yudao-admin-ui/src/views/bpm/task/todo.vue index 13a8f5c2e1..ce54183cf4 100644 --- a/yudao-admin-ui/src/views/bpm/task/todo.vue +++ b/yudao-admin-ui/src/views/bpm/task/todo.vue @@ -16,8 +16,6 @@ - -