src/app/app.component.ts
@@ -32,14 +32,14 @@ ) .subscribe(() => { // 删除多余透明蒙版中元素 let cdkOverlayContainer = $('.cdk-overlay-container'); const cdkOverlayContainer = $('.cdk-overlay-container'); if(cdkOverlayContainer!=null&&cdkOverlayContainer.children().length>1){ cdkOverlayContainer.children('div:first-child').nextAll().each( function(index,element){ if($(element).hasClass('cdk-overlay-backdrop-showing')){ $(element).remove(); function(index, el) { if ($(el).hasClass('cdk-overlay-backdrop-showing')) { $(el).remove(); }else{ $(element).empty(); $(el).empty(); } } ); src/app/business/entity/data.ts
@@ -34,7 +34,7 @@ provinceCode?: Column|any; rank?: Column|any; telephone?: Column|any; areaNames?: AreaNames|any ; areaNames?: AreaNames; } // 设备型号 @@ -135,14 +135,14 @@ username: string; } export interface TimePeriod{ startTime:number;//开始时间 endTime:number;//结束时间 startTime: Date; // 开始时间 endTime: Date; // 结束时间 } export interface DataCondition{ timeUnits:TimeUnits;//单位 actualTime:number;//实际时间 areaRange:AreaRange;//区域范围 areaRangeId:number;//区域范围的ID timeUnits?: TimeUnits; // 单位 actualTime?: Date; // 实际时间 areaRange?: AreaRange; // 区域范围 areaRangeId?: number; // 区域范围的ID } export interface LineChartCriteria{ sensorKey:String; src/app/business/entity/grid.ts
src/app/business/entity/token.ts
src/app/business/enum/patterns.enum.ts
src/app/business/enum/types.enum.ts
@@ -11,3 +11,6 @@ export enum AreaRange { PROVINCE='PROVINCE',CITY='CITY',AREA='AREA',MONITORPOINT='MONITORPOINT',DEVICE='DEVICE' } export enum ResultCode { SUCCESS= 1, FAIL= 0 } src/app/business/services/http/alarm-config.service.ts
src/app/business/services/http/device-adjust-value.service.ts
src/app/business/services/http/device.service.ts
src/app/business/services/http/login.service.ts
@@ -16,7 +16,7 @@ }; constructor(private http:HttpClient) { } public validate(username:string,password:string):Observable<Authorization>{ return this.http.post(this.urls.login,{username:username,password:password,mode:"Web"}).map( return this.http.post(this.urls.login, {username: username, password: password, mode: 'Web'}).map( (res:any) => { this.authorization = res; return res; src/app/business/services/http/monitor-point.service.ts
@@ -24,13 +24,32 @@ example.or().andLike({name: 'name', value: '%' + queryText + '%'}); } let orderByClause = ''; if (!!page) { if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { orderByClause = page.getOrderByClause(); } } else { page = {pageIndex: 0, pageSize: 20}; } const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, queryParams: example.getSqlParam(), orderByClause: orderByClause}; return this.http.get(this.urls.list, param); } public getPageByExample(page: PageBean, example: ExampleService): Observable<PageBean> { let orderByClause = ''; const _queryParams = !!example ? example.getSqlParam() : ''; if (!!page) { if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { orderByClause = page.getOrderByClause(); } } else { page = {pageIndex: 0, pageSize: 20}; } const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, queryParams: _queryParams, orderByClause: orderByClause}; return this.http.get(this.urls.list, param); } public save(data: any): Observable<any> { return this.http.post(this.urls.save, data); } src/app/business/services/http/organization.service.ts
src/app/business/services/http/sensors.service.ts
src/app/business/services/http/version.service.ts
src/app/business/services/util/example.service.ts
src/app/business/services/util/tools.service.ts
@@ -13,7 +13,7 @@ control.markAsDirty(); } } ) ); } public static removePrivate(obj:object){ Object.keys(obj).forEach( src/app/core/i18n/i18n.service.ts
src/app/core/net/default.interceptor.ts
@@ -28,7 +28,7 @@ private handleData(event: HttpResponse<any> | HttpErrorResponse): Observable<any> { // 可能会因为 `throw` 导出无法执行 `_HttpClient` 的 `end()` 操作 this.injector.get(_HttpClient).end(); // this.injector.get(_HttpClient).end(); // 业务处理:一些通用操作 switch (event.status) { case 200: @@ -52,8 +52,13 @@ this.goTo(`/${event.status}`); break; } // 这里不抛出错误 httpclient 无法捕捉 if (event instanceof HttpErrorResponse) { return ErrorObservable.create(event); } else { return of(event); } } intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> { src/app/routes/analysis/analysis.module.ts
@@ -1,3 +1,5 @@ import { MonitorPointService } from '@business/services/http/monitor-point.service'; import { AreacodeService } from '@business/services/http/areacode.service'; import { SensorsService } from '@business/services/http/sensors.service'; import { PipeModule } from '@business/pipe/pipe.module'; import { NgModule } from '@angular/core'; @@ -23,6 +25,6 @@ RouterModule.forChild(routes) ], declarations: [QueryComponent], providers:[SensorsService] providers: [SensorsService, AreacodeService, MonitorPointService] }) export class AnalysisModule { } src/app/routes/analysis/query/query.component.html
@@ -4,11 +4,13 @@ <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> <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> <li style="width:200px; cursor:pointer;" *ngFor="let sensor of sensorList" (click)="lineChartCriteria.sensorKey=sensor.sensorKey" nz-menu-item> <p> {{sensor.name}} </p> @@ -21,11 +23,12 @@ <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> <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> <li style="width:60px; cursor:pointer;" *ngFor="let item of timeUnits" (click)="timePeriodUnitValue = item.value" nz-menu-item> <p> {{item.label}} </p> @@ -34,18 +37,97 @@ </nz-dropdown> <em></em> </div> <div *ngIf="_timePeriodUnitValue!='YEAR'; else elseBlock" 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> <ng-template #elseBlock> <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> <nz-input-number style="width: 42%;" [(ngModel)]="startYear" [nzMin]="minStartYear" [nzMax]="maxStartYear" [nzStep]="1" [nzAllowClear]="false"></nz-input-number> <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> <nz-input-number style="width: 42%;" [(ngModel)]="endYear" [nzMin]="minEndYear" [nzMax]="maxEndYear" [nzStep]="1" [nzAllowClear]="false"></nz-input-number> </div> <input type="button" value="text" width="100px;" (click)="_isSameDay"/> </ng-template> </div> </nz-card> <nz-card [nzBordered]="true" title="数据取样"> <form> <div nz-row [nzGutter]="16"> <div nz-col nzMd="6" nzSm="12" nzXs="24"> <div nz-form-item nz-row> <div nz-form-label nz-col><label>省市区</label></div> <div nz-form-control nz-col nzHasFeedback> <nz-cascader [class.class123]="true" (nzChange)="setAreaCodes($event)" (nzLoad)="areaLazyLoad($event)" [nzPlaceHolder]="'选择 省/市/区'" [nzAllowClear]="false" [nzChangeOnSelect] ="true" [(ngModel)]="_areas" name="_areas"> </nz-cascader> </div> </div> </div> <div nz-col [nzMd]="{span:6, offset:3}" nzSm="12" nzXs="24"> <div nz-form-item nz-row> <div nz-form-label nz-col><label>监控点</label></div> <div nz-form-control nz-col nzHasFeedback> <nz-select name="_monitorPoint" style="width: 100%;" (click)="monitorPointChange(null)" [ngModel]="_monitorPoint" nzAllowClear (ngModelChange)="setMonitorPoint($event)" [nzPlaceHolder]="'选择 监控点(输入名称搜索)'" nzShowSearch (nzSearchChange)="monitorPointChange($event)" [nzNotFoundContent]="'无法找到'" > <nz-option *ngFor="let option of monitorPoints" [nzLabel]="option.name" [nzValue]="option.id"> </nz-option> </nz-select> </div> </div> </div> <div nz-col [nzMd]="{span:6, offset:3}" nzSm="12" nzXs="24"> <div nz-form-item nz-row> <div nz-form-label nz-col><label>设备</label></div> <div nz-form-control nz-col nzHasFeedback> 11111111111111111 </div> </div> </div> </div> <div style="margin-top: 20px;" nz-row [nzGutter]="16"> <div nz-col nzMd="6" nzSm="12" nzXs="24"> <div nz-form-item nz-row> <div nz-form-label nz-col><label>时间单位</label></div> <div nz-form-control nz-col nzHasFeedback> 222222222 </div> </div> </div> <div nz-col [nzMd]="{span:6, offset:3}" nzSm="12" nzXs="24"> <div nz-form-item nz-row> <div nz-form-label nz-col><label>具体时间</label></div> <div nz-form-control nz-col nzHasFeedback> 2222222222 </div> </div> </div> <div nz-col [nzMd]="{span:6, offset:3}" nzSm="12" nzXs="24"> <div nz-form-item nz-row> <div nz-form-label nz-col><label>设备</label></div> <div nz-form-control nz-col nzHasFeedback> 2222222222 </div> </div> </div> </div> </form> </nz-card> src/app/routes/analysis/query/query.component.ts
@@ -1,11 +1,17 @@ import { LineChartCriteria, TimePeriod } from '@business/entity/data'; import { PageBean } from '@business/entity/grid'; import { ExampleService } from '@business/services/util/example.service'; import { MonitorPointService } from '@business/services/http/monitor-point.service'; import { AreacodeService } from '@business/services/http/areacode.service'; import { DataCondition } from './../../../business/entity/data'; import { LineChartCriteria, TimePeriod, Organization, MonitorPoint } from '@business/entity/data'; import { PageBean, ResultBean } 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 { TimeUnits, AreaRange, ResultCode } from '@business/enum/types.enum'; import * as moment from 'moment'; import { CascaderOption } from 'ng-zorro-antd/src/cascader/nz-cascader.component'; import { environment } from '@env/environment'; @Component({ selector: 'app-query', @@ -15,43 +21,53 @@ 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:[]}; _areas: {label: any, value: any}; _monitorPoint; public monitorPoints: MonitorPoint[]; get lineChartSensorName():String{ return !!this.sensorList?this.sensorList.find( sensor => sensor.sensorKey==this.lineChartCriteria.sensorKey).name:null; return !!this.sensorList ? this.sensorList.find( sensor => sensor.sensorKey === this.lineChartCriteria.sensorKey).name : null; } private _timePeriodUnitValue:TimeUnits=TimeUnits.DAY; public _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.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.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"}; this.timeType.dateFormat = 'YYYY-MM-DD HH 时'; this.timeType.mode = 'day'; this.timeType.timePickerOption = true; break; case TimeUnits.MINUTE: this.timeType.dateFormat = 'YYYY-MM-DD HH:mm'; this.timeType.mode = 'day'; this.timeType.timePickerOption = true; break; } } public timeType:{dateFormat?:string,mode?:'year'|'month'|'day',timePickerOption?:{}} = {dateFormat:"YYYY-MM-DD",mode:"day",timePickerOption:null}; public timeType: {dateFormat?: string, mode?: 'month'|'day', timePickerOption?: boolean} = {dateFormat: 'YYYY-MM-DD', mode: 'day', timePickerOption: null}; get timePeriodUnitName():String { return this.timeUnits.find( item => item.value == this._timePeriodUnitValue).label; return this.timeUnits.find( item => item.value === this._timePeriodUnitValue).label; } constructor( private sensorsService:SensorsService private sensorsService: SensorsService, private areacodeService: AreacodeService, private http: _HttpClient, private monitorPointService: MonitorPointService, ) { this.initPage(); } private initPage(){ this.sensorsService.getPagingList(null,null).subscribe( (res: PageBean) => { @@ -65,27 +81,260 @@ {label:'时',value:TimeUnits.HOUR,disabled:false}, {label:'分',value:TimeUnits.MINUTE,disabled:false} ); const now = new Date(); this.lineChartCriteria.timePeriod.startTime = now; this.lineChartCriteria.timePeriod.endTime = new Date(now.getTime()); // 省市区 初始值 this.http.get(environment.SERVER_BASH_URL + 'organization/get-my-org').subscribe( ( res: ResultBean<Organization>) => { if (res.code === ResultCode.SUCCESS) { const org = res.data; if (!!org.areaNames) { const areaNames = org.areaNames; this._areas = {label: null, value: null}; this._areas.label = Object.values(areaNames).filter( val => !!val ).join('/'); if (areaNames.areaName != null) { this._areas.value = org.areaCode; this.dataConditionTemp.areaRange = AreaRange.AREA; this.dataConditionTemp.areaRangeId = org.areaCode; } else if (areaNames.cityName != null) { this._areas.value = org.cityCode; this.dataConditionTemp.areaRange = AreaRange.CITY; this.dataConditionTemp.areaRangeId = org.cityCode; } else { this._areas.value = org.provinceCode; this.dataConditionTemp.areaRange = AreaRange.PROVINCE; this.dataConditionTemp.areaRangeId = org.provinceCode; } } else { this._areas = {label: '江苏省/苏州市/昆山市', value: 320583}; this.dataConditionTemp.areaRange = AreaRange.AREA; this.dataConditionTemp.areaRangeId = 320583; } } } ); } monitorPointChange(text) { const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; const example = new ExampleService(); let areaName = ''; switch (this.dataConditionTemp.areaRange) { case AreaRange.PROVINCE: areaName = 'provinceCode'; break; case AreaRange.CITY: areaName = 'cityCode'; break; case AreaRange.AREA: areaName = 'areaCode'; break; } if (!!text) { example.or().andLike({name: 'name', value: '%' + text + '%'}) .andEqualTo({name: areaName, value: this.dataConditionTemp.areaRangeId}); } else { example.or() .andEqualTo({name: areaName, value: this.dataConditionTemp.areaRangeId}); } this.monitorPointService.getPageByExample(pageBean, example).subscribe( (res: PageBean) => { if (!!res && !!res.data) { this.monitorPoints = res.data; } } ); } ngOnInit() { this.initPage(); } 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) => { get _startShowTime() { return this.timeType.timePickerOption ? {nzHideDisabledOptions: true, nzDisabledHours: () => { const endTime = this.lineChartCriteria.timePeriod.endTime; const hours = this.newArray(50); return this._isSameDay && !!endTime ? hours.slice(endTime.getHours() + 1, 24) : []; }, nzDisabledMinutes: (h) => { if (this._timePeriodUnitValue === TimeUnits.MINUTE) { const endTime = this.lineChartCriteria.timePeriod.endTime; if (this._isSameDay && h === endTime.getHours()) { const minutes = this.newArray(122); return minutes.slice(endTime.getMinutes() + 1, 60); } else { return []; } } else { return this.newArray(60).slice(1); } }, nzDisabledSeconds: () => { return this.newArray(60).slice(1); } } : false; } get _endShowTime() { return this.timeType.timePickerOption ? {nzHideDisabledOptions: true, nzDisabledHours: () => { const startTime = this.lineChartCriteria.timePeriod.startTime; return this._isSameDay && !!startTime ? this.newArray(startTime.getHours()) : []; }, nzDisabledMinutes: (h) => { if (this._timePeriodUnitValue === TimeUnits.MINUTE) { const startTime = this.lineChartCriteria.timePeriod.startTime; if (this._isSameDay && h === startTime.getHours()) { return this.newArray(startTime.getMinutes()); } else { return []; } } else { return this.newArray(60).slice(1); } }, nzDisabledSeconds: () => { return this.newArray(60).slice(1); } } : false; } newArray = (len) => { const result = []; for (let i = 0; i < len; i++) { result.push(i); } return result; } _disabledStartDate = (startValue: Date) => { 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) => { let format = this.timeType.dateFormat; // 单位为时,开始日期中 日默认时间设置为 00.00.00 if (format.indexOf('H', 11)) { format = format.replace(/HH.*/, ''); } const _startValue = moment(moment(startValue).format(format), format); return _startValue.valueOf() > this.lineChartCriteria.timePeriod.endTime.getTime(); } _disabledEndDate = (endValue: Date) => { if (!endValue || !this.lineChartCriteria.timePeriod.startTime) { return false; } return endValue.getTime() < this.lineChartCriteria.timePeriod.startTime; }; const _endValue: Date = new Date(endValue.getTime()); _endValue.setHours(23); _endValue.setMinutes(59); _endValue.setSeconds(59); return _endValue.getTime() < this.lineChartCriteria.timePeriod.startTime.getTime(); } _timeChange = (type: string) => { const startTime = this.lineChartCriteria.timePeriod.startTime; const endTime = this.lineChartCriteria.timePeriod.endTime; if (type === 'start') { !!endTime ? '' : this.lineChartCriteria.timePeriod.endTime = startTime; } else { !!startTime ? '' : this.lineChartCriteria.timePeriod.startTime === endTime; } } get startYear(): number { !!this.lineChartCriteria.timePeriod.startTime ? '' : this.lineChartCriteria.timePeriod.startTime = new Date(); return this.lineChartCriteria.timePeriod.startTime.getFullYear(); } set startYear(value) { !!this.lineChartCriteria.timePeriod.startTime ? '' : this.lineChartCriteria.timePeriod.startTime = new Date(); if (this.startYear === this.endYear && value < this.startYear) { // 异步调用防止循环 setTimeout(() => { this.endYear += 1; }, 1); } this.lineChartCriteria.timePeriod.startTime.setFullYear(value); } get minStartYear(): number { const now = new Date(); return now.getFullYear() - 50; } get maxStartYear(): number { return this.endYear; } get endYear(): number { !!this.lineChartCriteria.timePeriod.endTime ? '' : this.lineChartCriteria.timePeriod.endTime = new Date(); return this.lineChartCriteria.timePeriod.endTime.getFullYear(); } set endYear(value) { !!this.lineChartCriteria.timePeriod.endTime ? '' : this.lineChartCriteria.timePeriod.endTime = new Date(); if (this.startYear === this.endYear && value > this.startYear) { // 异步调用防止循环 setTimeout(() => { this.startYear -= 1; }, 1); } this.lineChartCriteria.timePeriod.endTime.setFullYear(value); } get minEndYear(): number { return this.startYear; } get maxEndYear(): number { const now = new Date(); return now.getFullYear() + 50; } dataConditionTemp: DataCondition = {}; areaLazyLoad(event: { option: CascaderOption, index: number, resolve: (children: CascaderOption[]) => void, reject: () => void }) { const index = event['index']; const option = event.option; switch (index) { case -1: this.areacodeService.getProvinces().subscribe( (res: {label: string, value: string}[]) => { event.resolve( res ); } ); break; case 0: this.areacodeService.getCities(option.value).subscribe( (res: {label: string, value: string}[]) => { event.resolve( res ); } ); break; case 1: this.areacodeService.getAreas(option.value).subscribe( (res: {label: string, value: string}[]) => { event.resolve( res ); } ); break; } } setAreaCodes(codes: string[]) { if (!!codes && !!codes.length) { const n = codes.length; switch (n) { case 1: this.dataConditionTemp.areaRangeId = Number(codes[0]); this.dataConditionTemp.areaRange = AreaRange.PROVINCE; break; case 2: this.dataConditionTemp.areaRangeId = Number(codes[1]); this.dataConditionTemp.areaRange = AreaRange.CITY; break; case 3: this.dataConditionTemp.areaRangeId = Number(codes[2]); this.dataConditionTemp.areaRange = AreaRange.AREA; break; } this._monitorPoint = 1; } } setMonitorPoint(value) { console.log(value); this.dataConditionTemp.areaRangeId = value; this.dataConditionTemp.areaRange = AreaRange.MONITORPOINT; } } src/app/routes/dashboard/v1/v1.component.ts
src/app/routes/devices/basic-info/adjust-config/adjust-config.component.ts
@@ -75,7 +75,7 @@ this.sensorsService.getPageByVersionId(this.record.deviceVersionId) ).subscribe( ([adjustRes,sensorsRes]) => { if(adjustRes!=null && adjustRes.code==1 && sensorsRes != null && sensorsRes.data != null){ if (adjustRes != null && adjustRes.code === 1 && sensorsRes != null && sensorsRes.data != null) { this.data = { deviceId:this.record.id, value:{} @@ -104,7 +104,7 @@ } save($event) { // $event.preventDefault(); let isModify = Object.keys(this._dataValue).length != Object.keys(this.data.value).length; let isModify = Object.keys(this._dataValue).length !== Object.keys(this.data.value).length; if(!isModify){ isModify = Object.keys(this.data.value).some( key => { @@ -112,11 +112,10 @@ } ); } debugger; if(isModify){ this.adjustValueService.save(this.data).subscribe( (res:ResultBean<any>) =>{ if(res!=null&&res.code==1){ if (res != null && res.code === 1) { this.subject.destroy(); this.msgSrv.success('校准值配置成功'); } src/app/routes/devices/basic-info/basic-info.component.html
src/app/routes/devices/basic-info/basic-info.component.ts
@@ -80,7 +80,7 @@ }); } get listUrl() { return this.deviceService.getListUrl();; return this.deviceService.getListUrl(); } extraParams = { queryParams: null }; queryText: string; @@ -159,10 +159,10 @@ } configCoord(record:Device):void { Object.assign(this.coorPickerService.data,record); let _data = this.coorPickerService.data; const _data = this.coorPickerService.data; this.monitorPointService.getEntity(record.monitorPointId).subscribe( res => { if(res!=null && res.code==1 && res.data!=null){ if (res != null && res.code === 1 && res.data != null) { const areaNames = res.data.areaNames; let adress = null; if(areaNames != null){ @@ -177,10 +177,10 @@ id:record.id, longitude:_data.longitude, latitude:_data.latitude, } }; this.deviceService.save(data).subscribe( (res: any) => { if (res.code === 1) { (resp: any) => { if (resp.code === 1) { this.load(); this.msgSrv.success('坐标配置成功!'); } @@ -190,6 +190,6 @@ } ); } ) ); } } src/app/routes/devices/basic-info/device-edit/device-edit.component.ts
src/app/routes/devices/devices.module.ts
src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts
src/app/routes/devices/monitor-point/monitor-point.component.ts
@@ -179,7 +179,7 @@ } configCoord(record: MonitorPoint): void { Object.assign(this.coorPickerService.data, record); let _data = this.coorPickerService.data; const _data = this.coorPickerService.data; const areaNames = record.areaNames; let adress = null; if (areaNames != null) { @@ -193,7 +193,7 @@ id: record.id, longitude: _data.longitude, latitude: _data.latitude, } }; this.monitorPointService.save(data).subscribe( (res: any) => { if (res.code === 1) { src/app/routes/devices/version/version-edit/version-edit.component.ts
src/app/routes/map/coordinates-picker/coordinates-picker.component.ts
@@ -32,10 +32,10 @@ constructor(private subject:NzModalSubject,private coorPickerService:CoorPickerService) { this.data = this.coorPickerService.data; let lng = this.data.longitude; lng = lng ==0 || lng == null ? this.Default_LNG:lng; lng = lng === 0 || lng == null ? this.Default_LNG : lng; this.data.longitude = lng; let lat = this.data.latitude; lat = lat == 0||lat == null ? this.Default_LAT:lat; lat = lat === 0 || lat == null ? this.Default_LAT : lat; this.data.latitude = lat; this.options = { minZoom:3, @@ -51,7 +51,7 @@ this.navigationOpts = { anchor: ControlAnchor.BMAP_ANCHOR_BOTTOM_RIGHT, type: NavigationControlType.BMAP_NAVIGATION_CONTROL_LARGE } }; this.markerOption.point = { lng:lng, lat:lat @@ -91,7 +91,7 @@ this._localSearch= new this._BMap.LocalSearch(map, { renderOptions:{map: map} }); if(this.data.latitude==this.Default_LAT&&this.data.longitude==this.Default_LNG if (this.data.latitude === this.Default_LAT && this.data.longitude === this.Default_LNG &&this.data.address!=null){ this._localSearch.search(this.data.address); } @@ -100,7 +100,7 @@ queryTest:string; mapSearch(param:any){ let text = this.queryTest; text = text == null || text.trim() ==''?'昆山市':text; text = text == null || text.trim() === '' ? '昆山市' : text; this._localSearch.search(text); } clickMap(e: any) { src/app/routes/map/coordinates-picker/coordinates-picker.service.ts
src/app/routes/map/map.module.ts
src/app/routes/passport/login/login.component.ts
@@ -1,3 +1,5 @@ import { error } from 'selenium-webdriver'; import { HttpErrorResponse } from '@angular/common/http'; import { Authorization } from '@business/entity/token'; import { LoginService } from '@business/services/http/login.service'; import { SettingsService } from '@delon/theme'; @@ -97,22 +99,16 @@ this.router.navigate(['/']); } }, (err) => { // console.log(err); if(err instanceof ProgressEvent){ const error = <ProgressEvent>err; let xmlHttp = error.target; if(xmlHttp instanceof XMLHttpRequest){ const xmlHttpRequest = <XMLHttpRequest> xmlHttp; console.log(xmlHttpRequest.response); const response = JSON.parse(xmlHttpRequest.response); if(response.status == 401&&response.errorCode==10){ this.validateError["password_incorrect"]=true; (err: HttpErrorResponse) => { if (!!err) { const errMsg = err.error; console.log(errMsg); if (errMsg.status === 401 && errMsg.errorCode === 10) { this.validateError['password_incorrect'] = true; this.loading = false; } else if(response.status == 401&&response.errorCode==12) { this.validateError["account_expired"]=true; } else if (errMsg.status === 401 && errMsg.errorCode === 12) { this.validateError['account_expired'] = true; this.loading = false; } } } } src/app/routes/routes-routing.module.ts
src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.ts
src/app/routes/systems/account/account.component.ts
@@ -30,7 +30,7 @@ allChecked = false; indeterminate = false; sortMap: string[] = []; loading: boolean = true; loading = true; constructor( public http: HttpClient, @@ -47,7 +47,7 @@ this.query.pageIndex = 1; } this.http.get(environment.SERVER_BASH_URL + '/account/list', {params: this.query}).subscribe((res: any) => { if (res.code == 0) { if (res.code === 0) { this.msgSrv.error(res.message); } else { this.data = res.data.data; @@ -67,7 +67,7 @@ account = {}; } this.modalHelper.static(AccountEditComponent, {account}).subscribe((res: any) => { if (res.code == 0) { if (res.code === 0) { this.msgSrv.error(res.message); } else { this.msgSrv.success('账户保存成功!'); @@ -104,7 +104,7 @@ checkAll(value: boolean) { this.data.forEach(i => { if (i.isDelete == '1') { if (i.isDelete === '1') { i.checked = false; } else { i.checked = value; @@ -132,7 +132,7 @@ if (value) { this.sortMap.push(`${field} ${value}`); } this.query.sorter = this.sortMap.length > 0 ? this.sortMap.join(",") : ''; this.query.sorter = this.sortMap.length > 0 ? this.sortMap.join(',') : ''; this.load(true); } src/app/routes/systems/organization/organization-config/organization-config.component.html
@@ -51,7 +51,7 @@ </div> </div> </td> <td nz-td style="padding-top:0px;"> <td nz-td style="padding-top: 0;"> <div nz-form-control> <nz-switch formControlName="degressEnable" (click)="refreshHasDegression(f.value['alarmLevels'][row.sensorKey]['degressEnable'])" nzDisabled="{{ !f.value['alarmLevels'][row.sensorKey]['enable'] }}"></nz-switch> src/app/routes/systems/organization/organization-config/organization-config.component.ts
@@ -47,7 +47,7 @@ setTimeout(() => { this.grid.loading = true; }, 1); let pageBean = this.organizationService.config.pageBean; const pageBean = this.organizationService.config.pageBean; let resultBean = this.organizationService.config.resultBean; resultBean = resultBean == null ? {} : resultBean; if (pageBean != null && pageBean.data != null) { @@ -62,18 +62,18 @@ const alarmConfigValue = alarmConfig.value; const alarmLevels = alarmConfigValue.alarmLevels; let alarmLevelsGroupsConfig = {}; const alarmLevelsGroupsConfig = {}; Object.keys(alarmLevels).forEach(key => { let increment = alarmLevels[key].increment; increment = increment == null || increment.length != 3 ? [0, 0, 0] : increment; increment = increment == null || increment.length !== 3 ? [0, 0, 0] : increment; const incrementArray = this.formBuilder.array([ [increment[0]], [increment[1]], [increment[2]] ]); let degression = alarmLevels[key].degression; degression = degression == null || degression.length != 3 ? [0, 0, 0] : degression; degression = degression == null || degression.length !== 3 ? [0, 0, 0] : degression; const degressionArray = this.formBuilder.array([ [degression[0]], @@ -126,7 +126,7 @@ item => { this.setErrorMessage(); } ) ); this.refreshIndeterminate(); } this.refreshHasDegression(false); @@ -156,7 +156,7 @@ ); this.refreshIndeterminate(); } private _allCheckTriggers: number = 0; private _allCheckTriggers = 0; refreshIndeterminate() { const keys = this.grid.data.map( item => { @@ -167,7 +167,7 @@ const allUnChecked = keys.every(key => !this.validateForm.get('alarmLevels.' + key + '.enable').value); this.indeterminate = (!allChecked) && (!allUnChecked); } isSaving:boolean = false; isSaving = false; save($event, value, valid) { $event.preventDefault(); if (valid) { @@ -176,18 +176,17 @@ id:value._id, organizationId:this.organization.id, value:value } }; // ToolsService.removePrivate(data.value); this.alarmConfigService.save(data).subscribe( result => { if(result!=null&&result.code==1){ if (result != null && result.code === 1) { this.msgSrv.success(this.organization.name+' 配置成功!'); this.backToList(); } } ); } debugger; } setErrorMessage(){ @@ -198,16 +197,16 @@ this.errorMessage = '一级 二级 三级 依次递增'; } else if(errObj['degression']){ this.errorMessage = '反向一级 反向二级 反向三级 依次递减'; } else if(errObj['pattern']!=null&&errObj['pattern']['requiredPattern'] == '^'+patterns.num.toString()+'$'){ } else if (errObj['pattern'] != null && errObj['pattern']['requiredPattern'] === '^' + patterns.num.toString() + '$') { this.errorMessage = '阀值只能为数字'; } } } errorMessage:string = ''; errorMessage = ''; private removeError(error:'increment'|'degression',...controls:AbstractControl[]){ controls.forEach( item => { if(item.hasError(error)&&Object.keys(item.errors).length==1){ if (item.hasError(error) && Object.keys(item.errors).length === 1) { item.setErrors(null); } } @@ -216,7 +215,7 @@ private addError(error:'increment'|'degression',...controls:AbstractControl[]){ controls.forEach( item => { let errs = {}; const errs = {}; errs[error] = true; item.setErrors(errs); item.markAsDirty(); @@ -224,41 +223,41 @@ ); } private alarmLevelValidator = (control: FormControl): { [s: string]: boolean } => { const enable = control.get("enable").value; const degressEnable = control.get("degressEnable").value; const i0 = control.get("increment.0"); const i1 = control.get("increment.1"); const i2 = control.get("increment.2"); const d0 = control.get("degression.0"); const d1 = control.get("degression.1"); const d2 = control.get("degression.2"); const enable = control.get('enable').value; const degressEnable = control.get('degressEnable').value; const i0 = control.get('increment.0'); const i1 = control.get('increment.1'); const i2 = control.get('increment.2'); const d0 = control.get('degression.0'); const d1 = control.get('degression.1'); const d2 = control.get('degression.2'); // 如果未启用 删除错误信息,不验证 if(!enable){ this.removeError('increment',i0,i1,i2); this.removeError('degression',d0,d1,d2); return null; } let result = {}; const i0_value = parseInt(i0.value); const i1_value = parseInt(i1.value); const i2_value = parseInt(i2.value); if ((i0_value != 0 || i1_value != 0 || i2_value != 0)&&(i0_value >= i1_value||i1_value >= i2_value)) { const result = {}; const i0_value = parseInt(i0.value, 10); const i1_value = parseInt(i1.value, 10); const i2_value = parseInt(i2.value, 10); if ((i0_value !== 0 || i1_value !== 0 || i2_value !== 0) && (i0_value >= i1_value || i1_value >= i2_value)) { this.addError('increment',i0,i1,i2); result["increment"] = true; result['increment'] = true; }else{ this.removeError('increment',i0,i1,i2); } const d0_value = parseInt(d0.value); const d1_value = parseInt(d1.value); const d2_value = parseInt(d2.value); if(degressEnable&&(d0_value != 0 || d1_value != 0 || d2_value != 0)&&(d1_value >= d0_value||d2_value >= d1_value)) { const d0_value = parseInt(d0.value, 10); const d1_value = parseInt(d1.value, 10); const d2_value = parseInt(d2.value, 10); if (degressEnable && (d0_value !== 0 || d1_value !== 0 || d2_value !== 0) && (d1_value >= d0_value || d2_value >= d1_value)) { this.addError('degression',d0,d1,d2); result["degression"] = true; result['degression'] = true; }else{ this.removeError('degression',d0,d1,d2); } return Object.keys(result).length == 0?null:result; }; return Object.keys(result).length === 0 ? null : result; } getLastError(control:FormGroup|FormArray){ if(control.errors!=null){ return control.errors; @@ -286,7 +285,7 @@ ( item:any) => { return item['degressEnable']; } ) ); } } } src/app/routes/systems/organization/organization-edit/organization-edit.component.ts
src/app/routes/systems/organization/organization-list/organization-list.component.ts
src/app/routes/systems/systems.module.ts
src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.ts
@@ -25,7 +25,7 @@ const alarmUser = this.alarmUser; this.validateForm = this.formBuilder.group({ name: [alarmUser.name], mobile: [alarmUser.mobile, [Validators.pattern("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")]], mobile: [alarmUser.mobile, [Validators.pattern('^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$')]], email: [alarmUser.email, [Validators.email]], weixin: [alarmUser.weixin], organizationId: [alarmUser.organizationId], src/app/routes/users/alarm-user/alarm-user.component.ts
@@ -30,7 +30,7 @@ allChecked = false; indeterminate = false; sortMap: string[] = []; loading: boolean = true; loading = true; constructor( public http: HttpClient, @@ -64,7 +64,7 @@ alarmUser = {}; } this.modalHelper.static(AlarmUserEditComponent, {alarmUser}).subscribe((res: any) => { if (res.code == 0) { if (res.code === 0) { this.msgSrv.error(res.message); } else { this.msgSrv.success('账户保存成功!'); @@ -101,7 +101,7 @@ checkAll(value: boolean) { this.data.forEach(i => { if (i.isDelete == '1') { if (i.isDelete === '1') { i.checked = false; } else { i.checked = value; @@ -129,7 +129,7 @@ if (value) { this.sortMap.push(`${field} ${value}`); } this.query.sorter = this.sortMap.length > 0 ? this.sortMap.join(",") : ''; this.query.sorter = this.sortMap.length > 0 ? this.sortMap.join(',') : ''; this.load(true); } src/app/routes/users/installer/edit/edit.component.ts
@@ -29,7 +29,7 @@ const user = this.user; this.validateForm = this.formBuilder.group({ name: [user.name], mobile: [user.mobile, [Validators.pattern("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")]], mobile: [user.mobile, [Validators.pattern('^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$')]], email: [user.email], weixin: [user.weixin], organizationId: [user.organizationId], @@ -38,15 +38,15 @@ }); const mobileControl = this.validateForm.get('mobile'); mobileControl.valueChanges.filter(val => { return val != null && val.trim() != ''; return val != null && val.trim() !== ''; }).debounceTime(900).distinctUntilChanged().subscribe( value => { if(mobileControl.errors==null){ mobileControl.setErrors({unique:true}) mobileControl.setErrors({unique: true}); this.http.get(environment.SERVER_BASH_URL + '/operateUser/unique-mobile?mobile='+value) .pipe( catchError(() => { const req = <XMLHttpRequest>event.target; if(req.status==401){ if (req.status === 401) { this.subject.destroy(); } // 以错误的形式结束本次请求 @@ -54,8 +54,8 @@ }) ) .subscribe( (value:ResultBean<boolean>) => { if(value.code == 1 && value.data){ (val: ResultBean<boolean>) => { if (val.code === 1 && val.data) { this.validateForm.get('mobile').setErrors(null); } } src/app/routes/users/installer/installer.component.ts
@@ -28,7 +28,7 @@ allChecked = false; indeterminate = false; sortMap: any = {}; loading: boolean = true; loading = true; constructor( public http: HttpClient, @@ -87,7 +87,7 @@ checkAll(value: boolean) { this.curRows.forEach(i => { if (i.isDelete == '1') { if (i.isDelete === '1') { i.checked = false; } else { i.checked = value; src/app/routes/users/users.module.ts
tslint.json
@@ -68,7 +68,7 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": false, "no-unnecessary-initializer": true, "no-unused-expression": true, "no-unused-expression": false, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false,