/**
  * 无线链路状态
  */
 public static function getWirelessLinkStatus($areaId)
 {
     $ids = ViewTemplate::find()->where(["type" => ViewTemplate::TYPE_WIFI, "areaId" => $areaId])->select("device_id")->column();
     //var_dump($ids);
     $query = WirelessDeviceLink::find();
     $query->where(["or", ["leftDevice" => $ids], ["rightDevice" => $ids]]);
     $query->andWhere("status>1");
     $count = $query->count();
     return $count > 0 ? 2 : 1;
 }
 public static function getLinks($ids, $type = 2)
 {
     if ($type == 3) {
         $query = WirelessDeviceLink::find();
     } else {
         $query = DeviceLink::find();
     }
     $rows = $query->where(["leftDevice" => $ids, "rightDevice" => $ids])->select(["id", "status", "from" => "leftDevice", "to" => "rightDevice"])->asArray()->all();
     array_walk($rows, function (&$item) {
         $item["color"] = $item["status"] == 1 ? 'green' : 'red';
         $item["value"] = 2;
     });
     return $rows;
 }
 private function pathDetail($from, $to)
 {
     $model = WirelessDeviceLink::find()->where(["or", ["leftDevice" => $from, "rightDevice" => $to], ["leftDevice" => $to, "rightDevice" => $from]])->one();
     if (!$model) {
         return '链路不存在';
     }
     $alarmDatas = [];
     if ($model->status != 1) {
         $alarmDatas = (new Query())->from('wireless_device_info a')->innerJoin('wireless_device_alarm b', "a.id=b.deviceId")->where(["and", ["a.id" => [$from, $to]], "a.status>0", ['not like', 'b.alarmDesc', 'GigabitEthernet1/1/1']])->orderBy('b.id desc')->groupBy('b.deviceId')->all();
     }
     return $this->render("link-detail", ["model" => $model, "alarmDatas" => $alarmDatas]);
 }
 public function actionAjaxLinks()
 {
     $type = Yii::$app->request->get("type");
     $ids = ViewTemplate::find()->where(["type" => $type])->select("device_id")->column();
     if ($type == ViewTemplate::TYPE_WIFI) {
         $query = WirelessDeviceLink::find();
     } else {
         $query = DeviceLink::find();
     }
     $query->where(["or", ["leftDevice" => $ids], ["rightDevice" => $ids]])->select(["from" => "leftDevice", "to" => "rightDevice", "status" => "status"]);
     $links = $query->asArray()->all();
     return Json::encode($links);
 }