/** * 保存延时原因 * @param reason 延时原因 * @param last_step 上个步骤 * @param next_processing_time 下次执行时间 */ public function saveReason($reason, $last_step, $next_processing_time) { // 保存位置 $flow = Flow::find($this->flow->flow_id); $flow_attr = $flow->getAttributes(); $steps = Config::get('flow.' . $this->flow->tpl_name . '.steps'); $runing_config = $steps[$flow_attr['current_step']]; Step::create(array('project_name' => $this->flow->tpl_name, 'flow_id' => $this->flow->flow_id, 'title' => $runing_config['title'], 'real_title' => $runing_config['title'], 'content' => '', 'real_content' => $reason, 'step' => $flow_attr['current_step'], 'status' => Status::DELAY, 'created_user' => $user->name, 'created_role' => $flow->running_role)); Step::find($last_step)->update(['next_processing_time' => $next_processing_time]); return true; }
public function publish() { $user = \App\Models\User::info(); // 如果没有保存过,需要先保存 $flow = false; if (empty($this->flow->flow_id)) { $flow = $this->storage(); } $steps = Config::get('flow.' . $this->flow->tpl_name . '.steps'); $current = current($steps); $current_key = key($steps); $next_key = $current['createto']; // 校验是否可以流转 Condition::checkFlowOwner($this->flow); $now = date('Y-m-d H:i:s'); $yzt_fileno = Config::get('yzt.config.file_num_start') . date("Ymd", strtotime($now)) . str_pad($this->flow->flow_id, 3, 0, STR_PAD_LEFT); Flow::where('id', $this->flow->flow_id)->update(array('current_status' => Status::ARRIVED, 'current_step' => $next_key, 'created_at' => $now, 'yzt_fileno' => $yzt_fileno)); Step::create(array('project_name' => $this->flow->tpl_name, 'flow_id' => $this->flow->flow_id, 'title' => $current['title'], 'real_title' => $current['title'], 'content' => '', 'real_content' => '', 'step' => $current_key, 'status' => Status::CREATE, 'created_user' => $user->name, 'created_role' => $this->flow->running_role)); return $flow; }
/** * 流程接受 * * @param project_name 项目名称 * @param flow lib/flow类 * */ public static function over($flow) { $user = \App\Models\User::info(); $flow_mod = Flow::find($flow->flow_id); $flow_info = $flow_mod->getAttributes(); $steps = Config::get('flow.' . $flow->tpl_name . '.steps'); $runing_config = $steps[$flow->running_step]; // 如果之前已经有执行人 if (!empty($flow_info['accepted_users'])) { $accepted_users = explode(",", $flow_info['accepted_users']); // 去除当前执行人 $accepted_users_reverse = array_flip($accepted_users); unset($accepted_users_reverse[$user->name]); $accepted_users = array_flip($accepted_users_reverse); $accepted_users = implode(',', $accepted_users); } // 如果之前已经有执行人 if (!empty($flow_info['accepted_roles'])) { $accepted_roles = explode(",", $flow_info['accepted_roles']); // 去除当前执行人 $accepted_roles_reverse = array_flip($accepted_roles); unset($accepted_roles_reverse[$flow->running_role]); $accepted_roles = array_flip($accepted_roles_reverse); $accepted_roles = implode(',', $accepted_roles); } $content = Input::get('content'); $real_content = Input::get('real_content'); $flow_mod->update(array('accepted_users' => $accepted_users, 'accepted_roles' => $accepted_roles)); Step::create(array('project_name' => $flow->tpl_name, 'flow_id' => $flow->flow_id, 'title' => $runing_config['title'], 'real_title' => $runing_config['title'], 'content' => $content, 'real_content' => $real_content, 'step' => $flow->running_step, 'status' => Status::OVER, 'created_user' => $user->name, 'created_role' => $flow->running_role)); }