public function actionDetail($id) { $this->layout = '//main'; $model = $this->findModel($id); $perQuery = WirelessDeviceTaskSummary::find()->where(["and", ["devId" => $id], ["not", ["taskId" => [1, 5]]]])->orderBy("instId desc")->groupBy('taskId'); $lists = new ActiveDataProvider(['query' => $perQuery, 'pagination' => ["pageSize" => 10]]); $query = WirelessDeviceAlarm::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ["pageSize" => 10]]); $query->where(["deviceId" => $id])->orderBy("faultTime desc")->limit(5); $links = $nodes = $linkModels = []; $nodes[] = ["name" => $model->ip, "id" => $model->id]; $apProvider = null; if ($model->categoryId == 1003) { $query = WirelessDeviceAp::find()->where(["acDevId" => $id]); $apProvider = new ActiveDataProvider(["query" => $query, "pagination" => ["pageSize" => 10]]); } else { $linkModels = WirelessDeviceLink::find()->where(["or", ["leftDevice" => $id], ["rightDevice" => $id]])->all(); foreach ($linkModels as $link) { if ($link->leftDevice == $id) { $node = $link->right; } else { $node = $link->left; } if (!$node) { continue; } $nodes[] = ["name" => $node->ip, "id" => $node->id]; $links[] = ["source" => $model->ip, "target" => $node->ip, "weight" => 0.9]; $links[] = ["source" => $node->ip, "target" => $model->ip, "weight" => 1]; } } $interfaceQuery = WirelessDeviceTaskSummary::find()->where(["devId" => $id, "taskId" => [1, 5]])->orderBy("update_time desc")->groupBy("taskId,objIndex"); $interfaceProvider = new ActiveDataProvider(['query' => $interfaceQuery, 'pagination' => ["pageSize" => 10]]); return $this->render("detail_wlan", ['id' => $id, "model" => $model, "perflists" => $lists, "alarmProvider" => $dataProvider, "nodes" => $nodes, "links" => $links, "apProvider" => $apProvider, "ifProvider" => $interfaceProvider, 'linkModels' => $linkModels]); }
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]]); }