diff --git a/sql/ruoyi-vue-pro.sql b/sql/ruoyi-vue-pro.sql index b05d99db3..aee6db3a0 100644 --- a/sql/ruoyi-vue-pro.sql +++ b/sql/ruoyi-vue-pro.sql @@ -1194,6 +1194,10 @@ INSERT INTO `sys_menu` VALUES (1122, '请假申请删除', 'oa:leave:delete', 3, INSERT INTO `sys_menu` VALUES (1123, '请假申请导出', 'oa:leave:export', 3, 5, 1118, '', '', '', 0, '', '2021-09-20 08:51:03', '', '2021-09-20 08:51:03', b'0'); INSERT INTO `sys_menu` VALUES (1124, '待办请假', '', 2, 2, 5, 'todo', 'edit', 'oa/todo/index', 0, '1', '2021-09-20 22:10:09', '1', '2021-09-21 23:17:12', b'0'); INSERT INTO `sys_menu` VALUES (1125, '已办请假', '', 2, 3, 5, 'flow', 'form', 'oa/flow/index', 0, '1', '2021-10-23 22:10:09', '1', '2021-10-23 23:17:12', b'0'); +INSERT INTO `sys_menu` VALUES (1128, '工作流程定义', '', 2, 2, 1126, 'processDefinition/index', '#', 'bpm/processDefinition/index', 0, '1', '2021-11-19 11:18:38', '1', '2021-11-19 11:18:38', b'0'); +INSERT INTO `sys_menu` VALUES (1127, '工作流设计', '', 2, 1, 1126, 'model/index', '#', 'bpm/model/index', 0, '1', '2021-11-19 10:59:36', '1', '2021-11-19 11:01:59', b'0'); +INSERT INTO `sys_menu` VALUES (1126, '工作流管理', '', 1, 5, 0, '/bpm', 'tree-table', NULL, 0, '1', '2021-11-19 10:57:49', '1', '2021-11-19 11:05:05', b'0'); + COMMIT; -- ---------------------------- diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/ProcessDefinitionController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/ProcessDefinitionController.java index cb1010f62..073f2f5e2 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/ProcessDefinitionController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/ProcessDefinitionController.java @@ -1,6 +1,13 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmProcessDefinitionService; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; +import io.swagger.annotations.ApiOperation; import org.activiti.api.process.runtime.ProcessRuntime; import org.activiti.engine.RepositoryService; import org.springframework.web.bind.annotation.GetMapping; @@ -9,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; // TODO @json:swagger 和 validation 的注解,后续要补全下哈。可以等 workflow 基本写的差不多之后 @RestController @@ -20,15 +29,30 @@ public class ProcessDefinitionController { @Resource private ProcessRuntime processRuntime; + @Resource + private BpmProcessDefinitionService bpmProcessDefinitionService; @GetMapping(value = "/getStartForm") public CommonResult getStartForm(@RequestParam("processKey") String processKey){ - //这样查似乎有问题??, 暂时写死 // final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery(). // processDefinitionKey(processKey).latestVersion().singleResult(); // processRuntime.processDefinition(processDefinition.getId()).getFormKey(); + //这样查似乎有问题??, 暂时写死 return CommonResult.success("/flow/leave/apply"); } + @GetMapping ("/page") + @ApiOperation(value = "流程定义分页数据") + public CommonResult> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo) { + return CommonResult.success(bpmProcessDefinitionService.pageList(processDefinitionPageReqVo)); + } + + @GetMapping ("/export") + @ApiOperation(value = "流程定义的bpmnXml导出") + public void pageList(@RequestParam String processDefinitionId, HttpServletResponse response) throws IOException { + FileResp fileResp = bpmProcessDefinitionService.export(processDefinitionId); + ServletUtils.writeAttachment(response, fileResp.getFileName(), fileResp.getFileByte()); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/processdefinition/ProcessDefinitionPageReqVo.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/processdefinition/ProcessDefinitionPageReqVo.java new file mode 100644 index 000000000..4cace516e --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/processdefinition/ProcessDefinitionPageReqVo.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition; + +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; + +/** + * @author yunlong.li + */ +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +@ApiModel("流程定义分页 Request VO") +public class ProcessDefinitionPageReqVo extends PageParam { + @ApiModelProperty("流程名字") + private String name; +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/processdefinition/ProcessDefinitionRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/processdefinition/ProcessDefinitionRespVO.java new file mode 100644 index 000000000..e9aaade62 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/processdefinition/ProcessDefinitionRespVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + * @author yunlong.li + */ +@Data +@ApiModel("流程定义数据返回 Request VO") +public class ProcessDefinitionRespVO { + + private String formKey; + private String id; + private String key; + private String name; + private Integer version; +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/workflow/ProcessDefinitionConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/workflow/ProcessDefinitionConvert.java new file mode 100644 index 000000000..e2a48c693 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/workflow/ProcessDefinitionConvert.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow; + +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; +import org.activiti.engine.repository.ProcessDefinition; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * @author yunlong.li + */ +@Mapper +public interface ProcessDefinitionConvert { + ProcessDefinitionConvert INSTANCE = Mappers.getMapper(ProcessDefinitionConvert.class); + + ProcessDefinitionRespVO convert(ProcessDefinition processDefinition); + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmProcessDefinitionService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmProcessDefinitionService.java new file mode 100644 index 000000000..01a5cd6d0 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmProcessDefinitionService.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow; + +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 流程定义接口 + * @author yunlong.li + */ +public interface BpmProcessDefinitionService { + /** + * 流程定义分页 + * @param processDefinitionPageReqVo 分页入参 + * @return 分页model + */ + PageResult pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo); + + /** + * 导出流程 bpmn 模型 + * @param processDefinitionId 分页入参 + * @return 分页model + */ + FileResp export(String processDefinitionId); +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmProcessDefinitionServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmProcessDefinitionServiceImpl.java new file mode 100644 index 000000000..75a5b489c --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmProcessDefinitionServiceImpl.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl; + +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.ProcessDefinitionConvert; +import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmProcessDefinitionService; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.activiti.api.process.runtime.ProcessRuntime; +import org.activiti.bpmn.converter.BpmnXMLConverter; +import org.activiti.bpmn.model.BpmnModel; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.repository.ProcessDefinition; +import org.activiti.engine.repository.ProcessDefinitionQuery; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 流程定义实现 + * @author yunlongn + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService { + + private final RepositoryService repositoryService; + + private final ProcessRuntime processRuntime; + + @Override + public PageResult pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo) { + ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); + String likeName = processDefinitionPageReqVo.getName(); + if (StrUtil.isNotBlank(likeName)){ + processDefinitionQuery.processDefinitionNameLike("%"+likeName+"%"); + } + List processDefinitions = processDefinitionQuery.orderByProcessDefinitionId().desc() + .listPage((processDefinitionPageReqVo.getPageNo() - 1) * processDefinitionPageReqVo.getPageSize(), + processDefinitionPageReqVo.getPageSize()); + final List respVOList = processDefinitions.stream() + .map(ProcessDefinitionConvert.INSTANCE::convert).collect(Collectors.toList()); + return new PageResult<>(respVOList, processDefinitionQuery.count()); + } + + @Override + public FileResp export(String processDefinitionId) { + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); + byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(bpmnModel); + FileResp fileResp = new FileResp(); + fileResp.setFileName( "export"); + fileResp.setFileByte(bpmnBytes); + return fileResp; + } +} diff --git a/yudao-admin-ui/src/api/bpm/processDefinition.js b/yudao-admin-ui/src/api/bpm/processDefinition.js new file mode 100644 index 000000000..5467c707c --- /dev/null +++ b/yudao-admin-ui/src/api/bpm/processDefinition.js @@ -0,0 +1,17 @@ +import request from '@/utils/request' + + +export function page(query) { + return request({ + url: '/workflow/process/definition/page', + method: 'get', + params: query + }) +} + +export function exportProcessDefinition(query) { + return request({ + url: '/workflow/process/definition/export?processDefinitionId='+query.id, + method: 'get' + }) +} diff --git a/yudao-admin-ui/src/components/bpmn/VueBpmn.vue b/yudao-admin-ui/src/components/bpmn/VueBpmn.vue index a0860c17c..71d7dcd6f 100644 --- a/yudao-admin-ui/src/components/bpmn/VueBpmn.vue +++ b/yudao-admin-ui/src/components/bpmn/VueBpmn.vue @@ -1,5 +1,5 @@ \ No newline at end of file + + diff --git a/yudao-admin-ui/src/components/bpmn/panel/NodePropertyPanel.vue b/yudao-admin-ui/src/components/bpmn/panel/NodePropertyPanel.vue index de2eea529..25087d01a 100644 --- a/yudao-admin-ui/src/components/bpmn/panel/NodePropertyPanel.vue +++ b/yudao-admin-ui/src/components/bpmn/panel/NodePropertyPanel.vue @@ -129,7 +129,8 @@ diff --git a/yudao-admin-ui/src/components/bpmn/panel/dialog/GlobalEventListenerDialog.vue b/yudao-admin-ui/src/components/bpmn/panel/dialog/GlobalEventListenerDialog.vue index 52e2f1fac..d954454bc 100644 --- a/yudao-admin-ui/src/components/bpmn/panel/dialog/GlobalEventListenerDialog.vue +++ b/yudao-admin-ui/src/components/bpmn/panel/dialog/GlobalEventListenerDialog.vue @@ -111,7 +111,5 @@ export default { diff --git a/yudao-admin-ui/src/components/bpmn/panel/dialog/UserSelectDialog.vue b/yudao-admin-ui/src/components/bpmn/panel/dialog/UserSelectDialog.vue index 98c7938cc..621d1a57c 100644 --- a/yudao-admin-ui/src/components/bpmn/panel/dialog/UserSelectDialog.vue +++ b/yudao-admin-ui/src/components/bpmn/panel/dialog/UserSelectDialog.vue @@ -167,7 +167,5 @@ export default { \ No newline at end of file + + diff --git a/yudao-admin-ui/src/router/index.js b/yudao-admin-ui/src/router/index.js index 194cb58b2..d06a740e3 100644 --- a/yudao-admin-ui/src/router/index.js +++ b/yudao-admin-ui/src/router/index.js @@ -1,11 +1,9 @@ import Vue from 'vue' import Router from 'vue-router' - -Vue.use(Router) - /* Layout */ import Layout from '@/layout' -import ParentView from '@/components/ParentView'; + +Vue.use(Router) /** * Note: 路由配置项 @@ -98,19 +96,6 @@ export const constantRoutes = [ } ] }, - { - path: '/bpmn', - component: Layout, - hidden: true, - children: [ - { - path: 'model', - component: (resolve) => require(['@/views/bpm/model'], resolve), - name: 'model', - meta: { title: '工作流模型', icon: '' } - } - ] - }, { path: '/job', component: Layout, diff --git a/yudao-admin-ui/src/views/bpm/model/index.vue b/yudao-admin-ui/src/views/bpm/model/index.vue index 2540b4f1c..f8b983b2a 100644 --- a/yudao-admin-ui/src/views/bpm/model/index.vue +++ b/yudao-admin-ui/src/views/bpm/model/index.vue @@ -50,14 +50,14 @@ - + + +