优化项目

This commit is contained in:
459816669@qq.com 2021-01-13 22:46:14 +08:00
parent caa5602f48
commit 297202ffde
19 changed files with 454 additions and 342 deletions

View File

@ -8,6 +8,7 @@ import com.snow.common.core.page.PageModel;
import com.snow.common.core.page.TableDataInfo;
import com.snow.flowable.domain.*;
import com.snow.flowable.service.AppFormService;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.flowable.service.impl.FlowableServiceImpl;
import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.SysUser;
@ -38,9 +39,12 @@ public class FlowController extends BaseController {
@Autowired
private FlowableServiceImpl flowableService;
@Autowired
private AppFormService appFormService;
@Autowired
private FlowableTaskService flowableTaskService;
/**
* 跳转完成任务界面
@ -49,7 +53,7 @@ public class FlowController extends BaseController {
@GetMapping("/toFinishTask")
public String toFinishTask(String taskId,ModelMap mmap)
{
Task task = flowableService.getTask(taskId);
Task task = flowableTaskService.getTask(taskId);
//获取业务参数
AppForm appFrom = appFormService.getAppFrom(task.getProcessInstanceId());
mmap.put("appFrom", appFrom);
@ -71,6 +75,19 @@ public class FlowController extends BaseController {
flowableService.completeTask(completeTaskDTO);
return AjaxResult.success();
}
/**
* 获取我的待办
*/
@RequiresPermissions("flow:get:todoList")
@PostMapping("/findTasksByUserId")
@ResponseBody
public TableDataInfo findTasksByUserId(TaskBaseDTO taskBaseDTO)
{
Long userId = ShiroUtils.getUserId();
PageModel<TaskVO> taskList = flowableTaskService.findTasksByUserId(String.valueOf(userId), taskBaseDTO);
return getFlowDataTable(taskList);
}
/**
* 获取所有节点
* @param processInstanceId
@ -83,6 +100,10 @@ public class FlowController extends BaseController {
return AjaxResult.success(dynamicFlowNodeInfo);
}
/**
* 跳转我发起的流程
* @return
*/
@RequiresPermissions("flow:get:getMyStartProcess")
@GetMapping("/toMyStartProcess")
public String getMyHistoricProcessInstance()

View File

@ -7,6 +7,7 @@ import com.snow.common.core.page.PageModel;
import com.snow.common.core.page.TableDataInfo;
import com.snow.common.enums.BusinessType;
import com.snow.flowable.domain.*;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.flowable.service.impl.FlowablePublishServiceImpl;
import com.snow.flowable.service.impl.FlowableServiceImpl;
import com.snow.framework.util.ShiroUtils;
@ -37,8 +38,7 @@ public class FlowModelerController extends BaseController
{
private String prefix = "flow";
@Autowired
private IFinanceAlipayFlowService financeAlipayFlowService;
@Autowired
private FlowableServiceImpl flowableService;
@Autowired
@ -84,18 +84,7 @@ public class FlowModelerController extends BaseController
return getFlowDataTable(deploymentList);
}
/**
* 获取我的待办
*/
@RequiresPermissions("modeler:flow:todoList")
@PostMapping("/findTasksByUserId")
@ResponseBody
public TableDataInfo findTasksByUserId(TaskBaseDTO taskBaseDTO)
{
Long userId = ShiroUtils.getUserId();
PageModel<TaskVO> taskList = flowableService.findTasksByUserId(String.valueOf(userId), taskBaseDTO);
return getFlowDataTable(taskList);
}
/**
* 获取XML

View File

@ -16,6 +16,7 @@ import com.snow.flowable.domain.leave.SysOaLeaveForm;
import com.snow.flowable.domain.purchaseOrder.PurchaseOrderForm;
import com.snow.flowable.domain.purchaseOrder.PurchaseOrderMainTask;
import com.snow.flowable.service.FlowableService;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.framework.excel.FinanceAlipayFlowListener;
import com.snow.framework.excel.PurchaseOrderListener;
import com.snow.framework.util.ShiroUtils;
@ -58,9 +59,13 @@ public class PurchaseOrderController extends BaseController
@Autowired
private IPurchaseOrderMainService purchaseOrderMainService;
@Autowired
private FlowableService flowableService;
@Autowired
private FlowableTaskService flowableTaskService;
@Autowired
private ISysSequenceService sequenceService;
@RequiresPermissions("system:purchaseOrder:view")
@ -205,7 +210,7 @@ public class PurchaseOrderController extends BaseController
purchaseOrderForm.setBusVarUrl("/system/purchaseOrder/detail");
ProcessInstance processInstance = flowableService.startProcessInstanceByAppForm(purchaseOrderForm);
//推进任务节点
flowableService.automaticTask(processInstance.getProcessInstanceId());
flowableTaskService.automaticTask(processInstance.getProcessInstanceId());
return toAjax(i);
}

View File

@ -15,8 +15,10 @@ import com.snow.common.utils.StringUtils;
import com.snow.flowable.common.constants.FlowConstants;
import com.snow.flowable.domain.*;
import com.snow.flowable.domain.leave.LeaveFinishTaskDTO;
import com.snow.flowable.domain.leave.LeaveRestartTaskDTO;
import com.snow.flowable.domain.leave.SysOaLeaveForm;
import com.snow.flowable.service.AppFormService;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.flowable.service.impl.FlowableServiceImpl;
import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.SysUser;
@ -60,7 +62,7 @@ public class SysOaLeaveController extends BaseController
private ISysSequenceService sequenceService;
@Autowired
private AppFormService appFormService;
private FlowableTaskService flowableTaskService;
@RequiresPermissions("system:leave:view")
@ -221,93 +223,47 @@ public class SysOaLeaveController extends BaseController
@PostMapping("/managerFinishTask")
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult managerFinishTask(FinishTaskDTO finishTaskDTO)
public AjaxResult managerFinishTask(LeaveFinishTaskDTO finishTaskDTO)
{
SysUser sysUser = ShiroUtils.getSysUser();
List<FileEntry> files=Lists.newArrayList();
FileEntry fileEntry=new FileEntry();
fileEntry.setName("请假申请");
fileEntry.setUrl(finishTaskDTO.getSuggestionFileUrl());
files.add(fileEntry);
CompleteTaskDTO completeTaskDTO=new CompleteTaskDTO();
completeTaskDTO.setTaskId(finishTaskDTO.getTaskId());
completeTaskDTO.setUserId(String.valueOf(sysUser.getUserId()));
completeTaskDTO.setFiles(files);
completeTaskDTO.setComment(finishTaskDTO.getSuggestion());
Integer checkStatus = finishTaskDTO.getCheckStatus();
Map<String,Object> paramMap=Maps.newHashMap();
paramMap.put("hr",2);
completeTaskDTO.setParamMap(paramMap);
if(checkStatus==0){
completeTaskDTO.setIsPass(true);
}else {
completeTaskDTO.setIsPass(false);
}
flowableService.completeTask(completeTaskDTO);
finishTaskDTO.setUserId(String.valueOf(sysUser.getUserId()));
finishTaskDTO.setHr("2");
flowableTaskService.submitTask(finishTaskDTO);
return AjaxResult.success();
}
/**
* hr完成审批
*/
//@RequiresPermissions("system:leave:startLeaveProcess")
@Log(title = "hr完成审批", businessType = BusinessType.OTHER)
@PostMapping("/hrFinishTask")
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult hrFinishTask(FinishTaskDTO finishTaskDTO)
public AjaxResult hrFinishTask(LeaveFinishTaskDTO finishTaskDTO)
{
SysOaLeave sysOaLeave=new SysOaLeave();
sysOaLeave.setLeaveNo(finishTaskDTO.getBusinessKey());
List<SysOaLeave> sysOaLeaves = sysOaLeaveService.selectSysOaLeaveList(sysOaLeave);
if(StringUtils.isEmpty(sysOaLeaves)){
return AjaxResult.error("该业务参数不存在");
}
SysUser sysUser = ShiroUtils.getSysUser();
CompleteTaskDTO completeTaskDTO=new CompleteTaskDTO();
completeTaskDTO.setUserId(String.valueOf(sysUser.getUserId()));
completeTaskDTO.setTaskId(finishTaskDTO.getTaskId());
Integer checkStatus = finishTaskDTO.getCheckStatus();
if(checkStatus==0){
completeTaskDTO.setIsPass(true);
}else {
completeTaskDTO.setIsPass(false);
}
completeTaskDTO.setComment(finishTaskDTO.getSuggestion());
flowableService.completeTask(completeTaskDTO);
finishTaskDTO.setUserId(String.valueOf(sysUser.getUserId()));
flowableTaskService.submitTask(finishTaskDTO);
return AjaxResult.success();
}
/**
* 重新发起申请
*/
@Log(title = "重新发起申请", businessType = BusinessType.UPDATE)
@Log(title = "重新发起申请", businessType = BusinessType.OTHER)
@PostMapping("/reStartTask")
@ResponseBody
public AjaxResult reStartTask(LeaveFinishTaskDTO sysOaLeave)
@Transactional
public AjaxResult reStartTask(LeaveRestartTaskDTO finishTaskDTO)
{
SysUser sysUser = ShiroUtils.getSysUser();
sysOaLeave.setApplyPerson(sysUser.getUserName());
SysOaLeave sysOaLeave=new SysOaLeave();
BeanUtils.copyProperties(finishTaskDTO,sysOaLeave);
sysOaLeave.setUpdateBy(sysUser.getUserName());
int i = sysOaLeaveService.updateSysOaLeave(sysOaLeave);
SysOaLeave newSysOaLeave = sysOaLeaveService.selectSysOaLeaveById(sysOaLeave.getId());
String leaveString= JSON.toJSONString(newSysOaLeave);
//提交
CompleteTaskDTO completeTaskDTO=new CompleteTaskDTO();
completeTaskDTO.setUserId(String.valueOf(sysUser.getUserId()));
completeTaskDTO.setTaskId(sysOaLeave.getTaskId());
completeTaskDTO.setComment(sysOaLeave.getSuggestion());
Integer checkStatus = sysOaLeave.getCheckStatus();
if(checkStatus==0){
completeTaskDTO.setIsPass(true);
}else {
completeTaskDTO.setIsPass(false);
}
Map<String, Object> map=Maps.newHashMap();
map.put(FlowConstants.BUS_VAR,leaveString);
completeTaskDTO.setParamMap(map);
flowableService.completeTask(completeTaskDTO);
return toAjax(i);
finishTaskDTO.setUserId(String.valueOf(sysUser.getUserId()));
flowableTaskService.submitTask(finishTaskDTO);
return AjaxResult.success();
}
}

View File

@ -127,28 +127,20 @@
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('system:flow:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:flow:remove')}]];
var prefix = ctx + "modeler";
var prefixFlow = ctx + "flow";
$(function() {
var options = {
id: "bootstrap-table",
formId:"formIds",
url: prefix + "/findTasksByUserId",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
importUrl: prefix + "/importData",
importTemplateUrl: prefix + "/importTemplate",
striped: true, //是否显示行间隔色
formId:"formId",
url: prefixFlow + "/findTasksByUserId",
striped: true,
showToggle: false,
loadingFontSize:20,
showRefresh: false, // 是否显示刷新按钮
showColumns: false, // 是否显示隐藏某列下拉框
showToggle: false,
showSearch: false, // 是否显示检索信息
// rowStyle:rowStyle,//通过自定义函数设置行样式
modalName: "我的待办",
columns: [{
title: '序号',

View File

@ -11,8 +11,8 @@
<form class="form-horizontal m-t" id="signupForm">
<div class="row">
<div class="col-sm-offset-0 col-sm-10">
<button type="button" class="btn btn-sm btn-primary" onclick="submitCheckHandler()"><i class="fa fa-check"></i>通 过</button>&nbsp;
<button type="button" class="btn btn-sm btn-danger" onclick="submitHandler()"><i class="fa fa-remove"></i>驳 回</button>&nbsp;
<button type="button" class="btn btn-sm btn-primary" onclick="submitCheckHandler(true)"><i class="fa fa-check"></i>通 过</button>&nbsp;
<button type="button" class="btn btn-sm btn-danger" onclick="submitCheckHandler(false)"><i class="fa fa-remove"></i>驳 回</button>&nbsp;
</div>
</div>
<br/>
@ -58,13 +58,12 @@
<div class="form-group">
<label class="col-sm-3 control-label">人事审批意见:</label>
<div class="col-sm-8">
<textarea name="suggestion" class="form-control"></textarea>
<textarea name="comment" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">审批附件:</label>
<div class="col-sm-8">
<input type="hidden" name="suggestionFileUrl" >
<div class="file-loading">
<input class="form-control file-upload" id="suggestionFileUrl" name="file" type="file">
</div>
@ -77,12 +76,13 @@
<th:block th:include="include :: jsonview-js" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
var files=new Array();
$(function () {
var processInstanceId= $("#processInstanceId").val();
var url ="/modeler/getProcessDiagram?processInstanceId="+processInstanceId;
$(".imgcode").attr("src", url);
});
$(function() {
var reason = [[${appFrom.reason}]];
console.log(reason);
@ -94,6 +94,7 @@
});
$(".file-upload").each(function (i) {
var val = $("input[name='" + this.id + "']").val();
$(this).fileinput({
@ -103,27 +104,37 @@
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
$("input[name='" + event.currentTarget.id + "']").val(data.response.url)
files.push({"key": data.response.fileKey,"name": data.response.fileName, "url":data.response.url});
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
$(this).fileinput('_initFileActions');
});
function submitCheckHandler() {
function submitCheckHandler(status) {
if ($.validate.form()) {
var data = $("#signupForm").serializeArray();
data.push({"name": "checkStatus", "value": 0});
$.operate.saveTab("/system/leave/hrFinishTask", data);
}
}
function submitHandler() {
if ($.validate.form()) {
var data = $("#signupForm").serializeArray();
data.push({"name": "checkStatus", "value": 1});
for(var i=0;i<data.length;i++){
if(data[i].name=='comment'&&(data[i].value==''||data[i].value==null)){
$.modal.alertError("请填写审批意见");
return false;
}
}
if(files!=null||files!=''){
for(var i=0;i<files.length;i++){
data.push({"name": "files["+i+"].key", "value":files[i].key});
data.push({"name": "files["+i+"].name", "value":files[i].name});
data.push({"name": "files["+i+"].url", "value":files[i].url});
}
}
data.push({"name": "isPass", "value": status});
console.log(data);
$.operate.saveTab("/system/leave/hrFinishTask", data);
}
}
</script>
</body>
</html>

View File

@ -11,8 +11,8 @@
<form class="form-horizontal m-t" id="signupForm">
<div class="row">
<div class="col-sm-offset-0 col-sm-10">
<button type="button" class="btn btn-sm btn-primary" onclick="submitCheckHandler()"><i class="fa fa-check"></i>通 过</button>&nbsp;
<button type="button" class="btn btn-sm btn-danger" onclick="submitHandler()"><i class="fa fa-remove"></i>驳 回</button>&nbsp;
<button type="button" class="btn btn-sm btn-primary" onclick="submitCheckHandler(true)"><i class="fa fa-check"></i>通 过</button>&nbsp;
<button type="button" class="btn btn-sm btn-danger" onclick="submitCheckHandler(false)"><i class="fa fa-remove"></i>驳 回</button>&nbsp;
</div>
</div>
<br/>
@ -56,13 +56,12 @@
<div class="form-group">
<label class="col-sm-3 control-label">主管审批意见:</label>
<div class="col-sm-8">
<textarea name="suggestion" class="form-control" required></textarea>
<textarea name="comment" class="form-control" required></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">审批附件:</label>
<div class="col-sm-8">
<input type="hidden" name="suggestionFileUrl" >
<div class="file-loading">
<input class="form-control file-upload" id="suggestionFileUrl" name="file" type="file">
</div>
@ -74,6 +73,7 @@
<th:block th:include="include :: jsonview-js" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
var files=new Array();
$(function() {
var reason = [[${appFrom.reason}]];
console.log(reason);
@ -94,24 +94,33 @@
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
$("input[name='" + event.currentTarget.id + "']").val(data.response.url)
files.push({"key": data.response.fileKey,"name": data.response.fileName, "url":data.response.url});
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
$(this).fileinput('_initFileActions');
});
function submitCheckHandler() {
function submitCheckHandler(status) {
if ($.validate.form()) {
var data = $("#signupForm").serializeArray();
data.push({"name": "checkStatus", "value": 0});
$.operate.saveTab("/system/leave/managerFinishTask", data);
for(var i=0;i<data.length;i++){
if(data[i].name=='comment'&&(data[i].value==''||data[i].value==null)){
$.modal.alertError("请填写审批意见");
return false;
}
}
function submitHandler() {
if ($.validate.form()) {
var data = $("#signupForm").serializeArray();
data.push({"name": "checkStatus", "value": 1});
if(files!=null||files!=''){
for(var i=0;i<files.length;i++){
data.push({"name": "files["+i+"].key", "value":files[i].key});
data.push({"name": "files["+i+"].name", "value":files[i].name});
data.push({"name": "files["+i+"].url", "value":files[i].url});
}
}
data.push({"name": "isPass", "value": status});
console.log(data);
$.operate.saveTab("/system/leave/managerFinishTask", data);
}
}

View File

@ -4,14 +4,15 @@
<th:block th:include="include :: header('人事审批')" />
<th:block th:include="include :: jsonview-css" />
<th:block th:include="include :: bootstrap-fileinput-css"/>
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="signupForm" th:object="${sysOaLeave}">
<form class="form-horizontal m" id="signupForm" th:object="${appFrom}">
<div class="row">
<div class="col-sm-offset-0 col-sm-10">
<button type="button" class="btn btn-sm btn-primary" onclick="submitCheckHandler()"><i class="fa fa-check"></i>重新申请</button>&nbsp;
<button type="button" class="btn btn-sm btn-danger" onclick="submitHandler()"><i class="fa fa-remove"></i>删除</button>&nbsp;
<button type="button" class="btn btn-sm btn-primary" onclick="submitCheckHandler(true)"><i class="fa fa-check"></i>重新申请</button>&nbsp;
<button type="button" class="btn btn-sm btn-danger" onclick="submitCheckHandler(false)"><i class="fa fa-remove"></i>删除</button>&nbsp;
</div>
</div>
<br/>
@ -27,21 +28,21 @@
<div class="form-group">
<label class="col-sm-3 control-label">请假名称:</label>
<div class="col-sm-8">
<input name="name" th:field="*{name}" class="form-control" type="text">
<input name="name" th:field="*{name}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">请假理由:</label>
<div class="col-sm-8">
<textarea name="reason" class="form-control">[[*{reason}]]</textarea>
<textarea name="reason" class="form-control" required>[[*{reason}]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">开始时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="startTime" id="startTime" th:value="${#dates.format(sysOaLeave.startTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<input name="startTime" id="startTime" th:value="${#dates.format(appFrom.startTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
@ -50,7 +51,7 @@
<label class="col-sm-3 control-label">结束时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="endTime" id="endTime" th:value="${#dates.format(sysOaLeave.endTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<input name="endTime" id="endTime" th:value="${#dates.format(appFrom.endTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
@ -68,13 +69,13 @@
<div class="form-group">
<label class="col-sm-3 control-label">重新申请说明:</label>
<div class="col-sm-8">
<textarea name="suggestion" class="form-control"></textarea>
<textarea name="comment" class="form-control" required></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">审批附件:</label>
<div class="col-sm-8">
<input type="hidden" name="suggestionFileUrl" >
<div class="file-loading">
<input class="form-control file-upload" id="suggestionFileUrl" name="file" type="file">
</div>
@ -85,9 +86,10 @@
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: jsonview-js" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
var files=new Array();
$(".file-upload").each(function (i) {
var val = $("input[name='" + this.id + "']").val();
@ -98,7 +100,7 @@
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
$("input[name='" + event.currentTarget.id + "']").val(data.response.url)
files.push({"key": data.response.fileKey,"name": data.response.fileName, "url":data.response.url});
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
@ -107,17 +109,36 @@
$("#signupForm").validate({
focusCleanup: true
});
function submitCheckHandler() {
$("input[name='startTime']").datetimepicker({
format: "yyyy-mm-dd hh:ii:ss",
minView: "hour",
autoclose: true
});
$("input[name='endTime']").datetimepicker({
format: "yyyy-mm-dd hh:ii:ss",
minView: "hour",
autoclose: true
});
function submitCheckHandler(status) {
if ($.validate.form()) {
var data = $("#signupForm").serializeArray();
data.push({"name": "checkStatus", "value": 0});
$.operate.saveTab("/system/leave/reStartTask", data);
for(var i=0;i<data.length;i++){
if(data[i].name=='comment'&&(data[i].value==''||data[i].value==null)){
$.modal.alertError("请填写审批意见");
return false;
}
}
function submitHandler() {
if ($.validate.form()) {
var data = $("#signupForm").serializeArray();
data.push({"name": "checkStatus", "value": 1});
if(files!=null||files!=''){
for(var i=0;i<files.length;i++){
data.push({"name": "files["+i+"].key", "value":files[i].key});
data.push({"name": "files["+i+"].name", "value":files[i].name});
data.push({"name": "files["+i+"].url", "value":files[i].url});
}
}
data.push({"name": "isPass", "value": status});
console.log(data);
$.operate.saveTab("/system/leave/reStartTask", data);
}
}

View File

@ -7,6 +7,7 @@ import com.snow.flowable.domain.DeploymentQueryDTO;
import com.snow.flowable.domain.StartProcessDTO;
import com.snow.flowable.domain.TaskVO;
import com.snow.flowable.service.FlowableService;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.flowable.service.impl.FlowableUserServiceImpl;
import com.snow.system.domain.SysUser;
import lombok.extern.slf4j.Slf4j;
@ -39,6 +40,9 @@ public class FlowableServiceTests extends JunitTestApplication {
@Autowired
private FlowableUserServiceImpl flowableUserService;
@Autowired
private FlowableTaskService flowableTaskService;
@Test
public void startProcessInstanceByKey(){
StartProcessDTO startProcessDTO=new StartProcessDTO();
@ -72,7 +76,7 @@ public class FlowableServiceTests extends JunitTestApplication {
List<Task> list = taskQuery.list();
list.forEach(task -> {
List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(task.getId());
flowableService.getIdentityLinksForTask(task.getId(),"");
flowableTaskService.getIdentityLinksForTask(task.getId(),"");
log.info(JSON.toJSONString(identityLinksForTask));
});

View File

@ -16,9 +16,6 @@ import java.util.Map;
* @create: 2020-11-23 22:13
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FinishTaskDTO implements Serializable {
/**

View File

@ -18,6 +18,8 @@ import java.io.Serializable;
@NoArgsConstructor
@Builder
public class FlowBaseDTO implements Serializable {
/** 当前记录起始索引 */
private Integer pageNum;

View File

@ -13,13 +13,35 @@ import java.io.Serializable;
@Data
public class TaskBaseDTO extends FlowBaseDTO implements Serializable {
/**
* 流程实例ID
*/
private String processInstanceId;
/**
* 流程定义key
*/
private String definitionKey;
/**
* 任务ID
*/
private String taskId;
/**
* 任务名称
*/
private String taskName;
/**
* 业务参数
*/
private String businessKey;
/**
* 流程名称
*/
private String processDefinitionName;
}

View File

@ -29,6 +29,7 @@ import java.util.Set;
@NoArgsConstructor
public class TaskVO implements Serializable {
private static final long serialVersionUID = -8748902102208523880L;
/**
* 任务ID
*/

View File

@ -1,5 +1,6 @@
package com.snow.flowable.domain.leave;
import com.snow.flowable.domain.FinishTaskDTO;
import com.snow.system.domain.SysOaLeave;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -18,20 +19,12 @@ import java.io.Serializable;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LeaveFinishTaskDTO extends SysOaLeave implements Serializable {
public class LeaveFinishTaskDTO extends FinishTaskDTO implements Serializable {
private String taskId;
private String suggestion;
private String suggestionFileUrl;
private static final long serialVersionUID = -6573836100426806321L;
/**
* 0通过1--驳回
* hr userID
*/
private Integer checkStatus;
/**
* 业务参数
*/
private String businessKey;
private String hr;
}

View File

@ -0,0 +1,53 @@
package com.snow.flowable.domain.leave;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.snow.flowable.domain.FinishTaskDTO;
import lombok.Data;
import java.util.Date;
/**
* @program: snow
* @description
* @author: 没用的阿吉
* @create: 2021-01-13 21:48
**/
@Data
public class LeaveRestartTaskDTO extends FinishTaskDTO {
/** id */
private Integer id;
/** 请假名称 */
private String name;
/** 请假理由 */
private String reason;
/** 开始时间 */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/** 结束时间 */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/** 流程状态0--待审批1-审批中2--审批通过3--驳回) */
private Integer processStatus;
/** 流程实例ID */
private String processInstanceId;
/** 申请人 */
private String applyPerson;
/** 附件 */
private String fileUrl;
/** 请假单号 */
private String leaveNo;
}

View File

@ -85,53 +85,14 @@ public interface FlowableService {
ProcessInstance startProcessInstanceByAppForm(AppForm appForm);
/**
* 自动完成任务
* @param processInstanceId
*/
void automaticTask(String processInstanceId);
/**
* 根据任务ID获取代办
* @param taskId
* @return
*/
Task getTask(String taskId);
/**
* 获取代办 分页获取
* @param userId
* @param taskBaseDTO
* @return
*/
PageModel<TaskVO> findTasksByUserId(String userId,TaskBaseDTO taskBaseDTO);
/**
* 根据任务ID获取关联待办人待办组的人
* @param taskId
* @return
*/
Set<SysUser> getIdentityLinksForTask(String taskId,String type);
/**
* 获取历史的
* @param taskId
* @return
*/
Set<SysUser> getHistoricIdentityLinksForTask(String taskId);
/**
* 完成任务
* @param completeTaskDTO
*/
@Deprecated
void completeTask(CompleteTaskDTO completeTaskDTO);
/**
* 完成任务
* @param completeTaskDTO
* @param <T>
*/
<T extends CompleteTaskDTO> void submitTask(T completeTaskDTO);
/**
* 获取流程图

View File

@ -1,7 +1,14 @@
package com.snow.flowable.service;
import com.snow.common.core.page.PageModel;
import com.snow.flowable.domain.CompleteTaskDTO;
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 org.flowable.task.api.Task;
import java.util.Set;
/**
* @author qimingjin
@ -12,6 +19,34 @@ import com.snow.flowable.domain.FinishTaskDTO;
public interface FlowableTaskService {
/**
* 获取代办 分页获取
* @param userId
* @param taskBaseDTO
* @return
*/
PageModel<TaskVO> findTasksByUserId(String userId, TaskBaseDTO taskBaseDTO);
/**
* 根据任务ID获取关联待办人待办组的人
* @param taskId
* @return
*/
Set<SysUser> getIdentityLinksForTask(String taskId, String type);
/**
* 获取历史的
* @param taskId
* @return
*/
Set<SysUser> getHistoricIdentityLinksForTask(String taskId);
/**
* 根据ID获取任务
* @param taskId
* @return
*/
Task getTask(String taskId);
/**
* 完成任务
* @param finishTaskDTO
@ -19,6 +54,11 @@ public interface FlowableTaskService {
*/
<T extends FinishTaskDTO> void submitTask(T finishTaskDTO);
/**
* 自动完成任务
* @param processInstanceId
*/
void automaticTask(String processInstanceId);
/**
* 转办任务
* @param taskId 任务ID
@ -37,4 +77,6 @@ public interface FlowableTaskService {
void suspendOrActiveApply(String instanceId, String suspendState);
}

View File

@ -20,6 +20,7 @@ import com.snow.flowable.config.ICustomProcessDiagramGenerator;
import com.snow.flowable.domain.*;
import com.snow.flowable.enums.FlowFinishedStatusEnum;
import com.snow.flowable.service.FlowableService;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.flowable.service.FlowableUserService;
import com.snow.system.domain.ActDeModel;
import com.snow.system.domain.FlowGroupDO;
@ -94,8 +95,6 @@ public class FlowableServiceImpl implements FlowableService {
@Autowired
private TaskService taskService;
@Autowired
private ISysRoleService roleService;
@Autowired
private RepositoryService repositoryService;
@ -124,6 +123,9 @@ public class FlowableServiceImpl implements FlowableService {
@Resource
private FlowableUserService flowableUserService;
@Resource
private FlowableTaskService flowableTaskService;
@Override
public void saveModel(ActDeModel actDeModel) {
// 构建ModelEditorSource
@ -312,145 +314,12 @@ public class FlowableServiceImpl implements FlowableService {
return processInstance;
}
@Override
public void automaticTask(String processInstanceId){
CompleteTaskDTO completeTaskDTO=new CompleteTaskDTO();
Task task=getTaskProcessInstanceById(processInstanceId);
completeTaskDTO.setTaskId(task.getId());
completeTaskDTO.setIsStart(true);
completeTaskDTO.setUserId(task.getAssignee());
completeTask(completeTaskDTO);
}
@Override
public Task getTask(String taskId) {
Task task = taskService.createTaskQuery()
.taskId(taskId)
.singleResult();
return task;
}
@Override
public PageModel<TaskVO> findTasksByUserId(String userId, TaskBaseDTO taskBaseDTO) {
//根据用户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);
}
if(!StringUtils.isEmpty(taskBaseDTO.getProcessInstanceId())){
taskQuery.processInstanceId(taskBaseDTO.getProcessInstanceId());
}
if(!StringUtils.isEmpty(taskBaseDTO.getTaskId())){
taskQuery.taskId(taskBaseDTO.getTaskId());
}
if(!StringUtils.isEmpty(taskBaseDTO.getBusinessKey())){
taskQuery.processInstanceBusinessKey(taskBaseDTO.getBusinessKey());
}
if(StringUtils.isEmpty(taskBaseDTO.getDefinitionKey())){
taskQuery.processDefinitionKey(taskBaseDTO.getDefinitionKey());
}
long count = taskQuery
.orderByTaskCreateTime()
.desc()
.count();
List<Task> taskList = taskQuery.endOr()
.orderByTaskCreateTime()
.desc()
.listPage(taskBaseDTO.getPageNum(), taskBaseDTO.getPageSize());
List<TaskVO> taskVoList = taskList.stream().map(t -> {
TaskVO taskVO = new TaskVO();
taskVO.setTaskId(t.getId());
taskVO.setTaskName(t.getName());
taskVO.setProcessInstanceId(t.getProcessInstanceId());
taskVO.setCreateDate(t.getCreateTime());
taskVO.setFormKey(t.getFormKey());
taskVO.setParentTaskId(t.getParentTaskId());
taskVO.setAssignee(t.getAssignee());
taskVO.setOwner(t.getOwner());
HistoricProcessInstance historicProcessInstance = getHistoricProcessInstanceById(t.getProcessInstanceId());
taskVO.setProcessDefinitionName(historicProcessInstance.getProcessDefinitionName());
String startUserId = historicProcessInstance.getStartUserId();
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(startUserId));
taskVO.setStartUserId(startUserId);
taskVO.setStartUserName(sysUser.getUserName());
taskVO.setBusinessKey(historicProcessInstance.getBusinessKey());
taskVO.setStartTime(historicProcessInstance.getStartTime());
return taskVO;
}).collect(Collectors.toList());
PageModel<TaskVO> pageModel = new PageModel<> ();
pageModel.setTotalCount((int)count);
pageModel.setPagedRecords(taskVoList);
return pageModel;
}
@Override
public Set<SysUser> getIdentityLinksForTask(String taskId,String type){
Set<SysUser> userList=new HashSet<>();
List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
if(!CollectionUtils.isEmpty(identityLinksForTask)){
identityLinksForTask.stream().filter(identityLink ->
!StringUtils.isEmpty(identityLink.getGroupId())
&&identityLink.getType().equals(type)
)
.forEach(identityLink -> {
String groupId = identityLink.getGroupId();
List<SysUser> sysUsers=flowableUserService.getUserByFlowGroupId(Long.parseLong(groupId));
userList.addAll(sysUsers);
});
identityLinksForTask.stream().filter(identityLink ->
!StringUtils.isEmpty(identityLink.getUserId())
&&identityLink.getType().equals(type)
)
.forEach(identityLink -> {
String userId = identityLink.getUserId();
SysUser sysUsers = sysUserMapper.selectUserById(Long.parseLong(userId));
userList.add(sysUsers);
});
}
return userList;
}
/**
* starterUSER_ID与PROC_INST_ID_记录流程的发起者
* candidateUSER_ID_ GROUP_ID_ 其中一个必须有值TASK_ID_有值记录当前任务的指派人与指派组
* participant USER_ID与PROC_INST_ID_有值记录流程任务的参与者
* @param taskId
* @return
*/
@Override
public Set<SysUser> getHistoricIdentityLinksForTask(String taskId){
Set<SysUser> userList=new HashSet<>();
List<HistoricIdentityLink> historicIdentityLinksForTask = historyService.getHistoricIdentityLinksForTask(taskId);
if(!CollectionUtils.isEmpty(historicIdentityLinksForTask)){
historicIdentityLinksForTask.stream().filter(identityLink -> !StringUtils.isEmpty(identityLink.getGroupId())
&&identityLink.getType().equals("candidate"))
.forEach(identityLink -> {
String groupId = identityLink.getGroupId();
List<SysUser> sysUsers=flowableUserService.getUserByFlowGroupId(Long.parseLong(groupId));
userList.addAll(sysUsers);
});
historicIdentityLinksForTask.stream().filter(identityLink -> !StringUtils.isEmpty(identityLink.getUserId())
&&identityLink.getType().equals("candidate"))
.forEach(identityLink -> {
String userId = identityLink.getUserId();
SysUser sysUsers = sysUserMapper.selectUserById(Long.parseLong(userId));
userList.add(sysUsers);
});
}
return userList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void completeTask(CompleteTaskDTO completeTaskDTO) {
Task task = this.getTask(completeTaskDTO.getTaskId());
Task task = flowableTaskService.getTask(completeTaskDTO.getTaskId());
if(StringUtils.isEmpty(task)){
log.info("完成任务时该任务ID:%不存在",completeTaskDTO.getTaskId());
throw new BusinessException(String.format("该任务ID:%不存在",completeTaskDTO.getTaskId()));
@ -492,11 +361,7 @@ public class FlowableServiceImpl implements FlowableService {
taskService.complete(task.getId(),paramMap,true);
}
@Override
public <T extends CompleteTaskDTO> void submitTask(T completeTaskDTO) {
return;
}
@Override
public void getProcessDiagram(HttpServletResponse httpServletResponse, String processId) {
@ -646,7 +511,7 @@ public class FlowableServiceImpl implements FlowableService {
list.forEach(t -> {
//保存待办人
Set<SysUser> identityLinksForTask = getHistoricIdentityLinksForTask(t.getTaskId());
Set<SysUser> identityLinksForTask = flowableTaskService.getHistoricIdentityLinksForTask(t.getTaskId());
Optional.ofNullable(identityLinksForTask).ifPresent(m->{
List<String> userNameList = identityLinksForTask.stream().map(SysUser::getUserName).collect(Collectors.toList());
t.setHandleUserList(userNameList);

View File

@ -2,25 +2,36 @@ package com.snow.flowable.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.google.common.collect.Maps;
import com.snow.common.core.page.PageModel;
import com.snow.common.exception.BusinessException;
import com.snow.flowable.common.constants.FlowConstants;
import com.snow.flowable.domain.CompleteTaskDTO;
import com.snow.flowable.domain.FileEntry;
import com.snow.flowable.domain.FinishTaskDTO;
import com.snow.flowable.domain.*;
import com.snow.flowable.service.FlowableService;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.flowable.service.FlowableUserService;
import com.snow.system.domain.SysUser;
import com.snow.system.service.impl.SysUserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.identitylink.api.IdentityLink;
import org.flowable.identitylink.api.history.HistoricIdentityLink;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author qimingjin
@ -29,6 +40,7 @@ import java.util.Set;
* @date 2021/1/13 15:54
*/
@Slf4j
@Service
public class FlowableTaskServiceImpl implements FlowableTaskService {
@Autowired
@ -37,12 +49,158 @@ public class FlowableTaskServiceImpl implements FlowableTaskService {
@Autowired
private RuntimeService runtimeService;
@Autowired
private HistoryService historyService;
@Autowired
private FlowableService flowableService;
@Resource
private FlowableUserService flowableUserService;
@Autowired
private SysUserServiceImpl sysUserService;
@Override
public PageModel<TaskVO> findTasksByUserId(String userId, TaskBaseDTO taskBaseDTO) {
//根据用户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();
}
if(!StringUtils.isEmpty(taskBaseDTO.getProcessInstanceId())){
taskQuery.processInstanceId(taskBaseDTO.getProcessInstanceId());
}
if(!StringUtils.isEmpty(taskBaseDTO.getTaskId())){
taskQuery.taskId(taskBaseDTO.getTaskId());
}
if(!StringUtils.isEmpty(taskBaseDTO.getTaskName())){
taskQuery.taskNameLike("%"+taskBaseDTO.getTaskName()+"%");
}
if(!StringUtils.isEmpty(taskBaseDTO.getBusinessKey())){
taskQuery.processInstanceBusinessKeyLike("%"+taskBaseDTO.getBusinessKey()+"%");
}
if(!StringUtils.isEmpty(taskBaseDTO.getDefinitionKey())){
taskQuery.processDefinitionKey(taskBaseDTO.getDefinitionKey());
}
if(!StringUtils.isEmpty(taskBaseDTO.getProcessDefinitionName())){
taskQuery.processDefinitionNameLike("%"+taskBaseDTO.getProcessDefinitionName()+"%");
}
long count = taskQuery
.orderByTaskCreateTime()
.desc()
.count();
List<Task> taskList = taskQuery
.orderByTaskCreateTime()
.desc()
.listPage(taskBaseDTO.getPageNum(), taskBaseDTO.getPageSize());
List<TaskVO> taskVoList = taskList.stream().map(t -> {
TaskVO taskVO = new TaskVO();
taskVO.setTaskId(t.getId());
taskVO.setTaskName(t.getName());
taskVO.setProcessInstanceId(t.getProcessInstanceId());
taskVO.setCreateDate(t.getCreateTime());
taskVO.setFormKey(t.getFormKey());
taskVO.setParentTaskId(t.getParentTaskId());
taskVO.setAssignee(t.getAssignee());
taskVO.setOwner(t.getOwner());
HistoricProcessInstance historicProcessInstance = flowableService.getHistoricProcessInstanceById(t.getProcessInstanceId());
taskVO.setProcessDefinitionName(historicProcessInstance.getProcessDefinitionName());
String startUserId = historicProcessInstance.getStartUserId();
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(startUserId));
taskVO.setStartUserId(startUserId);
taskVO.setStartUserName(sysUser.getUserName());
taskVO.setBusinessKey(historicProcessInstance.getBusinessKey());
taskVO.setStartTime(historicProcessInstance.getStartTime());
return taskVO;
}).collect(Collectors.toList());
PageModel<TaskVO> pageModel = new PageModel<> ();
pageModel.setTotalCount((int)count);
pageModel.setPagedRecords(taskVoList);
return pageModel;
}
@Override
public Set<SysUser> getIdentityLinksForTask(String taskId, String type) {
Set<SysUser> userList=new HashSet<>();
List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
if(!CollectionUtils.isEmpty(identityLinksForTask)){
identityLinksForTask.stream().filter(identityLink ->
!StringUtils.isEmpty(identityLink.getGroupId())
&&identityLink.getType().equals(type)
)
.forEach(identityLink -> {
String groupId = identityLink.getGroupId();
List<SysUser> sysUsers=flowableUserService.getUserByFlowGroupId(Long.parseLong(groupId));
userList.addAll(sysUsers);
});
identityLinksForTask.stream().filter(identityLink ->
!StringUtils.isEmpty(identityLink.getUserId())
&&identityLink.getType().equals(type)
)
.forEach(identityLink -> {
String userId = identityLink.getUserId();
SysUser sysUsers = sysUserService.selectUserById(Long.parseLong(userId));
userList.add(sysUsers);
});
}
return userList;
}
/**
* starterUSER_ID与PROC_INST_ID_记录流程的发起者
* candidateUSER_ID_ GROUP_ID_ 其中一个必须有值TASK_ID_有值记录当前任务的指派人与指派组
* participant USER_ID与PROC_INST_ID_有值记录流程任务的参与者
* @param taskId
* @return
*/
@Override
public Set<SysUser> getHistoricIdentityLinksForTask(String taskId){
Set<SysUser> userList=new HashSet<>();
List<HistoricIdentityLink> historicIdentityLinksForTask = historyService.getHistoricIdentityLinksForTask(taskId);
if(!CollectionUtils.isEmpty(historicIdentityLinksForTask)){
historicIdentityLinksForTask.stream().filter(identityLink -> !StringUtils.isEmpty(identityLink.getGroupId())
&&identityLink.getType().equals("candidate"))
.forEach(identityLink -> {
String groupId = identityLink.getGroupId();
List<SysUser> sysUsers=flowableUserService.getUserByFlowGroupId(Long.parseLong(groupId));
userList.addAll(sysUsers);
});
historicIdentityLinksForTask.stream().filter(identityLink -> !StringUtils.isEmpty(identityLink.getUserId())
&&identityLink.getType().equals("candidate"))
.forEach(identityLink -> {
String userId = identityLink.getUserId();
SysUser sysUsers = sysUserService.selectUserById(Long.parseLong(userId));
userList.add(sysUsers);
});
}
return userList;
}
@Override
public Task getTask(String taskId) {
Task task = taskService.createTaskQuery()
.taskId(taskId)
.singleResult();
return task;
}
@Override
public <T extends FinishTaskDTO> void submitTask(T finishTaskDTO) {
Task task = flowableService.getTask(finishTaskDTO.getTaskId());
Task task = this.getTask(finishTaskDTO.getTaskId());
if(StringUtils.isEmpty(task)){
log.info("完成任务时该任务ID:%不存在",finishTaskDTO.getTaskId());
throw new BusinessException(String.format("该任务ID:%不存在",finishTaskDTO.getTaskId()));
@ -84,6 +242,16 @@ public class FlowableTaskServiceImpl implements FlowableTaskService {
taskService.complete(task.getId(),paramMap,true);
}
@Override
public void automaticTask(String processInstanceId){
FinishTaskDTO completeTaskDTO=new FinishTaskDTO();
Task task=flowableService.getTaskProcessInstanceById(processInstanceId);
completeTaskDTO.setTaskId(task.getId());
completeTaskDTO.setIsStart(true);
completeTaskDTO.setUserId(task.getAssignee());
submitTask(completeTaskDTO);
}
@Override
public void transferTask(String taskId, String curUserId, String targetUserId) {
try {