| | |
| | | import * as moment from 'moment'; |
| | | import { ExampleService } from '@business/services/util/example.service'; |
| | | import { DeviceService } from '@business/services/http/device.service'; |
| | | import { environment } from '@env/environment'; |
| | | import { CascaderOption } from 'ng-zorro-antd/src/cascader/nz-cascader.component'; |
| | | import { AreacodeService } from '@business/services/http/areacode.service'; |
| | | import { MonitorPointService } from '@business/services/http/monitor-point.service'; |
| | |
| | | this.isChartCollapse = !this.isChartCollapse; |
| | | } |
| | | public deviceOptions: Device[] = []; |
| | | public dataCondition: DataCondition = {areaRangeId: 320583, areaRange: AreaRange.AREA, deviceDimension:DeviceDimension.NONE}; |
| | | public dataCondition: DataCondition = {areaRangeId: 320583, areaRange: AreaRange.AREA, deviceDimension: DeviceDimension.NONE}; |
| | | |
| | | public dimensionOptions: MonitorPoint[] = []; |
| | | |
| | |
| | | set actualYear(year) { |
| | | this.actualTime.setFullYear(Number(year)); |
| | | } |
| | | dimensionsChange(text?: string){ |
| | | switch(this.dimensionItem.value){ |
| | | dimensionsChange(text?: string) { |
| | | switch (this.dimensionItem.value) { |
| | | case DeviceDimension.MONITORPOINT: |
| | | this.monitorPointsChange(text);break; |
| | | this.monitorPointsChange(text); break; |
| | | case DeviceDimension.PROFESSION: |
| | | this.professionsChange(text);break; |
| | | this.professionsChange(text); break; |
| | | } |
| | | } |
| | | professionsChange(text?: string){ |
| | | this.http.get<ResultBean<any[]>>(environment.SERVER_BASH_URL+"profession/getall").subscribe( |
| | | professionsChange(text?: string) { |
| | | this.http.get<ResultBean<any[]>>('profession/getall').subscribe( |
| | | result => { |
| | | if(!!result.code){ |
| | | if (!!result.code) { |
| | | this.dimensionOptions = result.data; |
| | | } |
| | | } |
| | |
| | | if (!!this.deviceDimension) { |
| | | const example = new ExampleService(); |
| | | const deviceDimensionProperty = |
| | | this.dimensionItem.value === DeviceDimension.MONITORPOINT ?'monitorPointId':'professionId'; |
| | | this.dimensionItem.value === DeviceDimension.MONITORPOINT ? 'monitorPointId' : 'professionId'; |
| | | if (!!text) { |
| | | example.or().andEqualTo({ name: deviceDimensionProperty, value: this.deviceDimension.id }) |
| | | .andLike({name: 'text', value: text}); |
| | |
| | | ); |
| | | this.actualYearOptions = this.newArray(this.actualYear - 9, 10).map(item => Number(item)).reverse(); |
| | | // 省市区 初始值 |
| | | this.http.get(environment.SERVER_BASH_URL + 'organization/get-my-org').subscribe( |
| | | this.http.get('organization/get-my-org').subscribe( |
| | | (res: ResultBean<Organization>) => { |
| | | if (res.code === ResultCode.SUCCESS) { |
| | | const org = res.data; |
| | |
| | | this.dimensionItem = this.dimensions[0]; |
| | | // this.dimensionsChange(); |
| | | } |
| | | public get sensorsLength():number { |
| | | return this.sensorOptions.length>0?this.sensorOptions[0].children.length:0; |
| | | public get sensorsLength(): number { |
| | | return this.sensorOptions.length > 0 ? this.sensorOptions[0].children.length : 0; |
| | | } |
| | | public get sensorsSelect():number{ |
| | | public get sensorsSelect(): number { |
| | | return Object.keys(this._sensors).length; |
| | | } |
| | | public areaLazyLoad(event: { option: CascaderOption, index: number, resolve: (children: CascaderOption[]) => void, reject: () => void }) { |
| | |
| | | if ( isChanged ) { |
| | | this._areas = areas; |
| | | this.deviceDimension = null; |
| | | if(this.dimensionItem.value === DeviceDimension.MONITORPOINT){ |
| | | if (this.dimensionItem.value === DeviceDimension.MONITORPOINT) { |
| | | this.dimensionsChange(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 第二步 设置 监控站点, 值变 改变设备选项,值为null 置空设备选项和设备值 |
| | | public dimensionItem:{label: string,value: DeviceDimension}; |
| | | public dimensions:{label: string,value: DeviceDimension}[] = [ |
| | | {label:"监控站点",value:DeviceDimension.MONITORPOINT}, |
| | | {label:"监控行业",value:DeviceDimension.PROFESSION} |
| | | public dimensionItem: {label: string, value: DeviceDimension}; |
| | | public dimensions: {label: string, value: DeviceDimension}[] = [ |
| | | {label: '监控站点', value: DeviceDimension.MONITORPOINT}, |
| | | {label: '监控行业', value: DeviceDimension.PROFESSION} |
| | | ]; |
| | | public get otherDimensions():{label: string,value: DeviceDimension}[] { |
| | | public get otherDimensions(): {label: string, value: DeviceDimension}[] { |
| | | return this.dimensions.filter( |
| | | item => { |
| | | return item.value != this.dimensionItem.value; |
| | | return item.value !== this.dimensionItem.value; |
| | | } |
| | | ); |
| | | } |
| | | public selectDimension(option:{label: string,value: DeviceDimension}){ |
| | | public selectDimension(option: {label: string, value: DeviceDimension}) { |
| | | this.dimensionItem = option; |
| | | this.dimensionsChange(); |
| | | this._deviceDimension = null; |
| | |
| | | this.device = null; |
| | | this.deviceOptions = null; |
| | | } |
| | | public _deviceDimension: {id: number,name: string}; |
| | | get deviceDimension(): {id: number,name: string} { |
| | | public _deviceDimension: {id: number, name: string}; |
| | | get deviceDimension(): {id: number, name: string} { |
| | | return this._deviceDimension; |
| | | } |
| | | set deviceDimension(value) { |
| | |
| | | const dimValue: number = !!this._deviceDimension ? this._deviceDimension.id : null; |
| | | const devValue: number = !!this._device ? this._device.id : null; |
| | | const areasData = [ devValue, dimValue, Number(this._areas.slice(-1).pop().value)]; |
| | | if(!!this.deviceDimension){ |
| | | if (!!this.deviceDimension) { |
| | | this.dataCondition.dimensionValue = this._deviceDimension.id; |
| | | this.dataCondition.deviceDimension = this.dimensionItem.value; |
| | | } |
| | |
| | | case 0: this.dataCondition.areaRange = AreaRange.DEVICE; break; |
| | | case 1: |
| | | // 维度为监控点 |
| | | if(this.dimensionItem.value === DeviceDimension.MONITORPOINT){ |
| | | if (this.dimensionItem.value === DeviceDimension.MONITORPOINT) { |
| | | this.dataCondition.areaRange = AreaRange.MONITORPOINT; |
| | | // 维度为行业 |
| | | }else{ |
| | | } else { |
| | | // 重新标定区域范围 |
| | | this.switchAreas(); |
| | | // 重新设置区域值 |
| | |
| | | // 清空数据 |
| | | this.grid.data = []; |
| | | console.log(lineChartCriteria); |
| | | this.http.post(environment.SERVER_BASH_URL + '/report/line-chart', lineChartCriteria).subscribe( |
| | | this.http.post('/report/line-chart', lineChartCriteria).subscribe( |
| | | (res: ResultBean<{[key: string]: Array<Array<number>>}>) => { |
| | | if (res.code === 1) { |
| | | const data = res.data; |
| | |
| | | } |
| | | ); |
| | | } |
| | | private switchAreas(): void{ |
| | | private switchAreas(): void { |
| | | switch (this._areas.length ) { |
| | | case 1: this.dataCondition.areaRange = AreaRange.PROVINCE; break; |
| | | case 2: this.dataCondition.areaRange = AreaRange.CITY; break; |
| | |
| | | public _chartTitleTemp = ''; |
| | | public _tableTitleTemp = ''; |
| | | public reloadChartTitle(): void { |
| | | const names = ['辖区', '地区', '维度','时间','项目']; |
| | | const names = ['辖区', '地区', '维度', '时间', '项目']; |
| | | switch ( this.dataCondition.areaRange ) { |
| | | case AreaRange.MONITORPOINT : |
| | | names[0] = '监控站点'; |
| | |
| | | break; |
| | | } |
| | | // 维度命名 |
| | | if(!!this._deviceDimension){ |
| | | switch(this.dataCondition.deviceDimension){ |
| | | if (!!this._deviceDimension) { |
| | | switch (this.dataCondition.deviceDimension) { |
| | | case DeviceDimension.PROFESSION : |
| | | names[2] ='['+this._deviceDimension.name+']'; |
| | | names[2] = '[' + this._deviceDimension.name + ']'; |
| | | break; |
| | | default : |
| | | names[2] =''; |
| | | names[2] = ''; |
| | | break; |
| | | } |
| | | }else{ |
| | | names[2] =''; |
| | | } else { |
| | | names[2] = ''; |
| | | } |
| | | |
| | | names[3] = moment(this.actualTime).format(this._timeType.dateFormat); |