private function getViewData()
 {
     $levels = AlarmLevel::find()->where(['not', ['id' => 255]])->select(["id", "text" => "desc"])->asArray()->all();
     $categorys = AlarmCategory::find()->select(["id", "text" => "subDesc"])->asArray()->all();
     $users = ArrayHelper::map(User::find()->select(["id", "username"])->all(), 'id', 'username');
     $templates = SmsTemplate::find()->select(["id", "name"])->asArray()->all();
     $templates = ArrayHelper::map($templates, 'id', 'name');
     return ["levels" => $levels, "categorys" => $categorys, "users" => $users, "templates" => $templates];
 }
 public function getConditionShow()
 {
     $items = json_decode($this->alarmSet, true);
     $conditions = [];
     foreach ($items as $item) {
         $tmp = '';
         switch ($item["key"]) {
             case 1:
                 $tmp = '告警类型:' . AlarmCategory::find()->where(["id" => $item["val"]])->select('subDesc')->scalar();
                 break;
             case 2:
                 $tmp = '告警等级:' . AlarmLevel::find()->where(["id" => $item["val"]])->select('desc')->scalar();
                 break;
             case 3:
                 $tmp = '关键字:' . $item['val'];
                 break;
             default:
                 continue;
         }
         if ($item["contain"] == 1) {
             $conditions[] = $tmp;
         } else {
             $conditions[] = ' 不包含(' . $tmp . ')';
         }
     }
     return implode(';  ', $conditions);
 }
 /**
  * 告警级别黑名单
  */
 public function actionLevelBlacklist()
 {
     if (Yii::$app->request->isPost) {
         $level = Yii::$app->request->post('level');
         $m = AlarmLevel::findOne(["id" => $level]);
         $exist = AlarmLevelBlacklist::find()->where(["level" => $level])->count();
         if ($m && !$exist) {
             $model = new AlarmLevelBlacklist(['level' => $level, "level_name" => $m->desc]);
             $model->save();
             echo '<script>alert("操作成功")</script>';
         } else {
             echo '<script>alert("操作失败")</script>';
         }
     }
     $model = AlarmLevelBlacklist::find();
     $provider = new ActiveDataProvider(['query' => $model]);
     $ids = AlarmLevelBlacklist::find()->select("level")->column();
     $ids[] = 255;
     $lists = AlarmLevel::find()->where(['not', ['id' => $ids]])->asArray()->all();
     $lists = ArrayHelper::map($lists, 'id', 'desc');
     return $this->render('blacklist', ['dataProvider' => $provider, 'lists' => $lists]);
 }