| | |
| | | private settings: SettingsService, |
| | | private router: Router, |
| | | private titleSrv: TitleService, |
| | | private loginService:LoginService) { |
| | | private loginService: LoginService) { |
| | | } |
| | | |
| | | ngOnInit() { |
| | |
| | | ) |
| | | .subscribe(() => { |
| | | // 删除多余透明蒙版中元素 |
| | | let cdkOverlayContainer = $('.cdk-overlay-container'); |
| | | if(cdkOverlayContainer!=null&&cdkOverlayContainer.children().length>1){ |
| | | 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(); |
| | | }else{ |
| | | $(element).empty(); |
| | | function(index, el) { |
| | | if ($(el).hasClass('cdk-overlay-backdrop-showing')) { |
| | | $(el).remove(); |
| | | } else { |
| | | $(el).empty(); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | // 关闭静态蒙版弹窗 |
| | | if($('.ant-modal-close').length>0){ |
| | | if ($('.ant-modal-close').length > 0) { |
| | | $('.ant-modal-close').click(); |
| | | } |
| | | // 下拉按钮模拟点击 |
| | | if($('.ant-select-open').length>0){ |
| | | if ($('.ant-select-open').length > 0) { |
| | | $('.ant-select-open').click(); |
| | | } |
| | | }); |
| | |
| | | provinceCode?: Column|any; |
| | | rank?: Column|any; |
| | | telephone?: Column|any; |
| | | areaNames?: AreaNames|any ; |
| | | areaNames?: AreaNames; |
| | | } |
| | | |
| | | // 设备型号 |
| | |
| | | |
| | | export interface AlarmConfigValue { |
| | | alarmMode: AlarmMode; |
| | | alarmLevels:{[key: string]:AlarmSensorLevel}; |
| | | alarmLevels: {[key: string]: AlarmSensorLevel}; |
| | | } |
| | | |
| | | |
| | | export interface AlarmSensorLevel { |
| | | enable: boolean|any []; |
| | | increment: number []|any[]; |
| | | degressEnable:boolean|any []; |
| | | degressEnable: boolean|any []; |
| | | degression: number []|any []; |
| | | } |
| | | export interface Device { |
| | |
| | | deviceId?: number|any[]; |
| | | id?: number|any[]; |
| | | updateTime?: number|any[]; |
| | | value?:{[s:string] : number}|any[]; |
| | | value?: {[s: string]: number}|any[]; |
| | | } |
| | | |
| | | export interface CoorPicker{ |
| | | longitude:number;// 经度 |
| | | latitude:number;// 纬度 |
| | | address:string; |
| | | describe:string; |
| | | name:string; |
| | | export interface CoorPicker { |
| | | longitude: number; // 经度 |
| | | latitude: number; // 纬度 |
| | | address: string; |
| | | describe: string; |
| | | name: string; |
| | | } |
| | | |
| | | export interface UserContext { |
| | |
| | | organizationId: number; |
| | | username: string; |
| | | } |
| | | export interface TimePeriod{ |
| | | startTime:number;//开始时间 |
| | | endTime:number;//结束时间 |
| | | export interface TimePeriod { |
| | | startTime: Date; // 开始时间 |
| | | endTime: Date; // 结束时间 |
| | | } |
| | | export interface DataCondition{ |
| | | timeUnits:TimeUnits;//单位 |
| | | actualTime:number;//实际时间 |
| | | areaRange:AreaRange;//区域范围 |
| | | areaRangeId:number;//区域范围的ID |
| | | export interface DataCondition { |
| | | timeUnits?: TimeUnits; // 单位 |
| | | actualTime?: Date; // 实际时间 |
| | | areaRange?: AreaRange; // 区域范围 |
| | | areaRangeId?: number; // 区域范围的ID |
| | | } |
| | | export interface LineChartCriteria{ |
| | | sensorKey:String; |
| | | timePeriod:TimePeriod; |
| | | dataConditions:DataCondition[]; |
| | | } |
| | | export interface LineChartCriteria { |
| | | sensorKey: String; |
| | | timePeriod: TimePeriod; |
| | | dataConditions: DataCondition[]; |
| | | } |
| | |
| | | return arr; |
| | | } |
| | | } |
| | | export interface ResultBean<T>{ |
| | | export interface ResultBean<T> { |
| | | code?: number; |
| | | data?: T; |
| | | message?: string; |
| | | } |
| | | } |
| | |
| | | export interface Authorization{ |
| | | token:string; |
| | | refreshToken:string; |
| | | } |
| | | export interface Authorization { |
| | | token: string; |
| | | refreshToken: string; |
| | | } |
| | |
| | | export enum patterns{ |
| | | export enum patterns { |
| | | num = '(\\-?)\\d+(\\.\\d+)?' |
| | | } |
| | |
| | | Date, Json |
| | | } |
| | | export enum AlarmStyle { |
| | | //微信,邮件,短信,语音 |
| | | weixin='weixin',email='email',sms='sms',voice='voice' |
| | | // 微信,邮件,短信,语音 |
| | | weixin= 'weixin', email= 'email', sms= 'sms', voice= 'voice' |
| | | } |
| | | export enum TimeUnits{ |
| | | YEAR='YEAR',MONTH='MONTH',DAY='DAY',HOUR='HOUR',MINUTE='MINUTE' |
| | | 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' |
| | | } |
| | | PROVINCE= 'PROVINCE', CITY= 'CITY', AREA= 'AREA', MONITORPOINT= 'MONITORPOINT', DEVICE= 'DEVICE' |
| | | } |
| | | export enum ResultCode { |
| | | SUCCESS= 1, FAIL= 0 |
| | | } |
| | |
| | | import { environment } from '@env/environment'; |
| | | import { Observable } from 'rxjs/Observable'; |
| | | import { ResultBean } from '@business/entity/grid'; |
| | | import { AlarmConfig, AlarmConfigValue,AlarmSensorLevel, AlarmMode } from '@business/entity/data'; |
| | | import { AlarmConfig, AlarmConfigValue, AlarmSensorLevel, AlarmMode } from '@business/entity/data'; |
| | | |
| | | @Injectable() |
| | | export class AlarmConfigService { |
| | |
| | | constructor( private http: _HttpClient) { |
| | | |
| | | } |
| | | public generateAlarmConfig(sensors: {sensorKey:string} [],alarmConfig?: AlarmConfig): AlarmConfig{ |
| | | const _alarmConfig : AlarmConfig = alarmConfig==null || alarmConfig.value == null ? {value:{ |
| | | alarmLevels:null, |
| | | alarmMode:null |
| | | }}: alarmConfig; |
| | | public generateAlarmConfig(sensors: {sensorKey: string} [], alarmConfig?: AlarmConfig): AlarmConfig { |
| | | const _alarmConfig: AlarmConfig = alarmConfig == null || alarmConfig.value == null ? {value: { |
| | | alarmLevels: null, |
| | | alarmMode: null |
| | | }} : alarmConfig; |
| | | let alarmLevels = _alarmConfig.value.alarmLevels; |
| | | alarmLevels = alarmLevels ==null ?{} :alarmLevels; |
| | | alarmLevels = alarmLevels == null ? {} : alarmLevels; |
| | | sensors.forEach( |
| | | sensor => { |
| | | const key = sensor.sensorKey; |
| | |
| | | alarmLevels[key] == null ? |
| | | { |
| | | enable: false, |
| | | increment: [0,0,0], |
| | | increment: [0, 0, 0], |
| | | degressEnable: false, |
| | | degression: [0,0,0] |
| | | degression: [0, 0, 0] |
| | | } : alarmLevels[key]; |
| | | } |
| | | ); |
| | | _alarmConfig.value.alarmLevels = alarmLevels; |
| | | //报警方式 |
| | | // 报警方式 |
| | | let alarmMode = _alarmConfig.value.alarmMode; |
| | | alarmMode = alarmMode == null ? { |
| | | enable: false, |
| | |
| | | _alarmConfig.value.alarmMode = alarmMode; |
| | | return _alarmConfig; |
| | | } |
| | | public getByOid(oid:number):Observable<ResultBean<AlarmConfig>>{ |
| | | return this.http.get(this.urls.getByOid,{organizationId:oid}); |
| | | public getByOid(oid: number): Observable<ResultBean<AlarmConfig>> { |
| | | return this.http.get(this.urls.getByOid, {organizationId: oid}); |
| | | } |
| | | public save(data: any): Observable<ResultBean<any>> { |
| | | return this.http.post(this.urls.save, data); |
| | |
| | | getByDid: environment.SERVER_BASH_URL + 'device-adjust/get-by-did', |
| | | save: environment.SERVER_BASH_URL + 'device-adjust/add-or-modify', |
| | | }; |
| | | constructor(private http:_HttpClient) { } |
| | | constructor(private http: _HttpClient) { } |
| | | /** |
| | | * |
| | | * @param did 设备ID |
| | | */ |
| | | public getByDid(did:number):Observable<ResultBean<DeviceAdjustValue>>{ |
| | | return this.http.get(this.urls.getByDid,{deviceId:did}); |
| | | public getByDid(did: number): Observable<ResultBean<DeviceAdjustValue>> { |
| | | return this.http.get(this.urls.getByDid, {deviceId: did}); |
| | | } |
| | | public save(data:DeviceAdjustValue): Observable<any> { |
| | | public save(data: DeviceAdjustValue): Observable<any> { |
| | | return this.http.post(this.urls.save, data); |
| | | } |
| | | } |
| | |
| | | save: environment.SERVER_BASH_URL + 'device/add-or-modify', |
| | | delete: environment.SERVER_BASH_URL + 'device/delete-by-ids' |
| | | }; |
| | | public getListUrl (){ |
| | | public getListUrl () { |
| | | return this.urls.list; |
| | | } |
| | | public getSqlParams(queryText:string){ |
| | | public getSqlParams(queryText: string) { |
| | | const example = new ExampleService(); |
| | | if (queryText != null && queryText !== '') { |
| | | example.or().andLike({name: 'name', value: '%' + queryText + '%'}); |
| | |
| | | delete(...ids: number[]): Observable< ResultBean<any> > { |
| | | return this.http.post(this.urls.delete, ids); |
| | | } |
| | | public save(data:Device): Observable<any> { |
| | | public save(data: Device): Observable<any> { |
| | | return this.http.post(this.urls.save, data); |
| | | } |
| | | } |
| | |
| | | |
| | | @Injectable() |
| | | export class LoginService { |
| | | public authorization:Authorization; |
| | | public userContext:UserContext; |
| | | public authorization: Authorization; |
| | | public userContext: UserContext; |
| | | private urls = { |
| | | login:environment.SERVER_BASH_URL+'auth/login', |
| | | userContext:environment.SERVER_BASH_URL+'user-context', |
| | | login: environment.SERVER_BASH_URL + 'auth/login', |
| | | userContext: environment.SERVER_BASH_URL + 'user-context', |
| | | }; |
| | | 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( |
| | | (res:any) => { |
| | | 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( |
| | | (res: any) => { |
| | | this.authorization = res; |
| | | return res; |
| | | } |
| | | ); |
| | | } |
| | | public loadUserContext():void{ |
| | | public loadUserContext(): void { |
| | | this.http.get(this.urls.userContext).subscribe( |
| | | (res:UserContext) => { |
| | | (res: UserContext) => { |
| | | this.userContext = res; |
| | | return res; |
| | | } |
| | |
| | | list: environment.SERVER_BASH_URL + '/monitor-point/page-list', |
| | | save: environment.SERVER_BASH_URL + '/monitor-point/add-or-modify', |
| | | delete: environment.SERVER_BASH_URL + '/monitor-point/delete-by-ids', |
| | | getOne:environment.SERVER_BASH_URL + '/monitor-point/get-by-id' |
| | | getOne: environment.SERVER_BASH_URL + '/monitor-point/get-by-id' |
| | | }; |
| | | constructor(private http: _HttpClient) { } |
| | | public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { |
| | |
| | | example.or().andLike({name: 'name', 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 = {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); |
| | | } |
| | | public delete(...ids: number[]): Observable<any> { |
| | | return this.http.post(this.urls.delete, ids); |
| | | } |
| | | public getEntity(id:number):Observable<ResultBean<MonitorPoint>>{ |
| | | return this.http.get(this.urls.getOne,{id:id}); |
| | | public getEntity(id: number): Observable<ResultBean<MonitorPoint>> { |
| | | return this.http.get(this.urls.getOne, {id: id}); |
| | | } |
| | | } |
| | |
| | | @Injectable() |
| | | export class OrganizationService { |
| | | handle: 'list'|'config' = 'list'; |
| | | config: {pageBean: PageBean,resultBean: ResultBean<AlarmConfig>}; |
| | | config: {pageBean: PageBean, resultBean: ResultBean<AlarmConfig>}; |
| | | data: Organization; |
| | | title: '组织列表'|'组织配置' = '组织列表'; |
| | | private urls = { |
| | |
| | | list: environment.SERVER_BASH_URL + '/sensor/page-list', |
| | | save: environment.SERVER_BASH_URL + '/sensor/add-or-modify', |
| | | delete: environment.SERVER_BASH_URL + '/sensor/delete-by-ids', |
| | | listByVersionId:environment.SERVER_BASH_URL + '/sensor/list-by-vid', |
| | | listByVersionId: environment.SERVER_BASH_URL + '/sensor/list-by-vid', |
| | | }; |
| | | constructor(private http: _HttpClient) { } |
| | | public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { |
| | |
| | | example.or().andEqualTo({name: 'version', value: queryText}); |
| | | } |
| | | let orderByClause = ''; |
| | | if(!!page){ |
| | | if (!!page) { |
| | | if (page.getOrderByClause != null && page.getOrderByClause instanceof Function) { |
| | | orderByClause = page.getOrderByClause(); |
| | | } |
| | | }else{ |
| | | page = {pageSize:0,pageIndex:0}; |
| | | } else { |
| | | page = {pageSize: 0, pageIndex: 0}; |
| | | } |
| | | const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, |
| | | queryParams: example.getSqlParam(), orderByClause: orderByClause}; |
| | | return this.http.get(this.urls.list, param); |
| | | } |
| | | public getPageByVersionId(versionId:number): Observable<PageBean> { |
| | | return this.http.get(this.urls.listByVersionId,{versionId:versionId}); |
| | | public getPageByVersionId(versionId: number): Observable<PageBean> { |
| | | return this.http.get(this.urls.listByVersionId, {versionId: versionId}); |
| | | } |
| | | public save(data: any): Observable<any> { |
| | | return this.http.post(this.urls.save, data); |
| | |
| | | orderByClause = page.getOrderByClause(); |
| | | } |
| | | const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, |
| | | queryParams: example.getSqlParam(), orderByClause:orderByClause}; |
| | | queryParams: example.getSqlParam(), orderByClause: orderByClause}; |
| | | return this.http.get(this.urls.list, param); |
| | | } |
| | | public save(data: any): Observable<any> { |
| | |
| | | return this.conditions; |
| | | } |
| | | |
| | | public addCondition(condition: string, colName:string, ...values: any[]){ |
| | | public addCondition(condition: string, colName: string, ...values: any[]) { |
| | | const split = Criteria.CONDITION_SPLIT; // '||' |
| | | this.conditions.push(condition+split + colName + split + values.join(split)); |
| | | this.conditions.push(condition + split + colName + split + values.join(split)); |
| | | } |
| | | public andLike(col: { name: string, value: any}): Criteria{ |
| | | public andLike(col: { name: string, value: any}): Criteria { |
| | | this.addCondition('andLike', col.name, col.value); |
| | | return this; |
| | | } |
| | | public andEqualTo(col: { name: string, value: any}): Criteria{ |
| | | public andEqualTo(col: { name: string, value: any}): Criteria { |
| | | this.addCondition('andEqualTo', col.name, col.value); |
| | | return this; |
| | | } |
| | |
| | | |
| | | public getSqlParam(): string { |
| | | let whereSql = ''; |
| | | for (const cri of this.criterion){ |
| | | for (const cri of this.criterion) { |
| | | const conditions = cri.getConditions(); |
| | | whereSql += ExampleService.OR_SPLIT + conditions.join(ExampleService.CRITERIA_SPLIT); |
| | | } |
| | |
| | | |
| | | @Injectable() |
| | | export class ToolsService { |
| | | public static markAsDirty(controlSet:FormGroup|FormArray){ |
| | | public static markAsDirty(controlSet: FormGroup|FormArray) { |
| | | const controls = controlSet.controls; |
| | | Object.values(controls).forEach( |
| | | (control:AbstractControl) => { |
| | | if(control instanceof FormGroup || control instanceof FormArray){ |
| | | (control: AbstractControl) => { |
| | | if (control instanceof FormGroup || control instanceof FormArray) { |
| | | ToolsService.markAsDirty(control); |
| | | }else{ |
| | | } else { |
| | | control.markAsDirty(); |
| | | } |
| | | } |
| | | ) |
| | | ); |
| | | } |
| | | public static removePrivate(obj:object){ |
| | | public static removePrivate(obj: object) { |
| | | Object.keys(obj).forEach( |
| | | (key:string) => { |
| | | if(key.startsWith('_')){ |
| | | (key: string) => { |
| | | if (key.startsWith('_')) { |
| | | delete obj[key]; |
| | | }else{ |
| | | if(obj[key] instanceof Object){ |
| | | } else { |
| | | if (obj[key] instanceof Object) { |
| | | ToolsService.removePrivate(obj[key]); |
| | | } |
| | | } |
| | |
| | | |
| | | private _default = 'zh-CN'; |
| | | |
| | | //默认语言设置 未中文 by fx |
| | | // 默认语言设置 未中文 by fx |
| | | private _langs = [ |
| | | { code: 'zh-CN', text: '中文' }, |
| | | { code: 'en', text: 'English' } |
| | |
| | | |
| | | 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: |
| | |
| | | this.goTo(`/${event.status}`); |
| | | break; |
| | | } |
| | | return of(event); |
| | | // 这里不抛出错误 httpclient 无法捕捉 |
| | | if (event instanceof HttpErrorResponse) { |
| | | return ErrorObservable.create(event); |
| | | } else { |
| | | return of(event); |
| | | } |
| | | } |
| | | |
| | | intercept(req: HttpRequest<any>, next: HttpHandler): |
| | |
| | | url: url |
| | | }); |
| | | return next.handle(newReq).pipe( |
| | | mergeMap((event: any) => { |
| | | mergeMap((event: any) => { |
| | | // 允许统一对请求错误处理,这是因为一个请求若是业务上错误的情况下其HTTP请求的状态是200的情况下需要 |
| | | if (event instanceof HttpResponse && event.status === 200) |
| | | return this.handleData(event); |
| | |
| | | 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'; |
| | |
| | | RouterModule.forChild(routes) |
| | | ], |
| | | declarations: [QueryComponent], |
| | | providers:[SensorsService] |
| | | providers: [SensorsService, AreacodeService, MonitorPointService] |
| | | }) |
| | | export class AnalysisModule { } |
| | |
| | | <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}} |
| | | <a class="ant-dropdown-link" nz-dropdown> |
| | | <p class="display-2">{{ lineChartSensorName }} |
| | | <i class="anticon anticon-down"></i> |
| | | </p> |
| | | </li> |
| | | </ul> |
| | | </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> |
| | | <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 *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> |
| | | <input type="button" value="text" width="100px;" (click)="_isSameDay"/> |
| | | <ng-template #elseBlock> |
| | | <div nz-col [nzSm]="8" class="header-info"> |
| | | <p class="text-grey-dark">横坐标时间区间</p> |
| | | <nz-input-number style="width: 42%;" [(ngModel)]="startYear" [nzMin]="minStartYear" [nzMax]="maxStartYear" [nzStep]="1" [nzAllowClear]="false"></nz-input-number> |
| | | <span>-</span> |
| | | <nz-input-number style="width: 42%;" [(ngModel)]="endYear" [nzMin]="minEndYear" [nzMax]="maxEndYear" [nzStep]="1" [nzAllowClear]="false"></nz-input-number> |
| | | </div> |
| | | </ng-template> |
| | | </div> |
| | | </nz-card> |
| | | </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> |
| | |
| | | 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', |
| | |
| | | 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; |
| | | public sensorList: Sensor[]; |
| | | public timeUnits: { label: string, value: TimeUnits, disabled: boolean }[] = []; |
| | | 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; |
| | | } |
| | | private _timePeriodUnitValue:TimeUnits=TimeUnits.DAY; |
| | | public set timePeriodUnitValue(value:TimeUnits){ |
| | | public _timePeriodUnitValue: TimeUnits = TimeUnits.DAY; |
| | | public set timePeriodUnitValue(value: TimeUnits) { |
| | | this._timePeriodUnitValue = value; |
| | | switch(value){ |
| | | //YYYY-MM-DD HH:mm:ss |
| | | 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}; |
| | | get timePeriodUnitName():String { |
| | | return this.timeUnits.find( item => item.value == this._timePeriodUnitValue).label; |
| | | 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; |
| | | } |
| | | constructor( |
| | | private sensorsService:SensorsService |
| | | ) { |
| | | this.initPage(); |
| | | private sensorsService: SensorsService, |
| | | private areacodeService: AreacodeService, |
| | | private http: _HttpClient, |
| | | private monitorPointService: MonitorPointService, |
| | | ) { |
| | | } |
| | | private initPage(){ |
| | | this.sensorsService.getPagingList(null,null).subscribe( |
| | | |
| | | 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} |
| | | {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} |
| | | ); |
| | | 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; |
| | | } |
| | | } |
| | |
| | | export class DashboardV1Component implements OnInit { |
| | | |
| | | constructor(private http: _HttpClient, public msg: NzMessageService, |
| | | public loginService:LoginService) { } |
| | | public loginService: LoginService) { } |
| | | |
| | | todoData: any[] = [ |
| | | { completed: true, avatar: '1', name: '苏先生', content: `请告诉我,我应该说点什么好?` }, |
| | |
| | | styles: [] |
| | | }) |
| | | export class AdjustConfigComponent implements OnInit { |
| | | record:Device; |
| | | _dataValue:{[s:string]:number} = {}; |
| | | data:DeviceAdjustValue; |
| | | record: Device; |
| | | _dataValue: {[s: string]: number} = {}; |
| | | data: DeviceAdjustValue; |
| | | deviceVersionId: number; |
| | | isSaving = false; |
| | | grid: Grid<Sensor> = new Grid(null); |
| | |
| | | constructor( |
| | | private subject: NzModalSubject, |
| | | private sensorsService: SensorsService, |
| | | private adjustValueService:DeviceAdjustValueService, |
| | | private adjustValueService: DeviceAdjustValueService, |
| | | public msgSrv: NzMessageService, |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | | if(this.record.deviceVersionId==null){ |
| | | if (this.record.deviceVersionId == null) { |
| | | swal(`请先选择设备型号`, '设备校准值到传感器类型由所属设备型号决定', 'info'); |
| | | this.subject.destroy(); |
| | | } |
| | |
| | | this.adjustValueService.getByDid(this.record.id), |
| | | this.sensorsService.getPageByVersionId(this.record.deviceVersionId) |
| | | ).subscribe( |
| | | ([adjustRes,sensorsRes]) => { |
| | | if(adjustRes!=null && adjustRes.code==1 && sensorsRes != null && sensorsRes.data != null){ |
| | | ([adjustRes, sensorsRes]) => { |
| | | if (adjustRes != null && adjustRes.code === 1 && sensorsRes != null && sensorsRes.data != null) { |
| | | this.data = { |
| | | deviceId:this.record.id, |
| | | value:{} |
| | | deviceId: this.record.id, |
| | | value: {} |
| | | }; |
| | | if(adjustRes.data!=null){ |
| | | if (adjustRes.data != null) { |
| | | // 存储修改前到值 |
| | | Object.assign(this._dataValue,adjustRes.data.value); |
| | | this.data['id'] =adjustRes.data.id; |
| | | Object.assign(this._dataValue, adjustRes.data.value); |
| | | this.data['id'] = adjustRes.data.id; |
| | | } |
| | | this.grid.initData(sensorsRes); |
| | | sensorsRes.data.forEach( |
| | | (item:Sensor) => { |
| | | this.data.value[item.sensorKey] = this._dataValue[item.sensorKey] == null?0:this._dataValue[item.sensorKey]; |
| | | (item: Sensor) => { |
| | | this.data.value[item.sensorKey] = this._dataValue[item.sensorKey] == null ? 0 : this._dataValue[item.sensorKey]; |
| | | } |
| | | ); |
| | | this.grid.refreshStatus(); |
| | |
| | | } |
| | | save($event) { |
| | | // $event.preventDefault(); |
| | | let isModify = Object.keys(this._dataValue).length != Object.keys(this.data.value).length; |
| | | if(!isModify){ |
| | | let isModify = Object.keys(this._dataValue).length !== Object.keys(this.data.value).length; |
| | | if (!isModify) { |
| | | isModify = Object.keys(this.data.value).some( |
| | | key => { |
| | | return this.data.value[key] !== this._dataValue[key]; |
| | | } |
| | | ); |
| | | } |
| | | debugger; |
| | | if(isModify){ |
| | | if (isModify) { |
| | | this.adjustValueService.save(this.data).subscribe( |
| | | (res:ResultBean<any>) =>{ |
| | | if(res!=null&&res.code==1){ |
| | | (res: ResultBean<any>) => { |
| | | if (res != null && res.code === 1) { |
| | | this.subject.destroy(); |
| | | this.msgSrv.success('校准值配置成功'); |
| | | } |
| | | } |
| | | ); |
| | | }else{ |
| | | } else { |
| | | this.subject.destroy(); |
| | | this.msgSrv.success('校准值配置未改变'); |
| | | } |
| | |
| | | </div> |
| | | <simple-table #simpleTable [data]="listUrl" [extraParams]="extraParams" [columns]="columns" [showTotal]="true" |
| | | [reqReName]="{pi: 'pageIndex',ps: 'pageSize'}" (checkboxChange)="checkboxChange($event)" [ps]="10" [resReName]="{list: 'data',total: 'total'}"></simple-table> |
| | | </nz-card> |
| | | </nz-card> |
| | |
| | | { title: '型号', index: 'deviceVersion.name' }, |
| | | { title: '监控点', index: 'monitorPoint.name' }, |
| | | { title: '维护人', index: 'operateUser.name' }, |
| | | { title: '生产时间',width: '100px', type: 'date', index: 'createTime' }, |
| | | { title: '安装时间', width: '100px',type: 'date', index: 'installTime' }, |
| | | { title: '生产时间', width: '100px', type: 'date', index: 'createTime' }, |
| | | { title: '安装时间', width: '100px', type: 'date', index: 'installTime' }, |
| | | { |
| | | title: '操作区', |
| | | buttons: [ |
| | |
| | | { |
| | | text: `配置校准值`, |
| | | type: 'static', |
| | | component:AdjustConfigComponent, |
| | | component: AdjustConfigComponent, |
| | | format: (record: any) => `<i class="anticon anticon-setting"></i>配置校准值` |
| | | }, |
| | | { |
| | |
| | | ]; |
| | | queryTextStream: Subject<string> = new Subject<string>(); |
| | | constructor( |
| | | private monitorPointService:MonitorPointService, |
| | | private monitorPointService: MonitorPointService, |
| | | private deviceService: DeviceService, |
| | | private confirmServ: NzModalService, |
| | | public msgSrv: NzMessageService, |
| | | private modalHelper: ModalHelper, |
| | | private coorPickerService:CoorPickerService |
| | | private coorPickerService: CoorPickerService |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | |
| | | }); |
| | | } |
| | | get listUrl() { |
| | | return this.deviceService.getListUrl();; |
| | | return this.deviceService.getListUrl(); |
| | | } |
| | | extraParams = { queryParams: null }; |
| | | queryText: string; |
| | |
| | | ); |
| | | }); |
| | | } |
| | | configCoord(record:Device):void { |
| | | Object.assign(this.coorPickerService.data,record); |
| | | let _data = this.coorPickerService.data; |
| | | configCoord(record: Device): void { |
| | | Object.assign(this.coorPickerService.data, record); |
| | | 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){ |
| | | adress = areaNames.provinceName+areaNames.cityName+areaNames.areaName+res.data.address; |
| | | if (areaNames != null) { |
| | | adress = areaNames.provinceName + areaNames.cityName + areaNames.areaName + res.data.address; |
| | | } |
| | | this.coorPickerService.data.address = adress; |
| | | this.coorPickerService.data['describe'] = '设备名称'; |
| | | } |
| | | this.modalHelper.static(CoordinatesPickerComponent).subscribe( |
| | | (staticComp) => { |
| | | const data:Device = { |
| | | id:record.id, |
| | | longitude:_data.longitude, |
| | | latitude:_data.latitude, |
| | | } |
| | | const data: Device = { |
| | | 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('坐标配置成功!'); |
| | | } |
| | |
| | | } |
| | | ); |
| | | } |
| | | ) |
| | | ); |
| | | } |
| | | } |
| | |
| | | styles: [] |
| | | }) |
| | | export class DeviceEditComponent implements OnInit { |
| | | public monitorPoints:any [] = []; |
| | | public deviceVersions:any [] = []; |
| | | public operateUsers:any [] = []; |
| | | public monitorPoints: any [] = []; |
| | | public deviceVersions: any [] = []; |
| | | public operateUsers: any [] = []; |
| | | public isSaving = false; |
| | | constructor( |
| | | private subject: NzModalSubject, |
| | | private formBuilder: FormBuilder, |
| | | private monitorPointService:MonitorPointService, |
| | | private versionService:VersionService, |
| | | private operateUserService:OperateUserService |
| | | private monitorPointService: MonitorPointService, |
| | | private versionService: VersionService, |
| | | private operateUserService: OperateUserService |
| | | ) { } |
| | | data:Device; |
| | | validateForm:FormGroup; |
| | | data: Device; |
| | | validateForm: FormGroup; |
| | | ngOnInit() { |
| | | const data = this.data; |
| | | this.monitorPointChange(null); |
| | |
| | | if (this.data.createTime == null) { |
| | | this.data.createTime = new Date().getTime(); |
| | | } |
| | | const validates:Device = { |
| | | name:[data.name,[Validators.required]], |
| | | mac:[data.mac,[Validators.required]], |
| | | deviceVersionId:[data.deviceVersionId], |
| | | monitorPointId:[data.monitorPointId], |
| | | operateUserId:[data.operateUserId], |
| | | address:[data.address], |
| | | id:[data.id], |
| | | longitude:[data.longitude], |
| | | latitude:[data.latitude], |
| | | createTime:[data.createTime], |
| | | installTime:[data.installTime] |
| | | const validates: Device = { |
| | | name: [data.name, [Validators.required]], |
| | | mac: [data.mac, [Validators.required]], |
| | | deviceVersionId: [data.deviceVersionId], |
| | | monitorPointId: [data.monitorPointId], |
| | | operateUserId: [data.operateUserId], |
| | | address: [data.address], |
| | | id: [data.id], |
| | | longitude: [data.longitude], |
| | | latitude: [data.latitude], |
| | | createTime: [data.createTime], |
| | | installTime: [data.installTime] |
| | | }; |
| | | this.validateForm = this.formBuilder.group( |
| | | validates |
| | | ); |
| | | } |
| | | close(){ |
| | | close() { |
| | | this.subject.destroy(); |
| | | } |
| | | save($event, value, valid){ |
| | | save($event, value, valid) { |
| | | $event.preventDefault(); |
| | | if(valid){ |
| | | if (valid) { |
| | | this.isSaving = true; |
| | | this.data = value; |
| | | this.subject.next( this ); |
| | | }else{ |
| | | } else { |
| | | ToolsService.markAsDirty(this.validateForm); |
| | | } |
| | | } |
| | | monitorPointChange(text){ |
| | | monitorPointChange(text) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.monitorPointService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | |
| | | } |
| | | ); |
| | | } |
| | | deviceVersionChange(text){ |
| | | deviceVersionChange(text) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.versionService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | |
| | | } |
| | | ); |
| | | } |
| | | operateUserChange(text){ |
| | | operateUserChange(text) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.operateUserService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | |
| | | import { CoordinatesPickerComponent } from 'app/routes/map/coordinates-picker/coordinates-picker.component'; |
| | | import { MapModule } from 'app/routes/map/map.module'; |
| | | import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; |
| | | const COMPONENTS_NOROUNT = [AdjustConfigComponent,DeviceEditComponent,VersionEditComponent, MonitorPointEditComponent, VersionSensorConfigComponent ]; |
| | | const COMPONENTS_NOROUNT = [AdjustConfigComponent, DeviceEditComponent, VersionEditComponent, MonitorPointEditComponent, VersionSensorConfigComponent ]; |
| | | |
| | | const routes: Routes = [ |
| | | { |
| | |
| | | MonitorPointComponent, |
| | | ...COMPONENTS_NOROUNT |
| | | ], |
| | | providers: [CoorPickerService,DeviceAdjustValueService,OrganizationService, VersionService, |
| | | providers: [CoorPickerService, DeviceAdjustValueService, OrganizationService, VersionService, |
| | | SensorsService, AreacodeService, MonitorPointService, |
| | | _HttpClient, FormBuilder,DeviceService,OperateUserService,ToolsService], |
| | | entryComponents: [CoordinatesPickerComponent,...COMPONENTS_NOROUNT] |
| | | _HttpClient, FormBuilder, DeviceService, OperateUserService, ToolsService], |
| | | entryComponents: [CoordinatesPickerComponent, ...COMPONENTS_NOROUNT] |
| | | }) |
| | | export class DevicesModule { } |
| | |
| | | } |
| | | } ); |
| | | this.subject.next( this ); |
| | | }else { |
| | | } else { |
| | | this.validate(); |
| | | } |
| | | } |
| | |
| | | this.grid.pageSize = 10; |
| | | } |
| | | constructor( |
| | | private coorPickerService:CoorPickerService, |
| | | private coorPickerService: CoorPickerService, |
| | | private monitorPointService: MonitorPointService, |
| | | |
| | | private confirmServ: NzModalService, |
| | |
| | | } |
| | | 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) { |
| | |
| | | id: record.id, |
| | | longitude: _data.longitude, |
| | | latitude: _data.latitude, |
| | | } |
| | | }; |
| | | this.monitorPointService.save(data).subscribe( |
| | | (res: any) => { |
| | | if (res.code === 1) { |
| | |
| | | } |
| | | } ); |
| | | this.subject.next( this ); |
| | | }else { |
| | | } else { |
| | | this.validate(); |
| | | } |
| | | } |
| | |
| | | import { NzModalSubject } from 'ng-zorro-antd'; |
| | | import { ReactiveFormsModule } from '@angular/forms'; |
| | | import { ViewEncapsulation,Component, ViewChild, ElementRef, NgZone } from '@angular/core'; |
| | | import { MapOptions,Point,MarkerOptions,ControlAnchor,NavigationControlOptions,NavigationControlType,BMapInstance } from 'angular2-baidu-map'; |
| | | import { ViewEncapsulation, Component, ViewChild, ElementRef, NgZone } from '@angular/core'; |
| | | import { MapOptions, Point, MarkerOptions, ControlAnchor, NavigationControlOptions, NavigationControlType, BMapInstance } from 'angular2-baidu-map'; |
| | | import { CoorPicker } from '@business/entity/data'; |
| | | import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; |
| | | |
| | |
| | | templateUrl: './coordinates-picker.component.html', |
| | | styleUrls: [ './coordinates-picker.component.css' ], |
| | | }) |
| | | export class CoordinatesPickerComponent{ |
| | | export class CoordinatesPickerComponent { |
| | | Default_LNG = 121; |
| | | Default_LAT = 31.4; |
| | | isSaving = false; |
| | | markerOption:{ |
| | | point:Point, |
| | | options:MarkerOptions |
| | | }= { |
| | | point:null, |
| | | options:null |
| | | markerOption: { |
| | | point: Point, |
| | | options: MarkerOptions |
| | | } = { |
| | | point: null, |
| | | options: null |
| | | }; |
| | | data:CoorPicker; |
| | | navigationOpts:NavigationControlOptions; |
| | | data: CoorPicker; |
| | | navigationOpts: NavigationControlOptions; |
| | | options: MapOptions; |
| | | _BMap:any = null; |
| | | _BMap: any = null; |
| | | |
| | | constructor(private subject:NzModalSubject,private coorPickerService:CoorPickerService) { |
| | | 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, |
| | | maxZoom:19, |
| | | cursor:'default', |
| | | minZoom: 3, |
| | | maxZoom: 19, |
| | | cursor: 'default', |
| | | centerAndZoom: { |
| | | lng:lng, |
| | | lat:lat, |
| | | lng: lng, |
| | | lat: lat, |
| | | zoom: 19 |
| | | }, |
| | | enableKeyboard: true |
| | |
| | | this.navigationOpts = { |
| | | anchor: ControlAnchor.BMAP_ANCHOR_BOTTOM_RIGHT, |
| | | type: NavigationControlType.BMAP_NAVIGATION_CONTROL_LARGE |
| | | } |
| | | }; |
| | | this.markerOption.point = { |
| | | lng:lng, |
| | | lat:lat |
| | | lng: lng, |
| | | lat: lat |
| | | }; |
| | | this.markerOption.options = { |
| | | icon: { |
| | |
| | | width: 30 |
| | | } |
| | | }, |
| | | offset:{ |
| | | height:-30, |
| | | width:-15 |
| | | offset: { |
| | | height: -30, |
| | | width: -15 |
| | | } |
| | | }; |
| | | } |
| | | private _marker:any = null; |
| | | loadMarker(marker){ |
| | | if(this._marker==null){ |
| | | private _marker: any = null; |
| | | loadMarker(marker) { |
| | | if (this._marker == null) { |
| | | this._marker = marker; |
| | | } |
| | | } |
| | |
| | | this._map.addOverlay(this._marker); |
| | | } |
| | | ); |
| | | this._localSearch= new this._BMap.LocalSearch(map, { |
| | | renderOptions:{map: map} |
| | | this._localSearch = new this._BMap.LocalSearch(map, { |
| | | renderOptions: {map: map} |
| | | }); |
| | | if(this.data.latitude==this.Default_LAT&&this.data.longitude==this.Default_LNG |
| | | &&this.data.address!=null){ |
| | | if (this.data.latitude === this.Default_LAT && this.data.longitude === this.Default_LNG |
| | | && this.data.address != null) { |
| | | this._localSearch.search(this.data.address); |
| | | } |
| | | |
| | | } |
| | | queryTest:string; |
| | | mapSearch(param:any){ |
| | | 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) { |
| | |
| | | |
| | | @Injectable() |
| | | export class CoorPickerService { |
| | | public data:CoorPicker = { |
| | | longitude:0, |
| | | latitude:0, |
| | | name:'', |
| | | describe:'', |
| | | address:'' |
| | | public data: CoorPicker = { |
| | | longitude: 0, |
| | | latitude: 0, |
| | | name: '', |
| | | describe: '', |
| | | address: '' |
| | | }; |
| | | constructor() { } |
| | | |
| | |
| | | CommonModule, |
| | | SharedModule, |
| | | BaiduMapModule.forRoot({ |
| | | ak:'rER1sgBIcQxkfNSlm2wmBGZGgEERrooM' |
| | | ak: 'rER1sgBIcQxkfNSlm2wmBGZGgEERrooM' |
| | | }) |
| | | ], |
| | | declarations: [CoordinatesPickerComponent], |
| | | exports:[CoordinatesPickerComponent] |
| | | exports: [CoordinatesPickerComponent] |
| | | }) |
| | | export class MapModule { } |
| | |
| | | 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'; |
| | |
| | | selector: 'passport-login', |
| | | templateUrl: './login.component.html', |
| | | styleUrls: [ './login.component.less' ], |
| | | providers: [ SocialService,CookieService] |
| | | providers: [ SocialService, CookieService] |
| | | }) |
| | | export class UserLoginComponent implements OnDestroy { |
| | | |
| | |
| | | private settingsService: SettingsService, |
| | | private socialService: SocialService, |
| | | @Optional() @Inject(ReuseTabService) private reuseTabService: ReuseTabService, |
| | | private loginService:LoginService, |
| | | private loginService: LoginService, |
| | | @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) { |
| | | this.form = fb.group({ |
| | | userName: [null, [Validators.required, Validators.minLength(5)]], |
| | |
| | | if (this.mobile.invalid || this.captcha.invalid) return; |
| | | } |
| | | this.loading = true; |
| | | this.loginService.validate(this.userName.value,this.password.value).subscribe( |
| | | (res:Authorization) => { |
| | | if(res.token!=null){ |
| | | this.loginService.validate(this.userName.value, this.password.value).subscribe( |
| | | (res: Authorization) => { |
| | | if (res.token != null) { |
| | | // 清空路由复用信息 |
| | | this.reuseTabService.clear(); |
| | | this.tokenService.set({ |
| | |
| | | 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; |
| | | this.loading = false; |
| | | } else if(response.status == 401&&response.errorCode==12) { |
| | | this.validateError["account_expired"]=true; |
| | | this.loading = false; |
| | | } |
| | | } |
| | | } |
| | | (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 (errMsg.status === 401 && errMsg.errorCode === 12) { |
| | | this.validateError['account_expired'] = true; |
| | | this.loading = false; |
| | | } |
| | | } |
| | | } |
| | | ); |
| | | |
| | | } |
| | | public validateError:{[s:string]:boolean} = {}; |
| | | public validateError: {[s: string]: boolean} = {}; |
| | | // region: social |
| | | |
| | | open(type: string, openType: SocialOpenType = 'href') { |
| | |
| | | path: 'passport', |
| | | component: LayoutPassportComponent, |
| | | children: [ |
| | | {data:{title:'登录页面'}, path: 'login', component: UserLoginComponent } |
| | | {data: {title: '登录页面'}, path: 'login', component: UserLoginComponent } |
| | | ] |
| | | }, // passport |
| | | { |
| | |
| | | } |
| | | } ); |
| | | this.subject.next( this ); |
| | | }else { |
| | | } else { |
| | | this.validate(); |
| | | } |
| | | } |
| | |
| | | allChecked = false; |
| | | indeterminate = false; |
| | | sortMap: string[] = []; |
| | | loading: boolean = true; |
| | | loading = true; |
| | | |
| | | constructor( |
| | | public http: HttpClient, |
| | |
| | | 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; |
| | |
| | | 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('账户保存成功!'); |
| | |
| | | |
| | | checkAll(value: boolean) { |
| | | this.data.forEach(i => { |
| | | if (i.isDelete == '1') { |
| | | if (i.isDelete === '1') { |
| | | i.checked = false; |
| | | } else { |
| | | i.checked = value; |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | </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> |
| | |
| | | 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) { |
| | |
| | | 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]], |
| | | [degression[1]], |
| | | [degression[2]] |
| | | ]); |
| | | //判断逆向是否启用 |
| | | // 判断逆向是否启用 |
| | | // let _degressionEnable = degression[0] != 0 || degression[1] != 0 || degression[2] != 0; |
| | | |
| | | const alarmSensorGroup = this.formBuilder.group( |
| | | { |
| | | degressEnable:[alarmLevels[key].degressEnable], |
| | | degressEnable: [alarmLevels[key].degressEnable], |
| | | enable: [alarmLevels[key].enable], |
| | | increment: incrementArray, |
| | | degression: degressionArray, |
| | |
| | | level3: [alarmMode.level3] |
| | | } |
| | | ), |
| | | '_id':alarmConfig.id, |
| | | '_id': alarmConfig.id, |
| | | '_allChecked': [] |
| | | }); |
| | | this.validateForm.statusChanges.subscribe( |
| | | item => { |
| | | this.setErrorMessage(); |
| | | } |
| | | ) |
| | | ); |
| | | this.refreshIndeterminate(); |
| | | } |
| | | this.refreshHasDegression(false); |
| | |
| | | ); |
| | | this.refreshIndeterminate(); |
| | | } |
| | | private _allCheckTriggers: number = 0; |
| | | private _allCheckTriggers = 0; |
| | | refreshIndeterminate() { |
| | | const keys = this.grid.data.map( |
| | | item => { |
| | |
| | | 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) { |
| | | this.isSaving = true; |
| | | const data:AlarmConfig = { |
| | | id:value._id, |
| | | organizationId:this.organization.id, |
| | | value:value |
| | | } |
| | | const data: AlarmConfig = { |
| | | 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){ |
| | | this.msgSrv.success(this.organization.name+' 配置成功!'); |
| | | if (result != null && result.code === 1) { |
| | | this.msgSrv.success(this.organization.name + ' 配置成功!'); |
| | | this.backToList(); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | debugger; |
| | | } |
| | | |
| | | setErrorMessage(){ |
| | | setErrorMessage() { |
| | | this.errorMessage = ''; |
| | | const errObj = this.getLastError(this.validateForm); |
| | | if(errObj!=null&&Object.keys(errObj).length>0){ |
| | | if(errObj['increment']){ |
| | | if (errObj != null && Object.keys(errObj).length > 0) { |
| | | if (errObj['increment']) { |
| | | this.errorMessage = '一级 二级 三级 依次递增'; |
| | | } else if(errObj['degression']){ |
| | | } 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 = ''; |
| | | private removeError(error:'increment'|'degression',...controls:AbstractControl[]){ |
| | | 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); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | private addError(error:'increment'|'degression',...controls:AbstractControl[]){ |
| | | private addError(error: 'increment'|'degression', ...controls: AbstractControl[]) { |
| | | controls.forEach( |
| | | item => { |
| | | let errs = {}; |
| | | const errs = {}; |
| | | errs[error] = true; |
| | | item.setErrors(errs); |
| | | item.markAsDirty(); |
| | |
| | | ); |
| | | } |
| | | 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); |
| | | 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)) { |
| | | this.addError('increment',i0,i1,i2); |
| | | result["increment"] = true; |
| | | }else{ |
| | | this.removeError('increment',i0,i1,i2); |
| | | 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; |
| | | } 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)) { |
| | | this.addError('degression',d0,d1,d2); |
| | | result["degression"] = true; |
| | | }else{ |
| | | this.removeError('degression',d0,d1,d2); |
| | | 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; |
| | | } else { |
| | | this.removeError('degression', d0, d1, d2); |
| | | } |
| | | return Object.keys(result).length == 0?null:result; |
| | | }; |
| | | getLastError(control:FormGroup|FormArray){ |
| | | if(control.errors!=null){ |
| | | return Object.keys(result).length === 0 ? null : result; |
| | | } |
| | | getLastError(control: FormGroup|FormArray) { |
| | | if (control.errors != null) { |
| | | return control.errors; |
| | | }else{ |
| | | } else { |
| | | const controls = Object.values(control.controls); |
| | | for(let i = controls.length-1;i>=0;i--){ |
| | | for (let i = controls.length - 1; i >= 0; i--) { |
| | | const c = controls[i]; |
| | | if(c.errors!=null){ |
| | | if (c.errors != null) { |
| | | return c.errors; |
| | | }else if(c instanceof FormArray||c instanceof FormGroup){ |
| | | } else if (c instanceof FormArray || c instanceof FormGroup) { |
| | | const result = this.getLastError(c); |
| | | if(result != null) { |
| | | if (result != null) { |
| | | return result; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | public hasDegression = false; |
| | | public refreshHasDegression(value){ |
| | | if(value){ |
| | | public refreshHasDegression(value) { |
| | | if (value) { |
| | | this.hasDegression = true; |
| | | }else{ |
| | | } else { |
| | | this.hasDegression = Object.values(this.validateForm.value['alarmLevels']).some( |
| | | ( item:any) => { |
| | | ( item: any) => { |
| | | return item['degressEnable']; |
| | | } |
| | | ) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } ); |
| | | this.subject.next( this ); |
| | | }else { |
| | | } else { |
| | | this.validate(); |
| | | } |
| | | } |
| | |
| | | public msgSrv: NzMessageService, |
| | | private modalHelper: ModalHelper, |
| | | private router: Router, |
| | | private sensorsService:SensorsService, |
| | | private alarmConfigService:AlarmConfigService, |
| | | private sensorsService: SensorsService, |
| | | private alarmConfigService: AlarmConfigService, |
| | | ) {} |
| | | |
| | | ngOnInit() { |
| | |
| | | this.grid.loading = true; |
| | | }, 1); |
| | | zip( |
| | | this.sensorsService.getPagingList({pageIndex:0,pageSize:0}, null), |
| | | this.sensorsService.getPagingList({pageIndex: 0, pageSize: 0}, null), |
| | | this.alarmConfigService.getByOid( row.id ) |
| | | ).subscribe(([pageBean, resultBean]) => { |
| | | console.log(pageBean); |
| | | this.grid.loading = false; |
| | | this.organizationService.handle = 'config' ; |
| | | this.organizationService.data = row; |
| | | this.organizationService.config = {pageBean,resultBean}; |
| | | this.organizationService.config = {pageBean, resultBean}; |
| | | this.organizationService.title = '组织配置'; |
| | | }); |
| | | } |
| | |
| | | OrganizationConfigComponent, |
| | | OrganizationListComponent |
| | | ], |
| | | providers: [ToolsService, SensorsService,OrganizationService, _HttpClient, FormBuilder, AreacodeService], |
| | | providers: [ToolsService, SensorsService, OrganizationService, _HttpClient, FormBuilder, AreacodeService], |
| | | entryComponents: COMPONENTS_NOROUNT |
| | | }) |
| | | export class SystemsModule { } |
| | |
| | | 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], |
| | |
| | | allChecked = false; |
| | | indeterminate = false; |
| | | sortMap: string[] = []; |
| | | loading: boolean = true; |
| | | loading = true; |
| | | |
| | | constructor( |
| | | public http: HttpClient, |
| | |
| | | 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('账户保存成功!'); |
| | |
| | | |
| | | checkAll(value: boolean) { |
| | | this.data.forEach(i => { |
| | | if (i.isDelete == '1') { |
| | | if (i.isDelete === '1') { |
| | | i.checked = false; |
| | | } else { |
| | | i.checked = value; |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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], |
| | |
| | | }); |
| | | 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}) |
| | | this.http.get(environment.SERVER_BASH_URL + '/operateUser/unique-mobile?mobile='+value) |
| | | if (mobileControl.errors == null) { |
| | | 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(); |
| | | } |
| | | // 以错误的形式结束本次请求 |
| | |
| | | }) |
| | | ) |
| | | .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); |
| | | } |
| | | } |
| | |
| | | import {ModalHelper} from '@delon/theme'; |
| | | import {HttpClient} from '@angular/common/http'; |
| | | import {UserInstallerEditComponent} from './edit/edit.component'; |
| | | import {environment} from 'environments/environment'; |
| | | import {environment} from 'environments/environment'; |
| | | import {DateService} from '@business/services/util/date.service'; |
| | | |
| | | @Component({ |
| | |
| | | allChecked = false; |
| | | indeterminate = false; |
| | | sortMap: any = {}; |
| | | loading: boolean = true; |
| | | loading = true; |
| | | |
| | | constructor( |
| | | public http: HttpClient, |
| | |
| | | |
| | | checkAll(value: boolean) { |
| | | this.curRows.forEach(i => { |
| | | if (i.isDelete == '1') { |
| | | if (i.isDelete === '1') { |
| | | i.checked = false; |
| | | } else { |
| | | i.checked = value; |
| | |
| | | } |
| | | ]; |
| | | |
| | | const COMPONENTS_NOROUNT = [ UserInstallerEditComponent,AlarmUserEditComponent ]; |
| | | const COMPONENTS_NOROUNT = [ UserInstallerEditComponent, AlarmUserEditComponent ]; |
| | | |
| | | @NgModule({ |
| | | imports: [ |
| | |
| | | "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, |