增加转办任务和委派任务
This commit is contained in:
parent
220efe669c
commit
e30315a627
|
@ -19,10 +19,7 @@ import org.flowable.task.api.Task;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -89,6 +86,7 @@ public class FlowController extends BaseController {
|
|||
|
||||
return prefix+"/myTask";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的待办
|
||||
*/
|
||||
|
@ -101,6 +99,7 @@ public class FlowController extends BaseController {
|
|||
PageModel<TaskVO> taskList = flowableTaskService.findTasksByUserId(String.valueOf(userId), taskBaseDTO);
|
||||
return getFlowDataTable(taskList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有节点
|
||||
* @param processInstanceId
|
||||
|
@ -124,6 +123,7 @@ public class FlowController extends BaseController {
|
|||
|
||||
return prefix+"/myStartProcess";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的流程实例
|
||||
* @param processInstanceDTO
|
||||
|
@ -173,6 +173,7 @@ public class FlowController extends BaseController {
|
|||
|
||||
return prefix+"/myTakePartInProcess";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我办结的任务列表
|
||||
* @param historicTaskInstanceDTO
|
||||
|
@ -187,4 +188,43 @@ public class FlowController extends BaseController {
|
|||
PageModel<HistoricTaskInstanceVO> historicTaskInstance = flowableService.getHistoricTaskInstance(historicTaskInstanceDTO);
|
||||
return getFlowDataTable(historicTaskInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转办任务
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/transferTask")
|
||||
@RequiresPermissions("flow:process:transferTask")
|
||||
@ResponseBody
|
||||
@RepeatSubmit
|
||||
public AjaxResult transferTask(TransferTaskDTO transferTaskDTO) {
|
||||
SysUser sysUser = ShiroUtils.getSysUser();
|
||||
flowableTaskService.transferTask(transferTaskDTO.getTaskId(),String.valueOf(sysUser.getUserId()),transferTaskDTO.getTargetUserId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 委派任务
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/delegateTask")
|
||||
@RequiresPermissions("flow:process:delegateTask")
|
||||
@ResponseBody
|
||||
@RepeatSubmit
|
||||
public AjaxResult delegateTask(TransferTaskDTO transferTaskDTO) {
|
||||
SysUser sysUser = ShiroUtils.getSysUser();
|
||||
flowableTaskService.delegateTask(transferTaskDTO.getTaskId(),String.valueOf(sysUser.getUserId()),transferTaskDTO.getTargetUserId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择用户
|
||||
*/
|
||||
@GetMapping("/selectUser")
|
||||
public String selectUser(String taskId,Integer flag,ModelMap mmap)
|
||||
{
|
||||
mmap.put("taskId",taskId);
|
||||
mmap.put("flag",flag);
|
||||
return prefix + "/selectUser";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
<script th:inline="javascript">
|
||||
var prefixFlow = ctx + "flow";
|
||||
var todoList = [[${@permission.hasPermi('flow:get:todoList')}]];
|
||||
var transferTask = [[${@permission.hasPermi('flow:process:transferTask')}]];
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
id: "bootstrap-table",
|
||||
|
@ -99,6 +101,8 @@
|
|||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-primary btn-xs ' + transferTask + '" href="javascript:void(0)" onclick="selectDelegateTaskUser(\''+row.taskId+'\')"><i class="fa fa-tasks"></i>委派</a> ');
|
||||
actions.push('<a class="btn btn-primary btn-xs ' + transferTask + '" href="javascript:void(0)" onclick="selectTransferTaskUser(\''+row.taskId+'\')"><i class="fa fa-tasks"></i>转办</a> ');
|
||||
actions.push('<a class="btn btn-success btn-xs ' + todoList + '" href="javascript:void(0)" onclick="cancelTask(\''+row.taskId+'\')"><i class="fa fa-edit"></i>处理</a> ');
|
||||
return actions.join('');
|
||||
}
|
||||
|
@ -108,12 +112,19 @@
|
|||
});
|
||||
|
||||
function cancelTask(taskId) {
|
||||
console.log(JSON.stringify(taskId));
|
||||
var preViewUrl=prefixFlow+'/toFinishTask?taskId='+taskId;
|
||||
$.modal.openTab("审批", preViewUrl);
|
||||
}
|
||||
|
||||
function selectDelegateTaskUser(taskId) {
|
||||
var url = prefixFlow + '/selectUser?taskId='+taskId+'&flag=0';
|
||||
$.modal.open("选择委派用户", url);
|
||||
}
|
||||
|
||||
function selectTransferTaskUser(taskId) {
|
||||
var url = prefixFlow + '/selectUser?taskId='+taskId+'&flag=1';
|
||||
$.modal.open("选择转办用户", url);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('分配角色选择用户')" />
|
||||
</head>
|
||||
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="role-form">
|
||||
<input type="hidden" id="taskId" name="taskId" th:value="${taskId}">
|
||||
|
||||
<input type="hidden" id="flag" name="flag" th:value="${flag}">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
登录名称:<input type="text" name="loginName"/>
|
||||
</li>
|
||||
<li>
|
||||
手机号码:<input type="text" name="phonenumber"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||
$(function() {
|
||||
var options = {
|
||||
url: "/system/user/list",
|
||||
queryParams: queryParams,
|
||||
sortName: "createTime",
|
||||
sortOrder: "desc",
|
||||
modalName: "用户",
|
||||
showSearch: false,
|
||||
showRefresh: false,
|
||||
showToggle: false,
|
||||
showColumns: false,
|
||||
clickToSelect: true,
|
||||
singleSelect:true,
|
||||
rememberSelected: true,
|
||||
columns: [{
|
||||
field: 'state',
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'userId',
|
||||
title: '用户ID',
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
field: 'loginName',
|
||||
title: '登录名称',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'userName',
|
||||
title: '用户名称'
|
||||
},
|
||||
{
|
||||
field: 'email',
|
||||
title: '邮箱'
|
||||
},
|
||||
{
|
||||
field: 'phonenumber',
|
||||
title: '手机'
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '用户状态',
|
||||
align: 'center',
|
||||
formatter: function (value, row, index) {
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
sortable: true
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
function queryParams(params) {
|
||||
var search = $.table.queryParams(params);
|
||||
return search;
|
||||
}
|
||||
|
||||
/* 添加用户-选择用户-提交 */
|
||||
function submitHandler() {
|
||||
var rows = $.table.selectFirstColumns();
|
||||
if (rows.length == 0) {
|
||||
$.modal.alertWarning("请至少选择一条记录");
|
||||
return;
|
||||
}
|
||||
var data = { "taskId": $("#taskId").val(), "targetUserId": rows.join() };
|
||||
var flag=$("#flag").val();
|
||||
if(flag==1){
|
||||
$.operate.save( "/flow/transferTask", data);
|
||||
}
|
||||
if(flag==0){
|
||||
$.operate.save( "/flow/delegateTask", data);
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -31,7 +31,7 @@ public enum DingTalkListenerType {
|
|||
|
||||
WORK_RECORD_UPDATE(3,20,"更新待办"),
|
||||
|
||||
ASYNCSEND_V2(10,20,"发送消息")
|
||||
ASYNCSEND_V2(10,20,"发送钉钉消息")
|
||||
;
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.io.Serializable;
|
|||
* @create: 2021-03-06 15:54
|
||||
**/
|
||||
@Data
|
||||
@Deprecated
|
||||
public class SendCommonMessageRequest implements Serializable {
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.snow.common.annotation.SyncLog;
|
|||
import com.snow.common.constant.Constants;
|
||||
import com.snow.common.enums.DingTalkListenerType;
|
||||
import com.snow.common.enums.DingTalkMessageType;
|
||||
import com.snow.common.enums.SyncLogType;
|
||||
import com.snow.common.exception.SyncDataException;
|
||||
import com.snow.common.utils.PatternUtils;
|
||||
import com.snow.common.utils.spring.SpringUtils;
|
||||
|
@ -129,7 +130,7 @@ public class WorkRecodeServiceImpl extends BaseService implements WorkRecodeServ
|
|||
|
||||
|
||||
@Override
|
||||
@SyncLog(dingTalkListenerType = DingTalkListenerType.ASYNCSEND_V2,dingTalkUrl=BaseConstantUrl.ASYNCSEND_V2)
|
||||
@SyncLog(dingTalkListenerType = DingTalkListenerType.ASYNCSEND_V2,dingTalkUrl=BaseConstantUrl.ASYNCSEND_V2,syncLogTpye=SyncLogType.SYNC_SYS)
|
||||
public Long sendCommonMessage(SysSendMessageDTO sysSendMessageDTO) {
|
||||
SysMessageTemplate sysMessageTemplate= sysMessageTemplateService.getSysMessageTemplateByCode(sysSendMessageDTO.getTemplateByCode());
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.ASYNCSEND_V2);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.snow.flowable.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @program: snow
|
||||
* @description
|
||||
* @author: 没用的阿吉
|
||||
* @create: 2021-03-06 19:06
|
||||
**/
|
||||
@Data
|
||||
public class TransferTaskDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 任务ID
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* 目标用户id
|
||||
*/
|
||||
private String targetUserId;
|
||||
}
|
|
@ -9,7 +9,6 @@ import com.google.common.collect.Sets;
|
|||
import com.snow.common.constant.MessageConstants;
|
||||
import com.snow.common.enums.DingTalkListenerType;
|
||||
import com.snow.common.enums.DingTalkMessageType;
|
||||
import com.snow.common.utils.PatternUtils;
|
||||
import com.snow.dingtalk.model.WorkrecordAddRequest;
|
||||
import com.snow.flowable.common.SpringContextUtil;
|
||||
import com.snow.flowable.common.enums.FlowDefEnum;
|
||||
|
@ -28,17 +27,14 @@ import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
|
|||
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.delegate.event.FlowableProcessStartedEvent;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.identitylink.api.IdentityLink;
|
||||
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.flowable.engine.task.Comment;
|
|||
import org.flowable.identitylink.api.IdentityLink;
|
||||
import org.flowable.identitylink.api.history.HistoricIdentityLink;
|
||||
import org.flowable.image.ProcessDiagramGenerator;
|
||||
import org.flowable.task.api.DelegationState;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.TaskQuery;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
|
@ -362,11 +363,30 @@ public class FlowableServiceImpl implements FlowableService {
|
|||
runtimeService.setVariable(task.getExecutionId(),CompleteTaskDTO.IS_START,completeTaskDTO.getIsStart());
|
||||
paramMap.put(CompleteTaskDTO.IS_START,completeTaskDTO.getIsStart());
|
||||
}
|
||||
|
||||
|
||||
//claim the task,当任务分配给了某一组人员时,需要该组人员进行抢占。抢到了就将该任务给谁处理,其他人不能处理。认领任务
|
||||
taskService.claim(task.getId(),completeTaskDTO.getUserId());
|
||||
taskService.complete(task.getId(),paramMap,true);
|
||||
// owner不为空说明可能存在委托任务
|
||||
if (!StringUtils.isEmpty(task.getOwner())) {
|
||||
DelegationState delegationState = task.getDelegationState();
|
||||
switch (delegationState) {
|
||||
//委派中
|
||||
case PENDING:
|
||||
// 被委派人处理完成任务
|
||||
taskService.resolveTask(task.getId(),paramMap);
|
||||
break;
|
||||
//委派任务已处理
|
||||
/* case RESOLVED:
|
||||
System.out.println("委托任务已经完成");
|
||||
break;*/
|
||||
default:
|
||||
//claim the task,当任务分配给了某一组人员时,需要该组人员进行抢占。抢到了就将该任务给谁处理,其他人不能处理。认领任务
|
||||
taskService.claim(task.getId(),completeTaskDTO.getUserId());
|
||||
taskService.complete(task.getId(),paramMap,true);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//claim the task,当任务分配给了某一组人员时,需要该组人员进行抢占。抢到了就将该任务给谁处理,其他人不能处理。认领任务
|
||||
taskService.claim(task.getId(),completeTaskDTO.getUserId());
|
||||
taskService.complete(task.getId(),paramMap,true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -257,6 +257,7 @@ public class FlowableTaskServiceImpl implements FlowableTaskService {
|
|||
@Override
|
||||
public void transferTask(String taskId, String curUserId, String targetUserId) {
|
||||
try {
|
||||
//todo 转办记录
|
||||
taskService.setOwner(taskId, curUserId);
|
||||
taskService.setAssignee(taskId,targetUserId);
|
||||
}catch (Exception e) {
|
||||
|
@ -266,11 +267,18 @@ public class FlowableTaskServiceImpl implements FlowableTaskService {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 委派:是将任务节点分给其他人处理,等其他人处理好之后,委派任务会自动回到委派人的任务中
|
||||
* @param taskId 任务ID
|
||||
* @param curUserId 当前人ID
|
||||
* @param targetUserId 目标人ID
|
||||
*/
|
||||
@Override
|
||||
public void delegateTask(String taskId, String curUserId, String targetUserId) {
|
||||
try {
|
||||
taskService.setOwner(taskId, curUserId);
|
||||
taskService.delegateTask(taskId,targetUserId);
|
||||
|
||||
}catch (Exception e) {
|
||||
log.error(e.getMessage(),e.getCause());
|
||||
throw new RuntimeException("转办任务失败,请联系管理员");
|
||||
|
|
Loading…
Reference in New Issue