TaskController.java
3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.trash.activiti.controller;
import com.github.pagehelper.Page;
import com.trash.common.annotation.RepeatSubmit;
import com.trash.common.core.controller.BaseController;
import com.trash.common.core.domain.AjaxResult;
import com.trash.common.core.page.PageDomain;
import com.trash.common.core.page.TableDataInfo;
import com.trash.common.core.page.TableSupport;
import com.trash.common.utils.ServletUtils;
import com.trash.activiti.domain.dto.ActTaskDTO;
import com.trash.activiti.domain.dto.ActWorkflowFormDataDTO;
import com.trash.activiti.mapper.ActReDeploymentMapper;
import com.trash.activiti.service.IActTaskService;
import org.activiti.api.task.runtime.TaskRuntime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/task")
public class TaskController extends BaseController {
@Autowired
private TaskRuntime taskRuntime;
@Autowired
private IActTaskService actTaskService;
@Autowired
private ActReDeploymentMapper actReDeploymentMapper;
//获取我的代办任务
@GetMapping(value = "/list")
public TableDataInfo getTasks() {
PageDomain pageDomain = TableSupport.buildPageRequest();
Page<ActTaskDTO> hashMaps = actTaskService.selectProcessDefinitionList(pageDomain);
List<String> allNames = actReDeploymentMapper.selectTitles();
List<String> names = new ArrayList<String>();
for(String str:allNames){
for(ActTaskDTO dto:hashMaps.getResult()){
if(str.equals(dto.getInstanceName())){
names.add(str);
}
}
}
TableDataInfo tableDataInfo = getDataTable(hashMaps);
int pageNum = pageDomain.getPageNum();
int pageSize = pageDomain.getPageSize();
tableDataInfo.setNames(names);
if(tableDataInfo.getRows().size() <= pageSize){
return tableDataInfo;
}
if(tableDataInfo.getRows().size() > (pageNum)*pageSize){
tableDataInfo.setRows(tableDataInfo.getRows().subList((pageNum -1)*pageSize, (pageNum)*pageSize));
}else{
tableDataInfo.setRows(tableDataInfo.getRows().subList((pageNum -1)*pageSize, tableDataInfo.getRows().size()));
}
return tableDataInfo;
}
@RequestMapping("/taskHistory")
public String taskHistory() {
return "taskHistory";
}
//渲染表单
@GetMapping(value = "/formDataShow/{taskID}")
public AjaxResult formDataShow(@PathVariable("taskID") String taskID) {
return AjaxResult.success(actTaskService.formDataShow(taskID));
}
//保存表单
@PostMapping(value = "/formDataSave/{taskID}")
@RepeatSubmit
public AjaxResult formDataSave(@PathVariable("taskID") String taskID,
@RequestBody List<ActWorkflowFormDataDTO> formData ) throws ParseException {
return toAjax(actTaskService.formDataSave(taskID, formData));
}
}