From 43e7ed40c26afa535aba24b1c9ddc1b87b607d8d Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Mon, 05 Mar 2018 09:26:26 +0800 Subject: [PATCH] 报表查看 --- src/app/business/enum/types.enum.ts | 6 + src/app/routes/analysis/query/query.component.less | 21 ++++ src/app/business/entity/data.ts | 18 +++ src/app/business/services/http/sensors.service.ts | 8 + src/app/routes/analysis/query/query.component.ts | 92 ++++++++++++++++++ src/app/routes/systems/organization/organization-config/organization-config.component.ts | 2 src/app/routes/analysis/analysis.module.ts | 28 +++++ src/app/routes/routes-routing.module.ts | 1 src/assets/app-data.json | 30 +++-- src/app/routes/analysis/query/query.component.html | 51 ++++++++++ 10 files changed, 241 insertions(+), 16 deletions(-) diff --git a/src/app/business/entity/data.ts b/src/app/business/entity/data.ts index f56e676..38e3557 100644 --- a/src/app/business/entity/data.ts +++ b/src/app/business/entity/data.ts @@ -1,5 +1,6 @@ +import { LineChartCriteria } from './data'; import { Column } from '@business/entity/grid'; -import { AlarmStyle } from '@business/enum/types.enum'; +import { AlarmStyle, TimeUnits, AreaRange } from '@business/enum/types.enum'; export interface AreaNames { @@ -132,4 +133,19 @@ mode: string; organizationId: number; username: string; +} +export interface TimePeriod{ + startTime:number;//������������ + endTime:number;//������������ +} +export interface DataCondition{ + timeUnits:TimeUnits;//������ + actualTime:number;//������������ + areaRange:AreaRange;//������������ + areaRangeId:number;//���������������ID +} +export interface LineChartCriteria{ + sensorKey:String; + timePeriod:TimePeriod; + dataConditions:DataCondition[]; } \ No newline at end of file diff --git a/src/app/business/enum/types.enum.ts b/src/app/business/enum/types.enum.ts index 7fdb678..55d7143 100644 --- a/src/app/business/enum/types.enum.ts +++ b/src/app/business/enum/types.enum.ts @@ -5,3 +5,9 @@ //��������������������������������� weixin='weixin',email='email',sms='sms',voice='voice' } +export enum TimeUnits{ + YEAR='YEAR',MONTH='MONTH',DAY='DAY',HOUR='HOUR',MINUTE='MINUTE' +} +export enum AreaRange { + PROVINCE='PROVINCE',CITY='CITY',AREA='AREA',MONITORPOINT='MONITORPOINT',DEVICE='DEVICE' +} \ No newline at end of file diff --git a/src/app/business/services/http/sensors.service.ts b/src/app/business/services/http/sensors.service.ts index 91ae9d5..08c4e3a 100644 --- a/src/app/business/services/http/sensors.service.ts +++ b/src/app/business/services/http/sensors.service.ts @@ -23,8 +23,12 @@ example.or().andEqualTo({name: 'version', value: queryText}); } let orderByClause = ''; - if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { - orderByClause = page.getOrderByClause(); + if(!!page){ + if (page.getOrderByClause != null && page.getOrderByClause instanceof Function) { + orderByClause = page.getOrderByClause(); + } + }else{ + page = {pageSize:0,pageIndex:0}; } const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, queryParams: example.getSqlParam(), orderByClause: orderByClause}; diff --git a/src/app/routes/analysis/analysis.module.ts b/src/app/routes/analysis/analysis.module.ts new file mode 100644 index 0000000..f61ca5e --- /dev/null +++ b/src/app/routes/analysis/analysis.module.ts @@ -0,0 +1,28 @@ +import { SensorsService } from '@business/services/http/sensors.service'; +import { PipeModule } from '@business/pipe/pipe.module'; +import { NgModule } from '@angular/core'; +import { SharedModule } from '@shared/shared.module'; +import { QueryComponent } from './query/query.component'; +import { Routes, RouterModule } from '@angular/router'; +import { CommonModule } from '@angular/common'; +const routes: Routes = [ + { + path: '', + children: [ + { path: 'query', component: QueryComponent } + ] + } +]; + +@NgModule({ + imports: [ + // ������������������������������������ + PipeModule, + CommonModule, + SharedModule, + RouterModule.forChild(routes) + ], + declarations: [QueryComponent], + providers:[SensorsService] +}) +export class AnalysisModule { } diff --git a/src/app/routes/analysis/query/query.component.html b/src/app/routes/analysis/query/query.component.html new file mode 100644 index 0000000..97a90da --- /dev/null +++ b/src/app/routes/analysis/query/query.component.html @@ -0,0 +1,51 @@ +<nz-card [nzBordered]="true"> + <div nz-row> + <div nz-col [nzXs]="20" [nzSm]="8" class="header-info"> + <p class="text-grey-dark">������������������</p> + <nz-dropdown> + <a class="ant-dropdown-link" nz-dropdown> + <p class="display-2">{{ lineChartSensorName }}<i class="anticon anticon-down"></i></p> + </a> + <ul style="height:280px;overflow:auto;" nz-menu> + <li style="width:200px;cursor:pointer;" *ngFor="let sensor of sensorList" + (click) = "lineChartCriteria.sensorKey=sensor.sensorKey" nz-menu-item> + <p> + {{sensor.name}} + </p> + </li> + </ul> + </nz-dropdown> + <em></em> + </div> + <div nz-col [nzXs]="20" [nzSm]="8" class="header-info"> + <p class="text-grey-dark">���������������������</p> + <nz-dropdown> + <a class="ant-dropdown-link" nz-dropdown> + <p class="display-2">{{ timePeriodUnitName }}<i class="anticon anticon-down"></i></p> + </a> + <ul nz-menu> + <li style="width:60px;cursor:pointer;" *ngFor="let item of timeUnits" + (click)="timePeriodUnitValue = item.value" nz-menu-item> + <p> + {{item.label}} + </p> + </li> + </ul> + </nz-dropdown> + <em></em> + </div> + <div nz-col [nzSm]="8" class="header-info"> + <p class="text-grey-dark">���������������������</p> + <nz-datepicker style="width: 42%;" + [(ngModel)]="lineChartCriteria.timePeriod.startTime" + [nzDisabledDate]="_disabledStartDate" + nzShowTime="{{ !!timeType.timePickerOption?timeType.timePickerOption:false }}" [nzMode]="timeType.mode" [nzFormat]="timeType.dateFormat" [nzPlaceHolder]="'Start date'"></nz-datepicker> + <span>-</span> + <nz-datepicker style="width: 42%;" + [nzDisabledDate]="_disabledEndDate" + [(ngModel)]="lineChartCriteria.timePeriod.endTime" + nzShowTime="{{ !!timeType.timePickerOption?timeType.timePickerOption:false }}" [nzMode]="timeType.mode" [nzFormat]="timeType.dateFormat" [nzPlaceHolder]="'End date'"></nz-datepicker> + </div> + <input type="button" value="text" width="100px;" (click)="_isSameDay"/> + </div> +</nz-card> \ No newline at end of file diff --git a/src/app/routes/analysis/query/query.component.less b/src/app/routes/analysis/query/query.component.less new file mode 100644 index 0000000..66c0e84 --- /dev/null +++ b/src/app/routes/analysis/query/query.component.less @@ -0,0 +1,21 @@ +.header-info { + position: relative; + text-align: center; + > em { + background-color: #e8e8e8; + position: absolute; + height: 56px; + width: 1px; + top: 0; + right: 0; + } +} + +@media screen and (max-width: 576px) { + .header-info { + margin-bottom: 16px; + > em { + display: none; + } + } +} diff --git a/src/app/routes/analysis/query/query.component.ts b/src/app/routes/analysis/query/query.component.ts new file mode 100644 index 0000000..6ab3e45 --- /dev/null +++ b/src/app/routes/analysis/query/query.component.ts @@ -0,0 +1,92 @@ +import { getService } from './../../../../testing/common.spec'; +import { LineChartCriteria, TimePeriod } from './../../../business/entity/data'; +import { PageBean } from '@business/entity/grid'; +import { Sensor } from '@business/entity/data'; +import { SensorsService } from '@business/services/http/sensors.service'; +import { Component, OnInit } from '@angular/core'; +import { _HttpClient } from '@delon/theme'; +import { TimeUnits } from '@business/enum/types.enum'; +import * as moment from 'moment'; + +@Component({ + selector: 'app-query', + templateUrl: './query.component.html', + styleUrls: [ './query.component.less' ] +}) +export class QueryComponent implements OnInit { + public sensorList:Sensor[]; + public timeUnits:{ label: string, value: TimeUnits, disabled: boolean }[] = []; + // public timePeriod:TimePeriod = {startTime:null,endTime:null}; + public lineChartCriteria:LineChartCriteria = {sensorKey:'e1', timePeriod:{startTime:null,endTime:null},dataConditions:[]}; + + get lineChartSensorName():String{ + return !!this.sensorList?this.sensorList.find( sensor => sensor.sensorKey==this.lineChartCriteria.sensorKey).name:null; + } + private _timePeriodUnitValue:TimeUnits=TimeUnits.DAY; + public set timePeriodUnitValue(value:TimeUnits){ + this._timePeriodUnitValue = value; + switch(value){ + //YYYY-MM-DD HH:mm:ss + case TimeUnits.MONTH: + this.timeType.dateFormat ="YYYY-MM"; + this.timeType.mode = "month"; + this.timeType.timePickerOption = null; + break; + case TimeUnits.DAY: + this.timeType.dateFormat ="YYYY-MM-DD"; + this.timeType.mode = "day"; + this.timeType.timePickerOption = null; + break; + case TimeUnits.HOUR: + this.timeType.dateFormat ="YYYY-MM-DD HH ���"; + this.timeType.timePickerOption = {nzFormat:"HH:mm"}; + break; + } + } + public timeType:{dateFormat?:string,mode?:'year'|'month'|'day',timePickerOption?:{}} + = {dateFormat:"YYYY-MM-DD",mode:"day",timePickerOption:null}; + get timePeriodUnitName():String { + return this.timeUnits.find( item => item.value == this._timePeriodUnitValue).label; + } + constructor( + private sensorsService:SensorsService + ) { + this.initPage(); + } + private initPage(){ + this.sensorsService.getPagingList(null,null).subscribe( + (res: PageBean) => { + this.sensorList = res.data; + } + ); + this.timeUnits.push( + {label:'���',value:TimeUnits.YEAR,disabled:false}, + {label:'���',value:TimeUnits.MONTH,disabled:false}, + {label:'���',value:TimeUnits.DAY,disabled:false}, + {label:'���',value:TimeUnits.HOUR,disabled:false}, + {label:'���',value:TimeUnits.MINUTE,disabled:false} + ); + } + ngOnInit() { + } + get _isSameDay() { + console.log(this.lineChartCriteria.timePeriod.startTime && this.lineChartCriteria.timePeriod.endTime && moment(this.lineChartCriteria.timePeriod.startTime).isSame(this.lineChartCriteria.timePeriod.endTime, 'day')); + return this.lineChartCriteria.timePeriod.startTime && this.lineChartCriteria.timePeriod.endTime && moment(this.lineChartCriteria.timePeriod.startTime).isSame(this.lineChartCriteria.timePeriod.endTime, 'day'); + } + _disabledStartDate = (startValue) => { + if (!startValue || !this.lineChartCriteria.timePeriod.endTime) { + return false; + } + console.log(startValue); + console.log("getTime:"+startValue.getTime()); + let _startValue = moment(startValue,this.timeType.dateFormat); + console.log("valueOf:"+_startValue.valueOf()); + return _startValue.valueOf() > this.lineChartCriteria.timePeriod.endTime; + }; + _disabledEndDate = (endValue) => { + if (!endValue || !this.lineChartCriteria.timePeriod.startTime) { + return false; + } + return endValue.getTime() < this.lineChartCriteria.timePeriod.startTime; + }; +} diff --git a/src/app/routes/routes-routing.module.ts b/src/app/routes/routes-routing.module.ts index 4cb980b..7a4e094 100644 --- a/src/app/routes/routes-routing.module.ts +++ b/src/app/routes/routes-routing.module.ts @@ -31,6 +31,7 @@ { path: 'sensors', loadChildren: './sensors/sensors.module#SensorsModule' }, { path: 'systems', loadChildren: './systems/systems.module#SystemsModule' }, { path: 'reports', loadChildren: './reports/reports.module#ReportsModule' }, + { path: 'analysis', loadChildren: './analysis/analysis.module#AnalysisModule' }, ] }, // passport { diff --git a/src/app/routes/systems/organization/organization-config/organization-config.component.ts b/src/app/routes/systems/organization/organization-config/organization-config.component.ts index f73e7b6..50c4d60 100644 --- a/src/app/routes/systems/organization/organization-config/organization-config.component.ts +++ b/src/app/routes/systems/organization/organization-config/organization-config.component.ts @@ -2,7 +2,6 @@ import { filter } from 'rxjs/operators'; import { HttpClient } from '@angular/common/http'; import { FormGroup, FormBuilder, FormControl, Validators, FormArray, AbstractControl } from '@angular/forms'; -import { SensorsService } from '@business/services/http/sensors.service'; import { Grid, PageBean } from '@business/entity/grid'; import { Organization, AlarmConfig, AlarmSensorLevel, AlarmConfigValue } from '@business/entity/data'; import { Component, OnInit, OnDestroy } from '@angular/core'; @@ -28,7 +27,6 @@ validateForm: FormGroup; constructor( private organizationService: OrganizationService, - private sensorsService: SensorsService, private alarmConfigService: AlarmConfigService, private formBuilder: FormBuilder, private http: _HttpClient, diff --git a/src/assets/app-data.json b/src/assets/app-data.json index b19eb23..420b56d 100644 --- a/src/assets/app-data.json +++ b/src/assets/app-data.json @@ -73,21 +73,17 @@ "link": "/sensors/basic" }] }, { - "text": "������������", - "icon": "icon-note", + "text": "������������", + "icon": "icon-graph", "children": [ { - "text": "������������", - "link": "/systems/account" - }, - { - "text": "������������", - "link": "/systems/organization" - } + "text": "������������", + "link": "/analysis/query" + } ] }, { "text": "������������", - "icon": "icon-note", + "icon": "icon-chart", "children": [ { "text": "���������������", @@ -98,8 +94,20 @@ "link": "/reports/excel" } ] + }, { + "text": "������������", + "icon": "icon-settings", + "children": [ + { + "text": "������������", + "link": "/systems/account" + }, + { + "text": "������������", + "link": "/systems/organization" + } + ] } - ] -- Gitblit v1.8.0