public function actionAjaxApTip() { $this->layout = false; $id = Yii::$app->request->get("id"); $fromWhere = Yii::$app->request->get("fromWhere"); if ($fromWhere == 'path') { $id1 = trim(Yii::$app->request->get("from"), 'pid'); $id2 = trim(Yii::$app->request->get("to"), 'pid'); return $this->pathDetail($id1, $id2); } $ap = WirelessDeviceAp::findOne($id); if (!$ap) { return 'AP 不存在'; } return $this->render("ap-tip", ["model" => $ap]); }
public function actionAjaxAcAp() { $area = Yii::$app->request->post("area"); $polymers = [["id" => "p2856", "label" => 'WLAN_AC_A', "children" => []]]; /* $rows = (new Query()) ->from("wireless_device_ap a") ->leftJoin("wireless_device_link b","((a.id=b.leftDevice and a.acDevId=b.rightDevice) or (a.id=b .rightDevice and a.acDevId=b.leftDevice))") ->where(["a.acIpAddress"=>'192.168.0.4',"a.area"=>$area]) ->select(["label"=>"ipAddress","id"=>"CONCAT('id',a.id)","group"=>"CONCAT('group',a.side,':',CONCAT('id',a.id))","status"=>"a.status","device_id"=>"a.id","linkStatus"=>"b.status","side"=>"a.side"]) ->all(); */ $rows = WirelessDeviceAp::find()->where(["acIpAddress" => '192.168.0.4', "area" => $area])->select(["label" => "sysName", "id" => "CONCAT('id',id)", "group" => "CONCAT('group',side,':',CONCAT('id',id))", "status" => "status", "device_id" => "id", "side" => "side"])->orderBy("ipAddress asc")->asArray()->all(); $groups = $links = []; $count = count($rows); foreach ($rows as $k => $one) { $group = "group" . ($k < $count / 2 ? 1 : 2); $polymers[0]["children"][] = $group . ':' . $one["id"]; $links[] = ["from" => $one["id"], "to" => 'p2856', "status" => 1]; $groups[$group][] = $one; } return json_encode(["status" => 1, "data" => ["groups" => $groups, "polymers" => $polymers, "links" => $links]]); }