From e91e87b7b86e8d1d66caeab727a3cdc68fdc09ef Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Fri, 03 Aug 2018 16:56:41 +0800
Subject: [PATCH] Merge branch 'master' of http://blit.7drlb.com:8888/r/screen_demo2

---
 src/app/routes/raise-dust/statistical-query/statistical-query.component.ts |   96 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 89 insertions(+), 7 deletions(-)

diff --git a/src/app/routes/raise-dust/statistical-query/statistical-query.component.ts b/src/app/routes/raise-dust/statistical-query/statistical-query.component.ts
index 22fc612..6c2ecdf 100644
--- a/src/app/routes/raise-dust/statistical-query/statistical-query.component.ts
+++ b/src/app/routes/raise-dust/statistical-query/statistical-query.component.ts
@@ -1,17 +1,99 @@
-import { Component, OnInit } from '@angular/core';
-import { _HttpClient } from '@delon/theme';
+import {environment} from '../../../../environments/environment';
+import {DateService} from '../../../business/services/util/date.service';
+import {NzMessageService} from 'ng-zorro-antd';
+import {Component, OnInit} from '@angular/core';
+import {HttpClient} from '@angular/common/http';
+import {zip} from 'rxjs/observable/zip';
+import * as echarts from 'echarts';
 
 @Component({
   selector: 'app-statistical-query',
   templateUrl: './statistical-query.component.html',
 })
 export class StatisticalQueryComponent implements OnInit {
+  [x: string]: any;
+  public query: any = {};
+  public sensorOptions = [];
+  public typeOptions = [
+    {value: 'year', label: '���', format: 'YYYY'},
+    {value: 'month', label: '���', format: 'YYYY-MM'},
+    {value: 'day', label: '���', format: 'YYYY-MM-DD'},
+    {value: 'hour', label: '���', format: 'YYYY-MM-DD HH'}
+  ];
 
-    constructor(
-        private http: _HttpClient
-    ) { }
+  constructor(
+    public http: HttpClient,
+    public dateSrv: DateService,
+    public msgSrv: NzMessageService
+  ) {
+    this.timeType = this.typeOptions[1];
+  }
 
-    ngOnInit() {
-    }
+  private echartOption = {
+    title: {
+      text: '',
+      left: 'center'
+    },
+    tooltip: {
+      trigger: 'item',
+      axisPointer: {
+        type: 'cross'
+      }
+    },
+    xAxis: {
+      type: 'category',
+      data: [],
+      name: ''
+    },
+    yAxis: {
+      type: 'value',
+      name: ''
 
+    },
+    series: [
+      {
+        data: [],
+        type: 'line',
+        smooth: true,
+        name: ''
+      }
+    ]
+  };
+
+  ngOnInit() {
+
+    zip(
+      this.http.get(environment.SERVER_BASH_URL + 'sensor/all'),
+      this.http.get(environment.SERVER_BASH_URL + 'monitor-point/list/region', {params: {name: 'areaCode', value: '320583'}})
+    ).subscribe(
+      ([sensors, monitorPoints]) => {
+        this.sensorOptions = sensors['data'];
+        this.monitorPointOptions = monitorPoints['data'];
+      });
+  }
+
+  _disabledDate(current: Date): boolean {
+    return current && current.getTime() > Date.now();
+  }
+
+  reportQuery() {
+    const query = this.query;
+    query.type = this.timeType.value;
+    const formatTime = this.dateSrv.date_format(this.time, this.timeType.format);
+    const queryItems = [{formatTime: formatTime, monitorPointId: this.monitorPoint.id}];
+    query.items = JSON.stringify(queryItems);
+    query.sensors = JSON.stringify([this.sensor.sensorKey]);
+    const myChart = echarts.init(document.getElementById('mydiv'));
+    myChart.showLoading();
+    this.http.get(environment.SERVER_BASH_URL + 'report/compare', {params: query}).subscribe((res: any) => {
+      const option = this.echartOption;
+      option.title.text = this.monitorPoint.name + '   ' + formatTime + '   ' + this.sensor.name + '   ' + this.timeType.label + '������';
+      option.yAxis.name = '���������' + this.sensor.unit;
+      option.xAxis.data = res.data.times;
+      option.series[0].data = res.data.datas[0][this.sensor.sensorKey];
+      myChart.setOption(option, true);
+      window.onresize = myChart.resize;
+      myChart.hideLoading();
+    });
+  }
 }

--
Gitblit v1.8.0