| | |
| | | <div class="content__title"> |
| | | <h1>Page Name</h1> |
| | | </div> |
| | | <pro-header [title]="'Page Name'"></pro-header> |
| | | <h1> |
| | | 设备维护 |
| | | <small>包含设备的查询、编辑、删除、配置等功能</small> |
| | | </h1> |
| | | </div> |
| | | <nz-card [nzBordered]="false"> |
| | | <div nz-row class="mb-sm"> |
| | | <div nz-col [nzSpan]="4"> |
| | | <button nz-button (click)="addOrModify($event)" [nzType]="'primary'" [nzSize]="'large'"> |
| | | <i class="anticon anticon-plus"></i><span>新建</span> |
| | | </button> |
| | | <ng-container *ngIf="selectedRows.length > 0"> |
| | | <button nz-button [nzSize]="'large'" (click)="deleteSelected()">批量删除</button> |
| | | </ng-container> |
| | | </div> |
| | | <div nz-col [nzSpan]="7"> |
| | | <span style="padding: 5px 10px;"> |
| | | 组织: |
| | | </span> |
| | | <nz-select style="width: 79%;" [(ngModel)]="queryMap.orgId" (ngModelChange)="setOrgId($event)" [nzPlaceHolder]="'选择 组织(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="orgSelectChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of orgOptions" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | | </div> |
| | | <div nz-col [nzSpan]="7"> |
| | | <span style="padding: 5px 10px;"> |
| | | 监控站: |
| | | </span> |
| | | <nz-select style="width: 75%;" [(ngModel)]="queryMap.mpointId" (ngModelChange)="setMpointId($event)" [nzPlaceHolder]="'选择 监控站名称(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="monitorPointChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of monitorPoints" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | | </div> |
| | | <div nz-col [nzSpan]="6"> |
| | | <nz-input [ngStyle]="{'width': '240px','float':'right'}" [(ngModel)]="queryText" name="" [nzPlaceHolder]="'请输入设备名称或设备mac'" |
| | | (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> |
| | | </div> |
| | | </div> |
| | | <div class="mb-md"> |
| | | <nz-alert *ngIf="selectedRows.length > 0" [nzType]="'info'" [nzShowIcon]="true"> |
| | | <span alert-body> |
| | | 已选择<strong class="text-primary">{{selectedRows.length}}</strong>项 |
| | | </span> |
| | | </nz-alert> |
| | | </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> |
| | | |
| | |
| | | import { Component, OnInit } from '@angular/core'; |
| | | import { _HttpClient } from '@delon/theme'; |
| | | import { MonitorPointService } from '@business/services/http/monitor-point.service'; |
| | | import { CoorPicker, Device } from '@business/entity/data'; |
| | | import { ModalHelper, _HttpClient } from '@delon/theme'; |
| | | import { NzModalService, NzMessageService } from 'ng-zorro-antd'; |
| | | import { PageBean, ResultBean } from '@business/entity/grid'; |
| | | import { DeviceService } from '@business/services/http/device.service'; |
| | | import { Component, OnInit, ElementRef, ViewChild } from '@angular/core'; |
| | | import { SimpleTableColumn, SimpleTableComponent } from '@delon/abc'; |
| | | import { Subject } from 'rxjs/Subject'; |
| | | import { CoordinatesPickerComponent } from 'app/routes/map/coordinates-picker/coordinates-picker.component'; |
| | | import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; |
| | | import { OrganizationService } from '@business/services/http/organization.service'; |
| | | import { ExampleService, Criteria } from '@business/services/util/example.service'; |
| | | import { AdjustConfigComponent } from '../../devices/basic-info/adjust-config/adjust-config.component'; |
| | | import { DeviceEditComponent } from '../../devices/basic-info/device-edit/device-edit.component'; |
| | | |
| | | @Component({ |
| | | selector: 'app-device-maintenance', |
| | | templateUrl: './device-maintenance.component.html', |
| | | }) |
| | | export class DeviceMaintenanceComponent implements OnInit { |
| | | |
| | | constructor( |
| | | private http: _HttpClient |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | | } |
| | | |
| | | } |
| | | columns: SimpleTableColumn[] = [ |
| | | { title: '编号', index: 'id', type: 'checkbox' }, |
| | | { title: '名称', index: 'name' }, |
| | | { title: 'mac', index: 'mac' }, |
| | | { 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: '操作区', |
| | | buttons: [ |
| | | { |
| | | text: '编辑', |
| | | type: 'none', |
| | | click: (record: any) => this.addOrModify(record) |
| | | }, |
| | | { |
| | | text: '删除', |
| | | type: 'del', |
| | | click: (record: any) => this.delete(record.id) |
| | | }, |
| | | { |
| | | text: '更多', |
| | | children: [ |
| | | { |
| | | text: `配置校准值`, |
| | | type: 'static', |
| | | component: AdjustConfigComponent, |
| | | format: (record: any) => `<i class="anticon anticon-setting"></i>配置校准值` |
| | | }, |
| | | { |
| | | text: `配置坐标`, |
| | | type: 'none', |
| | | click: (record: any) => this.configCoord(record), |
| | | format: (record: any) => `<i class="anticon anticon-environment-o"></i>配置坐标` |
| | | } |
| | | ] |
| | | } |
| | | ] |
| | | } |
| | | ]; |
| | | queryTextStream: Subject<string> = new Subject<string>(); |
| | | public queryMap: {orgId?: number, mpointId?: number, devMacOrName?: string} |
| | | = {orgId: null, mpointId: null, devMacOrName: ''}; |
| | | extraParams = { queryParams: null }; |
| | | public orgOptions = []; |
| | | public monitorPoints = []; |
| | | constructor( |
| | | private monitorPointService: MonitorPointService, |
| | | private deviceService: DeviceService, |
| | | private confirmServ: NzModalService, |
| | | public msgSrv: NzMessageService, |
| | | private modalHelper: ModalHelper, |
| | | private coorPickerService: CoorPickerService, |
| | | private organizationService: OrganizationService, |
| | | private http: _HttpClient |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | | this.queryTextStream |
| | | .debounceTime(900) |
| | | .distinctUntilChanged() |
| | | .subscribe(value => { |
| | | this.queryMap.devMacOrName = value; |
| | | this.load(); |
| | | }); |
| | | this.orgSelectChange(); |
| | | } |
| | | get listUrl() { |
| | | return this.deviceService.getListUrl(); |
| | | } |
| | | queryText: string; |
| | | selectedRows: any[] = []; |
| | | checkboxChange(list: any[]) { |
| | | this.selectedRows = list; |
| | | } |
| | | deleteSelected() { |
| | | this.confirmServ.confirm({ |
| | | title: '批量删除', |
| | | content: '注意:数据一旦删除,将不可恢复!', |
| | | okText: '确定', |
| | | cancelText: '取消' |
| | | }).on('onOk', () => { |
| | | if (this.selectedRows != null && this.selectedRows.length > 0) { |
| | | const ids = this.selectedRows.map( |
| | | (row: any) => { |
| | | |
| | | return Number.parseInt(row.id); |
| | | } |
| | | ); |
| | | this.delete(...ids); |
| | | } |
| | | }); |
| | | } |
| | | load() { |
| | | const example = this.initQueryExample(); |
| | | this.extraParams.queryParams = example.getSqlParam(); |
| | | this.selectedRows = []; |
| | | this.deviceService.countByExample(example).subscribe( |
| | | res => { |
| | | if (!!res && !!res.code) { |
| | | const count = res.data; |
| | | const pages = Math.ceil(count / this.simpleTable.ps); |
| | | const pi = this.simpleTable.pi > pages ? pages : this.simpleTable.pi; |
| | | this.simpleTable.load(pi); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | } |
| | | private initQueryExample() { |
| | | const example = new ExampleService(); |
| | | const orgId = !!this.queryMap.orgId ? this.queryMap.orgId : null; |
| | | const mpointId = !!this.queryMap.mpointId ? this.queryMap.mpointId : null; |
| | | const devMacOrName = !!this.queryMap.devMacOrName && !!(<string>this.queryMap.devMacOrName).trim() ? this.queryMap.devMacOrName : null; |
| | | let criWithMac: Criteria = null; |
| | | let criWithName: Criteria = null; |
| | | if (!!devMacOrName) { |
| | | criWithName = example.or().andLike({name: 'name', value: '%' + devMacOrName + '%'}); |
| | | criWithMac = example.or().andLike({name: 'mac', value: '%' + devMacOrName + '%'}); |
| | | } |
| | | if (!!mpointId) { |
| | | if (!!devMacOrName) { |
| | | criWithName.andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | criWithMac.andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | }else { |
| | | example.or().andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | } |
| | | } else if (!!orgId) { |
| | | if (!!devMacOrName) { |
| | | criWithName.andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | criWithMac.andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | }else { |
| | | example.or().andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | } |
| | | } |
| | | return example; |
| | | } |
| | | delete(...id: number[]) { |
| | | this.deviceService.delete(...id).subscribe( |
| | | (res: any) => { |
| | | if (res.code === 1) { |
| | | this.load(); |
| | | this.msgSrv.success('删除成功!'); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | @ViewChild('simpleTable') simpleTable: SimpleTableComponent; |
| | | queryTextChanged(event) { |
| | | this.queryTextStream.next(this.queryText); |
| | | } |
| | | addOrModify(d) { |
| | | const data = {}; |
| | | if (d != null) { |
| | | Object.assign(data, d); |
| | | } |
| | | let configMap = {}; |
| | | configMap = Object.assign(configMap, this.queryMap); |
| | | // Object.assign(configMap, this.queryMap); |
| | | if (!!configMap['mpointId'] && !d['monitorPoint']) { |
| | | data['monitorPoint'] = this.getMonitorPoint(configMap['mpointId']); |
| | | } |
| | | this.modalHelper.static(DeviceEditComponent, { data, configMap }).subscribe( |
| | | (ret: { data: any, close: Function }) => { |
| | | // 修改状态 |
| | | if (ret.data['id'] != null) { |
| | | const origData = d; |
| | | const isModified = Object.keys(ret.data).some( |
| | | (key: string) => { |
| | | return ret.data[key] !== origData[key]; |
| | | } |
| | | ); |
| | | // 未作修改 |
| | | if (!isModified) { |
| | | ret.close(); |
| | | this.msgSrv.success('数据未作任何修改!'); |
| | | return; |
| | | } |
| | | } |
| | | this.deviceService.save(ret.data).subscribe( |
| | | (res: any) => { |
| | | if (res.code === 1) { |
| | | this.load(); |
| | | ret.close(); |
| | | this.msgSrv.success('数据保存成功!'); |
| | | } |
| | | } |
| | | ); |
| | | }); |
| | | } |
| | | private getMonitorPoint(mpointId: number) { |
| | | return this.monitorPoints.find( |
| | | mpoint => mpoint.id === mpointId |
| | | ); |
| | | } |
| | | configCoord(record: Device): void { |
| | | // 复制数据放在此处,放在后面,adress会被覆盖 |
| | | Object.assign(this.coorPickerService.data, record); |
| | | this.coorPickerService.data['describe'] = '设备名称'; |
| | | // 当前 坐标未设置 取监控点地址 |
| | | if ((!record.latitude || !record.longitude) && !!record.monitorPointId) { |
| | | this.monitorPointService.getEntity(record.monitorPointId).subscribe( |
| | | res => { |
| | | if (res != null && res.code === 1 && res.data != null) { |
| | | const areaNames = res.data.areaNames; |
| | | let adress = ''; |
| | | if (areaNames != null) { |
| | | adress += !!areaNames.provinceName ? areaNames.provinceName : ''; |
| | | adress += ' '; |
| | | adress += !!areaNames.cityName ? areaNames.cityName : ''; |
| | | adress += ' '; |
| | | adress += !!areaNames.areaName ? areaNames.areaName : ''; |
| | | adress += ' '; |
| | | adress += !!res.data.address ? res.data.address : ''; |
| | | } |
| | | this.coorPickerService.data.address = adress; |
| | | this.openMap(record); |
| | | } |
| | | } |
| | | ); |
| | | } else { |
| | | this.openMap(record); |
| | | } |
| | | } |
| | | private openMap(record: Device) { |
| | | const _data = this.coorPickerService.data; |
| | | this.modalHelper.static(CoordinatesPickerComponent).subscribe( |
| | | (staticComp) => { |
| | | const data: Device = { |
| | | id: record.id, |
| | | mac: record.mac, |
| | | longitude: _data.longitude, |
| | | latitude: _data.latitude, |
| | | }; |
| | | this.deviceService.save(data).subscribe( |
| | | (resp: any) => { |
| | | if (resp.code === 1) { |
| | | this.load(); |
| | | this.msgSrv.success('坐标配置成功!'); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | ); |
| | | } |
| | | public setOrgId(orgId) { |
| | | this.queryMap.orgId = orgId; |
| | | this.queryMap.mpointId = null; |
| | | // this.queryMap.devMacOrName = null; |
| | | this.monitorPointChange(); |
| | | this.load(); |
| | | } |
| | | public setMpointId(mpointId) { |
| | | this.queryMap.mpointId = mpointId; |
| | | this.load(); |
| | | } |
| | | orgSelectChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.organizationService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.orgOptions = res.data; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | monitorPointChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | const example = new ExampleService(); |
| | | const organizationId = !!this.queryMap.orgId ? this.queryMap.orgId : null; |
| | | const mpointName = !!text ? '%' + text + '%' : null; |
| | | example.or() |
| | | .andEqualTo({name: 'organizationId', value: organizationId }) |
| | | .andLike({name: 'name', value: mpointName }); |
| | | this.monitorPointService.getPageByExample(pageBean, example).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.monitorPoints = res.data; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | } |
| | |
| | | <div class="content__title"> |
| | | <h1>Page Name</h1> |
| | | </div> |
| | | <pro-header [title]="'Page Name'"></pro-header> |
| | | <h1> |
| | | 设备状态 |
| | | <small>设备状态显示:正常,离线</small> |
| | | </h1> |
| | | </div> |
| | | <nz-card [nzBordered]="false"> |
| | | <div nz-row class="mb-sm"> |
| | | <div nz-col [nzSpan]="4"> |
| | | <button nz-button (click)="addOrModify($event)" [nzType]="'primary'" [nzSize]="'large'"> |
| | | <i class="anticon anticon-plus"></i><span>新建</span> |
| | | </button> |
| | | <ng-container *ngIf="selectedRows.length > 0"> |
| | | <button nz-button [nzSize]="'large'" (click)="deleteSelected()">批量删除</button> |
| | | </ng-container> |
| | | </div> |
| | | <div nz-col [nzSpan]="7"> |
| | | <span style="padding: 5px 10px;"> |
| | | 组织: |
| | | </span> |
| | | <nz-select style="width: 79%;" [(ngModel)]="queryMap.orgId" (ngModelChange)="setOrgId($event)" [nzPlaceHolder]="'选择 组织(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="orgSelectChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of orgOptions" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | | </div> |
| | | <div nz-col [nzSpan]="7"> |
| | | <span style="padding: 5px 10px;"> |
| | | 监控站: |
| | | </span> |
| | | <nz-select style="width: 75%;" [(ngModel)]="queryMap.mpointId" (ngModelChange)="setMpointId($event)" [nzPlaceHolder]="'选择 监控站名称(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="monitorPointChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of monitorPoints" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | | </div> |
| | | <div nz-col [nzSpan]="6"> |
| | | <nz-input [ngStyle]="{'width': '240px','float':'right'}" [(ngModel)]="queryText" name="" [nzPlaceHolder]="'请输入设备名称或设备mac'" |
| | | (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> |
| | | </div> |
| | | </div> |
| | | <div class="mb-md"> |
| | | <nz-alert *ngIf="selectedRows.length > 0" [nzType]="'info'" [nzShowIcon]="true"> |
| | | <span alert-body> |
| | | 已选择<strong class="text-primary">{{selectedRows.length}}</strong>项 |
| | | </span> |
| | | </nz-alert> |
| | | </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'}"> |
| | | <ng-template st-row="state-badge" let-item let-index="index"> |
| | | <ng-container [ngSwitch]="item.state"> |
| | | <span *ngSwitchCase="'0'"> |
| | | <nz-badge [nzStatus]="'success'" [nzText]="'正常'"></nz-badge> |
| | | </span> |
| | | <span *ngSwitchCase="'1'"> |
| | | <nz-badge [nzStatus]="'processing'" [nzText]="'轻度'"></nz-badge> |
| | | </span> |
| | | <span *ngSwitchCase="'2'"> |
| | | <nz-badge [nzStatus]="'warning'" [nzText]="'中度'"></nz-badge> |
| | | </span> |
| | | <span *ngSwitchCase="'3'"> |
| | | <nz-badge [nzStatus]="'error'" [nzText]="'严重'"></nz-badge> |
| | | </span> |
| | | <span *ngSwitchDefault> |
| | | <nz-badge [nzStatus]="'default'" [nzText]="'离线'"></nz-badge> |
| | | </span> |
| | | </ng-container> |
| | | </ng-template> |
| | | </simple-table> |
| | | </nz-card> |
| | | |
| | |
| | | import { Component, OnInit } from '@angular/core'; |
| | | import { _HttpClient } from '@delon/theme'; |
| | | import { MonitorPointService } from '@business/services/http/monitor-point.service'; |
| | | import { CoorPicker, Device } from '@business/entity/data'; |
| | | import { ModalHelper, _HttpClient } from '@delon/theme'; |
| | | import { NzModalService, NzMessageService } from 'ng-zorro-antd'; |
| | | import { PageBean, ResultBean } from '@business/entity/grid'; |
| | | import { DeviceService } from '@business/services/http/device.service'; |
| | | import { Component, OnInit, ElementRef, ViewChild } from '@angular/core'; |
| | | import { SimpleTableColumn, SimpleTableComponent } from '@delon/abc'; |
| | | import { Subject } from 'rxjs/Subject'; |
| | | import { CoordinatesPickerComponent } from 'app/routes/map/coordinates-picker/coordinates-picker.component'; |
| | | import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; |
| | | import { OrganizationService } from '@business/services/http/organization.service'; |
| | | import { ExampleService, Criteria } from '@business/services/util/example.service'; |
| | | import { AdjustConfigComponent } from '../../devices/basic-info/adjust-config/adjust-config.component'; |
| | | import { DeviceEditComponent } from '../../devices/basic-info/device-edit/device-edit.component'; |
| | | |
| | | @Component({ |
| | | selector: 'app-device-status', |
| | | templateUrl: './device-status.component.html', |
| | | }) |
| | | export class DeviceStatusComponent implements OnInit { |
| | | |
| | | constructor( |
| | | private http: _HttpClient |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | | } |
| | | |
| | | } |
| | | private getBadge(id): string { |
| | | return `<div>${id}</div>`; |
| | | } |
| | | columns: SimpleTableColumn[] = [ |
| | | { title: '编号', index: 'id', type: 'checkbox' }, |
| | | { title: '名称', index: 'name' }, |
| | | { title: 'mac', index: 'mac' }, |
| | | { |
| | | title: '状态', |
| | | render: 'state-badge' |
| | | }, |
| | | { 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' }, |
| | | ]; |
| | | queryTextStream: Subject<string> = new Subject<string>(); |
| | | public queryMap: {orgId?: number, mpointId?: number, devMacOrName?: string} |
| | | = {orgId: null, mpointId: null, devMacOrName: ''}; |
| | | extraParams = { queryParams: null }; |
| | | public orgOptions = []; |
| | | public monitorPoints = []; |
| | | constructor( |
| | | private monitorPointService: MonitorPointService, |
| | | private deviceService: DeviceService, |
| | | private confirmServ: NzModalService, |
| | | public msgSrv: NzMessageService, |
| | | private modalHelper: ModalHelper, |
| | | private coorPickerService: CoorPickerService, |
| | | private organizationService: OrganizationService, |
| | | private http: _HttpClient |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | | this.queryTextStream |
| | | .debounceTime(900) |
| | | .distinctUntilChanged() |
| | | .subscribe(value => { |
| | | this.queryMap.devMacOrName = value; |
| | | this.load(); |
| | | }); |
| | | this.orgSelectChange(); |
| | | } |
| | | get listUrl() { |
| | | return this.deviceService.getListUrl(); |
| | | } |
| | | queryText: string; |
| | | selectedRows: any[] = []; |
| | | checkboxChange(list: any[]) { |
| | | this.selectedRows = list; |
| | | } |
| | | deleteSelected() { |
| | | this.confirmServ.confirm({ |
| | | title: '批量删除', |
| | | content: '注意:数据一旦删除,将不可恢复!', |
| | | okText: '确定', |
| | | cancelText: '取消' |
| | | }).on('onOk', () => { |
| | | if (this.selectedRows != null && this.selectedRows.length > 0) { |
| | | const ids = this.selectedRows.map( |
| | | (row: any) => { |
| | | |
| | | return Number.parseInt(row.id); |
| | | } |
| | | ); |
| | | this.delete(...ids); |
| | | } |
| | | }); |
| | | } |
| | | load() { |
| | | const example = this.initQueryExample(); |
| | | this.extraParams.queryParams = example.getSqlParam(); |
| | | this.selectedRows = []; |
| | | this.deviceService.countByExample(example).subscribe( |
| | | res => { |
| | | if (!!res && !!res.code) { |
| | | const count = res.data; |
| | | const pages = Math.ceil(count / this.simpleTable.ps); |
| | | const pi = this.simpleTable.pi > pages ? pages : this.simpleTable.pi; |
| | | this.simpleTable.load(pi); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | } |
| | | private initQueryExample() { |
| | | const example = new ExampleService(); |
| | | const orgId = !!this.queryMap.orgId ? this.queryMap.orgId : null; |
| | | const mpointId = !!this.queryMap.mpointId ? this.queryMap.mpointId : null; |
| | | const devMacOrName = !!this.queryMap.devMacOrName && !!(<string>this.queryMap.devMacOrName).trim() ? this.queryMap.devMacOrName : null; |
| | | let criWithMac: Criteria = null; |
| | | let criWithName: Criteria = null; |
| | | if (!!devMacOrName) { |
| | | criWithName = example.or().andLike({name: 'name', value: '%' + devMacOrName + '%'}); |
| | | criWithMac = example.or().andLike({name: 'mac', value: '%' + devMacOrName + '%'}); |
| | | } |
| | | if (!!mpointId) { |
| | | if (!!devMacOrName) { |
| | | criWithName.andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | criWithMac.andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | }else { |
| | | example.or().andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | } |
| | | } else if (!!orgId) { |
| | | if (!!devMacOrName) { |
| | | criWithName.andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | criWithMac.andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | }else { |
| | | example.or().andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | } |
| | | } |
| | | return example; |
| | | } |
| | | delete(...id: number[]) { |
| | | this.deviceService.delete(...id).subscribe( |
| | | (res: any) => { |
| | | if (res.code === 1) { |
| | | this.load(); |
| | | this.msgSrv.success('删除成功!'); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | @ViewChild('simpleTable') simpleTable: SimpleTableComponent; |
| | | queryTextChanged(event) { |
| | | this.queryTextStream.next(this.queryText); |
| | | } |
| | | addOrModify(d) { |
| | | const data = {}; |
| | | if (d != null) { |
| | | Object.assign(data, d); |
| | | } |
| | | let configMap = {}; |
| | | configMap = Object.assign(configMap, this.queryMap); |
| | | // Object.assign(configMap, this.queryMap); |
| | | if (!!configMap['mpointId'] && !d['monitorPoint']) { |
| | | data['monitorPoint'] = this.getMonitorPoint(configMap['mpointId']); |
| | | } |
| | | this.modalHelper.static(DeviceEditComponent, { data, configMap }).subscribe( |
| | | (ret: { data: any, close: Function }) => { |
| | | // 修改状态 |
| | | if (ret.data['id'] != null) { |
| | | const origData = d; |
| | | const isModified = Object.keys(ret.data).some( |
| | | (key: string) => { |
| | | return ret.data[key] !== origData[key]; |
| | | } |
| | | ); |
| | | // 未作修改 |
| | | if (!isModified) { |
| | | ret.close(); |
| | | this.msgSrv.success('数据未作任何修改!'); |
| | | return; |
| | | } |
| | | } |
| | | this.deviceService.save(ret.data).subscribe( |
| | | (res: any) => { |
| | | if (res.code === 1) { |
| | | this.load(); |
| | | ret.close(); |
| | | this.msgSrv.success('数据保存成功!'); |
| | | } |
| | | } |
| | | ); |
| | | }); |
| | | } |
| | | private getMonitorPoint(mpointId: number) { |
| | | return this.monitorPoints.find( |
| | | mpoint => mpoint.id === mpointId |
| | | ); |
| | | } |
| | | configCoord(record: Device): void { |
| | | // 复制数据放在此处,放在后面,adress会被覆盖 |
| | | Object.assign(this.coorPickerService.data, record); |
| | | this.coorPickerService.data['describe'] = '设备名称'; |
| | | // 当前 坐标未设置 取监控点地址 |
| | | if ((!record.latitude || !record.longitude) && !!record.monitorPointId) { |
| | | this.monitorPointService.getEntity(record.monitorPointId).subscribe( |
| | | res => { |
| | | if (res != null && res.code === 1 && res.data != null) { |
| | | const areaNames = res.data.areaNames; |
| | | let adress = ''; |
| | | if (areaNames != null) { |
| | | adress += !!areaNames.provinceName ? areaNames.provinceName : ''; |
| | | adress += ' '; |
| | | adress += !!areaNames.cityName ? areaNames.cityName : ''; |
| | | adress += ' '; |
| | | adress += !!areaNames.areaName ? areaNames.areaName : ''; |
| | | adress += ' '; |
| | | adress += !!res.data.address ? res.data.address : ''; |
| | | } |
| | | this.coorPickerService.data.address = adress; |
| | | this.openMap(record); |
| | | } |
| | | } |
| | | ); |
| | | } else { |
| | | this.openMap(record); |
| | | } |
| | | } |
| | | private openMap(record: Device) { |
| | | const _data = this.coorPickerService.data; |
| | | this.modalHelper.static(CoordinatesPickerComponent).subscribe( |
| | | (staticComp) => { |
| | | const data: Device = { |
| | | id: record.id, |
| | | mac: record.mac, |
| | | longitude: _data.longitude, |
| | | latitude: _data.latitude, |
| | | }; |
| | | this.deviceService.save(data).subscribe( |
| | | (resp: any) => { |
| | | if (resp.code === 1) { |
| | | this.load(); |
| | | this.msgSrv.success('坐标配置成功!'); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | ); |
| | | } |
| | | public setOrgId(orgId) { |
| | | this.queryMap.orgId = orgId; |
| | | this.queryMap.mpointId = null; |
| | | // this.queryMap.devMacOrName = null; |
| | | this.monitorPointChange(); |
| | | this.load(); |
| | | } |
| | | public setMpointId(mpointId) { |
| | | this.queryMap.mpointId = mpointId; |
| | | this.load(); |
| | | } |
| | | orgSelectChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.organizationService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.orgOptions = res.data; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | monitorPointChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | const example = new ExampleService(); |
| | | const organizationId = !!this.queryMap.orgId ? this.queryMap.orgId : null; |
| | | const mpointName = !!text ? '%' + text + '%' : null; |
| | | example.or() |
| | | .andEqualTo({name: 'organizationId', value: organizationId }) |
| | | .andLike({name: 'name', value: mpointName }); |
| | | this.monitorPointService.getPageByExample(pageBean, example).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.monitorPoints = res.data; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | } |
| | |
| | | import { DeviceAdjustValueService } from '@business/services/http/device-adjust-value.service'; |
| | | import { ToolsService } from '@business/services/util/tools.service'; |
| | | import { SensorsService } from '@business/services/http/sensors.service'; |
| | | import { OrganizationService } from '@business/services/http/organization.service'; |
| | | import { MonitorPointService } from '@business/services/http/monitor-point.service'; |
| | | import { VersionService } from '@business/services/http/version.service'; |
| | | import { AreacodeService } from '@business/services/http/areacode.service'; |
| | | import { NgModule } from '@angular/core'; |
| | | import { CommonModule } from '@angular/common'; |
| | | import {RouterModule, Routes} from '@angular/router'; |
| | | import { SharedModule } from '@shared/shared.module'; |
| | | import { _HttpClient } from '@delon/theme/services/http/http.client'; |
| | | import { PipeModule } from '@business/pipe/pipe.module'; |
| | | import { FormBuilder } from '@angular/forms'; |
| | | import { DeviceService } from '@business/services/http/device.service'; |
| | | import { OperateUserService } from '@business/services/http/operate-user.service'; |
| | | 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'; |
| | | import { AdjustConfigComponent } from '../devices/basic-info/adjust-config/adjust-config.component'; |
| | | import { DeviceEditComponent } from '../devices/basic-info/device-edit/device-edit.component'; |
| | | import { VersionEditComponent } from '../devices/version/version-edit/version-edit.component'; |
| | | import { MonitorPointEditComponent } from '../devices/monitor-point/monitor-point-edit/monitor-point-edit.component'; |
| | | import { VersionSensorConfigComponent } from '../devices/version/version-sensor-config/version-sensor-config.component'; |
| | | import { DataAuditComponent } from './data-audit/data-audit.component'; |
| | | import { DeviceStatusComponent } from './device-status/device-status.component'; |
| | | import { DeviceMaintenanceComponent } from './device-maintenance/device-maintenance.component'; |
| | | import { PipeModule } from '@business/pipe/pipe.module'; |
| | | import { CommonModule } from '@angular/common'; |
| | | import { RouterModule, Routes } from '@angular/router'; |
| | | import { NgxEchartsModule } from 'ngx-echarts'; |
| | | import { NzTreeModule } from 'ng-tree-antd'; |
| | | import { SensorsService } from '@business/services/http/sensors.service'; |
| | | import { NzMessageService } from 'ng-zorro-antd'; |
| | | import { AreacodeService } from '@business/services/http/areacode.service'; |
| | | import { MonitorPointService } from '@business/services/http/monitor-point.service'; |
| | | import { DeviceService } from '@business/services/http/device.service'; |
| | | import { DateService } from '@business/services/util/date.service'; |
| | | import { NgxEchartsModule } from 'ngx-echarts'; |
| | | import { DeviceMaintenanceComponent } from './device-maintenance/device-maintenance.component'; |
| | | |
| | | const COMPONENTS_NOROUNT = [AdjustConfigComponent, DeviceEditComponent, |
| | | VersionEditComponent, MonitorPointEditComponent, |
| | | VersionSensorConfigComponent ]; |
| | | |
| | | const COMPONENT_NOROUNT = []; |
| | | |
| | | const routes: Routes = [ |
| | | { |
| | | path: '', |
| | | children: [ |
| | | { path: 'data-audit', component: DataAuditComponent }, |
| | | { path: 'device-status', component: DeviceStatusComponent }, |
| | | { path: 'device-maintenance', component: DeviceMaintenanceComponent } |
| | | ] |
| | | } |
| | | ]; |
| | | const routes: Routes = [ |
| | | { |
| | | path: '', |
| | | children: [ |
| | | { path: 'data-audit', component: DataAuditComponent }, |
| | | { path: 'device-status', component: DeviceStatusComponent }, |
| | | { path: 'device-maintenance', component: DeviceMaintenanceComponent } |
| | | ] |
| | | } |
| | | ]; |
| | | |
| | | @NgModule({ |
| | | imports: [ |
| | | // 管道模块必须当前模块导入 |
| | | PipeModule, |
| | | NzTreeModule, |
| | | NgxEchartsModule, |
| | | NzTreeModule, |
| | | CommonModule, |
| | | SharedModule, |
| | | MapModule, |
| | | RouterModule.forChild(routes) |
| | | ], |
| | | declarations: [ |
| | | ...COMPONENT_NOROUNT, |
| | | DataAuditComponent, |
| | | DeviceStatusComponent, |
| | | DeviceMaintenanceComponent, |
| | | DataAuditComponent, |
| | | DeviceStatusComponent, |
| | | DeviceMaintenanceComponent, |
| | | ...COMPONENTS_NOROUNT |
| | | ], |
| | | entryComponents: COMPONENT_NOROUNT, |
| | | providers: [SensorsService, NzMessageService, AreacodeService, |
| | | MonitorPointService, DeviceService, DateService], |
| | | providers: [CoorPickerService, DeviceAdjustValueService, OrganizationService, VersionService, |
| | | SensorsService, AreacodeService, MonitorPointService, |
| | | _HttpClient, FormBuilder, DeviceService, OperateUserService, ToolsService], |
| | | entryComponents: [...COMPONENTS_NOROUNT,CoordinatesPickerComponent] |
| | | }) |
| | | export class OperationModule { } |