From c73c50feef7c9b2674ed241061aa2412bf90f0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E7=8E=89=E7=90=A6?= <7507756+jiang_yuqi@user.noreply.gitee.com> Date: Sat, 9 Sep 2023 01:36:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FlowBusinessKeyController.java | 75 ++++ .../controller/FlowDefinitionController.java | 13 +- .../flowable/domain/dto/FlowTaskDto.java | 6 +- .../ruoyi/flowable/domain/vo/FlowQueryVo.java | 2 +- .../service/IFlowBusinessKeyService.java | 27 ++ .../service/IFlowDefinitionService.java | 17 +- .../impl/FlowBusinessKeyServiceImpl.java | 51 +++ .../impl/FlowDefinitionServiceImpl.java | 100 ++--- .../service/impl/FlowTaskServiceImpl.java | 83 ++-- .../ruoyi/system/domain/FlowTaskEntity.java | 308 +++++++++++++ .../system/mapper/FlowBusinessKeyMapper.java | 18 + .../ruoyi/system/mapper/FlowDeployMapper.java | 12 +- .../mapper/flowable/FlowBusinessKeyMapper.xml | 50 +++ .../mapper/flowable/FlowDeployMapper.xml | 32 +- .../src/views/flowable/definition/index.vue | 381 ++++++---------- .../views/flowable/task/finished/index.vue | 183 +++----- .../views/flowable/task/myProcess/index.vue | 406 +++++++++--------- .../task/myProcess/initTaskDrawer.vue | 4 +- .../views/flowable/task/todo/detail/index.vue | 16 +- .../src/views/flowable/task/todo/index.vue | 107 ++--- .../video/videoConfig/videoPlayDrawer.vue | 32 +- ruoyi-ui/src/views/video/videoList/index.vue | 36 +- .../yanzhu/jh/publics/PublicsController.java | 19 +- 23 files changed, 1194 insertions(+), 784 deletions(-) create mode 100644 ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowBusinessKeyController.java create mode 100644 ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowBusinessKeyService.java create mode 100644 ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowBusinessKeyServiceImpl.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowTaskEntity.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowBusinessKeyMapper.java create mode 100644 ruoyi-system/src/main/resources/mapper/flowable/FlowBusinessKeyMapper.xml diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowBusinessKeyController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowBusinessKeyController.java new file mode 100644 index 00000000..8320f4cb --- /dev/null +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowBusinessKeyController.java @@ -0,0 +1,75 @@ +package com.ruoyi.flowable.controller; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.enums.SysRoleEnum; +import com.ruoyi.flowable.service.IFlowBusinessKeyService; +import com.ruoyi.system.domain.FlowProcDefDto; +import com.ruoyi.system.domain.FlowTaskEntity; +import com.ruoyi.system.service.ISysDeptService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 业务工作流程自定义 + *

+ * + * @author JiangYuQi + * @date 2021-04-03 + */ +@Slf4j +@Api(tags = "流程定义") +@RestController +@RequestMapping("/flowable/businessKey") +public class FlowBusinessKeyController extends BaseController { + + @Autowired + private ISysDeptService sysDeptService; + + @Autowired + private IFlowBusinessKeyService flowBusinessKeyService; + + /** + * 根据条件查询所有流任务 + * @param flowTaskEntity + * @return + */ + @GetMapping(value = "/allList") + public TableDataInfo allList(FlowTaskEntity flowTaskEntity) { + startPage(); + flowTaskEntity.setNowRole(Convert.toStr(getUserFirstRole())); + if(SysRoleEnum.ZGS.getCode().equals(flowTaskEntity.getNowRole())){ + flowTaskEntity.setNowDept(Convert.toStr(sysDeptService.getZGSDeptId(getDeptId()))); + }else{ + flowTaskEntity.setNowDept(Convert.toStr(getDeptId())); + } + flowTaskEntity.setNowUser(Convert.toStr(getUserId())); + return getDataTable(flowBusinessKeyService.selectAllFlowTaskByParams(flowTaskEntity)); + } + + /** + * 根据条件统计所有流任务 + * @param flowTaskEntity + * @return + */ + @GetMapping(value = "/queryCount") + public AjaxResult queryCount(FlowTaskEntity flowTaskEntity) { + flowTaskEntity.setNowRole(Convert.toStr(getUserFirstRole())); + if(SysRoleEnum.ZGS.getCode().equals(flowTaskEntity.getNowRole())){ + flowTaskEntity.setNowDept(Convert.toStr(sysDeptService.getZGSDeptId(getDeptId()))); + }else{ + flowTaskEntity.setNowDept(Convert.toStr(getDeptId())); + } + flowTaskEntity.setNowUser(Convert.toStr(getUserId())); + return success(flowBusinessKeyService.quueryCount(flowTaskEntity)); + } +} diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java index 541ebd9f..1b3674c5 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java @@ -60,11 +60,20 @@ public class FlowDefinitionController extends BaseController { @ApiOperation(value = "流程定义列表", response = FlowProcDefDto.class) public AjaxResult list(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum, @ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize, - @ApiParam(value = "流程名称", required = false) @RequestParam(required = false) String name, - @ApiParam(value = "流程类型", required = false) @RequestParam(required = false) String category) { + @ApiParam(value = "流程类型", required = false) @RequestParam(required = false) String category, + @ApiParam(value = "流程名称", required = false) @RequestParam(required = false) String name) { return AjaxResult.success(flowDefinitionService.list(category, name, pageNum, pageSize)); } + @GetMapping(value = "/myList") + @ApiOperation(value = "流程定义列表", response = FlowProcDefDto.class) + public AjaxResult myList(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum, + @ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize, + @ApiParam(value = "流程类型", required = false) @RequestParam(required = false) String category, + @ApiParam(value = "流程名称", required = false) @RequestParam(required = false) String name) { + return AjaxResult.success(flowDefinitionService.myList(getUsername(), category, name, pageNum, pageSize)); + } + @ApiOperation(value = "导入流程文件", notes = "上传bpmn20的xml文件") @PostMapping("/import") diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowTaskDto.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowTaskDto.java index 0ef86c04..91a6749a 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowTaskDto.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowTaskDto.java @@ -1,7 +1,6 @@ package com.ruoyi.flowable.domain.dto; import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.common.core.domain.entity.SysUser; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; @@ -9,8 +8,6 @@ import lombok.Setter; import java.io.Serializable; import java.util.Date; -import java.util.List; -import java.util.Map; /** *

工作流任务

@@ -23,6 +20,9 @@ import java.util.Map; @ApiModel("工作流任务相关-返回参数") public class FlowTaskDto implements Serializable { + @ApiModelProperty("业务名称") + private String businessKeyName; + @ApiModelProperty("任务编号") private String taskId; diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/FlowQueryVo.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/FlowQueryVo.java index adba1efc..95657a8c 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/FlowQueryVo.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/FlowQueryVo.java @@ -20,7 +20,7 @@ public class FlowQueryVo { @ApiModelProperty("流程名称") private String name; - @ApiModelProperty("流程类型") + @ApiModelProperty("流程类别") private String category; @ApiModelProperty("开始时间") diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowBusinessKeyService.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowBusinessKeyService.java new file mode 100644 index 00000000..519f9724 --- /dev/null +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowBusinessKeyService.java @@ -0,0 +1,27 @@ +package com.ruoyi.flowable.service; + +import com.ruoyi.system.domain.FlowTaskEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author JiangYuQi + * @date 2021-04-03 14:41 + */ +public interface IFlowBusinessKeyService { + + /** + * 根据条件查询所有流任务 + * @param flowTaskEntity + * @return + */ + public List selectAllFlowTaskByParams(FlowTaskEntity flowTaskEntity); + + /** + * 根据条件统计所有流任务 + * @param flowTaskEntity + * @return + */ + public Map quueryCount(FlowTaskEntity flowTaskEntity); +} diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowDefinitionService.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowDefinitionService.java index b29fc4bc..008c0716 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowDefinitionService.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowDefinitionService.java @@ -16,15 +16,28 @@ public interface IFlowDefinitionService { boolean exist(String processDefinitionKey); - /** * 流程定义列表 * + * @param category 流程类别 + * @param name 流程名称 * @param pageNum 当前页码 * @param pageSize 每页条数 * @return 流程定义分页列表数据 */ - Page list(String category, String name,Integer pageNum, Integer pageSize); + Page list(String category,String name,Integer pageNum, Integer pageSize); + + /** + * 流程定义列表 + * + * @param username 用户名称 + * @param category 流程类别 + * @param name 流程名称 + * @param pageNum 当前页码 + * @param pageSize 每页条数 + * @return 流程定义分页列表数据 + */ + Page myList(String username, String category,String name,Integer pageNum, Integer pageSize); /** * 导入流程文件 diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowBusinessKeyServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowBusinessKeyServiceImpl.java new file mode 100644 index 00000000..12329514 --- /dev/null +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowBusinessKeyServiceImpl.java @@ -0,0 +1,51 @@ +package com.ruoyi.flowable.service.impl; + +import com.ruoyi.flowable.service.IFlowBusinessKeyService; +import com.ruoyi.system.domain.FlowTaskEntity; +import com.ruoyi.system.mapper.FlowBusinessKeyMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 业务工作流程自定义 + * + * @author Tony + * @date 2021-04-03 + */ +@Service +@Slf4j +public class FlowBusinessKeyServiceImpl implements IFlowBusinessKeyService { + + @Resource + private FlowBusinessKeyMapper flowBusinessKeyMapper; + /** + * 根据条件查询所有流任务 + * @param flowTaskEntity + * @return + */ + @Override + public List selectAllFlowTaskByParams(FlowTaskEntity flowTaskEntity) { + return flowBusinessKeyMapper.selectAllFlowTaskByParams(flowTaskEntity); + } + + /** + * 根据条件统计所有流任务 + * @param flowTaskEntity + * @return + */ + public Map quueryCount(FlowTaskEntity flowTaskEntity) { + flowTaskEntity.setActiveName("await"); + int awaitSize = flowBusinessKeyMapper.selectAllFlowTaskByParams(flowTaskEntity).size(); + flowTaskEntity.setActiveName("finished"); + int finishedSize = flowBusinessKeyMapper.selectAllFlowTaskByParams(flowTaskEntity).size(); + Map dataMap = new HashMap<>(); + dataMap.put("await",awaitSize); + dataMap.put("finished",finishedSize); + return dataMap; + } +} diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java index 8490721c..1cc7d6fa 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java @@ -3,6 +3,7 @@ package com.ruoyi.flowable.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.ruoyi.common.core.text.Convert; import com.ruoyi.flowable.common.constant.ProcessConstants; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; @@ -29,6 +30,7 @@ import org.flowable.image.impl.DefaultProcessDiagramGenerator; import org.flowable.task.api.Task; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; @@ -75,6 +77,8 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl /** * 流程定义列表 * + * @param category 流程类别 + * @param name 流程名称 * @param pageNum 当前页码 * @param pageSize 每页条数 * @return 流程定义分页列表数据 @@ -82,48 +86,47 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl @Override public Page list(String category, String name, Integer pageNum, Integer pageSize) { Page page = new Page<>(); -// // 流程定义列表数据查询 -// final ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); -// if (StringUtils.isNotEmpty(name)) { -// processDefinitionQuery.processDefinitionNameLike(name); -// } -//// processDefinitionQuery.orderByProcessDefinitionKey().asc(); -// page.setTotal(processDefinitionQuery.count()); -// List processDefinitionList = processDefinitionQuery.listPage(pageSize * (pageNum - 1), pageSize); -// -// List dataList = new ArrayList<>(); -// for (ProcessDefinition processDefinition : processDefinitionList) { -// String deploymentId = processDefinition.getDeploymentId(); -// Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); -// FlowProcDefDto reProcDef = new FlowProcDefDto(); -// BeanUtils.copyProperties(processDefinition, reProcDef); -// SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(deploymentId); -// if (Objects.nonNull(sysForm)) { -// reProcDef.setFormName(sysForm.getFormName()); -// reProcDef.setFormId(sysForm.getFormId()); -// } -// // 流程定义时间 -// reProcDef.setDeploymentTime(deployment.getDeploymentTime()); -// dataList.add(reProcDef); -// } PageHelper.startPage(pageNum, pageSize); - final List dataList = flowDeployMapper.selectDeployList(category, name); - /** - * 这里不启用挂载表单 - */ + final List dataList = flowDeployMapper.selectDeployList(category,name); // 加载挂表单 - //for (FlowProcDefDto procDef : dataList) { - //SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(procDef.getDeploymentId()); - //if (Objects.nonNull(sysForm)) { - // procDef.setFormName(sysForm.getFormName()); - // procDef.setFormId(sysForm.getFormId()); - //} - //} + for (FlowProcDefDto procDef : dataList) { + SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(procDef.getDeploymentId()); + if (Objects.nonNull(sysForm)) { + procDef.setFormName(sysForm.getFormName()); + procDef.setFormId(sysForm.getFormId()); + } + } page.setTotal(new PageInfo(dataList).getTotal()); page.setRecords(dataList); return page; } + /** + * 流程定义列表 + * + * @param category 流程类别 + * @param name 流程名称 + * @param pageNum 当前页码 + * @param pageSize 每页条数 + * @return 流程定义分页列表数据 + */ + @Override + public Page myList(String username, String category, String name, Integer pageNum, Integer pageSize) { + Page page = new Page<>(); + PageHelper.startPage(pageNum, pageSize); + final List dataList = flowDeployMapper.selectMyDeployList(username, category ,name); + // 加载挂表单 + for (FlowProcDefDto procDef : dataList) { + SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(procDef.getDeploymentId()); + if (Objects.nonNull(sysForm)) { + procDef.setFormName(sysForm.getFormName()); + procDef.setFormId(sysForm.getFormId()); + } + } + page.setTotal(new PageInfo(dataList).getTotal()); + page.setRecords(dataList); + return page; + } /** * 导入流程文件 @@ -191,6 +194,7 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl * @return */ @Override + @Transactional public AjaxResult startProcessInstanceById(String procDefId, Map variables) { try { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId) @@ -202,19 +206,19 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl SysUser sysUser = SecurityUtils.getLoginUser().getUser(); identityService.setAuthenticatedUserId(sysUser.getUserId().toString()); variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUserId()); - runtimeService.startProcessInstanceById(procDefId, variables); - // 流程发起时 跳过发起人节点 -// SysUser sysUser = SecurityUtils.getLoginUser().getUser(); -// identityService.setAuthenticatedUserId(sysUser.getUserId().toString()); -// variables.put(ProcessConstants.PROCESS_INITIATOR, ""); -// ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); -// // 给第一步申请人节点设置任务执行人和意见 -// Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult(); -// if (Objects.nonNull(task)) { -// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getNickName() + "发起流程申请"); -//// taskService.setAssignee(task.getId(), sysUser.getUserId().toString()); -// taskService.complete(task.getId(), variables); -// } + ProcessInstance processInstance; + if(variables.get("businessKey")!=null){ + processInstance = runtimeService.startProcessInstanceById(procDefId, Convert.toStr(variables.get("businessKey")),variables); + }else{ + processInstance = runtimeService.startProcessInstanceById(procDefId, variables); + } + // 给第一步申请人节点设置任务执行人和意见 + Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult(); + if (Objects.nonNull(task)) { + taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getNickName() + "发起流程申请"); + taskService.setAssignee(task.getId(), Convert.toStr(sysUser.getUserId())); + taskService.complete(task.getId(), variables); + } return AjaxResult.success("流程启动成功"); } catch (Exception e) { e.printStackTrace(); diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java index 3513c493..cfb6488d 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.text.Convert; import com.ruoyi.flowable.common.constant.ProcessConstants; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysRole; @@ -28,6 +29,7 @@ import com.ruoyi.flowable.service.IFlowTaskService; import com.ruoyi.flowable.service.ISysDeployFormService; import com.ruoyi.flowable.service.ISysFormService; import com.ruoyi.system.domain.SysForm; +import com.ruoyi.system.mapper.FlowBusinessKeyMapper; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; import lombok.extern.slf4j.Slf4j; @@ -86,6 +88,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask private ISysDeployFormService sysInstanceFormService; @Resource private ISysFormService sysFormService; + @Resource + private FlowBusinessKeyMapper flowBusinessKeyMapper; /** * 完成任务 @@ -521,46 +525,45 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask List historicProcessInstances = historicProcessInstanceQuery.listPage(queryVo.getPageSize() * (queryVo.getPageNum() - 1), queryVo.getPageSize()); page.setTotal(historicProcessInstanceQuery.count()); List flowList = new ArrayList<>(); - for (HistoricProcessInstance hisIns : historicProcessInstances) { - FlowTaskDto flowTask = new FlowTaskDto(); - flowTask.setCreateTime(hisIns.getStartTime()); - flowTask.setFinishTime(hisIns.getEndTime()); - flowTask.setProcInsId(hisIns.getId()); - - // 计算耗时 - if (Objects.nonNull(hisIns.getEndTime())) { - long time = hisIns.getEndTime().getTime() - hisIns.getStartTime().getTime(); - flowTask.setDuration(getDate(time)); - } else { - long time = System.currentTimeMillis() - hisIns.getStartTime().getTime(); - flowTask.setDuration(getDate(time)); - } - // 流程定义信息 - ProcessDefinition pd = repositoryService.createProcessDefinitionQuery() - .processDefinitionId(hisIns.getProcessDefinitionId()) - .singleResult(); - flowTask.setDeployId(pd.getDeploymentId()); - flowTask.setProcDefName(pd.getName()); - flowTask.setProcDefVersion(pd.getVersion()); - flowTask.setCategory(pd.getCategory()); - flowTask.setProcDefVersion(pd.getVersion()); - // 当前所处流程 - List taskList = taskService.createTaskQuery().processInstanceId(hisIns.getId()).list(); - if (CollectionUtils.isNotEmpty(taskList)) { - flowTask.setTaskId(taskList.get(0).getId()); - flowTask.setTaskName(taskList.get(0).getName()); - if (StringUtils.isNotBlank(taskList.get(0).getAssignee())) { - // 当前任务节点办理人信息 - SysUser sysUser = sysUserService.selectUserById(Long.parseLong(taskList.get(0).getAssignee())); - if (Objects.nonNull(sysUser)) { - flowTask.setAssigneeId(sysUser.getUserId()); - flowTask.setAssigneeName(sysUser.getNickName()); - flowTask.setAssigneeDeptName(Objects.nonNull(sysUser.getDept()) ? sysUser.getDept().getDeptName() : ""); - } + if(CollectionUtils.isNotEmpty(historicProcessInstances)){ + for (HistoricProcessInstance hisIns : historicProcessInstances) { + FlowTaskDto flowTask = new FlowTaskDto(); + flowTask.setCreateTime(hisIns.getStartTime()); + flowTask.setFinishTime(hisIns.getEndTime()); + flowTask.setProcInsId(hisIns.getId()); + // 计算耗时 + if (Objects.nonNull(hisIns.getEndTime())) { + long time = hisIns.getEndTime().getTime() - hisIns.getStartTime().getTime(); + flowTask.setDuration(getDate(time)); + } else { + long time = System.currentTimeMillis() - hisIns.getStartTime().getTime(); + flowTask.setDuration(getDate(time)); } - } else { - List historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(hisIns.getId()).orderByHistoricTaskInstanceEndTime().desc().list(); - if(CollectionUtils.isNotEmpty(historicTaskInstance)){ + // 流程定义信息 + ProcessDefinition pd = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(hisIns.getProcessDefinitionId()) + .singleResult(); + flowTask.setDeployId(pd.getDeploymentId()); + flowTask.setProcDefName(pd.getName()); + flowTask.setProcDefVersion(pd.getVersion()); + flowTask.setCategory(pd.getCategory()); + flowTask.setProcDefVersion(pd.getVersion()); + // 当前所处流程 + List taskList = taskService.createTaskQuery().processInstanceId(hisIns.getId()).list(); + if (CollectionUtils.isNotEmpty(taskList)) { + flowTask.setTaskId(taskList.get(0).getId()); + flowTask.setTaskName(taskList.get(0).getName()); + if (StringUtils.isNotBlank(taskList.get(0).getAssignee())) { + // 当前任务节点办理人信息 + SysUser sysUser = sysUserService.selectUserById(Long.parseLong(taskList.get(0).getAssignee())); + if (Objects.nonNull(sysUser)) { + flowTask.setAssigneeId(sysUser.getUserId()); + flowTask.setAssigneeName(sysUser.getNickName()); + flowTask.setAssigneeDeptName(Objects.nonNull(sysUser.getDept()) ? sysUser.getDept().getDeptName() : ""); + } + } + } else { + List historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(hisIns.getId()).orderByHistoricTaskInstanceEndTime().desc().list(); flowTask.setTaskId(historicTaskInstance.get(0).getId()); flowTask.setTaskName(historicTaskInstance.get(0).getName()); if (StringUtils.isNotBlank(historicTaskInstance.get(0).getAssignee())) { @@ -573,8 +576,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } } } + flowList.add(flowTask); } - flowList.add(flowTask); } page.setRecords(flowList); return AjaxResult.success(page); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowTaskEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowTaskEntity.java new file mode 100644 index 00000000..6d12dac5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowTaskEntity.java @@ -0,0 +1,308 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Date; + +/** + *

工作流任务

+ * + * @author JiangYuQi + * @date 2021-04-03 + */ +public class FlowTaskEntity extends BaseEntity{ + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("业务名称") + private String businessKeyName; + + @ApiModelProperty("任务编号") + private String taskId; + + @ApiModelProperty("任务执行编号") + private String executionId; + + @ApiModelProperty("任务名称") + private String taskName; + + @ApiModelProperty("任务Key") + private String taskDefKey; + + @ApiModelProperty("任务执行人Id") + private Long assigneeId; + + @ApiModelProperty("部门名称") + private String deptName; + + @ApiModelProperty("流程发起人部门名称") + private String startDeptName; + + @ApiModelProperty("任务执行人名称") + private String assigneeName; + + @ApiModelProperty("任务执行人部门") + private String assigneeDeptName;; + + @ApiModelProperty("流程发起人Id") + private String startUserId; + + @ApiModelProperty("流程发起人名称") + private String startUserName; + + @ApiModelProperty("流程类型") + private String category; + + @ApiModelProperty("流程变量信息") + private Object procVars; + + @ApiModelProperty("局部变量信息") + private Object taskLocalVars; + + @ApiModelProperty("流程部署编号") + private String deployId; + + @ApiModelProperty("流程ID") + private String procDefId; + + @ApiModelProperty("流程key") + private String procDefKey; + + @ApiModelProperty("流程定义名称") + private String procDefName; + + @ApiModelProperty("流程定义内置使用版本") + private int procDefVersion; + + @ApiModelProperty("流程实例ID") + private String procInsId; + + @ApiModelProperty("历史流程实例ID") + private String hisProcInsId; + + @ApiModelProperty("任务耗时") + private String duration; + + @ApiModelProperty("候选执行人") + private String candidate; + + @ApiModelProperty("任务创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + @ApiModelProperty("任务完成时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date finishTime; + + public String getBusinessKeyName() { + return businessKeyName; + } + + public void setBusinessKeyName(String businessKeyName) { + this.businessKeyName = businessKeyName; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getExecutionId() { + return executionId; + } + + public void setExecutionId(String executionId) { + this.executionId = executionId; + } + + public String getTaskName() { + return taskName; + } + + public void setTaskName(String taskName) { + this.taskName = taskName; + } + + public String getTaskDefKey() { + return taskDefKey; + } + + public void setTaskDefKey(String taskDefKey) { + this.taskDefKey = taskDefKey; + } + + public Long getAssigneeId() { + return assigneeId; + } + + public void setAssigneeId(Long assigneeId) { + this.assigneeId = assigneeId; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public String getStartDeptName() { + return startDeptName; + } + + public void setStartDeptName(String startDeptName) { + this.startDeptName = startDeptName; + } + + public String getAssigneeName() { + return assigneeName; + } + + public void setAssigneeName(String assigneeName) { + this.assigneeName = assigneeName; + } + + public String getAssigneeDeptName() { + return assigneeDeptName; + } + + public void setAssigneeDeptName(String assigneeDeptName) { + this.assigneeDeptName = assigneeDeptName; + } + + public String getStartUserId() { + return startUserId; + } + + public void setStartUserId(String startUserId) { + this.startUserId = startUserId; + } + + public String getStartUserName() { + return startUserName; + } + + public void setStartUserName(String startUserName) { + this.startUserName = startUserName; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Object getProcVars() { + return procVars; + } + + public void setProcVars(Object procVars) { + this.procVars = procVars; + } + + public Object getTaskLocalVars() { + return taskLocalVars; + } + + public void setTaskLocalVars(Object taskLocalVars) { + this.taskLocalVars = taskLocalVars; + } + + public String getDeployId() { + return deployId; + } + + public void setDeployId(String deployId) { + this.deployId = deployId; + } + + public String getProcDefId() { + return procDefId; + } + + public void setProcDefId(String procDefId) { + this.procDefId = procDefId; + } + + public String getProcDefKey() { + return procDefKey; + } + + public void setProcDefKey(String procDefKey) { + this.procDefKey = procDefKey; + } + + public String getProcDefName() { + return procDefName; + } + + public void setProcDefName(String procDefName) { + this.procDefName = procDefName; + } + + public int getProcDefVersion() { + return procDefVersion; + } + + public void setProcDefVersion(int procDefVersion) { + this.procDefVersion = procDefVersion; + } + + public String getProcInsId() { + return procInsId; + } + + public void setProcInsId(String procInsId) { + this.procInsId = procInsId; + } + + public String getHisProcInsId() { + return hisProcInsId; + } + + public void setHisProcInsId(String hisProcInsId) { + this.hisProcInsId = hisProcInsId; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getCandidate() { + return candidate; + } + + public void setCandidate(String candidate) { + this.candidate = candidate; + } + + @Override + public Date getCreateTime() { + return createTime; + } + + @Override + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getFinishTime() { + return finishTime; + } + + public void setFinishTime(Date finishTime) { + this.finishTime = finishTime; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowBusinessKeyMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowBusinessKeyMapper.java new file mode 100644 index 00000000..455118d7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowBusinessKeyMapper.java @@ -0,0 +1,18 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.FlowTaskEntity; + +import java.util.List; + +/*** + * 工作流业务相关 + */ +public interface FlowBusinessKeyMapper { + + /** + * 根据条件查询所有流任务 + * @param flowTaskEntity + * @return + */ + public List selectAllFlowTaskByParams(FlowTaskEntity flowTaskEntity); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowDeployMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowDeployMapper.java index af588909..b17340a1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowDeployMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowDeployMapper.java @@ -16,8 +16,18 @@ public interface FlowDeployMapper { /** * 流程定义列表 - * @param name + * @param category 流程类别 + * @param name 流程名称 * @return */ List selectDeployList(@Param("category")String category, @Param("name")String name); + + /** + * 我的流程定义列表 + * @param username 登录用户 + * @param category 流程类别 + * @param name 流程名称 + * @return + */ + List selectMyDeployList(@Param("username")String username, @Param("category")String category, @Param("name")String name); } diff --git a/ruoyi-system/src/main/resources/mapper/flowable/FlowBusinessKeyMapper.xml b/ruoyi-system/src/main/resources/mapper/flowable/FlowBusinessKeyMapper.xml new file mode 100644 index 00000000..6c56707f --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/flowable/FlowBusinessKeyMapper.xml @@ -0,0 +1,50 @@ + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/flowable/FlowDeployMapper.xml b/ruoyi-system/src/main/resources/mapper/flowable/FlowDeployMapper.xml index 0c1d13fa..d541e328 100644 --- a/ruoyi-system/src/main/resources/mapper/flowable/FlowDeployMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/flowable/FlowDeployMapper.xml @@ -3,10 +3,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + \ No newline at end of file diff --git a/ruoyi-ui/src/views/flowable/definition/index.vue b/ruoyi-ui/src/views/flowable/definition/index.vue index 92292505..6d8b72a6 100644 --- a/ruoyi-ui/src/views/flowable/definition/index.vue +++ b/ruoyi-ui/src/views/flowable/definition/index.vue @@ -1,51 +1,25 @@