/**
  * 无线链路状态
  */
 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 function actionTest()
 {
     $f = ViewTemplate::isInArea([371, 272], [[305, 144], [110, 233], [387, 414], [588, 312]]);
     var_dump($f);
 }
 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);
 }