|
@@ -672,18 +672,18 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
Task task = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
|
|
|
Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
|
|
|
|
|
|
- if (Objects.nonNull(task.getAssignee()) && task.getAssignee().equals(userId.toString())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
|
|
|
- } else {
|
|
|
- List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
|
|
|
- if (!CollectionUtils.isEmpty(identityLinkList)) {
|
|
|
- for (IdentityLink i : identityLinkList) {
|
|
|
- if (i.getTaskId().equals(taskId.toString()) && i.getUserId().equals(userId.toString())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (Objects.nonNull(task.getAssignee()) && task.getAssignee().equals(userId.toString())) {
|
|
|
+ // throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
|
|
|
+ // } else {
|
|
|
+ // List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
|
|
|
+ // if (!CollectionUtils.isEmpty(identityLinkList)) {
|
|
|
+ // for (IdentityLink i : identityLinkList) {
|
|
|
+ // if (i.getTaskId().equals(taskId.toString()) && i.getUserId().equals(userId.toString())) {
|
|
|
+ // throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_EXCHANGE_PREFIX + taskId, taskId,
|
|
|
SystemConstant.LOCK_FLOW_TIME_OUT);
|
|
|
if (!lock) {
|
|
@@ -695,27 +695,28 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
boolean multiInstance = false;
|
|
|
if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {//会签
|
|
|
multiInstance = true;
|
|
|
-
|
|
|
- List<Task> taskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId())
|
|
|
- .list();
|
|
|
- List<String> taskApproveList = new ArrayList<>();
|
|
|
- for (Task t : taskList) {
|
|
|
- if (Objects.equals(String.valueOf(t.getAssignee()), String.valueOf(userId))) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
|
|
|
- }
|
|
|
- taskApproveList.add(t.getAssignee());
|
|
|
- }
|
|
|
- if (taskApproveList.contains(userId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
- }
|
|
|
- } else {//或签
|
|
|
- Task taskUser = taskService.createTaskQuery().taskId(String.valueOf(taskId))
|
|
|
- .taskCandidateOrAssigned(String.valueOf(userId)).singleResult();
|
|
|
- if (Objects.nonNull(taskUser)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
- }
|
|
|
+ // List<Task> taskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId())
|
|
|
+ // .list();
|
|
|
+ // List<String> taskApproveList = new ArrayList<>();
|
|
|
+ // for (Task t : taskList) {
|
|
|
+ // if (Objects.equals(String.valueOf(t.getAssignee()), String.valueOf(userId))) {
|
|
|
+ // throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
|
|
|
+ // }
|
|
|
+ // taskApproveList.add(t.getAssignee());
|
|
|
+ // }
|
|
|
+ // if (taskApproveList.contains(userId)) {
|
|
|
+ // throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
+ // }
|
|
|
}
|
|
|
-
|
|
|
+ // else {//或签
|
|
|
+ // Task taskUser = taskService.createTaskQuery().taskId(String.valueOf(taskId))
|
|
|
+ // .taskCandidateOrAssigned(String.valueOf(userId)).singleResult();
|
|
|
+ // if (Objects.nonNull(taskUser)) {
|
|
|
+ // throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ boolean replace = false;
|
|
|
if (!multiInstance) {
|
|
|
String oldUserId = task.getAssignee();
|
|
|
if (Objects.nonNull(task.getAssignee())) {
|
|
@@ -731,12 +732,21 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- taskService.deleteCandidateUser(String.valueOf(taskId), oldUserId);
|
|
|
- taskService.addCandidateUser(String.valueOf(taskId), String.valueOf(userId));
|
|
|
+ if (!Objects.equals(oldUserId, String.valueOf(userId))) {
|
|
|
+ replace = true;
|
|
|
+ taskService.deleteCandidateUser(String.valueOf(taskId), oldUserId);
|
|
|
+ taskService.addCandidateUser(String.valueOf(taskId), String.valueOf(userId));
|
|
|
+ }
|
|
|
} else {
|
|
|
- taskService.setAssignee(String.valueOf(taskId), String.valueOf(userId));
|
|
|
+ if (!Objects.equals(task.getAssignee(), String.valueOf(userId))) {
|
|
|
+ replace = true;
|
|
|
+ taskService.setAssignee(String.valueOf(taskId), String.valueOf(userId));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ if (!replace) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
|
|
|
new QueryWrapper<TFCustomFlowEntity>().lambda()
|
|
|
.eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
|