完善数据大屏的流程概况

This commit is contained in:
459816669@qq.com 2021-02-23 22:11:41 +08:00
parent b0ef815359
commit 671d77e17e
10 changed files with 187 additions and 50 deletions

View File

@ -10,6 +10,8 @@ import com.snow.common.utils.CookieUtils;
import com.snow.common.utils.DateUtils; import com.snow.common.utils.DateUtils;
import com.snow.common.utils.ServletUtils; import com.snow.common.utils.ServletUtils;
import com.snow.common.utils.StringUtils; import com.snow.common.utils.StringUtils;
import com.snow.flowable.domain.FlowGeneralSituationVO;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.framework.shiro.service.SysPasswordService; import com.snow.framework.shiro.service.SysPasswordService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -47,6 +49,9 @@ public class SysIndexController extends BaseController
@Autowired @Autowired
private SysPasswordService passwordService; private SysPasswordService passwordService;
@Autowired
private FlowableTaskService flowableTaskService;
// 系统首页 // 系统首页
@GetMapping("/index") @GetMapping("/index")
public String index(ModelMap mmap) public String index(ModelMap mmap)
@ -162,10 +167,14 @@ public class SysIndexController extends BaseController
return false; return false;
} }
// 系统首页 // 数据大屏
@GetMapping("/system/bigScreen") @GetMapping("/system/bigScreen")
public String bigScreen(ModelMap mmap) public String bigScreen(ModelMap mmap)
{ {
SysUser user = ShiroUtils.getSysUser();
//流程概况
FlowGeneralSituationVO flowGeneralSituation = flowableTaskService.getFlowGeneralSituation(String.valueOf(user.getUserId()));
mmap.put("flowGeneralSituation",flowGeneralSituation);
return "big_screen"; return "big_screen";
} }
} }

View File

@ -59,25 +59,25 @@
<div class="loadbox"> <img th:src="@{/images/loading.gif}"> 页面加载中... </div> <div class="loadbox"> <img th:src="@{/images/loading.gif}"> 页面加载中... </div>
</div> </div>
<div class="head"> <div class="head">
<h1><img th:src="@{/images/logo.png}" >Ding-Flow可视化大屏</h1> <h1>Ding-Flow可视化大屏</h1>
<div class="weather"><img th:src="@{/images/weather.png}"><span>多云转小雨</span><span>2017-12-30</span></div> <div class="weather"><img th:src="@{/images/weather.png}"><span>多云转小雨</span><span>2017-12-30</span></div>
</div> </div>
<div class="mainbox"> <div class="mainbox">
<ul class="clearfix"> <ul class="clearfix">
<li> <li>
<div class="boxall" style="height: 2.7rem"> <div class="boxall" style="height: 2.7rem">
<div class="alltitle">生意参谋</div> <div class="alltitle">流程概况</div>
<div class="sycm"> <div class="sycm">
<ul class="clearfix"> <ul class="clearfix">
<li><h2>1824</h2><span>今日销售额</span></li> <li><h2 th:text="${flowGeneralSituation.todoTaskNum}"></h2><span>我的待办数</span></li>
<li><h2>1920</h2><span>昨日销售额</span></li> <li><h2 th:text="${flowGeneralSituation.doneTaskNum}"></h2><span>我的已办数</span></li>
<li><h2>19%</h2><span>环比增长</span></li> <li><h2 th:text="${flowGeneralSituation.myStartProcessInstanceNum}"></h2><span>我发起的审批数</span></li>
</ul> </ul>
<div style="border-bottom: 1px solid rgba(255,255,255,.1)"></div> <div style="border-bottom: 1px solid rgba(255,255,255,.1)"></div>
<ul class="clearfix"> <ul class="clearfix">
<li><h2>1824</h2><span>今日销售额</span></li> <li><h2 style="color: red" th:text="${flowGeneralSituation.threeTodoTaskNum}"></h2><span>超时任务数(3天)</span></li>
<li><h2>1920</h2><span>昨日销售额</span></li> <li><h2 th:text="${flowGeneralSituation.processInstanceNum}"></h2><span>总流程数</span></li>
<li><h2>19%</h2><span>环比增长</span></li> <li><h2>19%</h2><span>环比增长</span></li>
</ul> </ul>

View File

@ -13,13 +13,13 @@
<div class="row"> <div class="row">
<ul> <ul>
<li> <li>
<label>name</label> <label>名称</label>
<input type="text" name="deploymentNameLike"/> <input type="text" name="deploymentNameLike"/>
</li> </li>
<li> <li>
<label>流程分类:</label> <label>分类:</label>
<select name="category" th:with="type=${@dict.getType('flow_category')}"> <select name="deploymentCategory" th:with="type=${@dict.getType('flow_category')}">
<option value="">所有</option> <option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select> </select>
@ -77,23 +77,26 @@
field: 'name', field: 'name',
title: '流程名称' title: '流程名称'
}, },
{ {
field: 'category', field: 'category',
title: '分类', title: '分类',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return $.table.selectDictLabel(flowCategoryDatas, value); return $.table.selectDictLabel(flowCategoryDatas, value);
} }
}, },
{
field: 'key',
title: '发布key'
},
{
field: 'engineVersion',
title: '版本号'
},
{ {
field: 'deploymentTime', field: 'deploymentTime',
title: '流程发布时间' title: '流程发布时间'
}, },
{
field: 'key',
title: '发布key'
},
{ {
title: '操作', title: '操作',
align: 'center', align: 'center',

View File

@ -13,7 +13,7 @@
<div class="row"> <div class="row">
<ul> <ul>
<li> <li>
<label>name</label> <label>名称</label>
<input type="text" name="name"/> <input type="text" name="name"/>
</li> </li>
<li> <li>
@ -91,10 +91,10 @@
title: '流程发布时间' title: '流程发布时间'
}, },
/* { {
field: 'key', field: 'engineVersion',
title: '发布key' title: '版本号'
},*/ },
{ {
title: '操作', title: '操作',

View File

@ -13,12 +13,24 @@ import java.io.Serializable;
@Data @Data
public class DeploymentQueryDTO extends FlowBaseDTO implements Serializable { public class DeploymentQueryDTO extends FlowBaseDTO implements Serializable {
/**
* 发布key 模糊
*/
private String deploymentKeyLike; private String deploymentKeyLike;
/**
* 发布id
*/
private String deploymentId; private String deploymentId;
/**
* 发布名称 模糊
*/
private String deploymentNameLike; private String deploymentNameLike;
/**
* 流程定义key 模糊
*/
private String processDefinitionKeyLike; private String processDefinitionKeyLike;
/** /**

View File

@ -1,15 +1,10 @@
package com.snow.flowable.domain; package com.snow.flowable.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.flowable.common.engine.api.repository.EngineResource;
import org.flowable.engine.repository.ProcessDefinition;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map;
/** /**
* @program: snow * @program: snow
@ -50,6 +45,17 @@ public class DeploymentVO implements Serializable {
/** /**
* 版本 * 版本
*/ */
private String engineVersion; private int engineVersion;
/**
* xml
*/
private String resourceName;
/**
* 图片
*/
private String dgrmResourceName;
} }

View File

@ -0,0 +1,50 @@
package com.snow.flowable.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @program: snow
* @description 流程概况
* @author: 没用的阿吉
* @create: 2021-02-23 20:10
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class FlowGeneralSituationVO implements Serializable {
private static final long serialVersionUID = 5709897875619881275L;
/**
* 待办数
*/
private long todoTaskNum;
/**
* 已办数
*/
private long doneTaskNum;
/**
* 我发起的流程数
*/
private long myStartProcessInstanceNum;
/**
* 三天未办数
*/
private long threeTodoTaskNum;
/**
* 流程数
*/
private long processInstanceNum;
}

View File

@ -1,10 +1,7 @@
package com.snow.flowable.service; package com.snow.flowable.service;
import com.snow.common.core.page.PageModel; import com.snow.common.core.page.PageModel;
import com.snow.flowable.domain.CompleteTaskDTO; import com.snow.flowable.domain.*;
import com.snow.flowable.domain.FinishTaskDTO;
import com.snow.flowable.domain.TaskBaseDTO;
import com.snow.flowable.domain.TaskVO;
import com.snow.system.domain.SysUser; import com.snow.system.domain.SysUser;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
@ -75,8 +72,15 @@ public interface FlowableTaskService {
*/ */
void delegateTask(String taskId,String curUserId,String targetUserId); void delegateTask(String taskId,String curUserId,String targetUserId);
/**
* 挂起或激活流程
* @param instanceId
* @param suspendState
*/
void suspendOrActiveApply(String instanceId, String suspendState); void suspendOrActiveApply(String instanceId, String suspendState);
/**
* 获取流程概况流程大屏显示
*/
FlowGeneralSituationVO getFlowGeneralSituation(String userId);
} }

View File

@ -205,7 +205,7 @@ public class FlowableServiceImpl implements FlowableService {
DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery(); DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery();
if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentNameLike())){ if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentNameLike())){
deploymentQuery.deploymentNameLike(deploymentQueryDTO.getDeploymentNameLike()); deploymentQuery.deploymentNameLike("%"+deploymentQueryDTO.getDeploymentNameLike()+"%");
} }
if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentCategory())){ if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentCategory())){
deploymentQuery.deploymentCategory(deploymentQueryDTO.getDeploymentCategory()); deploymentQuery.deploymentCategory(deploymentQueryDTO.getDeploymentCategory());
@ -214,18 +214,26 @@ public class FlowableServiceImpl implements FlowableService {
deploymentQuery.deploymentId(deploymentQueryDTO.getDeploymentId()); deploymentQuery.deploymentId(deploymentQueryDTO.getDeploymentId());
} }
if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentKeyLike())){ if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentKeyLike())){
deploymentQuery.deploymentKeyLike(deploymentQueryDTO.getDeploymentKeyLike()); deploymentQuery.deploymentKeyLike("%"+deploymentQueryDTO.getDeploymentKeyLike()+"%");
} }
if(!StringUtils.isEmpty(deploymentQueryDTO.getProcessDefinitionKeyLike())){ if(!StringUtils.isEmpty(deploymentQueryDTO.getProcessDefinitionKeyLike())){
deploymentQuery.processDefinitionKeyLike(deploymentQueryDTO.getProcessDefinitionKeyLike()); deploymentQuery.processDefinitionKeyLike("%"+deploymentQueryDTO.getProcessDefinitionKeyLike()+"%");
} }
long count = deploymentQuery.orderByDeploymenTime().desc(). long count = deploymentQuery.orderByDeploymenTime().desc().
count(); count();
List<Deployment> deployments = deploymentQuery.orderByDeploymenTime().desc(). List<Deployment> deployments = deploymentQuery.orderByDeploymenTime().desc().
listPage(deploymentQueryDTO.getPageNum(), deploymentQueryDTO.getPageSize()); listPage(deploymentQueryDTO.getPageNum(), deploymentQueryDTO.getPageSize());
List<DeploymentVO> deploymentVoList = deployments.stream().map(t -> { List<DeploymentVO> deploymentVoList = deployments.stream().map(t -> {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(t.getId()).singleResult();
DeploymentVO deploymentVO = new DeploymentVO(); DeploymentVO deploymentVO = new DeploymentVO();
BeanUtils.copyProperties(t, deploymentVO); BeanUtils.copyProperties(t, deploymentVO);
deploymentVO.setEngineVersion(processDefinition.getVersion());
deploymentVO.setResourceName(processDefinition.getResourceName());
deploymentVO.setDgrmResourceName(processDefinition.getDiagramResourceName());
return deploymentVO; return deploymentVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@ -448,7 +456,7 @@ public class FlowableServiceImpl implements FlowableService {
return historyService.createHistoricProcessInstanceQuery() return historyService.createHistoricProcessInstanceQuery()
.processInstanceId(id) .processInstanceId(id)
//标识查询的时候返回流程变量参数不然取不到 //标识查询的时候返回流程变量参数不然取不到
.includeProcessVariables() //.includeProcessVariables()
.singleResult(); .singleResult();
} }

View File

@ -1,10 +1,12 @@
package com.snow.flowable.service.impl; package com.snow.flowable.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.snow.common.core.page.PageModel; import com.snow.common.core.page.PageModel;
import com.snow.common.exception.BusinessException; import com.snow.common.exception.BusinessException;
import com.snow.flowable.common.constants.FlowConstants; import com.snow.flowable.common.constants.FlowConstants;
import com.snow.flowable.common.enums.FlowDefEnum;
import com.snow.flowable.domain.*; import com.snow.flowable.domain.*;
import com.snow.flowable.service.FlowableService; import com.snow.flowable.service.FlowableService;
import com.snow.flowable.service.FlowableTaskService; import com.snow.flowable.service.FlowableTaskService;
@ -17,20 +19,20 @@ import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.identitylink.api.IdentityLink; import org.flowable.identitylink.api.IdentityLink;
import org.flowable.identitylink.api.history.HistoricIdentityLink; import org.flowable.identitylink.api.history.HistoricIdentityLink;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery; import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashSet; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -69,7 +71,7 @@ public class FlowableTaskServiceImpl implements FlowableTaskService {
TaskQuery taskQuery = taskService.createTaskQuery() TaskQuery taskQuery = taskService.createTaskQuery()
.or() .or()
.taskCandidateOrAssigned(userId); .taskCandidateOrAssigned(userId);
//这个地方查询去查询系统的用户组表希望的是查询自己的用户表 //这个地方查询去查询系统的用户组表希望的是查询自己的用户表
if(!CollectionUtils.isEmpty(sysRoles)) { if(!CollectionUtils.isEmpty(sysRoles)) {
List<String> roleIds = sysRoles.stream().map(t -> List<String> roleIds = sysRoles.stream().map(t ->
String.valueOf(t) String.valueOf(t)
@ -116,7 +118,7 @@ public class FlowableTaskServiceImpl implements FlowableTaskService {
taskVO.setParentTaskId(t.getParentTaskId()); taskVO.setParentTaskId(t.getParentTaskId());
taskVO.setAssignee(t.getAssignee()); taskVO.setAssignee(t.getAssignee());
taskVO.setOwner(t.getOwner()); taskVO.setOwner(t.getOwner());
HistoricProcessInstance historicProcessInstance = flowableService.getHistoricProcessInstanceById(t.getProcessInstanceId()); ProcessInstance historicProcessInstance = flowableService.getProcessInstanceById(t.getProcessInstanceId());
taskVO.setProcessDefinitionName(historicProcessInstance.getProcessDefinitionName()); taskVO.setProcessDefinitionName(historicProcessInstance.getProcessDefinitionName());
String startUserId = historicProcessInstance.getStartUserId(); String startUserId = historicProcessInstance.getStartUserId();
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(startUserId)); SysUser sysUser = sysUserService.selectUserById(Long.parseLong(startUserId));
@ -279,4 +281,47 @@ public class FlowableTaskServiceImpl implements FlowableTaskService {
public void suspendOrActiveApply(String instanceId, String suspendState) { public void suspendOrActiveApply(String instanceId, String suspendState) {
} }
@Override
public FlowGeneralSituationVO getFlowGeneralSituation(String userId) {
//根据用户ID获取角色
Set<Long> sysRoles = flowableUserService.getFlowGroupByUserId(Long.parseLong(userId));
TaskQuery taskQuery = taskService.createTaskQuery()
.or()
.taskCandidateOrAssigned(userId);
//这个地方查询会去查询系统的用户组表希望的是查询自己的用户表
if(!CollectionUtils.isEmpty(sysRoles)) {
List<String> roleIds = sysRoles.stream().map(t ->
String.valueOf(t)
).collect(Collectors.toList());
taskQuery.taskCandidateGroupIn(roleIds).endOr();
}
List<Task> taskList = taskQuery.list();
//待办总数
FlowGeneralSituationVO.FlowGeneralSituationVOBuilder flowGeneralSituationVOBuilder = FlowGeneralSituationVO.builder().todoTaskNum(taskQuery.count());
//获取我发起的流程数
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().startedBy(userId);
flowGeneralSituationVOBuilder.myStartProcessInstanceNum(historicProcessInstanceQuery.count());
//我的已办任务数
HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(userId);
List<HistoricProcessInstance> list = historicProcessInstanceQuery.list();
flowGeneralSituationVOBuilder.doneTaskNum(historicTaskInstanceQuery.count());
//获取超过三天未处理的待办
long count = taskList.stream().filter(t ->
DateUtil.betweenDay(t.getCreateTime(), new Date(),false) > 3
).count();
flowGeneralSituationVOBuilder.threeTodoTaskNum(count);
//流程数
int length = FlowDefEnum.values().length;
return flowGeneralSituationVOBuilder.processInstanceNum(length).build();
}
} }