|
@@ -658,20 +658,27 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public Boolean taskApproverExchange(Long userId, Long taskId) {
|
|
public Boolean taskApproverExchange(Long userId, Long taskId) {
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
- if (Objects.equals(String.valueOf(sysUser.getId()), String.valueOf(userId))) {
|
|
|
|
|
|
+ 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("不能转给自己!");
|
|
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,
|
|
boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_EXCHANGE_PREFIX + taskId, taskId,
|
|
SystemConstant.LOCK_FLOW_TIME_OUT);
|
|
SystemConstant.LOCK_FLOW_TIME_OUT);
|
|
if (!lock) {
|
|
if (!lock) {
|
|
throw ExceptionResultEnum.ERROR.exception("正在转审中,请稍候再试!");
|
|
throw ExceptionResultEnum.ERROR.exception("正在转审中,请稍候再试!");
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- Task task = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
|
|
|
|
- Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
|
|
|
|
-
|
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
|
|
FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
|
|
boolean multiInstance = false;
|
|
boolean multiInstance = false;
|
|
@@ -699,7 +706,21 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
}
|
|
}
|
|
|
|
|
|
if (!multiInstance) {
|
|
if (!multiInstance) {
|
|
- taskService.deleteCandidateUser(String.valueOf(taskId), String.valueOf(sysUser.getId()));
|
|
|
|
|
|
+ String oldUserId = task.getAssignee();
|
|
|
|
+ if (Objects.nonNull(task.getAssignee())) {
|
|
|
|
+ oldUserId = task.getAssignee();
|
|
|
|
+ } else {
|
|
|
|
+ List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
|
|
|
|
+ if (!CollectionUtils.isEmpty(identityLinkList)) {
|
|
|
|
+ for (IdentityLink i : identityLinkList) {
|
|
|
|
+ if (i.getTaskId().equals(taskId.toString())) {
|
|
|
|
+ oldUserId = i.getUserId();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ taskService.deleteCandidateUser(String.valueOf(taskId), oldUserId);
|
|
taskService.addCandidateUser(String.valueOf(taskId), String.valueOf(userId));
|
|
taskService.addCandidateUser(String.valueOf(taskId), String.valueOf(userId));
|
|
} else {
|
|
} else {
|
|
taskService.setAssignee(String.valueOf(taskId), String.valueOf(userId));
|
|
taskService.setAssignee(String.valueOf(taskId), String.valueOf(userId));
|
|
@@ -715,6 +736,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(
|
|
FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(
|
|
GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getOrgId(), sysUser.getId(), sysUser.getId(),
|
|
TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getOrgId(), sysUser.getId(), sysUser.getId(),
|
|
currFlowTaskResult.getSetup(), Long.parseLong(task.getProcessInstanceId()),
|
|
currFlowTaskResult.getSetup(), Long.parseLong(task.getProcessInstanceId()),
|
|
Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), String.valueOf(userId));
|
|
Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), String.valueOf(userId));
|