From 84416591b6952a81df00d69b7dd3b330fff4272d 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: Sun, 17 Sep 2023 02:06:22 +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 --- ruoyi-flowable/pom.xml | 9 - .../controller/FlowBusinessKeyController.java | 3 + .../controller/FlowDefinitionController.java | 6 +- .../controller/FlowInstanceController.java | 4 +- .../controller/FlowTaskController.java | 8 + .../ruoyi/flowable/domain/vo/StartTaskVO.java | 63 ++++++ .../service/IFlowDefinitionService.java | 6 +- .../impl/FlowBusinessKeyServiceImpl.java | 1 - .../impl/FlowDefinitionServiceImpl.java | 47 ++-- .../service/impl/FlowTaskServiceImpl.java | 68 +++--- .../ruoyi/system/domain/FlowProcDefDto.java | 3 + .../system/mapper/SysUserRoleMapper.java | 8 + .../ruoyi/system/service/ISysUserService.java | 9 + .../service/impl/SysUserServiceImpl.java | 10 + .../mapper/flowable/FlowBusinessKeyMapper.xml | 1 + .../mapper/flowable/FlowDeployMapper.xml | 2 + .../mapper/system/SysUserRoleMapper.xml | 6 + .../task/myProcess/editLeaveTaskDrawer.vue | 3 +- .../task/myProcess/editTaskDrawer.vue | 1 + .../views/flowable/task/myProcess/index.vue | 4 +- .../task/myProcess/initLeaveTaskDrawer.vue | 2 +- .../task/myProcess/initTaskDrawer.vue | 6 +- .../checkDetection/checkDetectionDrawer.vue | 4 +- ruoyi-wechat/pom.xml | 5 + .../controller/FlowableController.java | 209 ++++++++++++++++++ .../ProjectProblemmodifyController.java | 10 +- .../mapper/SmzSspProblemmodifyMapper.java | 8 + .../service/ISmzSspProblemmodifyService.java | 8 + .../impl/SmzSspProblemmodifyServiceImpl.java | 12 + .../trouble/SmzSspProblemmodifyMapper.xml | 15 +- 30 files changed, 471 insertions(+), 70 deletions(-) create mode 100644 ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/StartTaskVO.java create mode 100644 ruoyi-wechat/src/main/java/com/ruoyi/web/flowable/controller/FlowableController.java diff --git a/ruoyi-flowable/pom.xml b/ruoyi-flowable/pom.xml index 35442c28..5464e4ae 100644 --- a/ruoyi-flowable/pom.xml +++ b/ruoyi-flowable/pom.xml @@ -84,13 +84,4 @@ - - - - - - - - - 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 index 2a97526c..848802fb 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowBusinessKeyController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowBusinessKeyController.java @@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.stream.Collectors; + /** *

* 业务工作流程自定义 @@ -106,6 +108,7 @@ public class FlowBusinessKeyController extends BaseController { flowTaskEntity.setNowDept(Convert.toStr(getDeptId())); } flowTaskEntity.setNowUser(Convert.toStr(SecurityUtils.getUserId())); + flowTaskEntity.setRoleIds(SecurityUtils.getLoginUser().getUser().getRoles().stream().map(role -> role.getRoleId()).collect(Collectors.toList())); return getDataTable(flowBusinessKeyService.selectMyAwaitFlowTask(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 1b3674c5..b7ef624c 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 @@ -1,9 +1,11 @@ package com.ruoyi.flowable.controller; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.flowable.domain.dto.FlowSaveXmlVo; import com.ruoyi.flowable.service.IFlowDefinitionService; import com.ruoyi.system.domain.FlowProcDefDto; @@ -165,10 +167,12 @@ public class FlowDefinitionController extends BaseController { @ApiOperation(value = "发起流程") + @Log(title = "发起流程", businessType = BusinessType.INSERT) @PostMapping("/start/{procDefId}") public AjaxResult start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, @ApiParam(value = "变量集合,json对象") @RequestBody Map variables) { - return flowDefinitionService.startProcessInstanceById(procDefId, variables); + SysUser sysUser = getLoginUser().getUser(); + return flowDefinitionService.startProcessInstanceById(procDefId, sysUser.getUserId().toString(), sysUser.getNickName(), variables); } diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowInstanceController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowInstanceController.java index 0a521221..15308709 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowInstanceController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowInstanceController.java @@ -1,7 +1,8 @@ package com.ruoyi.flowable.controller; - +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.flowable.domain.vo.FlowTaskVo; import com.ruoyi.flowable.service.IFlowInstanceService; import io.swagger.annotations.Api; @@ -53,6 +54,7 @@ public class FlowInstanceController { } @ApiOperation(value = "删除流程实例") + @Log(title = "删除流程", businessType = BusinessType.INSERT) @DeleteMapping(value = "/delete/{instanceIds}") public AjaxResult delete(@ApiParam(value = "流程实例ID", required = true) @PathVariable String[] instanceIds, @ApiParam(value = "删除原因") @RequestParam(required = false) String deleteReason) { diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java index 226857da..3e53f26c 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java @@ -1,6 +1,8 @@ package com.ruoyi.flowable.controller; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.flowable.domain.dto.FlowTaskDto; import com.ruoyi.flowable.domain.vo.FlowQueryVo; import com.ruoyi.flowable.domain.vo.FlowTaskVo; @@ -41,12 +43,14 @@ public class FlowTaskController { } @ApiOperation(value = "取消申请", response = FlowTaskDto.class) + @Log(title = "终止申请", businessType = BusinessType.UPDATE) @PostMapping(value = "/stopProcess") public AjaxResult stopProcess(@RequestBody FlowTaskVo flowTaskVo) { return flowTaskService.stopProcess(flowTaskVo); } @ApiOperation(value = "撤回流程", response = FlowTaskDto.class) + @Log(title = "撤回流程", businessType = BusinessType.UPDATE) @PostMapping(value = "/revokeProcess") public AjaxResult revokeProcess(@RequestBody FlowTaskVo flowTaskVo) { return flowTaskService.revokeProcess(flowTaskVo); @@ -85,12 +89,14 @@ public class FlowTaskController { } @ApiOperation(value = "审批任务") + @Log(title = "审批流程", businessType = BusinessType.UPDATE) @PostMapping(value = "/complete") public AjaxResult complete(@RequestBody FlowTaskVo flowTaskVo) { return flowTaskService.complete(flowTaskVo); } @ApiOperation(value = "驳回任务") + @Log(title = "驳回流程", businessType = BusinessType.UPDATE) @PostMapping(value = "/reject") public AjaxResult taskReject(@RequestBody FlowTaskVo flowTaskVo) { flowTaskService.taskReject(flowTaskVo); @@ -98,6 +104,7 @@ public class FlowTaskController { } @ApiOperation(value = "退回任务") + @Log(title = "退回流程", businessType = BusinessType.UPDATE) @PostMapping(value = "/return") public AjaxResult taskReturn(@RequestBody FlowTaskVo flowTaskVo) { flowTaskService.taskReturn(flowTaskVo); @@ -111,6 +118,7 @@ public class FlowTaskController { } @ApiOperation(value = "删除任务") + @Log(title = "删除流程", businessType = BusinessType.UPDATE) @DeleteMapping(value = "/delete") public AjaxResult delete(@RequestBody FlowTaskVo flowTaskVo) { flowTaskService.deleteTask(flowTaskVo); diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/StartTaskVO.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/StartTaskVO.java new file mode 100644 index 00000000..826157c3 --- /dev/null +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/StartTaskVO.java @@ -0,0 +1,63 @@ +package com.ruoyi.flowable.domain.vo; + +import java.io.Serializable; +import java.util.Map; + +/** + * 流程实例启动 + * + * @author JiangYuQi + * @date 2020-07-07 + */ +public class StartTaskVO implements Serializable +{ + + private static final long serialVersionUID = 1L; + + //流程实例ID + private String procDefId; + private String userId; + private String userName; + private String nickName; + private Map variables; + + public String getProcDefId() { + return procDefId; + } + + public void setProcDefId(String procDefId) { + this.procDefId = procDefId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public Map getVariables() { + return variables; + } + + public void setVariables(Map variables) { + this.variables = variables; + } +} 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 008c0716..0607c9fc 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 @@ -3,9 +3,11 @@ package com.ruoyi.flowable.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.domain.FlowProcDefDto; +import org.flowable.bpmn.model.FlowElement; import java.io.IOException; import java.io.InputStream; +import java.util.List; import java.util.Map; /** @@ -64,7 +66,7 @@ public interface IFlowDefinitionService { * @return */ - AjaxResult startProcessInstanceById(String procDefId, Map variables); + AjaxResult startProcessInstanceById(String procDefId, String userId, String nickName, Map variables); /** @@ -90,4 +92,6 @@ public interface IFlowDefinitionService { * @return */ InputStream readImage(String deployId); + + public List readNodes(String deployId); } 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 index efdb90e6..aa199912 100644 --- 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 @@ -88,7 +88,6 @@ public class FlowBusinessKeyServiceImpl implements IFlowBusinessKeyService { */ @Override public List> selectMyAwaitFlowTask(FlowTaskEntity flowTaskEntity){ - flowTaskEntity.setRoleIds(SecurityUtils.getLoginUser().getUser().getRoles().stream().map(role -> role.getRoleId()).collect(Collectors.toList())); return flowBusinessKeyMapper.selectMyAwaitFlowTask(flowTaskEntity); } 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 70f6beb2..83dc2de0 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 @@ -21,6 +21,8 @@ import com.ruoyi.system.service.ISysUserService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.FlowElement; +import org.flowable.bpmn.model.GraphicInfo; import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.repository.ProcessDefinitionQuery; @@ -35,6 +37,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.stream.Collectors; /** * 流程定义 @@ -114,13 +117,13 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl 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()); - } - } + //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; @@ -184,6 +187,23 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl } + @Override + public List readNodes(String deployId) { + List list = new ArrayList<>(); + ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); + //获得图片流 + DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator(); + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); + Collection flowElements = bpmnModel.getProcesses().get(0).getFlowElements(); + if(flowElements.size()>0){ + for(FlowElement fe:flowElements){ + list.add(fe); + } + } + //输出为节点描述 + return list; + } + /** * 根据流程定义ID启动流程实例 * @@ -193,17 +213,16 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl */ @Override @Transactional - public AjaxResult startProcessInstanceById(String procDefId, Map variables) { + public AjaxResult startProcessInstanceById(String procDefId, String userId, String nickName, Map variables) { try { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId) .latestVersion().singleResult(); if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) { - return AjaxResult.error("流程已被挂起,请先激活流程"); + return AjaxResult.error("流程已被挂起,请联系管理员先激活流程"); } // 设置流程发起人Id到流程中 - SysUser sysUser = SecurityUtils.getLoginUser().getUser(); - identityService.setAuthenticatedUserId(sysUser.getUserId().toString()); - variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUserId()); + identityService.setAuthenticatedUserId(userId); + variables.put(ProcessConstants.PROCESS_INITIATOR, userId); ProcessInstance processInstance; if(variables.get("businessKey")!=null){ processInstance = runtimeService.startProcessInstanceById(procDefId, Convert.toStr(variables.get("businessKey")),variables); @@ -213,8 +232,8 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl // 给第一步申请人节点设置任务执行人和意见 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.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), nickName + "发起流程申请"); + taskService.setAssignee(task.getId(), Convert.toStr(userId)); taskService.complete(task.getId(), variables); } return AjaxResult.success("流程启动成功"); 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 1a8fd200..725a157f 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 @@ -40,6 +40,7 @@ import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.*; import org.flowable.common.engine.api.FlowableException; import org.flowable.common.engine.api.FlowableObjectNotFoundException; +import org.flowable.common.engine.impl.identity.Authentication; import org.flowable.engine.ProcessEngineConfiguration; import org.flowable.engine.history.HistoricActivityInstance; import org.flowable.engine.history.HistoricProcessInstance; @@ -105,10 +106,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment()); taskService.resolveTask(taskVo.getTaskId(), taskVo.getVariables()); } else { - if(task.getName().equals("提交申请")){ - taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), "重新提交流程申请!!"); - }else{ + if(StringUtils.isNotEmpty(taskVo.getComment())){ taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment()); + }else{ + taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getAssignee()+"重新提交流程申请!!"); } taskService.setAssignee(taskVo.getTaskId(), taskVo.getUserId()); taskService.complete(taskVo.getTaskId(), taskVo.getVariables()); @@ -305,6 +306,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask })); // 设置回退意见 currentTaskIds.forEach(currentTaskId -> taskService.addComment(currentTaskId, task.getProcessInstanceId(), FlowComment.REBACK.getType(), flowTaskVo.getComment())); + taskService.setAssignee(flowTaskVo.getTaskId(), flowTaskVo.getUserId()); try { // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1) @@ -608,11 +610,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask List endNodes = process.findFlowElementsOfType(EndEvent.class, false); if (CollectionUtils.isNotEmpty(endNodes)) { // TODO 取消流程为什么要设置流程发起人? -// SysUser loginUser = SecurityUtils.getLoginUser().getUser(); -// Authentication.setAuthenticatedUserId(loginUser.getUserId().toString()); - -// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(), -// StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment()); + Authentication.setAuthenticatedUserId(flowTaskVo.getUserId()); + taskService.addComment(task.get(0).getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(), + StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment()); + taskService.setAssignee(task.get(0).getId(), flowTaskVo.getUserId()); // 获取当前流程最后一个节点 String endId = endNodes.get(0).getId(); List executions = runtimeService.createExecutionQuery() @@ -1136,36 +1137,39 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask public AjaxResult flowXmlAndNode(String procInsId, String deployId) { try { List flowViewerList = new ArrayList<>(); - // 获取已经完成的节点 - List listFinished = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(procInsId) - .finished() - .list(); + if(StringUtils.isNotEmpty(procInsId)){ + // 获取已经完成的节点 + List listFinished = historyService.createHistoricActivityInstanceQuery() + .processInstanceId(procInsId) + .finished() + .list(); - // 保存已经完成的流程节点编号 - listFinished.forEach(s -> { - FlowViewerDto flowViewerDto = new FlowViewerDto(); - flowViewerDto.setKey(s.getActivityId()); - flowViewerDto.setCompleted(true); - flowViewerList.add(flowViewerDto); - }); + // 保存已经完成的流程节点编号 + listFinished.forEach(s -> { + FlowViewerDto flowViewerDto = new FlowViewerDto(); + flowViewerDto.setKey(s.getActivityId()); + flowViewerDto.setCompleted(true); + flowViewerList.add(flowViewerDto); + }); - // 获取代办节点 - List listUnFinished = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(procInsId) - .unfinished() - .list(); + // 获取代办节点 + List listUnFinished = historyService.createHistoricActivityInstanceQuery() + .processInstanceId(procInsId) + .unfinished() + .list(); - // 保存需要代办的节点编号 - listUnFinished.forEach(s -> { - FlowViewerDto flowViewerDto = new FlowViewerDto(); - flowViewerDto.setKey(s.getActivityId()); - flowViewerDto.setCompleted(false); - flowViewerList.add(flowViewerDto); - }); + // 保存需要代办的节点编号 + listUnFinished.forEach(s -> { + FlowViewerDto flowViewerDto = new FlowViewerDto(); + flowViewerDto.setKey(s.getActivityId()); + flowViewerDto.setCompleted(false); + flowViewerList.add(flowViewerDto); + }); + } Map result = new HashMap(); // xmlData 数据 ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); + InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName()); String xmlData = IOUtils.toString(inputStream, StandardCharsets.UTF_8); result.put("nodeData", flowViewerList); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowProcDefDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowProcDefDto.java index 5bc4adfa..8bbea030 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowProcDefDto.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowProcDefDto.java @@ -33,6 +33,9 @@ public class FlowProcDefDto implements Serializable { @ApiModelProperty("流程分类") private String category; + @ApiModelProperty("流程分类名称") + private String categoryName; + @ApiModelProperty("配置表单名称") private String formName; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java index 3143ec82..4d4db379 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java @@ -11,6 +11,14 @@ import com.ruoyi.system.domain.SysUserRole; */ public interface SysUserRoleMapper { + /** + * 通过用户手机查询用户角色 + * + * @param phonenumber 用户手机 + * @return 结果 + */ + public List selectUserRoles(String phonenumber); + /** * 通过用户ID删除用户和角色关联 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 10bc2abc..38e1d522 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -10,6 +10,15 @@ import com.ruoyi.common.core.domain.entity.SysUser; */ public interface ISysUserService { + + /** + * 通过用户手机查询用户角色 + * + * @param phonenumber 用户手机 + * @return 结果 + */ + public List selectUserRoles(String phonenumber); + /** * 根据条件分页查询用户列表 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index ed685cfd..7121d40f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -554,4 +554,14 @@ public class SysUserServiceImpl implements ISysUserService } return successMsg.toString(); } + + /** + * 通过用户手机查询用户角色 + * + * @param phonenumber 用户手机 + * @return 结果 + */ + public List selectUserRoles(String phonenumber) { + return userRoleMapper.selectUserRoles(phonenumber); + } } diff --git a/ruoyi-system/src/main/resources/mapper/flowable/FlowBusinessKeyMapper.xml b/ruoyi-system/src/main/resources/mapper/flowable/FlowBusinessKeyMapper.xml index f590f1e5..a83a135f 100644 --- a/ruoyi-system/src/main/resources/mapper/flowable/FlowBusinessKeyMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/flowable/FlowBusinessKeyMapper.xml @@ -67,6 +67,7 @@ where 1=1 and fa.procDefName like concat('%', #{procDefName}, '%') + and fa.businessKey = #{businessKey} and fa.businessKeyName like concat('%', #{businessKeyName}, '%') and fa.category = #{category} and fa.createTime between #{params.beginDate} and #{params.endDate} diff --git a/ruoyi-system/src/main/resources/mapper/flowable/FlowDeployMapper.xml b/ruoyi-system/src/main/resources/mapper/flowable/FlowDeployMapper.xml index d541e328..0000bc75 100644 --- a/ruoyi-system/src/main/resources/mapper/flowable/FlowDeployMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/flowable/FlowDeployMapper.xml @@ -34,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" rp.deployment_id_ as deploymentId, rd.name_ as name, rd.category_ as category, + sdd.dict_label as categoryName, rp.key_ as flowKey, rp.version_ as version, rp.suspension_state_ as suspensionState, @@ -41,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM act_re_procdef rp LEFT JOIN act_re_deployment rd ON rp.deployment_id_ = rd.id_ + left join sys_dict_data sdd on sdd.dict_type='sys_process_category' and sdd.dict_value = rd.category_ left join act_re_procdef_role rpr on rp.key_ = rpr.PROCDEF_KEY_ left join sys_user_role sur on sur.role_id = rpr.ROLE_ID_ left join sys_user su on su.user_id = sur.user_id diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml index dd726891..c1b24b8c 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml @@ -16,6 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + delete from sys_user_role where user_id in diff --git a/ruoyi-ui/src/views/flowable/task/myProcess/editLeaveTaskDrawer.vue b/ruoyi-ui/src/views/flowable/task/myProcess/editLeaveTaskDrawer.vue index a1220394..2018435a 100644 --- a/ruoyi-ui/src/views/flowable/task/myProcess/editLeaveTaskDrawer.vue +++ b/ruoyi-ui/src/views/flowable/task/myProcess/editLeaveTaskDrawer.vue @@ -106,7 +106,7 @@ @@ -227,6 +227,7 @@ export default { this.form.taskId = this.options.taskId; this.form.taskName = this.options.taskName; this.form.userId = store.getters.userId; + this.form.assignee = store.getters.name; this.form.procInsId = this.options.procInsId; this.form.instanceId = this.options.procInsId; this.times = res.data.day; diff --git a/ruoyi-ui/src/views/flowable/task/myProcess/editTaskDrawer.vue b/ruoyi-ui/src/views/flowable/task/myProcess/editTaskDrawer.vue index e62d7b9d..0ec7b836 100644 --- a/ruoyi-ui/src/views/flowable/task/myProcess/editTaskDrawer.vue +++ b/ruoyi-ui/src/views/flowable/task/myProcess/editTaskDrawer.vue @@ -185,6 +185,7 @@ this.form.taskId = this.options.taskId; this.form.taskName = this.options.taskName; this.form.userId = store.getters.userId; + this.form.assignee = store.getters.name; this.form.procInsId = this.options.procInsId; this.form.instanceId = this.options.procInsId; }).catch(res => { diff --git a/ruoyi-ui/src/views/flowable/task/myProcess/index.vue b/ruoyi-ui/src/views/flowable/task/myProcess/index.vue index f1d72185..381981d5 100644 --- a/ruoyi-ui/src/views/flowable/task/myProcess/index.vue +++ b/ruoyi-ui/src/views/flowable/task/myProcess/index.vue @@ -132,8 +132,8 @@ @@ -452,7 +452,7 @@ export default { instanceId: row.procInsId } let that = this; - this.$modal.confirm('撤销流程会终止,是否继续?').then(function() { + this.$modal.confirm('是否终止当前流程申请?').then(function() { that.loading = true; return stopProcess(params); }).then(res => { diff --git a/ruoyi-ui/src/views/flowable/task/myProcess/initLeaveTaskDrawer.vue b/ruoyi-ui/src/views/flowable/task/myProcess/initLeaveTaskDrawer.vue index 52614161..319d4bdb 100644 --- a/ruoyi-ui/src/views/flowable/task/myProcess/initLeaveTaskDrawer.vue +++ b/ruoyi-ui/src/views/flowable/task/myProcess/initLeaveTaskDrawer.vue @@ -106,7 +106,7 @@ diff --git a/ruoyi-ui/src/views/flowable/task/myProcess/initTaskDrawer.vue b/ruoyi-ui/src/views/flowable/task/myProcess/initTaskDrawer.vue index 26757e20..f41626e2 100644 --- a/ruoyi-ui/src/views/flowable/task/myProcess/initTaskDrawer.vue +++ b/ruoyi-ui/src/views/flowable/task/myProcess/initTaskDrawer.vue @@ -19,9 +19,9 @@ label-width="120px" style="padding-right: 35px" > -

-
-
+
+
+
diff --git a/ruoyi-wechat/pom.xml b/ruoyi-wechat/pom.xml index 22557c42..dffe8447 100644 --- a/ruoyi-wechat/pom.xml +++ b/ruoyi-wechat/pom.xml @@ -30,6 +30,11 @@ mysql-connector-java + + com.ruoyi + ruoyi-flowable + + com.yanzhu.jh yanzhu-jh diff --git a/ruoyi-wechat/src/main/java/com/ruoyi/web/flowable/controller/FlowableController.java b/ruoyi-wechat/src/main/java/com/ruoyi/web/flowable/controller/FlowableController.java new file mode 100644 index 00000000..161f42a6 --- /dev/null +++ b/ruoyi-wechat/src/main/java/com/ruoyi/web/flowable/controller/FlowableController.java @@ -0,0 +1,209 @@ +package com.ruoyi.web.flowable.controller; + +import com.ruoyi.common.annotation.Log; +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.enums.BusinessType; +import com.ruoyi.flowable.domain.dto.FlowTaskDto; +import com.ruoyi.flowable.domain.vo.FlowTaskVo; +import com.ruoyi.flowable.domain.vo.StartTaskVO; +import com.ruoyi.flowable.service.IFlowBusinessKeyService; +import com.ruoyi.flowable.service.IFlowDefinitionService; +import com.ruoyi.flowable.service.IFlowInstanceService; +import com.ruoyi.flowable.service.IFlowTaskService; +import com.ruoyi.system.domain.FlowTaskEntity; +import com.ruoyi.system.service.ISysUserService; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * @version : V1.0 + * @ClassName: FlowTaskController + * @Description: 工作流任务 + * @Auther: JiangYuQi + * @Date: 2020/7/7 18:03 + */ +@RestController +@RequestMapping("/wechat/flowTask") +public class FlowableController extends BaseController { + + @Autowired + private ISysUserService sysUserService; + + @Autowired + private IFlowTaskService flowTaskService; + + @Autowired + private IFlowDefinitionService flowDefinitionService; + + @Autowired + IFlowInstanceService flowInstanceService; + + @Autowired + private IFlowBusinessKeyService flowBusinessKeyService; + + /** + * 启动流程实例 + * @param startTaskVO + * @return + */ + @Log(title = "发起流程", businessType = BusinessType.INSERT) + @PostMapping("/startProcessInstance") + public AjaxResult startProcessInstance(@RequestBody StartTaskVO startTaskVO) { + return flowDefinitionService.startProcessInstanceById(startTaskVO.getProcDefId(), startTaskVO.getUserId(), startTaskVO.getNickName(), startTaskVO.getVariables()); + } + + /** + * 我的流程实例列表 + * @param username + * @param category + * @return + */ + @GetMapping(value = "/myFlowDefinitionList") + public AjaxResult myFlowDefinitionList(String username, String category) { + return AjaxResult.success(flowDefinitionService.myList(username, category, null, 1, 1000)); + } + + /** + * 查询流程节点 + * @param deployId + * @return + */ + @ApiOperation(value = "查询流程节点") + @GetMapping("/readNotes/{deployId}") + public AjaxResult readNotes(@ApiParam(value = "流程定义id") @PathVariable(value = "deployId") String deployId) { + return success(flowDefinitionService.readNodes(deployId)); + } + + /** + * 取消申请 + * @param flowTaskVo + * @return + */ + @ApiOperation(value = "取消申请", response = FlowTaskDto.class) + @Log(title = "终止流程", businessType = BusinessType.UPDATE) + @PostMapping(value = "/stopProcess") + public AjaxResult stopProcess(@RequestBody FlowTaskVo flowTaskVo) { + return flowTaskService.stopProcess(flowTaskVo); + } + + /** + * 撤回流程 + * @param flowTaskVo + * @return + */ + @ApiOperation(value = "撤回流程", response = FlowTaskDto.class) + @Log(title = "撤回流程", businessType = BusinessType.UPDATE) + @PostMapping(value = "/revokeProcess") + public AjaxResult revokeProcess(@RequestBody FlowTaskVo flowTaskVo) { + return flowTaskService.revokeProcess(flowTaskVo); + } + + /** + * 审批任务 + * @param flowTaskVo + * @return + */ + @ApiOperation(value = "审批任务") + @Log(title = "审批流程", businessType = BusinessType.UPDATE) + @PostMapping(value = "/complete") + public AjaxResult complete(@RequestBody FlowTaskVo flowTaskVo) { + return flowTaskService.complete(flowTaskVo); + } + + /** + * 驳回任务 + * @param flowTaskVo + * @return + */ + @ApiOperation(value = "驳回任务") + @Log(title = "驳回流程", businessType = BusinessType.UPDATE) + @PostMapping(value = "/reject") + public AjaxResult taskReject(@RequestBody FlowTaskVo flowTaskVo) { + flowTaskService.taskReject(flowTaskVo); + return AjaxResult.success(); + } + + /** + * 退回任务 + * @param flowTaskVo + * @return + */ + @ApiOperation(value = "退回任务") + @Log(title = "退回流程", businessType = BusinessType.UPDATE) + @PostMapping(value = "/return") + public AjaxResult taskReturn(@RequestBody FlowTaskVo flowTaskVo) { + flowTaskService.taskReturn(flowTaskVo); + return AjaxResult.success(); + } + + @ApiOperation(value = "删除流程实例") + @Log(title = "删除流程", businessType = BusinessType.INSERT) + @DeleteMapping(value = "/delete/{instanceId}") + public AjaxResult delete(@ApiParam(value = "流程实例ID", required = true) @PathVariable String instanceId, + @ApiParam(value = "删除原因") @RequestParam(required = false) String deleteReason) { + flowInstanceService.delete(instanceId,deleteReason); + return AjaxResult.success(); + } + + /** + * 获取所有可回退的节点 + * @param flowTaskVo + * @return + */ + @ApiOperation(value = "获取所有可回退的节点") + @PostMapping(value = "/returnList") + public AjaxResult findReturnTaskList(@RequestBody FlowTaskVo flowTaskVo) { + return flowTaskService.findReturnTaskList(flowTaskVo); + } + + /** + * 根据流程Id查询操作日志 + * @param procInsId + * @return + */ + @GetMapping(value = "/findCommentByProcInsId") + public AjaxResult findCommentByProcInsId(String procInsId) { + return success(flowBusinessKeyService.selectCommentByProcInsId(procInsId)); + } + + /** + * 根据流程Id查询表单数据 + * @param procInsId + * @return + */ + @GetMapping(value = "/findFormDatasByProcInsId") + public AjaxResult findFormDatasByProcInsId(String procInsId) { + return success(flowBusinessKeyService.selectFormDatasByProcInsId(procInsId)); + } + + /** + * 根据条件查询我的代办任务 + * @param flowTaskEntity + * @return + */ + @PostMapping(value = "/myAwaitFlowTaskList") + public TableDataInfo myAwaitFlowTaskList(@RequestBody FlowTaskEntity flowTaskEntity) { + //这里不分页,这里实时查询用户角色 + flowTaskEntity.setRoleIds(sysUserService.selectUserRoles(flowTaskEntity.getNowUserName())); + return getDataTable(flowBusinessKeyService.selectMyAwaitFlowTask(flowTaskEntity)); + } + + /** + * 根据条件查询我的已办任务 + * @param flowTaskEntity + * @return + */ + @GetMapping(value = "/myFinishedFlowTaskList") + public TableDataInfo myFinishedFlowTaskList(FlowTaskEntity flowTaskEntity) { + startPage(); + return getDataTable(flowBusinessKeyService.selectMyFinishedFlowTask(flowTaskEntity)); + } + +} diff --git a/ruoyi-wechat/src/main/java/com/ruoyi/web/project/controller/ProjectProblemmodifyController.java b/ruoyi-wechat/src/main/java/com/ruoyi/web/project/controller/ProjectProblemmodifyController.java index 1729de29..6e8e464c 100644 --- a/ruoyi-wechat/src/main/java/com/ruoyi/web/project/controller/ProjectProblemmodifyController.java +++ b/ruoyi-wechat/src/main/java/com/ruoyi/web/project/controller/ProjectProblemmodifyController.java @@ -153,5 +153,13 @@ public class ProjectProblemmodifyController extends BaseController { return success(smzSspProblemmodifyService.findGroupCountByProjectId(smzSspProblemmodify)); } - + /** + * 查询用户上次在该项目提交的隐患信息 + * @param smzSspProblemmodify + * @return + */ + @GetMapping("/findLastDataByParams") + public AjaxResult findLastDataByParams(SmzSspProblemmodify smzSspProblemmodify){ + return success(smzSspProblemmodifyService.findLastDataByParams(smzSspProblemmodify)); + } } diff --git a/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/mapper/SmzSspProblemmodifyMapper.java b/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/mapper/SmzSspProblemmodifyMapper.java index bec7b0c5..33e4e4a0 100644 --- a/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/mapper/SmzSspProblemmodifyMapper.java +++ b/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/mapper/SmzSspProblemmodifyMapper.java @@ -132,4 +132,12 @@ public interface SmzSspProblemmodifyMapper public int countTimeout(SmzSspProblemmodifyWhere where); + /** + * 根据条件查询最后一条隐患数据 + * + * @param smzSspProblemmodify 隐患排查 + * @return 结果 + */ + public SmzSspProblemmodify findLastDataByParams(SmzSspProblemmodify smzSspProblemmodify); + } diff --git a/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/service/ISmzSspProblemmodifyService.java b/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/service/ISmzSspProblemmodifyService.java index 715e3f54..e6c91500 100644 --- a/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/service/ISmzSspProblemmodifyService.java +++ b/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/service/ISmzSspProblemmodifyService.java @@ -103,6 +103,14 @@ public interface ISmzSspProblemmodifyService */ public List> findGroupCountByProjectId(SmzSspProblemmodify smzSspProblemmodify); + /** + * 根据条件查询最后一条隐患数据 + * + * @param smzSspProblemmodify 隐患排查 + * @return 结果 + */ + public SmzSspProblemmodify findLastDataByParams(SmzSspProblemmodify smzSspProblemmodify); + /** * 分类汇总(按项目) * @param deptId 部门编号 0为全部 diff --git a/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/service/impl/SmzSspProblemmodifyServiceImpl.java b/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/service/impl/SmzSspProblemmodifyServiceImpl.java index a32ec6d3..43a6c1dc 100644 --- a/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/service/impl/SmzSspProblemmodifyServiceImpl.java +++ b/yanzhu-jh/src/main/java/com/yanzhu/jh/trouble/service/impl/SmzSspProblemmodifyServiceImpl.java @@ -269,8 +269,20 @@ public class SmzSspProblemmodifyServiceImpl implements ISmzSspProblemmodifyServi * @param smzSspProblemmodify 隐患排查 * @return 结果 */ + @Override public List> findGroupCountByProjectId(SmzSspProblemmodify smzSspProblemmodify){ return smzSspProblemmodifyMapper.findGroupCountByProjectId(smzSspProblemmodify); } + /** + * 根据条件查询最后一条隐患数据 + * + * @param smzSspProblemmodify 隐患排查 + * @return 结果 + */ + @Override + public SmzSspProblemmodify findLastDataByParams(SmzSspProblemmodify smzSspProblemmodify) { + return smzSspProblemmodifyMapper.findLastDataByParams(smzSspProblemmodify); + } + } diff --git a/yanzhu-jh/src/main/resources/mapper/trouble/SmzSspProblemmodifyMapper.xml b/yanzhu-jh/src/main/resources/mapper/trouble/SmzSspProblemmodifyMapper.xml index 86fbb131..3c14516b 100644 --- a/yanzhu-jh/src/main/resources/mapper/trouble/SmzSspProblemmodifyMapper.xml +++ b/yanzhu-jh/src/main/resources/mapper/trouble/SmzSspProblemmodifyMapper.xml @@ -261,7 +261,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join sys_dict_data sdd3 on sdd3.dict_type = 'sys_dept_type' and sdd3.dict_value = spui.unitType where ssp.id = #{id} - + + + + insert into smz_ssp_problemmodify