|
@@ -353,14 +353,22 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
|
|
FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
|
|
+ Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
|
|
+ boolean multiInstance = false;
|
|
if (currFlow instanceof UserTask) {
|
|
if (currFlow instanceof UserTask) {
|
|
UserTask userTask = (UserTask) currFlow;
|
|
UserTask userTask = (UserTask) currFlow;
|
|
String id = userTask.getId().substring(userTask.getId().length() - 1, userTask.getId().length());
|
|
String id = userTask.getId().substring(userTask.getId().length() - 1, userTask.getId().length());
|
|
|
|
+ if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
|
+ nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_COMPLETED_INSTANCES);
|
|
|
|
+ nrOfCompletedInstances++;
|
|
|
|
+ nrOfInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_INSTANCES);
|
|
|
|
+ multiInstance = true;
|
|
|
|
+ }
|
|
remark = Objects.nonNull(map.get(SystemConstant.APPROVE_REMARK)) ? map.get(SystemConstant.APPROVE_REMARK).toString() : null;
|
|
remark = Objects.nonNull(map.get(SystemConstant.APPROVE_REMARK)) ? map.get(SystemConstant.APPROVE_REMARK).toString() : null;
|
|
//流程流水日志
|
|
//流程流水日志
|
|
tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(processInstanceId), examTask.getId(), sysUser.getId(), sysUser.getId(), remark);
|
|
tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(processInstanceId), examTask.getId(), sysUser.getId(), sysUser.getId(), remark);
|
|
- FlowApprovePassEnum approvePass = (FlowApprovePassEnum) map.get(SystemConstant.APPROVE_OPERATION);
|
|
|
|
//判断流程审批是通过还是驳回
|
|
//判断流程审批是通过还是驳回
|
|
|
|
+ FlowApprovePassEnum approvePass = (FlowApprovePassEnum) map.get(SystemConstant.APPROVE_OPERATION);
|
|
Map<String, FlowTaskResult> setupMap = (Map<String, FlowTaskResult>) flowProcessVarMap.get(SystemConstant.SETUP_MAP);
|
|
Map<String, FlowTaskResult> setupMap = (Map<String, FlowTaskResult>) flowProcessVarMap.get(SystemConstant.SETUP_MAP);
|
|
//获取当前流程和下一流程setup
|
|
//获取当前流程和下一流程setup
|
|
currFlowTaskResult = gson.fromJson(gson.toJson(setupMap.get(userTask.getId())), FlowTaskResult.class);
|
|
currFlowTaskResult = gson.fromJson(gson.toJson(setupMap.get(userTask.getId())), FlowTaskResult.class);
|
|
@@ -370,101 +378,92 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
//获取最后一条审批记录,确认网关走向流程节点
|
|
//获取最后一条审批记录,确认网关走向流程节点
|
|
TFFlowLog tfFlowLogLast = tfFlowLogService.findByLast(flowId, examTask.getSchoolId(), FlowApproveOperationEnum.REJECT);
|
|
TFFlowLog tfFlowLogLast = tfFlowLogService.findByLast(flowId, examTask.getSchoolId(), FlowApproveOperationEnum.REJECT);
|
|
Optional.ofNullable(tfFlowLogLast).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程驳回节点数据为空"));
|
|
Optional.ofNullable(tfFlowLogLast).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程驳回节点数据为空"));
|
|
- for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
|
- FlowTaskResult flowTaskResultTemp = gson.fromJson(gson.toJson(entry.getValue()), FlowTaskResult.class);
|
|
|
|
- if (flowTaskResultTemp.getSetup().intValue() == tfFlowLogLast.getApproveSetup().intValue()) {
|
|
|
|
- nextFlowTaskResult = flowTaskResultTemp;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Optional.ofNullable(nextFlowTaskResult).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该节点不能审批通过"));
|
|
|
|
- if (currFlowTaskResult.getSetup().intValue() == setupMap.size() - 1) {
|
|
|
|
- tfFlowApprove.setSetup(FlowApproveSetupEnum.FINISH.getSetup());
|
|
|
|
- } else {
|
|
|
|
- if (tfFlowApprove.getStatus() == FlowStatusEnum.START) {
|
|
|
|
- tfFlowLog.setApproveOperation(FlowApproveOperationEnum.SUBMIT);
|
|
|
|
- } else {
|
|
|
|
- tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
|
|
|
|
- }
|
|
|
|
- tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
|
|
|
|
- tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ currFlowTaskResult,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ tfFlowLogLast.getApproveSetup().intValue(),
|
|
|
|
+ setupMap,
|
|
|
|
+ gson,
|
|
|
|
+ approvePass);
|
|
|
|
+
|
|
|
|
+ this.approvePass(currFlowTaskResult,
|
|
|
|
+ setupMap,
|
|
|
|
+ multiInstance,
|
|
|
|
+ nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ tfFlowApprove,
|
|
|
|
+ tfFlowLog,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ map,
|
|
|
|
+ id);
|
|
} else {//走正常路线
|
|
} else {//走正常路线
|
|
int currSetup = currFlowTaskResult.getSetup().intValue();
|
|
int currSetup = currFlowTaskResult.getSetup().intValue();
|
|
currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
|
|
currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
|
|
- if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
|
- MultiInstanceActivityBehavior behavior = (MultiInstanceActivityBehavior) currFlow.getBehavior();
|
|
|
|
- }
|
|
|
|
- for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
|
- FlowTaskResult flowTaskResultTemp = gson.fromJson(gson.toJson(entry.getValue()), FlowTaskResult.class);
|
|
|
|
- if (flowTaskResultTemp.getSetup().intValue() == currSetup) {
|
|
|
|
- nextFlowTaskResult = flowTaskResultTemp;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Optional.ofNullable(nextFlowTaskResult).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该节点不能审批通过"));
|
|
|
|
- if (currFlowTaskResult.getSetup().intValue() == setupMap.size() - 1) {
|
|
|
|
- tfFlowApprove.setSetup(FlowApproveSetupEnum.FINISH.getSetup());
|
|
|
|
- } else {
|
|
|
|
- if (tfFlowApprove.getStatus() == FlowStatusEnum.START) {
|
|
|
|
- tfFlowLog.setApproveOperation(FlowApproveOperationEnum.SUBMIT);
|
|
|
|
- } else {
|
|
|
|
- tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
|
|
|
|
- }
|
|
|
|
- tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
|
|
|
|
- tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
|
|
|
|
- if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
|
- map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + id, v -> 0);
|
|
|
|
|
|
+
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ currFlowTaskResult,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ currSetup,
|
|
|
|
+ setupMap,
|
|
|
|
+ gson,
|
|
|
|
+ approvePass);
|
|
|
|
+
|
|
|
|
+ this.approvePass(currFlowTaskResult,
|
|
|
|
+ setupMap,
|
|
|
|
+ multiInstance,
|
|
|
|
+ nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ tfFlowApprove,
|
|
|
|
+ tfFlowLog,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ map,
|
|
|
|
+ id);
|
|
}
|
|
}
|
|
} else if (approvePass == FlowApprovePassEnum.REJECT) {
|
|
} else if (approvePass == FlowApprovePassEnum.REJECT) {
|
|
Optional.ofNullable(map.get(SystemConstant.APPROVE_SETUP)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程驳回节点不能为空"));
|
|
Optional.ofNullable(map.get(SystemConstant.APPROVE_SETUP)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程驳回节点不能为空"));
|
|
Integer rejectSetup = Integer.parseInt(map.get(SystemConstant.APPROVE_SETUP).toString());
|
|
Integer rejectSetup = Integer.parseInt(map.get(SystemConstant.APPROVE_SETUP).toString());
|
|
- for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
|
- FlowTaskResult flowTaskResultTemp = gson.fromJson(gson.toJson(entry.getValue()), FlowTaskResult.class);
|
|
|
|
- if (flowTaskResultTemp.getSetup().intValue() == rejectSetup) {
|
|
|
|
- nextFlowTaskResult = flowTaskResultTemp;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Optional.ofNullable(nextFlowTaskResult).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该节点不能驳回"));
|
|
|
|
- if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
|
- map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + id, v -> 1);
|
|
|
|
- }
|
|
|
|
- map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
|
|
|
|
- tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
- tfFlowApprove.setStatus(FlowStatusEnum.REJECT);
|
|
|
|
- tfFlowLog.setApproveOperation(FlowApproveOperationEnum.REJECT);
|
|
|
|
|
|
+
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ currFlowTaskResult,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ rejectSetup,
|
|
|
|
+ setupMap,
|
|
|
|
+ gson,
|
|
|
|
+ approvePass);
|
|
|
|
+
|
|
|
|
+ this.approveReject(multiInstance,
|
|
|
|
+ map,
|
|
|
|
+ id,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ tfFlowApprove,
|
|
|
|
+ tfFlowLog);
|
|
}
|
|
}
|
|
//获取流程变量
|
|
//获取流程变量
|
|
- if (Objects.nonNull(agginessMap.get(nextFlowTaskResult.getTaskKey()))) {
|
|
|
|
- CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(nextFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
|
|
|
|
- map.computeIfAbsent(customFlowVarDto.getFlowTaskVar(), v -> customFlowVarDto.getApproveIds().size() == 1 ? customFlowVarDto.getApproveIds().get(0) : customFlowVarDto.getApproveIds());
|
|
|
|
- }
|
|
|
|
|
|
+ this.getAgginess(nextFlowTaskResult,
|
|
|
|
+ gson,
|
|
|
|
+ map,
|
|
|
|
+ agginessMap);
|
|
}
|
|
}
|
|
- tfFlowApprove.updateInfo(sysUser.getId());
|
|
|
|
- tfFlowApprove.setApproveId(sysUser.getId());
|
|
|
|
- tfFlowLog.setApproveSetup(currFlowTaskResult.getSetup());
|
|
|
|
- tfFlowLog.setApproveId(sysUser.getId());
|
|
|
|
- tfFlowLog.setApproveRemark(remark);
|
|
|
|
- tfFlowLog.setPaperAttachmentId((String) map.get(SystemConstant.PAPAER_ATTACHMENT_IDS));
|
|
|
|
- CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(nextFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
|
|
|
|
- if (Objects.nonNull(customFlowVarDto)) {
|
|
|
|
- tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
- }
|
|
|
|
- map.put(SystemConstant.APPROVE_TF_FLOW_LOG, tfFlowLog);
|
|
|
|
|
|
+ this.setApproveInfo(tfFlowApprove,
|
|
|
|
+ tfFlowLog,
|
|
|
|
+ sysUser,
|
|
|
|
+ map,
|
|
|
|
+ multiInstance,
|
|
|
|
+ nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ currFlowTaskResult,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ gson,
|
|
|
|
+ agginessMap,
|
|
|
|
+ examTask,
|
|
|
|
+ objectMap);
|
|
//当前实例的执行到哪个节点
|
|
//当前实例的执行到哪个节点
|
|
// int i = 1 / 0;
|
|
// int i = 1 / 0;
|
|
taskService.complete(String.valueOf(flowTaskId), map);
|
|
taskService.complete(String.valueOf(flowTaskId), map);
|
|
- tfFlowApproveService.saveOrUpdate(tfFlowApprove);
|
|
|
|
- tfFlowLogService.save(tfFlowLog);
|
|
|
|
- examTask.updateInfo(sysUser.getId());
|
|
|
|
- examTaskService.updateById(examTask);
|
|
|
|
- objectMap.putIfAbsent("tfFlowApprove", tfFlowApprove);
|
|
|
|
- objectMap.putIfAbsent("examTask", examTask);
|
|
|
|
- objectMap.putIfAbsent("sysUser", sysUser);
|
|
|
|
return objectMap;
|
|
return objectMap;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
@@ -479,6 +478,222 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 设置审批信息
|
|
|
|
+ *
|
|
|
|
+ * @param tfFlowApprove
|
|
|
|
+ * @param tfFlowLog
|
|
|
|
+ * @param sysUser
|
|
|
|
+ * @param map
|
|
|
|
+ * @param multiInstance
|
|
|
|
+ * @param nrOfCompletedInstances
|
|
|
|
+ * @param nrOfInstances
|
|
|
|
+ * @param currFlowTaskResult
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @param gson
|
|
|
|
+ * @param agginessMap
|
|
|
|
+ * @param examTask
|
|
|
|
+ * @param objectMap
|
|
|
|
+ */
|
|
|
|
+ protected void setApproveInfo(TFFlowApprove tfFlowApprove,
|
|
|
|
+ TFFlowLog tfFlowLog,
|
|
|
|
+ SysUser sysUser,
|
|
|
|
+ Map<String, Object> map,
|
|
|
|
+ boolean multiInstance,
|
|
|
|
+ Integer nrOfCompletedInstances,
|
|
|
|
+ Integer nrOfInstances,
|
|
|
|
+ FlowTaskResult currFlowTaskResult,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult,
|
|
|
|
+ Gson gson,
|
|
|
|
+ Map<String, CustomFlowVarDto> agginessMap,
|
|
|
|
+ ExamTask examTask,
|
|
|
|
+ Map<String, Object> objectMap) {
|
|
|
|
+ tfFlowApprove.updateInfo(sysUser.getId());
|
|
|
|
+ if (tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.APPROVE) {
|
|
|
|
+ tfFlowApprove.setApproveSetup(nrOfCompletedInstances);
|
|
|
|
+ tfFlowApprove.setApproveMaxSetup(nrOfInstances);
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowApprove.setApproveSetup(null);
|
|
|
|
+ tfFlowApprove.setApproveMaxSetup(null);
|
|
|
|
+ }
|
|
|
|
+ tfFlowApprove.setApproveId(sysUser.getId());
|
|
|
|
+ tfFlowLog.setApproveSetup(currFlowTaskResult.getSetup());
|
|
|
|
+ tfFlowLog.setApproveMultiSetup(nrOfCompletedInstances);
|
|
|
|
+ tfFlowLog.setPaperAttachmentId((String) map.get(SystemConstant.PAPAER_ATTACHMENT_IDS));
|
|
|
|
+ CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(nextFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
|
|
|
|
+ if (Objects.nonNull(customFlowVarDto)) {
|
|
|
|
+ if (tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.APPROVE && multiInstance && Objects.nonNull(nrOfCompletedInstances)
|
|
|
|
+ && Objects.nonNull(nrOfInstances)
|
|
|
|
+ && nrOfCompletedInstances.intValue() != nrOfInstances.intValue()) {
|
|
|
|
+ tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().subList(nrOfCompletedInstances, nrOfInstances).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ map.put(SystemConstant.APPROVE_TF_FLOW_LOG, tfFlowLog);
|
|
|
|
+ tfFlowApproveService.saveOrUpdate(tfFlowApprove);
|
|
|
|
+ tfFlowLogService.save(tfFlowLog);
|
|
|
|
+ examTask.updateInfo(sysUser.getId());
|
|
|
|
+ examTaskService.updateById(examTask);
|
|
|
|
+ objectMap.putIfAbsent("tfFlowApprove", tfFlowApprove);
|
|
|
|
+ objectMap.putIfAbsent("examTask", examTask);
|
|
|
|
+ objectMap.putIfAbsent("sysUser", sysUser);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取审批人
|
|
|
|
+ *
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @param gson
|
|
|
|
+ * @param map
|
|
|
|
+ * @param agginessMap
|
|
|
|
+ */
|
|
|
|
+ protected void getAgginess(FlowTaskResult nextFlowTaskResult,
|
|
|
|
+ Gson gson,
|
|
|
|
+ Map<String, Object> map,
|
|
|
|
+ Map<String, CustomFlowVarDto> agginessMap) {
|
|
|
|
+ if (Objects.nonNull(agginessMap.get(nextFlowTaskResult.getTaskKey()))) {
|
|
|
|
+ CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(nextFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
|
|
|
|
+ map.computeIfAbsent(customFlowVarDto.getFlowTaskVar(), v -> customFlowVarDto.getApproveIds().size() == 1 ? customFlowVarDto.getApproveIds().get(0) : customFlowVarDto.getApproveIds());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 审批驳回
|
|
|
|
+ *
|
|
|
|
+ * @param multiInstance
|
|
|
|
+ * @param map
|
|
|
|
+ * @param id
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @param tfFlowApprove
|
|
|
|
+ * @param tfFlowLog
|
|
|
|
+ */
|
|
|
|
+ protected void approveReject(boolean multiInstance,
|
|
|
|
+ Map<String, Object> map,
|
|
|
|
+ String id,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult,
|
|
|
|
+ TFFlowApprove tfFlowApprove,
|
|
|
|
+ TFFlowLog tfFlowLog) {
|
|
|
|
+ if (multiInstance) {
|
|
|
|
+ map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + id, v -> 1);
|
|
|
|
+ }
|
|
|
|
+ map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
|
|
|
|
+ tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.REJECT);
|
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.REJECT);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取下级审核节点
|
|
|
|
+ *
|
|
|
|
+ * @param nrOfCompletedInstances
|
|
|
|
+ * @param nrOfInstances
|
|
|
|
+ * @param currFlowTaskResult
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @param currSetup
|
|
|
|
+ * @param setupMap
|
|
|
|
+ * @param gson
|
|
|
|
+ * @param approvePass
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ protected FlowTaskResult getNextFlowTaskResult(Integer nrOfCompletedInstances,
|
|
|
|
+ Integer nrOfInstances,
|
|
|
|
+ FlowTaskResult currFlowTaskResult,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult,
|
|
|
|
+ int currSetup,
|
|
|
|
+ Map<String, FlowTaskResult> setupMap,
|
|
|
|
+ Gson gson,
|
|
|
|
+ FlowApprovePassEnum approvePass) {
|
|
|
|
+ if (approvePass == FlowApprovePassEnum.PASS) {
|
|
|
|
+ if (Objects.nonNull(nrOfCompletedInstances)
|
|
|
|
+ && Objects.nonNull(nrOfInstances)
|
|
|
|
+ && nrOfCompletedInstances.intValue() != nrOfInstances.intValue()) {
|
|
|
|
+ nextFlowTaskResult = currFlowTaskResult;
|
|
|
|
+ } else {
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(setupMap, gson, currSetup, nextFlowTaskResult);
|
|
|
|
+ }
|
|
|
|
+ } else if (approvePass == FlowApprovePassEnum.REJECT) {
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(setupMap, gson, currSetup, nextFlowTaskResult);
|
|
|
|
+ }
|
|
|
|
+ Optional.ofNullable(nextFlowTaskResult).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该节点不能审批通过"));
|
|
|
|
+ return nextFlowTaskResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取下级审核节点
|
|
|
|
+ *
|
|
|
|
+ * @param setupMap
|
|
|
|
+ * @param gson
|
|
|
|
+ * @param currSetup
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ protected FlowTaskResult getNextFlowTaskResult(Map<String, FlowTaskResult> setupMap,
|
|
|
|
+ Gson gson,
|
|
|
|
+ int currSetup,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult) {
|
|
|
|
+ for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
|
+ FlowTaskResult flowTaskResultTemp = gson.fromJson(gson.toJson(entry.getValue()), FlowTaskResult.class);
|
|
|
|
+ if (flowTaskResultTemp.getSetup().intValue() == currSetup) {
|
|
|
|
+ nextFlowTaskResult = flowTaskResultTemp;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return nextFlowTaskResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 审批通过
|
|
|
|
+ *
|
|
|
|
+ * @param currFlowTaskResult
|
|
|
|
+ * @param setupMap
|
|
|
|
+ * @param multiInstance
|
|
|
|
+ * @param nrOfCompletedInstances
|
|
|
|
+ * @param nrOfInstances
|
|
|
|
+ * @param tfFlowApprove
|
|
|
|
+ * @param tfFlowLog
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @param map
|
|
|
|
+ * @param id
|
|
|
|
+ */
|
|
|
|
+ protected void approvePass(FlowTaskResult currFlowTaskResult,
|
|
|
|
+ Map<String, FlowTaskResult> setupMap,
|
|
|
|
+ boolean multiInstance,
|
|
|
|
+ Integer nrOfCompletedInstances,
|
|
|
|
+ Integer nrOfInstances,
|
|
|
|
+ TFFlowApprove tfFlowApprove,
|
|
|
|
+ TFFlowLog tfFlowLog,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult,
|
|
|
|
+ Map<String, Object> map,
|
|
|
|
+ String id) {
|
|
|
|
+ if (multiInstance) {
|
|
|
|
+ map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + id, v -> 0);
|
|
|
|
+ }
|
|
|
|
+ if (currFlowTaskResult.getSetup().intValue() == setupMap.size() - 1) {
|
|
|
|
+ if (multiInstance && Objects.nonNull(nrOfCompletedInstances)
|
|
|
|
+ && Objects.nonNull(nrOfInstances)
|
|
|
|
+ && nrOfCompletedInstances.intValue() == nrOfInstances.intValue()) {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.FINISH);
|
|
|
|
+ tfFlowApprove.setSetup(FlowApproveSetupEnum.FINISH.getSetup());
|
|
|
|
+ } else if (!multiInstance) {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.FINISH);
|
|
|
|
+ tfFlowApprove.setSetup(FlowApproveSetupEnum.FINISH.getSetup());
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
|
|
|
|
+ tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
|
|
|
|
+ tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
+ }
|
|
|
|
+ if (tfFlowApprove.getStatus() == FlowStatusEnum.START) {
|
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.SUBMIT);
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
|
|
|
|
+ }
|
|
|
|
+ map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取所有流程节点
|
|
* 获取所有流程节点
|
|
*
|
|
*
|