1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
| import { Component, OnInit } from '@angular/core';
| import { NzMessageService } from 'ng-zorro-antd';
| import { _HttpClient } from '@delon/theme';
| import * as moment from "moment";
| import { DeviceControllerService } from '../device-controller/device-controller.service';
|
| @Component({
| selector: 'app-device-data',
| templateUrl: './device-data.component.html'
| })
| export class DeviceDataComponent implements OnInit {
| data = {
| advancedOperation1: [],
| advancedOperation2: [],
| advancedOperation3: []
| };
| public selectedIndex = 0;
| public get deviceData() {
| return this.deviceControllerService.data;
| }
| public get deviceStatusName() {
| if(!!this.deviceControllerService
| &&this.deviceControllerService.data
| &&this.deviceControllerService.data.state) {
| switch (this.deviceControllerService.data.state) {
| case "0":
| return '正常';
| case "1":
| return '轻度';
| case "2":
| return '中度';
| case "3":
| return '严重';
| default:
| return '离线';
| }
| }else {
| return '离线';
| }
| }
| constructor(
| public msg: NzMessageService,
| private http: _HttpClient,
| private deviceControllerService:DeviceControllerService,
| ) {
| }
| /**
| * 返回设备列表页面
| * toDeviceStatus
| */
| public toDeviceStatus() {
| this.deviceControllerService.incumbent = 'status';
| }
| /**
| * getTableList
| */
| public historys = [
| {"CO": "1.1", "O3": "10.0", "AQI": "170.0", "NO2": "76.0", "SO2": "13.0", "PM10": "187.0", "city": "杭州市", "PM2_5": "129.0", "level": "4", "quality": "中度污染", "latitude": "30.2111727272727", "city_code": "330100", "longitude": "120.081909090909", "pollutions": "细颗粒物(PM2.5)"},
| {"CO": "1.3", "O3": "3.0", "AQI": "169.0", "NO2": "77.0", "SO2": "18.0", "PM10": "185.0", "city": "杭州市", "PM2_5": "128.0", "level": "4", "quality": "中度污染", "latitude": "30.2111727272727", "city_code": "330100", "longitude": "120.081909090909", "pollutions": "细颗粒物(PM2.5)"},
| {"CO": "1.5", "O3": "3.0", "AQI": "156.0", "NO2": "79.0", "SO2": "19.0", "PM10": "178.0", "city": "杭州市", "PM2_5": "119.0", "level": "4", "quality": "中度污染", "latitude": "30.2111727272727", "city_code": "330100", "longitude": "120.081909090909", "pollutions": "细颗粒物(PM2.5)"},
| {"CO": "1.1", "O3": "6.0", "AQI": "100.0", "NO2": "64.0", "SO2": "11.0", "PM10": "112.0", "city": "杭州市", "PM2_5": "75.0", "level": "2", "quality": "良", "latitude": "30.2111727272727", "city_code": "330100", "longitude": "120.081909090909", "pollutions": "细颗粒物(PM2.5)"},
| {"CO": "1.2", "O3": "4.0", "AQI": "77.0", "NO2": "72.0", "SO2": "14.0", "PM10": "97.0", "city": "杭州市", "PM2_5": "56.0", "level": "2", "quality": "良", "latitude": "30.2111727272727", "city_code": "330100", "longitude": "120.081909090909", "pollutions": "细颗粒物(PM2.5)"},
| {"CO": "0.7", "O3": "31.0", "AQI": "70.0", "NO2": "41.0", "SO2": "10.0", "PM10": "77.0", "city": "杭州市", "PM2_5": "51.0", "level": "2", "quality": "良", "latitude": "30.2111727272727", "city_code": "330100", "longitude": "120.081909090909", "pollutions": "细颗粒物(PM2.5)"},
| {"CO": "0.8", "O3": "10.0", "AQI": "50.0", "NO2": "62.0", "SO2": "10.0", "PM10": "44.0", "city": "杭州市", "PM2_5": "35.0", "level": "1", "quality": "优", "latitude": "30.2111727272727", "city_code": "330100", "longitude": "120.081909090909", "pollutions": "—"},
| {"CO": "0.7", "O3": "31.0", "AQI": "70.0", "NO2": "41.0", "SO2": "10.0", "PM10": "77.0", "city": "杭州市", "PM2_5": "51.0", "level": "2", "quality": "良", "latitude": "30.2111727272727", "city_code": "330100", "longitude": "120.081909090909", "pollutions": "细颗粒物(PM2.5)"},
| {"CO": "1.5", "O3": "70.0", "AQI": "185.0", "NO2": "46.0", "SO2": "12.0", "PM10": "167.0", "city": "杭州市", "PM2_5": "139.0", "level": "", "quality": "中度污染", "station": "和睦小学", "latitude": "30.3119", "city_code": "330100", "longitude": "120.12", "pollutions": "细颗粒物(PM2.5)", "station_code": "1230A"},
| {"CO": "1.6", "O3": "24.0", "AQI": "202.0", "NO2": "82.0", "SO2": "10.0", "PM10": "186.0", "city": "杭州市", "PM2_5": "152.0", "level": "", "quality": "重度污染", "station": "和睦小学", "latitude": "30.3119", "city_code": "330100", "longitude": "120.12", "pollutions": "细颗粒物(PM2.5)", "station_code": "1230A"}
| ];
| public getTableList(type) {
| let index = 1;
| return this.historys.map(
| item => {
| const date = moment().subtract(index,'days').format('YYYY-MM-DD');
| let content = '';
| switch (type) {
| case 'history':
| content = `
| CO:${item.CO} ug/m3,
| O3:${item.O3} mg/m3,
| NO2:${item.NO2} mg/m3,
| SO2:${item.SO2} mg/m3,
| PM10:${item.PM10} mg/m3,
| PM2_5:${item.PM2_5} mg/m3
| `;
| break;
| case 'alarm':
| content = `${item.quality}`;
| break;
| case 'violation':
| content = `${item.pollutions}`;
| break;
| default:
| break;
| }
| index++;
| return {
| date:date,
| content:content
| }
| }
| );
| }
| ngOnInit() {
| this.http.get('/profile/advanced').subscribe((res: any) => this.data = res);
| }
| }
|
|