Exemple #1
0
 /**
  * 保存延时原因
  * @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;
 }
Exemple #2
0
 /** 
  * 流程接受
  * 
  * @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));
 }
Exemple #3
0
 private function turnTo($dest_action, $dest_status)
 {
     $flow_id = $this->flow->flow_id;
     $flow = Flow::find($flow_id);
     $flow_info = $flow->getAttributes();
     $from = $flow_info['current_step'];
     $steps = Config::get('flow.' . $this->flow->tpl_name . '.steps');
     $current_config = $steps[$from];
     $to = $current_config[$dest_action];
     // 校验是否可以流转
     Condition::checkTransitionCondition($this->flow);
     // 流转
     Step::turnTo($this->flow, $from, $to, $dest_status);
 }