import { statisticsInAndOut, realTimeAlarmTaskRate, statisticsComprehensive, realTimeCapture } from '../api/home'
|
export default class CategoryData {
|
public dataType: String = "";
|
public showType: String = "";
|
public xAxisArray: Array<String> = [];
|
public seriesArray: Array<object> = [];
|
public pieData: Array<object> = [];
|
public pieName: String = "";
|
public pieList: Array<object> = [];
|
public mutPieCameraList: Array<number> = [];
|
public mutPieVisitorList: Array<number> = [];
|
public mutAnalysisList: Array<number> = [];
|
public warnCount: Number = 0;
|
public warnInfo: Object = {};
|
public personList: Array<object> = [];
|
public isShow: Boolean = false;
|
public dataStatus: String = "";
|
public dataTitle: String = "";
|
public intervalId: number = 0;
|
|
constructor() {
|
this.dataType = "person";
|
this.showType = "echarts";//echarts:图表 || list:记录
|
this.xAxisArray = ['06:00', '09:00', '12:00', '15:00', '18:00', '21:00'];
|
this.seriesArray = []
|
//预警事件数据源
|
this.pieData = []
|
this.pieName = "预警事件"
|
this.pieList = []
|
//设备在线情况统计
|
this.mutPieCameraList = []
|
this.mutPieVisitorList = []
|
this.mutAnalysisList = []
|
//当前预警总数
|
this.warnCount = 0
|
//当前预警信息
|
this.warnInfo = {}
|
//预警列表数据
|
this.personList = []
|
this.isShow = false
|
//预警列表显示数据类型 详情:default 人脸:person 行为:action
|
this.dataStatus = "default"
|
//预警列表title:
|
this.dataTitle = "行为"
|
//报警列表请求函数定时id
|
this.intervalId = 0
|
}
|
|
async statisticsInAndOut() {
|
const res: any = await statisticsInAndOut({
|
category: this.dataType
|
})
|
if (res && res.success) {
|
this.xAxisArray = res.data.timestamp
|
if (this.dataType === 'person') {
|
this.seriesArray = [
|
{
|
name: '进校人数',
|
data: res.data.inOfPerson.totalInOfPerson,
|
type: 'line',
|
itemStyle: {
|
color: '#43DBDB'
|
}
|
},
|
{
|
name: '出校人数',
|
data: res.data.outOfPerson.totalInOfPerson,
|
type: 'line',
|
itemStyle: {
|
color: '#F50387'
|
}
|
}
|
]
|
} else {
|
this.seriesArray = [
|
{
|
name: '进校车辆',
|
data: res.data.inOfCar.totalInOfPerson,
|
type: 'line',
|
itemStyle: {
|
color: '#43DBDB'
|
}
|
},
|
{
|
name: '出校车辆',
|
data: res.data.outOfCar.totalInOfPerson,
|
type: 'line',
|
itemStyle: {
|
color: '#F50387'
|
}
|
}
|
]
|
}
|
// console.log(res,this.seriesArray,this.xAxisArray,'进出入折线图')
|
}
|
}
|
|
async realTimeAlarmTaskRate() {
|
const res: any = await realTimeAlarmTaskRate({})
|
if (res && res.success) {
|
this.pieData = res.data.map(i => {
|
let obj: any = {}
|
obj.value = i.value
|
obj.name = i.name
|
return obj
|
})
|
// console.log(this.pieData, '预警事件')
|
}
|
|
}
|
|
async statisticsComprehensive() {
|
const res: any = await statisticsComprehensive({})
|
// console.log(res,'当前预警总数')
|
if (res && res.success) {
|
//this.warnCount = res.data
|
this.warnInfo = res.data
|
}
|
}
|
|
async realTimeCapture() {
|
let str = ''
|
if (this.dataStatus === 'default') {
|
str = 'all'
|
} else if (this.dataStatus === 'person') {
|
str = 'face'
|
} else {
|
str = this.dataStatus.toString()
|
}
|
|
const res: any = await realTimeCapture({
|
category: str,
|
init: true,
|
isAlarm: 'true'
|
})
|
// console.log(res,'预警列表数据')
|
if (res && res.success) {
|
this.personList = res.data.dataList
|
// console.log(this.personList, "realTimeCapture")
|
}
|
}
|
|
setInterval() {
|
this.intervalId = window.setInterval(() => {
|
// this.realTimeCapture()
|
this.realTimeAlarmTaskRate()
|
}, 11 * 1000)
|
// console.log(this.intervalId,'定时器id')
|
}
|
clearInterval() {
|
clearInterval(this.intervalId)
|
}
|
}
|