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); }
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]; }