flowable集成

This commit is contained in:
459816669@qq.com 2020-11-26 22:32:43 +08:00
parent dc76bd8a30
commit fc9ea59be4
6 changed files with 314 additions and 142 deletions

View File

@ -6,14 +6,13 @@ import com.snow.common.core.page.PageModel;
import com.snow.common.core.page.TableDataInfo;
import com.snow.common.exception.BusinessException;
import com.snow.common.utils.StringUtils;
import com.snow.flowable.domain.ProcessInstanceDTO;
import com.snow.flowable.domain.ProcessInstanceVO;
import com.snow.flowable.domain.TaskVO;
import com.snow.flowable.domain.*;
import com.snow.flowable.service.impl.FlowableServiceImpl;
import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.SysOaLeave;
import com.snow.system.domain.SysUser;
import com.snow.system.service.ISysOaLeaveService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
@ -79,11 +78,19 @@ public class FlowController extends BaseController {
return AjaxResult.success(dynamicFlowNodeInfo);
}
@RequiresPermissions("flow:get:getMyStartProcess")
@GetMapping("/toMyStartProcess")
public String getMyHistoricProcessInstance()
{
return prefix+"/myStartProcess";
}
/**
* 获取我的流程实例
* @param processInstanceDTO
* @return
*/
@RequiresPermissions("flow:process:getMyStartProcess")
@PostMapping("/getMyHistoricProcessInstance")
@ResponseBody
public TableDataInfo getMyHistoricProcessInstance(ProcessInstanceDTO processInstanceDTO){
@ -92,4 +99,26 @@ public class FlowController extends BaseController {
PageModel<ProcessInstanceVO> historicProcessInstance = flowableService.getHistoricProcessInstance(processInstanceDTO);
return getFlowDataTable(historicProcessInstance);
}
@RequiresPermissions("flow:process:getMyTakePartInProcess")
@GetMapping("/toMyTakePartInProcess")
public String getMyTakePartInProcess()
{
return prefix+"/myTakePartInProcess";
}
/**
* 获取我的流程实例
* @param historicTaskInstanceDTO
* @return
*/
@RequiresPermissions("flow:process:getMyTakePartInProcess")
@PostMapping("/getMyTakePartInProcess")
@ResponseBody
public TableDataInfo getMyTakePartInProcess(HistoricTaskInstanceDTO historicTaskInstanceDTO){
SysUser sysUser = ShiroUtils.getSysUser();
historicTaskInstanceDTO.setUserId(String.valueOf(sysUser.getUserId()));
PageModel<HistoricTaskInstanceVO> historicTaskInstance = flowableService.getHistoricTaskInstance(historicTaskInstanceDTO);
return getFlowDataTable(historicTaskInstance);
}
}

View File

@ -0,0 +1,130 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('我发起的流程')" />
<th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<div class="row">
<ul>
<li>
<label>&nbsp;&nbsp; 流程名称:</label>
<input type="text" name="processDefinitionName"/>
</li>
<li>
<label>单号:</label>
<input type="text" name="businessKey"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</div>
</form>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
var removeFlag = [[${@permission.hasPermi('system:flow:remove')}]];
var processInstanceStatusDatas = [[${@dict.getType('process_instance_status')}]];
var prefix = ctx + "modeler";
var prefixFlow = ctx + "flow";
$(function() {
var options = {
url: prefixFlow + "/getMyHistoricProcessInstance",
modalName: "我发起的流程",
striped: true, //是否显示行间隔色
showToggle: false,
loadingFontSize:20,
showRefresh: false, // 是否显示刷新按钮
showColumns: false, // 是否显示隐藏某列下拉框
showToggle: false,
showSearch: false, // 是否显示检索信息
// rowStyle:rowStyle,//通过自定义函数设置行样式
columns: [
{
title: '序号',
formatter: function (value, row, index) {
return index+1;
}
},
{
field: 'processDefinitionName',
title: '流程名称'
},
{
field: 'businessKey',
title: '单号'
},
{
field: 'startUserId',
title: '流程发起人',
formatter: function(value, row, index) {
var data= $.common.getDataById('/system/user/getUserInfoById',value);
return data.userName;
}
},
{
field: 'isFinished',
title: '流程状态',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processInstanceStatusDatas, value);
}
},
{
field: 'startTime',
title: '流程创建时间'
},
{
field: 'endTime',
title: '流程结束时间'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="getProcessDiagram(\'' + row.id + '\')"><i class="fa fa-eye"></i>流程图</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
function getProcessDiagram(processInstanceId) {
var preViewUrl=prefix+'/getProcessDiagram?processInstanceId='+processInstanceId;
$.modal.openTab("流程图", preViewUrl);
}
function rowStyle(row, index) {
var classes = [ 'success', 'info', 'warning', 'danger'];
if (index % 2 === 0 && index / 2 < classes.length) {
return {
classes: classes[index / 2]
};
}
return {};
}
</script>
</body>
</html>

View File

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('我参与的流程')" />
<th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<div class="row">
<ul>
<li>
<label>单号:</label>
<input type="text" name="businessKeyLike"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</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" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
var removeFlag = [[${@permission.hasPermi('system:flow:remove')}]];
var prefix = ctx + "modeler";
var prefixFlow = ctx + "flow";
$(function() {
var options = {
url: prefixFlow + "/getMyTakePartInProcess",
modalName: "我的已办",
striped: true, //是否显示行间隔色
showToggle: false,
loadingFontSize:20,
showRefresh: false, // 是否显示刷新按钮
showColumns: false, // 是否显示隐藏某列下拉框
showToggle: false,
showSearch: false, // 是否显示检索信息
columns: [
{
title: '序号',
formatter: function (value, row, index) {
return index+1;
}
},
{
field: 'processName',
title: '流程名称'
},
{
field: 'name',
title: '任务名称'
},
{
field: 'businessKey',
title: '单号'
},
{
field: 'assignee',
title: '任务完成人'
},
{
field: 'endTime',
title: '完成时间'
},
{
field: 'spendTime',
title: '任务耗时'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="getProcessDiagram(\'' + row.processInstanceId + '\')"><i class="fa fa-eye"></i>流程图</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
function getProcessDiagram(processInstanceId) {
var preViewUrl=prefix+'/getProcessDiagram?processInstanceId='+processInstanceId;
$.modal.openTab("流程图", preViewUrl);
}
</script>
</body>
</html>

View File

@ -88,7 +88,7 @@
</div>
<div class="ibox-content">
<div class="row">
<!-- <div class="col-sm-12 search-collapse">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
@ -107,9 +107,9 @@
</ul>
</div>
</form>
</div>-->
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table1"></table>
<table id="bootstrap-table"></table>
</div>
</div>
</div>
@ -117,49 +117,6 @@
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>我发起的流程</h5>
<div class="pull-right">
<div class="btn-group">
时间
</div>
</div>
</div>
<div class="ibox-content">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formIds">
<div class="select-list">
<ul>
<li>
<label>节点名称:</label>
<input type="text" name="taskName"/>
</li>
<li>
<label>单号:</label>
<input type="text" name="businessKey"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
@ -175,7 +132,7 @@
var prefixFlow = ctx + "flow";
$(function() {
var options = {
id: "bootstrap-table1",
id: "bootstrap-table",
formId:"formIds",
url: prefix + "/findTasksByUserId",
createUrl: prefix + "/add",
@ -258,93 +215,5 @@
$.modal.openTab("流程图", preViewUrl);
}
</script>
<script th:inline="javascript">
var removeFlag = [[${@permission.hasPermi('system:flow:remove')}]];
var processInstanceStatusDatas = [[${@dict.getType('process_instance_status')}]];
var prefix = ctx + "modeler";
var prefixFlow = ctx + "flow";
$(function() {
var options = {
url: prefixFlow + "/getMyHistoricProcessInstance",
modalName: "我的待办",
striped: true, //是否显示行间隔色
showToggle: false,
loadingFontSize:20,
showRefresh: false, // 是否显示刷新按钮
showColumns: false, // 是否显示隐藏某列下拉框
showToggle: false,
showSearch: false, // 是否显示检索信息
// rowStyle:rowStyle,//通过自定义函数设置行样式
columns: [
{
title: '序号',
formatter: function (value, row, index) {
return index+1;
}
},
{
field: 'processDefinitionName',
title: '流程名称'
},
{
field: 'businessKey',
title: '单号'
},
{
field: 'startUserId',
title: '流程发起人',
formatter: function(value, row, index) {
var data= $.common.getDataById('/system/user/getUserInfoById',value);
return data.userName;
}
},
{
field: 'isFinished',
title: '流程状态',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processInstanceStatusDatas, value);
}
},
{
field: 'startTime',
title: '流程创建时间'
},
{
field: 'endTime',
title: '流程结束时间'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="getProcessDiagram(\'' + row.id + '\')"><i class="fa fa-eye"></i>流程图</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
function getProcessDiagram(processInstanceId) {
var preViewUrl=prefix+'/getProcessDiagram?processInstanceId='+processInstanceId;
$.modal.openTab("流程图", preViewUrl);
}
function rowStyle(row, index) {
var classes = [ 'success', 'info', 'warning', 'danger'];
if (index % 2 === 0 && index / 2 < classes.length) {
return {
classes: classes[index / 2]
};
}
return {};
}
</script>
</body>
</html>

View File

@ -1,5 +1,6 @@
package com.snow.flowable.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.snow.common.utils.StringUtils;
import com.snow.common.utils.bean.BeanUtils;
import lombok.Data;
@ -22,16 +23,29 @@ import java.util.stream.Collectors;
public class HistoricTaskInstanceVO implements Serializable {
public String executionId;
public String processInstanceId;
public String processDefinitionId;
/**
*流程名称
*/
public String processName;
public String businessKey;
public String taskDefinitionId;
public String scopeId;
public String subScopeId;
public String scopeType;
public String scopeDefinitionId;
public String propagatedStageInstanceId;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
public Date createTime;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
public Date endTime;
public Long durationInMillis;
/**
* 用时
*/
public String spendTime;
public String deleteReason;
public String name;
public String localizedName;
@ -43,6 +57,10 @@ public class HistoricTaskInstanceVO implements Serializable {
* 用户ID
*/
public String assignee;
public String assigneeName;
public String taskDefinitionKey;
public String formKey;
public int priority;

View File

@ -1,5 +1,7 @@
package com.snow.flowable.service.impl;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -512,13 +514,31 @@ public class FlowableServiceImpl implements FlowableService {
List<HistoricTaskInstance> historicTaskInstances = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().
desc().
listPage(historicTaskInstanceDTO.getPageNum(), historicTaskInstanceDTO.getPageSize());
// List<HistoricTaskInstanceVO> processInstanceVOS = com.snow.common.utils.bean.BeanUtils.transformList(historicTaskInstances, HistoricTaskInstanceVO.class);
List<HistoricTaskInstanceVO> historicTaskInstanceVOS = historicTaskInstances.stream().map(t -> {
HistoricTaskInstanceVO historicTaskInstanceVO = new HistoricTaskInstanceVO();
BeanUtils.copyProperties(t, historicTaskInstanceVO);
if (!StringUtils.isEmpty(t.getAssignee())) {
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(t.getAssignee()));
historicTaskInstanceVO.setAssignee(sysUser.getUserName());
}
String spendTime = DateUtil.formatBetween(DateUtil.between(t.getCreateTime(), t.getEndTime(), DateUnit.MS));
historicTaskInstanceVO.setSpendTime(spendTime);
HistoricProcessInstance historicProcessInstance = getHistoricProcessInstanceById(t.getProcessInstanceId());
historicTaskInstanceVO.setProcessName(historicProcessInstance.getProcessDefinitionName());
historicTaskInstanceVO.setBusinessKey(historicProcessInstance.getBusinessKey());
return historicTaskInstanceVO;
}).collect(Collectors.toList());
PageModel<HistoricTaskInstanceVO> pageModel = new PageModel<> ();
pageModel.setTotalCount((int)count);
pageModel.setPagedRecords(HistoricTaskInstanceVO.warpList(historicTaskInstances));
pageModel.setPagedRecords(historicTaskInstanceVOS);
return pageModel;
}
/**
* 获取所有的任务节点
* @param processInstance