zhangzengfei
2020-09-17 c534501542feeaa6711f78c6cd91661f04eb4bcf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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)
  }
}