/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DcmdTaskNodeHistory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['subtask_id' => $this->subtask_id, 'task_id' => $this->task_id, 'state' => $this->state, 'ignored' => $this->ignored, 'start_time' => $this->start_time, 'finish_time' => $this->finish_time, 'utime' => $this->utime, 'ctime' => $this->ctime, 'opr_uid' => $this->opr_uid]);
     $query->andFilterWhere(['like', 'task_cmd', $this->task_cmd])->andFilterWhere(['like', 'svr_pool', $this->svr_pool])->andFilterWhere(['like', 'svr_name', $this->svr_name])->andFilterWhere(['like', 'ip', $this->ip])->andFilterWhere(['like', 'process', $this->process])->andFilterWhere(['like', 'err_msg', $this->err_msg]);
     return $dataProvider;
 }
 /**
  * Displays a single DcmdTaskHistory model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $task = $this->findModel($id);
     $app_id = $task->app_id;
     ////$query->app_id;
     $app_name = $task->app_name;
     $ret = xml_to_array($task->task_arg);
     $args = "";
     if (is_array($ret['env'])) {
         foreach ($ret['env'] as $k => $v) {
             $args .= $k . '=' . $v . " ; ";
         }
     }
     ///服务池子
     $query = DcmdTaskServicePoolHistory::find()->andWhere(['task_id' => $id]);
     $svr_dataProvider = new ActiveDataProvider(['query' => $query]);
     $svr_searchModel = new DcmdTaskServicePoolHistorySearch();
     ///未运行的任务
     $con = array('task_id' => $id, 'state' => 0);
     $query = DcmdTaskNodeHistory::find()->andWhere($con)->orderBy("utime desc")->limit(5);
     $init_dataProvider = new ActiveDataProvider(['query' => $query]);
     $init_searchModel = new DcmdTaskNodeHistorySearch();
     ///在运行
     $con = array('task_id' => $id, 'state' => 1);
     $query = DcmdTaskNodeHistory::find()->andWhere($con)->orderBy("utime desc")->limit(5);
     $run_dataProvider = new ActiveDataProvider(['query' => $query]);
     $run_searchModel = new DcmdTaskNodeHistorySearch();
     ///失败任务
     $con = array('task_id' => $id, 'state' => 3);
     $query = DcmdTaskNodeHistory::find()->andWhere($con)->orderBy("utime desc")->limit(5);
     $fail_dataProvider = new ActiveDataProvider(['query' => $query]);
     $fail_searchModel = new DcmdTaskNodeHistorySearch();
     ///完成任务
     $con = array('task_id' => $id, 'state' => 2);
     $query = DcmdTaskNodeHistory::find()->andWhere($con)->orderBy("utime desc")->limit(5);
     $suc_dataProvider = new ActiveDataProvider(['query' => $query]);
     $suc_searchModel = new DcmdTaskNodeHistorySearch();
     return $this->render('monitor', ['task' => $task, 'app_id' => $app_id, 'app_name' => $app_name, 'args' => $args, 'svr_dataProvider' => $svr_dataProvider, 'svr_searchModel' => $svr_searchModel, 'init_dataProvider' => $init_dataProvider, 'init_searchModel' => $init_searchModel, 'run_dataProvider' => $run_dataProvider, 'run_searchModel' => $run_searchModel, 'fail_dataProvider' => $fail_dataProvider, 'fail_searchModel' => $fail_searchModel, 'suc_dataProvider' => $suc_dataProvider, 'suc_searchModel' => $suc_searchModel]);
 }