修改流程引擎退回逻辑

This commit is contained in:
乐风 2021-04-09 23:18:01 +08:00
parent 4560ef7c93
commit 12d70a9192
2 changed files with 43 additions and 1 deletions

View File

@ -558,7 +558,8 @@ class WorkflowController extends DefaultController
$next_steps = StepService::getNextSteps($steps, $run_step['step_id'], $gets);
break;
case 'back':
$next_steps = StepService::getBackSteps($steps, $run_step['step_id'], $gets);
$next_steps = StepService::getBackStep($log, $run_step, $gets);
//$next_steps = StepService::getBackSteps($steps, $run_step['step_id'], $gets);
break;
}

View File

@ -107,6 +107,47 @@ class StepService
return $ret;
}
/**
* 获取上一步审核节点(单节点)
*/
public static function getBackStep($log, $run_step, $gets)
{
$run_id = $log['run_id'];
// 查找上级记录
$parent_log = DB::table('model_run_log')
->where('run_id', $run_id)
->where('id', $log['parent_id'])->first();
// 获取上级运行节点
$parent_run_step = DB::table('model_run_step')
->where('run_id', $run_id)
->where('id', $parent_log['run_step_id'])
->first();
if ($parent_log['parent_id'] > 0) {
$parent_user_ids = DB::table('model_run_log')
->where('run_id', $run_id)
->where('parent_id', $parent_log['parent_id'])
->get()->toArray();
} else {
// 退回到开始取最后一个开始节点
$parent_user_id = DB::table('model_run_log')
->where('run_id', $run_id)
->where('parent_id', $parent_log['parent_id'])
->orderBy('id', 'desc')
->value('user_id');
$parent_user_ids = [$parent_user_id];
}
// 上级记录的相关用户
$parent_run_step['user_ids'] = $parent_user_ids;
$steps = [$parent_run_step['step_id'] => $parent_run_step];
return $steps;
}
/**
* 匹配节点相关人员
*/