/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $ips = []) { $query = WirelessDeviceInfo::find(); $query->joinWith(['series', 'model']); //$query->andFilterWhere(["ip"=>$ips]); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['device_info.id' => $this->id, 'status' => $this->status, 'lastPoll' => $this->lastPoll, 'categoryId' => $this->categoryId, 'supportPing' => $this->supportPing, 'webMgrPort' => $this->webMgrPort, 'configPollTime' => $this->configPollTime, 'statePollTime' => $this->statePollTime, 'positionX' => $this->positionX, 'positionY' => $this->positionY, 'symbolType' => $this->symbolType, 'phyCreateTime' => $this->phyCreateTime, 'series_id' => $this->series_id, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'ip', $this->ip])->andFilterWhere(['like', 'mask', $this->mask])->andFilterWhere(['like', 'sysName', $this->sysName])->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'sysOid', $this->sysOid])->andFilterWhere(['like', 'runtime', $this->runtime])->andFilterWhere(['like', 'typeName', $this->typeName])->andFilterWhere(['like', 'symbolDesc', $this->symbolDesc])->andFilterWhere(['like', 'mac', $this->mac])->andFilterWhere(['like', 'phyName', $this->phyName])->andFilterWhere(['like', 'model_id', $this->model_id])->andFilterWhere(['like', 'interfaces', $this->interfaces])->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'series_name', $this->series_name])->andFilterWhere(['like', 'model_name', $this->model_name])->andFilterWhere(['like', 'device_model.name', $this->model])->andFilterWhere(['like', 'device_series.name', $this->series]); return $dataProvider; }
/** * 获取区域内设备 */ public static function getAreaDeviceData($area, $type = 2) { $template = self::find()->where(["type" => $type, "areaId" => $area])->select("device_id,attributes")->asArray()->all(); $data = ArrayHelper::map($template, 'device_id', "attributes"); $deviceIds = array_keys($data); //var_dump($deviceIds); if ($type == 3) { //无线设备 $rows = WirelessDeviceInfo::find()->with(["category"])->where(["id" => $deviceIds])->select("id,label,categoryId")->asArray()->all(); } else { $rows = DeviceInfo::find()->with(["category"])->where(["id" => $deviceIds])->select("id,label,categoryId")->asArray()->all(); } $result = []; foreach ($rows as $row) { //$pos = self::getPosition($data[$row["id"]]); $result[] = ["id" => $row["id"], "label" => $row["label"], "group" => isset($row["category"]) ? $row["category"]["node_group"] : '']; } return $result; }
/** * 从表中获取无线设备信息 */ private function getWirelessDevices($ipAry = array()) { $query = WirelessDeviceInfo::find(); if (!empty($ipAry)) { $query->where(['ip' => $ipAry]); } return $query->all(); }
/** * 无线网络 */ public function actionWireless() { $lists = WirelessDeviceInfo::getDeviceList(); $selected = ViewTemplate::getTempateSet(ViewTemplate::TYPE_WIFI); $categorys = ArrayHelper::map(WirelessDeviceCategory::find()->all(), "node_group", "name"); return $this->render('editWireless', ['deviceList' => $lists, 'selected' => json_encode($selected), 'type' => ViewTemplate::TYPE_WIFI, "categorys" => $categorys]); }
/** * 获取Echarts 和弦图数据 */ public static function getEData($id1, $id2) { $links = []; $nodes = WirelessDeviceInfo::find()->where(["id" => [$id1, $id2]])->select(["id", "name" => "label"])->asArray()->all(); /* array_walk($nodes,function(&$val,$key,$id1){ $nodeStyle= []; if($val["id"]== $id1){ $nodeStyle['normal'] = [ 'color' => 'green' ]; }else{ $nodeStyle['normal'] = [ //'color' => '#45d3c9' 'color' => 'green' ]; } $val["itemStyle"] = $nodeStyle; },$id1); */ $filterIds = DeviceIpfilter::find()->where(["type_id" => DeviceIpfilter::TYPE_WIRELESS])->select("ip")->column(); $lefts = (new Query())->from('wireless_device_link a')->leftJoin("wireless_device_info b", "a.leftDevice = b.id")->where(['and', ["a.rightDevice" => [$id1, $id2], "b.ip" => $filterIds], ["not", ["a.leftDevice" => [$id1, $id2]]]])->select(["leftDevice", "rightDevice", "name" => "b.ip", "id" => "b.id"])->all(); $rows = (new Query())->from('wireless_device_link a')->leftJoin("wireless_device_info b", "a.rightDevice = b.id")->where(["and", ["a.leftDevice" => [$id1, $id2], "b.ip" => $filterIds], ["not", ["a.rightDevice" => [$id1, $id2]]]])->select(["leftDevice", "rightDevice", "name" => "b.ip", "id" => "b.id"])->all(); $rows = array_merge($lefts, $rows); $tmp = ArrayHelper::map($nodes, "id", "name"); foreach ($rows as $row) { $nodes[] = ["id" => $row["id"], "name" => $row["name"]]; if (isset($tmp[$row["leftDevice"]])) { $source = $tmp[$row["leftDevice"]]; $target = $row["name"]; } else { $source = $tmp[$row["rightDevice"]]; $target = $row["name"]; } if ($row['leftDevice'] == $id1 || $row["rightDevice"] == $id1) { $color = 'green'; } else { $color = '#45d3c9'; } $links[] = ['source' => $source, 'target' => $target, 'weight' => 1, 'itemStyle' => ['normal' => ['color' => $color, 'width' => 2]]]; $links[] = ['source' => $target, 'target' => $source, 'weight' => 0.9, 'itemStyle' => ['normal' => ['color' => $color, 'width' => 2]]]; } return ["nodes" => $nodes, "links" => $links]; }
public function search($params) { $query = WirelessDeviceInfo::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'typeName', $this->typeName])->andFilterWhere(['like', 'ip', $this->ip]); return $dataProvider; }
public function actionAjaxDeviceTip() { $this->layout = false; $id = Yii::$app->request->get("id"); $fromWhere = Yii::$app->request->get("fromWhere"); if ($fromWhere == 'path') { return $this->pathDetail(Yii::$app->request->get("from"), Yii::$app->request->get("to")); } $device = WirelessDeviceInfo::find()->with(["type", "model"])->where(["id" => $id])->one(); $deviceConfig = ArrayHelper::map(InfoConfig::getTipConfig(1), "key", "value"); $perfConfig = ArrayHelper::map(InfoConfig::getTipConfig(2), "key", "value"); $perfData = WirelessDeviceTaskSummary::find()->where(["taskId" => array_values($perfConfig), "devId" => $id])->select(["taskId", "currentValue"])->groupBy("taskId")->asArray()->all(); $perfData = ArrayHelper::map($perfData, "taskId", "currentValue"); return $this->render("tip", ["model" => $device, "deviceConfig" => $deviceConfig, "perfConfig" => $perfConfig, "perfData" => $perfData]); }