From 6efb2a0076a544b5714bccba214d81904264540d Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Tue, 12 Jun 2018 08:49:31 +0800
Subject: [PATCH] 报表展示 增加镇村选项
---
src/app/routes/dashboard/workplace/workplace.component.ts | 496 +++++++++++++++++++++---------------------------------
1 files changed, 196 insertions(+), 300 deletions(-)
diff --git a/src/app/routes/dashboard/workplace/workplace.component.ts b/src/app/routes/dashboard/workplace/workplace.component.ts
index 7698053..bc27c03 100644
--- a/src/app/routes/dashboard/workplace/workplace.component.ts
+++ b/src/app/routes/dashboard/workplace/workplace.component.ts
@@ -1,125 +1,211 @@
+import { environment } from '../../../../environments/environment';
import { zip } from 'rxjs/observable/zip';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { getTimeDistance, yuan, fixedZero } from '@delon/abc';
import { _HttpClient } from '@delon/theme';
-import {HttpClient} from '@angular/common/http';
+import { HttpClient } from '@angular/common/http';
import * as moment from 'moment';
+import { DeviceService } from '@business/services/http/device.service';
+import { ExampleService } from '@business/services/util/example.service';
+import { ResultBean } from '@business/entity/grid';
+import { TimeUnits } from '@business/enum/types.enum';
+import { ToolsService } from '@business/services/util/tools.service';
@Component({
selector: 'app-dashboard-workplace',
templateUrl: './workplace.component.html',
- styleUrls: ['./workplace.component.less']
+ styleUrls: ['./workplace.component.less'],
+ providers: [DeviceService]
})
export class DashboardWorkplaceComponent implements OnInit, OnDestroy {
- totalDeviceCountList: any[] = [];
- totalDeviceCount = 0;
- avgDeviceCount: string;
-
- notice: any[] = [];
+ totalDeviceCountList = null;
+ totalDeviceCount = '';
+ avgDeviceCount = '';
+ deviceCountLoading = true;
+ // ������������
+ alarmCountList:{x: string,y: number}[] = null;
+ alarmCountCurrMonth = '';
+ alarmCountCurrDay = '';// ������������������
+ alarmCountLoading = true;
+ operationLoading = true;
+ operNormalPercent = 0;
activities: any[] = [];
radarData: any[] = [];
loading = true;
-
- // region: mock data
- links = [
- {
- title: '���������',
- href: '',
- },
- {
- title: '���������',
- href: '',
- },
- {
- title: '���������',
- href: '',
- },
- {
- title: '���������',
- href: '',
- },
- {
- title: '���������',
- href: '',
- },
- {
- title: '���������',
- href: '',
- },
+ public alarmData: any = {};
+ public alarmDatas = [
+ { title: '������', color: 'purple', data: [] },
+ { title: '������', color: 'yellow', data: [] },
+ { title: '������', color: 'orange', data: [] },
+ { title: '������', color: 'red', data: [] }
];
+ public alertData = [[], [], [], []];
+ salesType = '0';
+ salesTotal = 0;
+ salesPieData: any;
members = [
{
- id: 'members-1',
- title: '���������������',
- logo: 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png',
- link: '',
+ id: 'members-1',
+ title: '������������',
+ logo: 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png',
+ link: '',
},
{
- id: 'members-2',
- title: '���������������',
- logo: 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png',
- link: '',
+ id: 'members-2',
+ title: '������������',
+ logo: 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png',
+ link: '',
},
{
- id: 'members-3',
- title: '������������',
- logo: 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png',
- link: '',
+ id: 'members-3',
+ title: '���������',
+ logo: 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png',
+ link: '',
},
{
- id: 'members-4',
- title: '���������������',
- logo: 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png',
- link: '',
- },
- {
- id: 'members-5',
- title: '������������������',
- logo: 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png',
- link: '',
- },
- ];
- // endregion
+ id: 'members-4',
+ title: '���������',
+ logo: 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png',
+ link: '',
+ }
+ ];
- ngOnDestroy(): void {
- }
-
-
- data: any = {
- salesData: [],
- offlineData: []
- };
+ data: any = {};
q: any = {
start: null,
end: null
};
- rankingListData: any[] = Array(7).fill({}).map((item, i) => {
- return {
- title: `��������� ${i} ������`,
- total: 323234
- };
- });
- constructor(private http: _HttpClient, public msg: NzMessageService,
- private http2: HttpClient) {}
+ rankingListData: any[] = [];
+
+ constructor(
+ private deviceService: DeviceService,
+ private http: _HttpClient,
+ public msg: NzMessageService,
+ private http2: HttpClient) {
+ }
+
+ selectedIndexChange(index) {
+ this.rankingListData = [];
+ if (this.alarmDatas[index].data.length < 1) {
+ this.http2.get(environment.SERVER_BASH_URL + 'report/alarm-year', { params: { state: index > 0 ? index : null } }).subscribe((res: any) => {
+ const data = [];
+ for (let i = 0; i < res.data.length; i += 1) {
+ data.push({ x: `${i + 1}���`, y: !!res.data[i] ? res.data[i] : 0 });
+ }
+ this.alarmDatas[index].data = data;
+ });
+ }
+ if (this.alertData[index].length > 0) {
+ this.alertData[index].forEach(item => {
+ this.rankingListData.push(
+ {
+ title: item.x,
+ total: item.y
+ }
+ );
+ });
+ } else {
+ this.http2.get(environment.SERVER_BASH_URL + 'report/alarm-month', { params: { state: index > 0 ? index : null } }).subscribe((res: any) => {
+ const data = [];
+ for (let i = 0; i < res.data.length; i += 1) {
+ for (const key in res.data[i]) {
+ data.push({ x: key, y: res.data[i][key] });
+ this.rankingListData.push(
+ {
+ title: key,
+ total: res.data[i][key]
+ }
+ );
+ }
+ }
+ this.alertData[index] = data;
+ });
+ }
+ }
+
+ changeSaleType() {
+ if (this.alertData[this.salesType].length > 0) {
+ this.salesPieData = this.alertData[this.salesType];
+ this.salesTotal = this.salesPieData.reduce((pre, now) => now.y + pre, 0);
+ } else {
+ this.http2.get(environment.SERVER_BASH_URL + 'report/alarm-month', { params: { state: this.salesType === '0' ? null : this.salesType } }).subscribe((res: any) => {
+ const data = [];
+ for (let i = 0; i < res.data.length; i += 1) {
+ for (const key in res.data[i]) {
+ data.push({ x: key, y: res.data[i][key] });
+ }
+ }
+ this.salesPieData = this.alertData[this.salesType] = data;
+ this.salesTotal = this.salesPieData.reduce((pre, now) => now.y + pre, 0);
+ });
+ }
+ }
ngOnInit() {
+ this.selectedIndexChange(0);
+ this.changeSaleType();
- const today = new Date().getTime();
- const fakeDC = [60, 135, 70, 112, 80, 170, 200, 140, 52, 119, 164, 230];
- for (let i = 0; i < 12; i += 1) {
- this.totalDeviceCountList.push({
- x: moment(today).subtract(-1*i, 'months').format(
- "YYYY-MM"
- ),
- y: fakeDC[i]
- });
- this.totalDeviceCount += fakeDC[i];
- }
- this.avgDeviceCount = (this.totalDeviceCount/12).toFixed(0);
+ // const today = new Date().getTime();
+ // const fakeDC = [60, 135, 70, 112, 80, 170, 200, 140, 52, 119, 164, 230];
+ // for (let i = 0; i < 12; i += 1) {
+ // this.totalDeviceCountList.push({
+ // x: moment(today).subtract(-1 * i, 'months').format(
+ // "YYYY-MM"
+ // ),
+ // y: fakeDC[i]
+ // });
+ // this.totalDeviceCount += fakeDC[i];
+ // }
+ let example1 = new ExampleService();
+ let mo = moment();
+ example1.or().andGreaterThanOrEqualTo({ name: "createTime", value: mo.format('YYYY-MM-01 00:00:00') });
+ let example2 = new ExampleService();
+ let example3 = new ExampleService();
+ example3.or().andNotEqualTo({name:'state',value:4});
+ zip(this.deviceService.countByExample(example1),
+ this.deviceService.countByExample(example2),
+ this.http.get<ResultBean<{time: string,count: number}[]>>('device/count-by-times',{start:mo.format('YYYY-01-01 00:00:00'),end:mo.format('YYYY-12-31 23:59:59')}),
+ this.deviceService.countByExample(example3)).subscribe(
+ ([rWtihAvg, rWithToltal,rWithList,rWithNormal]) => {
+ if (!!rWtihAvg.code && !!rWithToltal&&!!rWithList.code) {
+ this.avgDeviceCount = ToolsService.toThousands(rWtihAvg.data.toString());
+ this.totalDeviceCount = ToolsService.toThousands(rWithToltal.data.toString());
+ this.totalDeviceCountList = rWithList.data.map(item => {
+ return {x:item.time,y:item.count};
+ })
+ this.operNormalPercent = Math.round(rWithNormal.data/rWithToltal.data*100);
+ this.deviceCountLoading = false;
+ this.operationLoading = false;
+ }
+ }
+ );
+ zip(
+ this.http.get<ResultBean<{time: string,count: number}[]>>("alarm/count-by-times",{start: mo.format('YYYY-MM-01 00:00:00'),end: null,timeUnits: TimeUnits.DAY}),
+ this.http.get<ResultBean<{time: string,count: number}[]>>("alarm/count-by-times",{start: mo.format('YYYY-MM-01 00:00:00'),end: null}),
+ this.http.get<ResultBean<{time: string,count: number}[]>>("alarm/count-by-times",{start: mo.format('YYYY-MM-DD 00:00:00'),end: null})
+ ).subscribe(
+ ([rWithList,rWithMonth,rWithDay]) => {
+ if(!!rWithList.code&&!!rWithMonth.code&&!!rWithDay.code){
+ this.alarmCountList = rWithList.data.map(
+ item => {
+ return {x:item.time,y:item.count};
+ }
+ );
+ if(!!rWithMonth.data&&rWithMonth.data.length>0){
+ this.alarmCountCurrMonth = ToolsService.toThousands(rWithMonth.data[0].count.toString());
+ }
+ if(!!rWithDay.data&&rWithDay.data.length>0) {
+ this.alarmCountCurrDay = ToolsService.toThousands(rWithDay.data[0].count.toString());
+ }
+ this.alarmCountLoading = false;
+ }
+ }
+ );
+ // this.avgDeviceCount = (this.totalDeviceCount / 12).toFixed(0);
const visitData = [];
@@ -129,7 +215,7 @@
for (let i = 0; i < fakeY.length; i += 1) {
visitData.push({
x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format(
- "YYYY-MM-DD"
+ 'YYYY-MM-DD'
),
y: fakeY[i]
});
@@ -139,109 +225,9 @@
for (let i = 0; i < fakeY2.length; i += 1) {
visitData2.push({
x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format(
- "YYYY-MM-DD"
+ 'YYYY-MM-DD'
),
y: fakeY2[i]
- });
- }
- const salesData = [];
- for (let i = 0; i < 12; i += 1) {
- salesData.push({
- x: `${i + 1}���`,
- y: Math.floor(Math.random() * 1000) + 200
- });
- }
-
- const salesTypeData = [
- {
- x: "������������",
- y: 4544
- },
- {
- x: "������������",
- y: 3321
- },
- {
- x: "������������",
- y: 3113
- },
- {
- x: "������������",
- y: 2341
- },
- {
- x: "������������",
- y: 1231
- },
- {
- x: "������",
- y: 1231
- }
- ];
-
- const salesTypeDataOnline = [
- {
- x: "������������",
- y: 244
- },
- {
- x: "������������",
- y: 321
- },
- {
- x: "������������",
- y: 311
- },
- {
- x: "������������",
- y: 41
- },
- {
- x: "������������",
- y: 121
- },
- {
- x: '������',
- y: 111
- }
- ];
-
- const salesTypeDataOffline = [
- {
- x: '������������',
- y: 99
- },
- {
- x: '������������',
- y: 188
- },
- {
- x: '������������',
- y: 344
- },
- {
- x: '������������',
- y: 255
- },
- {
- x: '������',
- y: 65
- }
- ];
-
- const offlineData = [];
- for (let i = 0; i < 10; i += 1) {
- offlineData.push({
- name: `������${i}`,
- cvr: Math.ceil(Math.random() * 9) / 10
- });
- }
- const offlineChartData = [];
- for (let i = 0; i < 20; i += 1) {
- offlineChartData.push({
- x: new Date().getTime() + 1000 * 60 * 30 * i,
- y1: Math.floor(Math.random() * 100) + 10,
- y2: Math.floor(Math.random() * 100) + 10
});
}
@@ -301,39 +287,21 @@
status: Math.floor((Math.random() * 10) % 2)
});
}
- var res = {
+ const res = {
+
visitData: visitData,
- salesData: salesData,
visitData2: visitData2,
- salesTypeData: salesTypeData,
- salesTypeDataOnline: salesTypeDataOnline,
- salesTypeDataOffline: salesTypeDataOffline,
- offlineData: offlineData,
- offlineChartData: offlineChartData,
+
radarOriginData: radarOriginData,
radarData: radarData,
searchData: searchData
};
- res.offlineData.forEach((item: any) => {
- item.chart = Object.assign([], res.offlineChartData);
- });
this.data = res;
this.loading = false;
- this.changeSaleType();
this.radarData = res.radarData;
- const titles = [
- 'Alipay',
- 'Angular',
- 'Ant Design',
- 'Ant Design Pro',
- 'Bootstrap',
- 'React',
- 'Vue',
- 'Webpack'
- ];
const avatars = [
'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay
@@ -346,71 +314,7 @@
'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png' // Webpack
];
- var notice = [
- {
- id: 'xxx1',
- title: titles[0],
- logo: avatars[0],
- description: '������������������������������ ���������������������������������������',
- updatedAt: new Date(),
- member: '���������������',
- href: '',
- memberLink: '',
- },
- {
- id: 'xxx2',
- title: titles[1],
- logo: avatars[1],
- description: '���������������������������������������������������������������������������',
- updatedAt: new Date('2017-07-24'),
- member: '���������������������',
- href: '',
- memberLink: '',
- },
- {
- id: 'xxx3',
- title: titles[2],
- logo: avatars[2],
- description: '������������������������������������������������������������������',
- updatedAt: new Date(),
- member: '���������������',
- href: '',
- memberLink: '',
- },
- {
- id: 'xxx4',
- title: titles[3],
- logo: avatars[3],
- description: '���������������������������������������������������������������������',
- updatedAt: new Date('2017-07-23'),
- member: '���������������',
- href: '',
- memberLink: '',
- },
- {
- id: 'xxx5',
- title: titles[4],
- logo: avatars[4],
- description: '������������',
- updatedAt: new Date('2017-07-23'),
- member: '���������������������',
- href: '',
- memberLink: '',
- },
- {
- id: 'xxx6',
- title: titles[5],
- logo: avatars[5],
- description: '������������������������������������������������������',
- updatedAt: new Date('2017-07-23'),
- member: '���������������������',
- href: '',
- memberLink: '',
- },
- ];
- this.notice = notice;
-
- var activities = [
+ const activities = [
{
id: 'trend-1',
updatedAt: new Date(),
@@ -509,6 +413,19 @@
},
template: '��� @{group} ������������ @{project}',
},
+ {
+ id: 'trend-7',
+ updatedAt: new Date(),
+ user: {
+ name: '���������',
+ avatar: avatars[3],
+ },
+ project: {
+ name: '���������������',
+ link: 'http://github.com/',
+ },
+ template: '��� @{project} ���������������������',
+ }
];
this.activities = activities.map((item: any) => {
item.template = item.template.split(/@\{([^{}]*)\}/gi).map((key: string) => {
@@ -517,23 +434,17 @@
});
return item;
});
-
-
-
}
- setDate(type: any) {
- const rank = getTimeDistance(type);
- this.q.start = rank[0];
- this.q.end = rank[1];
+ ngOnDestroy(): void {
}
sort(sortName, sortValue) {
this.data.searchData = [
...(<any[]>this.data.searchData).sort((a, b) => {
- if (a[ sortName ] > b[ sortName ]) {
+ if (a[sortName] > b[sortName]) {
return (sortValue === 'ascend') ? 1 : -1;
- } else if (a[ sortName ] < b[ sortName ]) {
+ } else if (a[sortName] < b[sortName]) {
return (sortValue === 'ascend') ? -1 : 1;
} else {
return 0;
@@ -542,22 +453,7 @@
];
}
- salesType = 'all';
- salesPieData: any;
- salesTotal = 0;
- changeSaleType() {
- this.salesPieData = this.salesType === 'all' ? this.data.salesTypeData : (
- this.salesType === 'online' ? this.data.salesTypeDataOnline : this.data.salesTypeDataOffline
- );
- if (this.salesPieData) this.salesTotal = this.salesPieData.reduce((pre, now) => now.y + pre, 0);
- }
-
handlePieValueFormat(value: any) {
- return yuan(value);
- }
-
- _activeTab = 0;
- _tabChange(value: any) {
- console.log('tab', this._activeTab, value);
+ return value + '���';
}
}
--
Gitblit v1.8.0