|
@@ -330,8 +330,6 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
Long flowId = SystemConstant.convertIdToLong(processInstanceId);
|
|
|
ExamTask examTask = examTaskService.findByFlowId(flowId);
|
|
|
|
|
|
-// String processDefinitionId = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId();
|
|
|
-// ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId);
|
|
|
//获取当前流程节点
|
|
|
String currActivityId = task.getTaskDefinitionKey();
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
@@ -344,14 +342,15 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
Map<String, Object> objectMap = new HashMap<>();
|
|
|
TFFlowLog tfFlowLog = null;
|
|
|
|
|
|
- QueryWrapper<TFCustomFlow> tfCustomFlowQueryWrapper = new QueryWrapper<>();
|
|
|
- tfCustomFlowQueryWrapper.lambda().eq(TFCustomFlow::getFlowId, flowId);
|
|
|
- TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(tfCustomFlowQueryWrapper);
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.findByFlowId(flowId);
|
|
|
Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
|
|
|
|
|
|
String remark = null;
|
|
|
FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
|
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
+ if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
|
|
|
+ agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
|
|
|
+ }
|
|
|
Gson gson = new Gson();
|
|
|
Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
|
boolean multiInstance = false;
|
|
@@ -1009,60 +1008,64 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
throw ExceptionResultEnum.ERROR.exception("流程已结束或已终止");
|
|
|
}
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
-// List<Long> ids = null;
|
|
|
-// String variableName = null;
|
|
|
- switch (tfFlowApprove.getSetup()) {
|
|
|
- case 1:
|
|
|
- case 4:
|
|
|
- if (Objects.nonNull(task) && Objects.nonNull(task.getAssignee()) && Objects.equals(task.getAssignee(), userId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("不能转给自己");
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- case 3:
|
|
|
- case 5:
|
|
|
- if (Objects.nonNull(task) && Objects.nonNull(task.getAssignee()) && Objects.equals(task.getAssignee(), userId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("不能转给自己");
|
|
|
- } else {
|
|
|
- Task taskUser = taskService.createTaskQuery().taskId(taskId).taskCandidateUser(userId).singleResult();
|
|
|
- if (Objects.nonNull(taskUser)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
- }
|
|
|
- }
|
|
|
-// if (tfFlowApprove.getSetup() == FlowGdykdxApproveSetupEnum.PRIMARY_APPROVE.getSetup()) {
|
|
|
-// ids = (List<Long>) taskService.getVariable(taskId, SystemConstant.APPROVE_DIRECTOR_USER_IDS);
|
|
|
-// variableName = SystemConstant.APPROVE_DIRECTOR_USER_IDS;
|
|
|
-// } else {
|
|
|
-// ids = (List<Long>) taskService.getVariable(taskId, SystemConstant.APPROVE_PRESIDENT_USER_IDS);
|
|
|
-// variableName = SystemConstant.APPROVE_PRESIDENT_USER_IDS;
|
|
|
-// }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ if (Objects.nonNull(task) && Objects.nonNull(task.getAssignee()) && Objects.equals(task.getAssignee(), userId)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("不能转给自己");
|
|
|
+ }
|
|
|
+ Task taskUser = taskService.createTaskQuery().taskId(taskId).taskAssignee(userId).singleResult();
|
|
|
+ if (Objects.nonNull(taskUser)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
|
|
|
}
|
|
|
- taskService.deleteCandidateUser(taskId, String.valueOf(sysUser.getId()));
|
|
|
- taskService.addCandidateUser(taskId, userId);
|
|
|
-// if (Objects.nonNull(ids) && ids.size() > 0) {
|
|
|
-// ids.remove(sysUser.getId());
|
|
|
-// ids.add(Long.parseLong(userId));
|
|
|
-// taskService.setVariable(taskId, variableName, ids);
|
|
|
-// }
|
|
|
- ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
|
|
|
|
//获取当前流程节点
|
|
|
String currActivityId = task.getTaskDefinitionKey();
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
|
FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
|
|
|
+ UserTask userTask = null;
|
|
|
+ if (currFlow instanceof UserTask) {
|
|
|
+ userTask = (UserTask) currFlow;
|
|
|
+ }
|
|
|
+ Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
|
+ boolean multiInstance = false;
|
|
|
+ if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
+ nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_COMPLETED_INSTANCES);
|
|
|
+ nrOfInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_INSTANCES);
|
|
|
+ multiInstance = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.findByFlowId(tfFlowApprove.getFlowId());
|
|
|
+ Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
|
|
|
+ Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
+ if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
|
|
|
+ agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
|
|
|
+ }
|
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
+ CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
|
|
|
+ if (customFlowVarDto.getApproveIds().size() == 1) {
|
|
|
+ customFlowVarDto.setApproveIds(new ArrayList<>(Arrays.asList(userId)));
|
|
|
+ } else {
|
|
|
+ if (multiInstance && Objects.nonNull(nrOfCompletedInstances)) {
|
|
|
+ List<String> approveIds = customFlowVarDto.getApproveIds();
|
|
|
+ approveIds.remove(nrOfCompletedInstances.intValue());
|
|
|
+ approveIds.add(nrOfCompletedInstances.intValue(), userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ agginessMap.put(userTask.getId(), customFlowVarDto);
|
|
|
+ taskService.setAssignee(taskId, userId);
|
|
|
+
|
|
|
+ tfFlowApprove.setTransferAssignee(JacksonUtil.parseJson(agginessMap));
|
|
|
+ tfFlowApproveService.updateById(tfFlowApprove);
|
|
|
+
|
|
|
+ ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
|
SysUser exchangeUser = sysUserService.getById(userId);
|
|
|
//流程流水日志
|
|
|
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()));
|
|
|
- if (currFlow instanceof UserTask) {
|
|
|
- UserTask userTask = (UserTask) currFlow;
|
|
|
- FlowApproveSetupEnum setupEnum = FlowApproveSetupEnum.convertToInstance(userTask.getId());
|
|
|
- tfFlowLog.setApproveSetup(setupEnum.getSetup());
|
|
|
- taskService.setVariable(taskId, SystemConstant.APPROVE_EXCHANGE_USER_ID + setupEnum.getId(), String.valueOf(exchangeUser.getId()));
|
|
|
+ if (multiInstance) {
|
|
|
+ tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().subList(nrOfCompletedInstances, nrOfInstances).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
}
|
|
|
+
|
|
|
+ tfFlowLog.setApproveSetup(tfFlowApprove.getSetup());
|
|
|
tfFlowLogService.save(tfFlowLog);
|
|
|
return true;
|
|
|
}
|