|
|
|
import { Component, OnInit, ViewContainerRef } from '@angular/core';
|
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
import { NzModalService } from 'ng-zorro-antd/modal';
|
|
|
|
import { GetOutOfLineDetailsComponent } from './get-out-of-line-details/get-out-of-line-details.component';
|
|
|
|
// import { TreeService } from 'src/app/service/tree.service';
|
|
|
|
// import { NavChangeService } from 'src/app/service/navChange.service';
|
|
|
|
import { TreeService } from '../../service/tree.service';
|
|
|
|
import { NavChangeService } from '../../service/navChange.service';
|
|
|
|
import * as moment from 'moment';
|
|
|
|
import { DispositionComponent } from '../disposition/disposition.component';
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message';
|
|
|
|
@Component({
|
|
|
|
selector: 'app-today-warning',
|
|
|
|
templateUrl: './today-warning.component.html',
|
|
|
|
styleUrls: ['./today-warning.component.scss']
|
|
|
|
})
|
|
|
|
export class TodayWarningComponent implements OnInit {
|
|
|
|
validateForm!: FormGroup;
|
|
|
|
constructor(private http: HttpClient, private fb: FormBuilder, private toTree: TreeService, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private navChangeService: NavChangeService, private message: NzMessageService) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.validateForm = this.fb.group({
|
|
|
|
level: [null],
|
|
|
|
type: [null],
|
|
|
|
area: [null],
|
|
|
|
datePickerStart: [new Date(`${moment(new Date()).format('YYYY-MM-DD')} 00:00`)],
|
|
|
|
datePickerEnd: [new Date(`${moment(new Date()).format('YYYY-MM-DD')} 23:59`)]
|
|
|
|
});
|
|
|
|
this.warningType()
|
|
|
|
this.getEarlyWarningList()
|
|
|
|
}
|
|
|
|
|
|
|
|
//预警类型接口
|
|
|
|
warningTypes: any //预警接口数据
|
|
|
|
warningTypesDetails: any
|
|
|
|
warningType() {
|
|
|
|
this.http.get('/api/services/app/Violation/GetAllList').subscribe((data: any) => {
|
|
|
|
this.warningTypesDetails = data.result
|
|
|
|
this.warningTypes = (data.result as any).groupBy((t) => { return t.violationType });
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
typeChange(e) {
|
|
|
|
this.warningTypes.forEach(element => {
|
|
|
|
if (element.key == e) {
|
|
|
|
this.warningTypesDetails = element
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//获得预警列表
|
|
|
|
list: any = [
|
|
|
|
]
|
|
|
|
totalCount: string //预警总数
|
|
|
|
getEarlyWarningList() {
|
|
|
|
let ViolationIds = []
|
|
|
|
if (this.validateForm.value.type) {
|
|
|
|
this.warningTypesDetails.forEach(item => {
|
|
|
|
item.id ? ViolationIds.push(item.id) : null
|
|
|
|
});
|
|
|
|
}
|
|
|
|
let params = {
|
|
|
|
Level: this.validateForm.value.level,
|
|
|
|
ViolationIds: ViolationIds,
|
|
|
|
ViolateArea: this.validateForm.value.area,
|
|
|
|
organizationUnitId: JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id,
|
|
|
|
ViolateTime: (this.validateForm.value.datePickerEnd && this.validateForm.value.datePickerStart) ? [moment(this.validateForm.value.datePickerStart).format('yyyy-MM-DD HH:mm:ss'), moment(this.validateForm.value.datePickerEnd).format('yyyy-MM-DD HH:mm:ss')] : null,
|
|
|
|
// ViolateTime: ['2021-10-27', '2021-11-26'],
|
|
|
|
IsContainsChildren: 'true',
|
|
|
|
SkipCount: '0',
|
|
|
|
MaxResultCount: '9999'
|
|
|
|
}
|
|
|
|
this.http.get('/api/services/app/ViolateRecord/GetAll', {
|
|
|
|
params: params
|
|
|
|
}).subscribe((data: any) => {
|
|
|
|
this.list = data.result.items
|
|
|
|
this.totalCount = data.result.totalCount
|
|
|
|
console.log('预警列表', this.list)
|
|
|
|
|
|
|
|
let obj = {
|
|
|
|
name: '改变数量',
|
|
|
|
num: this.totalCount
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
this.navChangeService.sendMessage(obj);//发布一条消息
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
submitForm(): void {
|
|
|
|
for (const i in this.validateForm.controls) {
|
|
|
|
this.validateForm.controls[i].markAsDirty();
|
|
|
|
this.validateForm.controls[i].updateValueAndValidity();
|
|
|
|
}
|
|
|
|
this.getEarlyWarningList()
|
|
|
|
}
|
|
|
|
resetForm(e: MouseEvent): void {
|
|
|
|
e.preventDefault();
|
|
|
|
this.validateForm.reset();
|
|
|
|
for (const key in this.validateForm.controls) {
|
|
|
|
this.validateForm.controls[key].markAsPristine();
|
|
|
|
this.validateForm.controls[key].updateValueAndValidity();
|
|
|
|
}
|
|
|
|
this.validateForm.patchValue({
|
|
|
|
datePickerStart: new Date(`${moment(new Date()).format('YYYY-MM-DD')} 00:00`),
|
|
|
|
datePickerEnd: new Date(`${moment(new Date()).format('YYYY-MM-DD')} 23:59`)
|
|
|
|
});
|
|
|
|
this.getEarlyWarningList()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
look(item) {
|
|
|
|
console.log(item)
|
|
|
|
if (item.violation.eventSystemName == '灭火器维护' || item.violation.eventSystemName == '证照预警') {
|
|
|
|
this.message.create('warning', item.desc);
|
|
|
|
} else {
|
|
|
|
const modal = this.modal.create({
|
|
|
|
nzContent: GetOutOfLineDetailsComponent,
|
|
|
|
nzWrapClassName: "vertical-center-modal",
|
|
|
|
nzViewContainerRef: this.viewContainerRef,
|
|
|
|
nzWidth: (document.documentElement.clientHeight < 650 || document.documentElement.clientWidth < 1400) ? 1000 : 1200,
|
|
|
|
nzBodyStyle: {
|
|
|
|
'border': '1px solid #6d9cc7',
|
|
|
|
'border-radius': '0px',
|
|
|
|
'padding': '0px',
|
|
|
|
'box-shadow': '0 0 8px 0 #fff',
|
|
|
|
'background': '#000D21',
|
|
|
|
},
|
|
|
|
nzComponentParams: {
|
|
|
|
data: item
|
|
|
|
},
|
|
|
|
nzFooter: null,
|
|
|
|
nzOnOk: async () => {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const instance = modal.getContentComponent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dispose(item) {
|
|
|
|
console.log(item)
|
|
|
|
if (item.isEnableHandle) {
|
|
|
|
const modal = this.modal.create({
|
|
|
|
nzContent: DispositionComponent,
|
|
|
|
nzWrapClassName: "vertical-center-modal",
|
|
|
|
nzViewContainerRef: this.viewContainerRef,
|
|
|
|
nzWidth: 380,
|
|
|
|
nzBodyStyle: {
|
|
|
|
'border': '1px solid #91CCFF',
|
|
|
|
'border-radius': '0px',
|
|
|
|
'padding': '7px',
|
|
|
|
'box-shadow': '0 0 8px 0 #fff',
|
|
|
|
'background-image': 'linear-gradient(#003665, #000f25)'
|
|
|
|
},
|
|
|
|
nzComponentParams: {},
|
|
|
|
nzFooter: null,
|
|
|
|
nzClosable: false,
|
|
|
|
nzOnOk: async () => {
|
|
|
|
if (instance.validateForm.valid) {
|
|
|
|
await new Promise(resolve => {
|
|
|
|
let body = {
|
|
|
|
id: item.id,
|
|
|
|
handleRecord: instance.validateForm.value.content
|
|
|
|
}
|
|
|
|
this.http.post('/api/services/app/ViolateRecord/HandleViolateRecord', body).subscribe(data => {
|
|
|
|
resolve(data)
|
|
|
|
this.message.create('success', '处置成功!');
|
|
|
|
item.handleTime = new Date()
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.message.create('warning', '请填写完整!');
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const instance = modal.getContentComponent();
|
|
|
|
} else {
|
|
|
|
this.message.create('warning', '无处置权限!');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|