|
@@ -714,44 +714,56 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public boolean taskApproverExchange(String userId, String taskId) {
|
|
public boolean taskApproverExchange(String userId, String taskId) {
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ if (Objects.equals(String.valueOf(sysUser.getId()), userId)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("不能转给自己");
|
|
|
|
+ }
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
|
|
Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
|
|
String flowId = task.getProcessInstanceId();
|
|
String flowId = task.getProcessInstanceId();
|
|
- TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), Long.parseLong((String) ServletUtil.getRequestHeaderSchoolId()));
|
|
|
|
|
|
+ TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), sysUser.getSchoolId());
|
|
Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到流程状态记录"));
|
|
Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到流程状态记录"));
|
|
if (tfFlowApprove.getSetup() <= 0) {
|
|
if (tfFlowApprove.getSetup() <= 0) {
|
|
throw ExceptionResultEnum.ERROR.exception("流程已结束或已终止");
|
|
throw ExceptionResultEnum.ERROR.exception("流程已结束或已终止");
|
|
}
|
|
}
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
- if (Objects.nonNull(task) && Objects.nonNull(task.getAssignee()) && Objects.equals(task.getAssignee(), userId)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("不能转给自己");
|
|
|
|
- }
|
|
|
|
- Task taskUser = taskService.createTaskQuery().taskId(taskId).taskCandidateOrAssigned(userId).singleResult();
|
|
|
|
- if (Objects.nonNull(taskUser)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
|
|
|
+
|
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(tfFlowApprove.getFlowId());
|
|
|
|
+ Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
|
|
|
|
+ Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
|
+ if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
|
|
|
|
+ agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
|
|
}
|
|
}
|
|
|
|
|
|
//获取当前流程节点
|
|
//获取当前流程节点
|
|
String currActivityId = task.getTaskDefinitionKey();
|
|
String currActivityId = task.getTaskDefinitionKey();
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
|
|
FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
|
|
|
|
+
|
|
UserTask userTask = null;
|
|
UserTask userTask = null;
|
|
if (currFlow instanceof UserTask) {
|
|
if (currFlow instanceof UserTask) {
|
|
userTask = (UserTask) currFlow;
|
|
userTask = (UserTask) currFlow;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ Gson gson = new Gson();
|
|
Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
boolean multiInstance = false;
|
|
boolean multiInstance = false;
|
|
- if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
|
|
|
+ if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {//会签
|
|
nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_COMPLETED_INSTANCES);
|
|
nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_COMPLETED_INSTANCES);
|
|
nrOfInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_INSTANCES);
|
|
nrOfInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_INSTANCES);
|
|
multiInstance = true;
|
|
multiInstance = true;
|
|
- }
|
|
|
|
|
|
|
|
- TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(tfFlowApprove.getFlowId());
|
|
|
|
- Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
|
|
|
|
- Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
|
- if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
|
|
|
|
- agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
|
|
|
|
|
|
+ CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
|
|
|
|
+ if (Objects.nonNull(customFlowVarDto)) {
|
|
|
|
+ List<String> approveIds = customFlowVarDto.getApproveIds();
|
|
|
|
+ if (Objects.nonNull(approveIds) && approveIds.size() > 0 && approveIds.contains(userId)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {//或签
|
|
|
|
+ Task taskUser = taskService.createTaskQuery().taskId(taskId).taskCandidateOrAssigned(userId).singleResult();
|
|
|
|
+ if (Objects.nonNull(taskUser)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
@@ -761,7 +773,6 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
|
|
|
//流程流水日志
|
|
//流程流水日志
|
|
TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()), tfFlowJoin.getObjectTable());
|
|
TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()), tfFlowJoin.getObjectTable());
|
|
- Gson gson = new Gson();
|
|
|
|
CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
|
|
CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
|
|
if (customFlowVarDto.getApproveIds().size() == 1) {
|
|
if (customFlowVarDto.getApproveIds().size() == 1) {
|
|
customFlowVarDto.setApproveIds(new ArrayList<>(Arrays.asList(userId)));
|
|
customFlowVarDto.setApproveIds(new ArrayList<>(Arrays.asList(userId)));
|