|
@@ -33,10 +33,10 @@ import org.activiti.engine.task.Task;
|
33
|
33
|
import org.activiti.engine.task.TaskInfo;
|
34
|
34
|
import org.activiti.engine.task.TaskQuery;
|
35
|
35
|
import org.apache.commons.lang3.StringUtils;
|
36
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
37
|
36
|
import org.springframework.stereotype.Service;
|
38
|
37
|
import org.springframework.transaction.annotation.Transactional;
|
39
|
38
|
|
|
39
|
+import javax.annotation.Resource;
|
40
|
40
|
import java.util.*;
|
41
|
41
|
|
42
|
42
|
/**
|
|
@@ -46,15 +46,15 @@ import java.util.*;
|
46
|
46
|
*/
|
47
|
47
|
@Service
|
48
|
48
|
public class ActTaskService extends BaseServiceImpl {
|
49
|
|
- @Autowired
|
|
49
|
+ @Resource
|
50
|
50
|
protected TaskService taskService;
|
51
|
|
- @Autowired
|
|
51
|
+ @Resource
|
52
|
52
|
protected HistoryService historyService;
|
53
|
|
- @Autowired
|
|
53
|
+ @Resource
|
54
|
54
|
protected RepositoryService repositoryService;
|
55
|
|
- @Autowired
|
|
55
|
+ @Resource
|
56
|
56
|
protected RuntimeService runtimeService;
|
57
|
|
- @Autowired
|
|
57
|
+ @Resource
|
58
|
58
|
private SysRoleUserService sysRoleUserService;
|
59
|
59
|
|
60
|
60
|
/**
|
|
@@ -65,8 +65,8 @@ public class ActTaskService extends BaseServiceImpl {
|
65
|
65
|
*/
|
66
|
66
|
public PageData<TaskDTO> page(Map<String, Object> params) {
|
67
|
67
|
String userId = (String) params.get("userId");
|
68
|
|
- Integer curPage = 1;
|
69
|
|
- Integer limit = 10;
|
|
68
|
+ int curPage = 1;
|
|
69
|
+ int limit = 10;
|
70
|
70
|
if (params.get(Constant.PAGE) != null) {
|
71
|
71
|
curPage = Integer.parseInt((String) params.get(Constant.PAGE));
|
72
|
72
|
}
|
|
@@ -78,7 +78,7 @@ public class ActTaskService extends BaseServiceImpl {
|
78
|
78
|
taskQuery.taskAssignee(userId);
|
79
|
79
|
}
|
80
|
80
|
if (StringUtils.isNotEmpty((String)params.get("taskName"))){
|
81
|
|
- taskQuery.taskNameLike("%"+(String)params.get("taskName")+"%");
|
|
81
|
+ taskQuery.taskNameLike("%"+ params.get("taskName") +"%");
|
82
|
82
|
}
|
83
|
83
|
if(StringUtils.isNotEmpty((String)params.get("isRoleGroup"))&&"1".equals(params.get("isRoleGroup"))){
|
84
|
84
|
List<Long> listRoles = sysRoleUserService.getRoleIdList(SecurityUser.getUserId());
|
|
@@ -87,11 +87,7 @@ public class ActTaskService extends BaseServiceImpl {
|
87
|
87
|
listStr.add(role.toString());
|
88
|
88
|
}
|
89
|
89
|
listStr.add(SecurityUser.getUserId().toString());
|
90
|
|
- if(!listStr.isEmpty()){
|
91
|
|
- taskQuery.taskCandidateGroupIn(listStr);
|
92
|
|
- } else {
|
93
|
|
- return new PageData<>(new ArrayList<>(), 0);
|
94
|
|
- }
|
|
90
|
+ taskQuery.taskCandidateGroupIn(listStr);
|
95
|
91
|
}
|
96
|
92
|
taskQuery.orderByTaskCreateTime().desc();
|
97
|
93
|
List<Task> list = taskQuery.listPage((curPage - 1) * limit, limit);
|
|
@@ -259,10 +255,10 @@ public class ActTaskService extends BaseServiceImpl {
|
259
|
255
|
|
260
|
256
|
public void deleteTaskVariable(String taskId, String variableName, String scope) {
|
261
|
257
|
if (StringUtils.isNotEmpty(scope)) {
|
262
|
|
- if ("global".equals(scope.toLowerCase())) {
|
|
258
|
+ if ("global".equalsIgnoreCase(scope)) {
|
263
|
259
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
264
|
260
|
runtimeService.removeVariable(task.getExecutionId(), variableName);
|
265
|
|
- } else if ("local".equals(scope.toLowerCase())) {
|
|
261
|
+ } else if ("local".equalsIgnoreCase(scope)) {
|
266
|
262
|
taskService.removeVariable(taskId, variableName);
|
267
|
263
|
}
|
268
|
264
|
} else {
|
|
@@ -277,7 +273,7 @@ public class ActTaskService extends BaseServiceImpl {
|
277
|
273
|
*/
|
278
|
274
|
@Transactional(rollbackFor = Exception.class)
|
279
|
275
|
public void doBackPreviousTask(String taskId, String comment) {
|
280
|
|
- Map<String, Object> variables = null;
|
|
276
|
+ Map<String, Object> variables;
|
281
|
277
|
HistoricTaskInstance currTask = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
|
282
|
278
|
if(this.isMultiInstance(taskId)){
|
283
|
279
|
throw new EitcException(ErrorCode.BACK_PROCESS_PARALLEL_ERROR);
|
|
@@ -291,11 +287,8 @@ public class ActTaskService extends BaseServiceImpl {
|
291
|
287
|
if(canBackActivitys.isEmpty()) {
|
292
|
288
|
throw new EitcException(ErrorCode.SUPERIOR_NOT_EXIST);
|
293
|
289
|
}
|
294
|
|
- List<PvmTransition> originPvmTransitionList = new ArrayList<PvmTransition>();
|
295
|
290
|
List<PvmTransition> pvmTransitionList = currActivity.getOutgoingTransitions();
|
296
|
|
- for (PvmTransition pvmTransition : pvmTransitionList) {
|
297
|
|
- originPvmTransitionList.add(pvmTransition);
|
298
|
|
- }
|
|
291
|
+ List<PvmTransition> originPvmTransitionList = new ArrayList<>(pvmTransitionList);
|
299
|
292
|
pvmTransitionList.clear();
|
300
|
293
|
List<HistoricActivityInstance> historicActivityInstances = historyService
|
301
|
294
|
.createHistoricActivityInstanceQuery().activityType("userTask")
|
|
@@ -408,12 +401,9 @@ public class ActTaskService extends BaseServiceImpl {
|
408
|
401
|
taskService.complete(taskId);
|
409
|
402
|
} else {
|
410
|
403
|
ActivityImpl currActivity = findActivitiImpl(taskId, null);
|
411
|
|
- List<PvmTransition> oriPvmTransitionList = new ArrayList<PvmTransition>();
|
412
|
|
- List<PvmTransition> pvmTransitionList = currActivity
|
413
|
|
- .getOutgoingTransitions();
|
414
|
|
- for (PvmTransition pvmTransition : pvmTransitionList) {
|
415
|
|
- oriPvmTransitionList.add(pvmTransition);
|
416
|
|
- }
|
|
404
|
+ assert currActivity != null;
|
|
405
|
+ List<PvmTransition> pvmTransitionList = currActivity.getOutgoingTransitions();
|
|
406
|
+ List<PvmTransition> oriPvmTransitionList = new ArrayList<>(pvmTransitionList);
|
417
|
407
|
pvmTransitionList.clear();
|
418
|
408
|
TransitionImpl newTransition = currActivity.createOutgoingTransition();
|
419
|
409
|
ActivityImpl pointActivity = findActivitiImpl(taskId, endActivity.getId());
|
|
@@ -425,12 +415,11 @@ public class ActTaskService extends BaseServiceImpl {
|
425
|
415
|
comment = message + "["+ comment+ "]";
|
426
|
416
|
taskService.addComment(task.getId(), task.getProcessInstanceId(), comment);
|
427
|
417
|
taskService.complete(taskId);
|
|
418
|
+ assert pointActivity != null;
|
428
|
419
|
pointActivity.getIncomingTransitions().remove(newTransition);
|
429
|
420
|
List<PvmTransition> pvmTransitionListC = currActivity.getOutgoingTransitions();
|
430
|
421
|
pvmTransitionListC.clear();
|
431
|
|
- for (PvmTransition pvmTransition : oriPvmTransitionList) {
|
432
|
|
- pvmTransitionListC.add(pvmTransition);
|
433
|
|
- }
|
|
422
|
+ pvmTransitionListC.addAll(oriPvmTransitionList);
|
434
|
423
|
}
|
435
|
424
|
|
436
|
425
|
}
|
|
@@ -447,7 +436,7 @@ public class ActTaskService extends BaseServiceImpl {
|
447
|
436
|
if (StringUtils.isEmpty(activityId)) {
|
448
|
437
|
activityId = task.getTaskDefinitionKey();
|
449
|
438
|
}
|
450
|
|
- if ("END".equals(activityId.toUpperCase())) {
|
|
439
|
+ if ("END".equalsIgnoreCase(activityId)) {
|
451
|
440
|
for (ActivityImpl activityImpl : processDefinition.getActivities()) {
|
452
|
441
|
String type = (String)activityImpl.getProperty("type");
|
453
|
442
|
if("endEvent".equals(type)){
|
|
@@ -455,8 +444,7 @@ public class ActTaskService extends BaseServiceImpl {
|
455
|
444
|
}
|
456
|
445
|
}
|
457
|
446
|
}
|
458
|
|
- ActivityImpl activityImpl = processDefinition.findActivity(activityId);
|
459
|
|
- return activityImpl;
|
|
447
|
+ return processDefinition.findActivity(activityId);
|
460
|
448
|
}
|
461
|
449
|
|
462
|
450
|
/**
|
|
@@ -505,17 +493,14 @@ public class ActTaskService extends BaseServiceImpl {
|
505
|
493
|
throw new EitcException(ErrorCode.REJECT_PROCESS_HANDLEING_ERROR);
|
506
|
494
|
}
|
507
|
495
|
ActivityImpl currActivity = processDefinitionEntity.findActivity(currTask.getTaskDefinitionKey());
|
508
|
|
- List<PvmTransition> originPvmTransitionList = new ArrayList<>();
|
509
|
496
|
List<PvmTransition> pvmTransitionList = currActivity.getOutgoingTransitions();
|
510
|
|
- for (PvmTransition pvmTransition : pvmTransitionList) {
|
511
|
|
- originPvmTransitionList.add(pvmTransition);
|
512
|
|
- }
|
|
497
|
+ List<PvmTransition> originPvmTransitionList = new ArrayList<>(pvmTransitionList);
|
513
|
498
|
pvmTransitionList.clear();
|
514
|
499
|
List<HistoricActivityInstance> historicActivityInstances = historyService
|
515
|
500
|
.createHistoricActivityInstanceQuery().activityType("userTask")
|
516
|
501
|
.processInstanceId(processInstance.getId())
|
517
|
502
|
.finished().orderByHistoricActivityInstanceEndTime().asc().list();
|
518
|
|
- TransitionImpl transitionImpl = null;
|
|
503
|
+ TransitionImpl transitionImpl;
|
519
|
504
|
if (historicActivityInstances.size() > 0) {
|
520
|
505
|
ActivityImpl lastActivity = processDefinitionEntity.findActivity(historicActivityInstances.get(0).getActivityId());
|
521
|
506
|
transitionImpl = currActivity.createOutgoingTransition();
|
|
@@ -534,18 +519,14 @@ public class ActTaskService extends BaseServiceImpl {
|
534
|
519
|
}
|
535
|
520
|
currActivity.getOutgoingTransitions().remove(transitionImpl);
|
536
|
521
|
|
537
|
|
- for (PvmTransition pvmTransition : originPvmTransitionList) {
|
538
|
|
- pvmTransitionList.add(pvmTransition);
|
539
|
|
- }
|
|
522
|
+ pvmTransitionList.addAll(originPvmTransitionList);
|
540
|
523
|
}
|
541
|
524
|
|
542
|
525
|
public void completeTaskByVariables(TaskDTO taskDTO) {
|
543
|
526
|
if(null != taskDTO.getParams()){
|
544
|
|
- Set keySet = taskDTO.getParams().keySet();
|
545
|
|
- Iterator iterator = keySet.iterator();
|
546
|
|
- while(iterator.hasNext()){
|
547
|
|
- String key = (String)iterator.next();
|
548
|
|
- this.setTaskVariable(taskDTO.getTaskId(),key , taskDTO.getParams().get(key));
|
|
527
|
+ Set<String> keySet = taskDTO.getParams().keySet();
|
|
528
|
+ for (String key : keySet) {
|
|
529
|
+ this.setTaskVariable(taskDTO.getTaskId(), key, taskDTO.getParams().get(key));
|
549
|
530
|
}
|
550
|
531
|
}
|
551
|
532
|
this.completeTask(taskDTO.getTaskId(), taskDTO.getComment());
|