|
@@ -348,7 +348,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
rejectLinkMap.remove(userTask.getId());
|
|
|
tfFlowApprove.setRejectLink(rejectLinkMap.size() == 0 ? null : JacksonUtil.parseJson(rejectLinkMap));
|
|
|
}
|
|
|
- } else if (approvePass == FlowApprovePassEnum.REJECT) {
|
|
|
+ } else if (approvePass == FlowApprovePassEnum.REJECT || approvePass == FlowApprovePassEnum.CANCEL) {
|
|
|
Optional.ofNullable(map.get(SystemConstant.APPROVE_SETUP)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程驳回节点不能为空"));
|
|
|
Integer rejectSetup = Integer.parseInt(map.get(SystemConstant.APPROVE_SETUP).toString());
|
|
|
|
|
@@ -369,7 +369,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
tfFlowApprove,
|
|
|
tfFlowLog,
|
|
|
agginessMap,
|
|
|
- gson);
|
|
|
+ gson,
|
|
|
+ approvePass);
|
|
|
}
|
|
|
//获取流程变量
|
|
|
this.getAgginess(nextFlowTaskResult,
|
|
@@ -520,6 +521,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
* @param tfFlowLog
|
|
|
* @param agginessMap
|
|
|
* @param gson
|
|
|
+ * @param approvePass
|
|
|
*/
|
|
|
protected void approveReject(boolean multiInstance,
|
|
|
Map<String, Object> map,
|
|
@@ -529,16 +531,17 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
TFFlowApprove tfFlowApprove,
|
|
|
TFFlowLog tfFlowLog,
|
|
|
Map<String, CustomFlowVarDto> agginessMap,
|
|
|
- Gson gson) {
|
|
|
+ Gson gson,
|
|
|
+ FlowApprovePassEnum approvePass) {
|
|
|
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);
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.convertToEnum(approvePass.name()));
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.convertToEnum(approvePass.name()));
|
|
|
CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(currFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
|
|
|
- if (Objects.nonNull(customFlowVarDto) && customFlowVarDto.getRejectResubmitType() == CustomFlowRejectResubmitTypeEnum.PREV_STEP) {
|
|
|
+ if (approvePass == FlowApprovePassEnum.REJECT && Objects.nonNull(customFlowVarDto) && customFlowVarDto.getRejectResubmitType() == CustomFlowRejectResubmitTypeEnum.PREV_STEP) {
|
|
|
Map<String, FlowTaskResult> rejectLinkMap = null;
|
|
|
if (Objects.nonNull(tfFlowApprove.getRejectLink())) {
|
|
|
rejectLinkMap = JacksonUtil.readJson(tfFlowApprove.getRejectLink(), Map.class);
|
|
@@ -579,7 +582,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
} else {
|
|
|
nextFlowTaskResult = this.getNextFlowTaskResult(setupMap, gson, currSetup, nextFlowTaskResult);
|
|
|
}
|
|
|
- } else if (approvePass == FlowApprovePassEnum.REJECT) {
|
|
|
+ } else if (approvePass == FlowApprovePassEnum.REJECT || approvePass == FlowApprovePassEnum.CANCEL) {
|
|
|
nextFlowTaskResult = this.getNextFlowTaskResult(setupMap, gson, currSetup, nextFlowTaskResult);
|
|
|
}
|
|
|
Optional.ofNullable(nextFlowTaskResult).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该节点不能审批通过"));
|
|
@@ -714,44 +717,56 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
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();
|
|
|
Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
|
|
|
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("未找到流程状态记录"));
|
|
|
if (tfFlowApprove.getSetup() <= 0) {
|
|
|
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();
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
|
FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
|
|
|
+
|
|
|
UserTask userTask = null;
|
|
|
if (currFlow instanceof UserTask) {
|
|
|
userTask = (UserTask) currFlow;
|
|
|
}
|
|
|
+
|
|
|
+ Gson gson = new Gson();
|
|
|
Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
|
boolean multiInstance = false;
|
|
|
- if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
+ 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;
|
|
|
- }
|
|
|
|
|
|
- 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));
|
|
@@ -761,7 +776,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());
|
|
|
- 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)));
|