コード例 #1
0
 /**
  * 链路提示信息
  */
 public function getLinkTip($d1, $d2)
 {
     $this->layout = false;
     $model = DeviceLink::find()->where(["or", ["and", ["leftDevice" => $d1, "rightDevice" => $d2]], ["and", ["leftDevice" => $d2, "rightDevice" => $d1]]])->one();
     if (!$model) {
         return '链路不存在';
     }
     $alarmDatas = [];
     /*
             if($model->status > 1){
                 $alarmDatas = (new Query())
                     ->from('device_info a')
                     ->innerJoin('device_alarm b',"a.id=b.deviceId")
                     ->where(["and",["a.id"=>[$d1,$d2]],"a.status>0",['not like','b.alarmDesc','GigabitEthernet1/1/1']])
                     ->all();
             }*/
     return $this->render('link-detail', ["model" => $model, "alarmDatas" => $alarmDatas]);
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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);
 }