From b0a7de005f68d59a47a11294c1168c45699f13c9 Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Fri, 20 Jul 2018 16:17:28 +0800
Subject: [PATCH] 站点数据 分析

---
 src/app/routes/reports/query2/query2.component.ts   |   65 +++++++++++++++++++-------------
 src/app/routes/reports/query2/query2.component.html |   26 ++++++------
 2 files changed, 52 insertions(+), 39 deletions(-)

diff --git a/src/app/routes/reports/query2/query2.component.html b/src/app/routes/reports/query2/query2.component.html
index be20c17..27e994a 100644
--- a/src/app/routes/reports/query2/query2.component.html
+++ b/src/app/routes/reports/query2/query2.component.html
@@ -5,13 +5,13 @@
             <ng-template #extra>
                 <div class="sales-card-extra">
                     <div class="sales-type-radio">
-                        <nz-radio-group [(ngModel)]="salesType" (ngModelChange)="changeSaleType()" [nzSize]="'large'">
-                            <label nz-radio-button [nzValue]="'1'"><span>PM2.5</span></label>
-                            <label nz-radio-button [nzValue]="'2'"><span>PM10</span></label>
-                            <label nz-radio-button [nzValue]="'3'"><span>SO2</span></label>
-                            <label nz-radio-button [nzValue]="'4'"><span>NO3</span></label>
-                            <label nz-radio-button [nzValue]="'5'"><span>O3</span></label>
-                            <label nz-radio-button [nzValue]="'6'"><span>CO</span></label>
+                        <nz-radio-group [(ngModel)]="sensorKey1" (ngModelChange)="changeSensorKey($event)" [nzSize]="'large'">
+                            <label nz-radio-button [nzValue]="'e1'"><span>PM2.5</span></label>
+                            <label nz-radio-button [nzValue]="'e2'"><span>PM10</span></label>
+                            <label nz-radio-button [nzValue]="'e11'"><span>SO2</span></label>
+                            <label nz-radio-button [nzValue]="'e16'"><span>NO2</span></label>
+                            <label nz-radio-button [nzValue]="'e15'"><span>O3</span></label>
+                            <label nz-radio-button [nzValue]="'e10'"><span>CO</span></label>
                         </nz-radio-group>
                     </div>
                 </div>
@@ -19,22 +19,22 @@
             <ng-template #body>
                 <h4 class="margin:8px 0 32px 0;">������������������</h4>
 
-                <nz-table #keyTable [nzDataSource]="data.searchData" [nzPageSize]="5" nzSize="small">
+                <nz-table #keyTable [nzDataSource]="_dataSet" [nzPageSize]="5" nzSize="small">
                     <thead nz-thead>
                     <tr>
                         <th nz-th><span>������</span></th>
                         <th nz-th><span>������������</span></th>
                         <th nz-th class="text-right">
                             <span>������������ mg/m3</span>
-                            <nz-table-sort (nzValueChange)="sort('count',$event)"></nz-table-sort>
+                            <nz-table-sort (nzValueChange)="sort('avg',$event)"></nz-table-sort>
                         </th>
                     </tr>
                     </thead>
                     <tbody nz-tbody>
-                    <tr nz-tbody-tr *ngFor="let i of keyTable.data">
-                        <td nz-td>{{i.index}}</td>
-                        <td nz-td><a (click)="msg.success(i.point)">{{i.point}}</a></td>
-                        <td nz-td class="text-right">{{i.value}}</td>
+                    <tr nz-tbody-tr *ngFor="let i of keyTable.data;let index = index">
+                        <td nz-td>{{index + 1}}</td>
+                        <td nz-td><a>{{i.name}}</a></td>
+                        <td nz-td class="text-right">{{i.avg}}</td>
                     </tr>
                     </tbody>
                 </nz-table>
diff --git a/src/app/routes/reports/query2/query2.component.ts b/src/app/routes/reports/query2/query2.component.ts
index 3580a3b..3134b45 100644
--- a/src/app/routes/reports/query2/query2.component.ts
+++ b/src/app/routes/reports/query2/query2.component.ts
@@ -1,3 +1,5 @@
+import { environment } from '../../../../environments/environment';
+import { HttpClient } from '@angular/common/http';
 import { Component, OnInit, ViewChild } from '@angular/core';
 import { _HttpClient } from '@delon/theme';
 import { Sensor, Device, DataCondition, MonitorPoint, Organization, LineChartCriteria } from '@business/entity/data';
@@ -204,20 +206,45 @@
     private monitorPointService: MonitorPointService,
     private msg: NzMessageService,
     private dateService: DateService,
+    private http2: HttpClient
     ) { }
-    ngOnInit() {
-        const searchData = [];
-        for (let i = 0; i < 50; i += 1) {
-            searchData.push({
-                index: i + 1,
-                point: `������������-${i}`,
-                value: Math.floor(Math.random() * 100)
-            });
-        }
+  
+  _dataSet = [];
+    
+    changeSensorKey(sensorKey) {
+      const params = {sensorKey: sensorKey, dimension: 'monitorPoint', regionCode: '320583', accountId: '1', timeType: 'month'};
+      this.http2.get(environment.SERVER_BASH_URL + 'screen/region_ranking_data', {params: params}).subscribe((res: any) => {
+        this._dataSet = res.data;
+      });
+    }
+      sort(sortName, sortValue) {
+        this._dataSet = [
+            ...(<any[]>this._dataSet).sort((a, b) => {
+                if (a[sortName] > b[sortName]) {
+                    return (sortValue === 'ascend') ? 1 : -1;
+                } else if (a[sortName] < b[sortName]) {
+                    return (sortValue === 'ascend') ? -1 : 1;
+                } else {
+                    return 0;
+                }
+            })
+        ];
+    }
 
-        this.data = {
-            searchData: searchData
-        };
+    ngOnInit() {
+      this.changeSensorKey('e1');
+//        const searchData = [];
+//        for (let i = 0; i < 50; i += 1) {
+//            searchData.push({
+//                index: i + 1,
+//                point: `������������-${i}`,
+//                value: Math.floor(Math.random() * 100)
+//            });
+//        }
+//
+//        this.data = {
+//            searchData: searchData
+//        };
 
         this.initPage();
         // ������������ tree click ������
@@ -514,7 +541,6 @@
     public loadGrid(): void {
         // ������������
         const sensors = Object.values(this._sensors);
-        debugger;
         if ( sensors.length === 0 ) {
             this.msg.error(' ������������ ������������');
             return ;
@@ -830,19 +856,6 @@
     }
 
 
-    sort(sortName, sortValue) {
-        this.data.searchData = [
-            ...(<any[]>this.data.searchData).sort((a, b) => {
-                if (a[sortName] > b[sortName]) {
-                    return (sortValue === 'ascend') ? 1 : -1;
-                } else if (a[sortName] < b[sortName]) {
-                    return (sortValue === 'ascend') ? -1 : 1;
-                } else {
-                    return 0;
-                }
-            })
-        ];
-    }
 }
 
 

--
Gitblit v1.8.0