/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DcmdTaskServicePoolHistory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'task_id' => $this->task_id, 'svr_pool_id' => $this->svr_pool_id, 'undo_node' => $this->undo_node, 'doing_node' => $this->doing_node, 'finish_node' => $this->finish_node, 'fail_node' => $this->fail_node, 'ignored_fail_node' => $this->ignored_fail_node, 'ignored_doing_node' => $this->ignored_doing_node, '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', 'env_ver', $this->env_ver])->andFilterWhere(['like', 'repo', $this->repo])->andFilterWhere(['like', 'run_user', $this->run_user]);
     return $dataProvider;
 }
 /**
  * Finds the DcmdTaskServicePoolHistory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DcmdTaskServicePoolHistory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DcmdTaskServicePoolHistory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 function actionFinishTask()
 {
     $suc_msg = "";
     $err_msg = "";
     if (array_key_exists('selection', Yii::$app->request->post())) {
         $task_ids = Yii::$app->request->post()['selection'];
         foreach ($task_ids as $id) {
             $task = $this->findModel($id);
             if (Yii::$app->user->getIdentity()->admin != 1 && $task->opr_uid != Yii::$app->user->getId()) {
                 ///判断是否为同一产品组
                 $app = DcmdApp::findOne($task->app_id);
                 $query = DcmdUserGroup::findOne(['uid' => Yii::$app->user->getId(), 'gid' => $app['svr_gid']]);
                 if ($query == NULL) {
                     $err_msg .= $task->task_name . ": 没有权限<br>";
                     continue;
                 }
             }
             ///删除dcmd_task_service_pool_history
             DcmdTaskServicePoolHistory::deleteAll(['task_id' => $id]);
             ///dcmd_task_node_history
             DcmdTaskNodeHistory::deleteAll(['task_id' => $id]);
             ///dcmd_command_history
             DcmdCommandHistory::deleteAll(['task_id' => $id]);
             ///dcmd_task_service_pool_attr_history
             DcmdTaskServicePoolAttrHistory::deleteAll(['task_id' => $id]);
             $task->delete();
             $this->oprlog(3, "delete history task:" . $task->task_name);
             $suc_msg .= $task->task_name . ": 删除成功<br>";
         }
     }
     if ($suc_msg != "") {
         Yii::$app->getSession()->setFlash('success', $suc_msg);
     }
     if ($err_msg != "") {
         Yii::$app->getSession()->setFlash('error', $err_msg);
     }
     $this->redirect(array('index'));
 }