ZZJ
2022-07-18 65752fcffafa02c5f646d0a6207c85bf81284b73
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
import {
  getSearchList,
  getTagList,
  getTaskList,
  getAlarmLevel,
  findPersonByPic,
  findPerson,
  addToBase
} from "@/api/search";
export default class VideoPhotoData {
  public searchFrom: string = 'search';
  public preCards: Array<object> = [];
  public cards: Array<object> = [];
  public persons: Array<object> = [];
  public activeName: string = "pic"
  public page: number = 1;
  public size: number;
  public pageSizeOption: Array<number>;
  public alarmlevel: Array<object>;
  public dictionary: object = {};
  public monitorLevel: Array<object> = [];
  public queryAlarmlevel: Array<string> = [];
  public inputValue: string;
  public searchTime: Array<string>;
  public showType: string;
  public tabs: Array<object>;
  public blackList: Array<object> = [];
  public selectBlacks: Array<object> = [];
  public whiteList: Array<object> = [];
  public selectWhites: Array<object> = [];
  public queryTabs: Array<string> = [];
  public compareTabs: Array<string> = [];
  public tasks: Array<object>;
  public queryTasks: Array<string> = [];
  public treeNodes: Array<string>;
  public total: number = 0;
  public tabsForUploadImg: Array<object> = [];
  public picUrl: string = "";
  public threshold: number = 60;
  public activeCard: number | string = "";
  public uploadImg: any = "";
  public captureId: string = "";
  public compareNum: string = "";
  public compTargetId: string = "";
  public compTargetType: string = "1";
  public rightSectionDisplay: boolean = false;
  public scrollContainDom: any = '';
  public uploadDiaplay: boolean = false;
  public uploadType: boolean = false;
 
  constructor() {
    this.cards = [];
    this.size = 60;
    this.pageSizeOption = [30, 60, 120]
    this.alarmlevel = [];
    this.inputValue = "";
    this.searchTime = [];
    this.showType = "search";
    this.tabs = [];
    this.tasks = [];
    this.treeNodes = [];
  }
 
  clearStatus() {
    //this.cards = [];
    this.page = 1;
    this.size = 60;
    this.pageSizeOption = [30, 60, 120]
    this.alarmlevel = [];
    this.inputValue = "";
    this.showType = "search";
  }
 
  async querySearchList() {
    this.cards = []
    this.preCards = []
    var param: any = {
      page: this.page,
      size: this.size,
      searchTime: this.searchTime,
      alarmlevel: this.queryAlarmlevel,
      inputValue: this.inputValue,
      tabs: this.queryTabs,
      tasks: this.queryTasks,
      treeNodes: this.treeNodes,
      dataSource: "camera"
    }
    if (this.searchFrom == 'cluster') {
      param.isAll = true
    }
    const rsp: any = await getSearchList(param);
    if (rsp && rsp.success) {
      this.cards.length = 0 // 清两次,第一次是为了点完之后不会出现之前数据的残影,这次是为了防止因为异步问题两次请求会出现双倍数据的问题
      this.preCards.length = 0
      if (rsp.data.datalist) {
        rsp.data.datalist.forEach(element => {
 
    if(element.activeObject.targetInfo&&element.activeObject.targetInfo.length === 0) {
      element.activeObject.targetInfo = null
    }
    
    if(element.list[0].targetInfo&&element.list[0].targetInfo.length === 0) {
      element.list[0].targetInfo = null
    }
 
          element.ownerPage = this.page
          this.cards.push(element as any);
          // 只允许每个card渲染一张图片
          // var obj = {activeObject: element.activeObject,ownerPage: element.ownerPage,list: [],length: element.list.length}
          // obj.list.push(element.activeObject)
          // this.preCards.push(obj)
        });
      }
      //console.log("cards的数量",this.cards)
      this.total = rsp.data.total;
    }
  }
 
  async findPerson() {
    this.cards = []
    var param = {
      page: this.page,
      size: this.size,
      searchTime: this.searchTime,
      alarmlevel: this.queryAlarmlevel,
      inputValue: this.inputValue,
      tabs: this.queryTabs,
      treeNodes: this.treeNodes,
      picUrl: this.picUrl,
      databases: this.compareTabs,
      threshold: this.threshold,
      isAll: this.searchFrom == "cluster" ? true : false
    }
    const rsp: any = await findPersonByPic(param);
    if (rsp && rsp.success) {
      rsp.data.totalList.forEach(element => {
        var obj = {
          activeObject: (element as any),
          list: []
        }
        element.ownerPage = this.page
        obj.list.push((element as any))
        this.cards.push(obj)
      });
      // console.log("以图搜图查回来的人",this.persons)
      this.total = rsp.data.total
      this.compareNum = rsp.data.compareNum
    }
  }
  async findPerson2() {
    // 111
    this.cards = []
    var compType = this.compTargetType == "1" ? 1 : 0
    let param
    if (this.searchFrom == "cluster") {
      param = {
        page: this.page,
        size: this.size,
        searchTime: this.searchTime,
        picUrl: this.picUrl,
        alarmlevel: this.queryAlarmlevel,
        inputValue: this.inputValue,
        tasks: this.queryTasks,
        treeNodes: this.treeNodes,
        compTargetId: this.compTargetId,
        compTargetType: compType,
        databases: this.compareTabs,
        threshold: this.threshold,
        isAll: true
      }
    } else {
      param = {
        page: this.page,
        size: this.size,
        searchTime: this.searchTime,
        picUrl: this.picUrl,
        alarmlevel: this.queryAlarmlevel,
        inputValue: this.inputValue,
        tasks: this.queryTasks,
        treeNodes: this.treeNodes,
        compTargetId: this.compTargetId,
        compTargetType: compType,
        databases: this.compareTabs,
        threshold: this.threshold,
      }
    }
    const rsp: any = await findPersonByPic(param);
    if (rsp && rsp.success) {
      rsp.data.totalList.forEach(element => {
        var obj = {
          activeObject: (element as any),
          list: []
        }
        element.ownerPage = this.page
        obj.list.push((element as any))
        this.cards.push(obj)
      });
      this.total = rsp.data.total
      this.compareNum = rsp.data.compareNum
    }
  }
  async findPersonByPage() {
    this.cards = []
    var param = {
      page: this.page,
      size: this.size,
      searchTime: this.searchTime,
      alarmlevel: this.queryAlarmlevel,
      inputValue: this.inputValue,
      tasks: this.queryTasks,
      treeNodes: this.treeNodes,
      picUrl: this.picUrl,
      databases: this.compareTabs,
      compareNum: this.compareNum,
      threshold: this.threshold,
      isAll: this.searchFrom == "cluster" ? true : false
    }
    const rsp: any = await findPerson(param);
    if (rsp && rsp.success) {
      rsp.data.totalList.forEach(element => {
        var obj = {
          activeObject: (element as any),
          list: []
        }
        element.ownerPage = this.page
        obj.list.push((element as any))
        this.cards.push(obj)
      });
      this.total = rsp.data.total
      // console.log("findPersonByPage---", this.total, this.persons)
    }
  }
  async queryTagList() {
    const rsp: any = await getTagList({});
    this.tabsForUploadImg.splice(0, this.tabsForUploadImg.length)
    if (rsp && rsp.success) {
      var arr1 = new Array
      arr1 = rsp.data&&rsp.data.tags.filter(i => {
        if (i.status === 1) {
          i.title = i.title + '(已删除)'
          return i
        }
      });
      this.tabs = rsp.data&&rsp.data.tags.filter(function (i) {
        if (i.status !== 1) {
          return i
        }
      })
      this.tabs.push(...arr1)
      this.tabsForUploadImg.push({ key: "esData", title: "抓拍库" });
      rsp.data.tags.forEach(element => {
        this.tabsForUploadImg.push(element as any);
      });
      // 放置黑白名单 0为白名单
      this.blackList.length = 0
      this.whiteList.length = 0
      var josn = JSON.stringify(rsp)
      var resp = JSON.parse(josn)
      resp.data.tags.forEach(i => {
        if (i.status === 0 && i.bwType === "0") { //白名单
          if (i.analyServerId === "") { //同步库
            i.title = i.title + '(同步库)'
            this.whiteList.push(i)
          } else {
            this.whiteList.push(i)
          }
        }
        if (i.status === 0 && i.bwType === "1") { //黑名单
          if (i.analyServerId === "") { //同步库
            i.title = i.title + '(同步库)'
            this.blackList.push(i)
          } else {
            this.blackList.push(i)
          }
        }
      });
    } else {
      // this.$notify({
      //   title: "失败",
      //   message: "检索数据查询失败!",
      //   type: "warning"
      // });
    }
  }
 
  async queryTaskList() {
    let params: any = {};
    if (this.searchFrom == 'cluster') {
      params.isPlatform = 1
    }
    console.log(params)
    const rsp: any = await getTaskList(params);
    if (rsp && rsp.success) {
      // this.tasks.splice(0, this.tasks.length)
      // rsp.data.forEach(element => {
      //   this.tasks.push((element as any).task);
      // });
      let taskNames = [];
      this.tasks = [];
      rsp.data.aggs.forEach((d: any) => {
        if (taskNames.indexOf(d.name) < 0) {
          taskNames.push(d.name);
          this.tasks.push(d)
        } else {
          let repeatOne = this.tasks.find((one: any) => one.name == d.name);
          repeatOne['id'] += `,${d.id}`;
          repeatOne['isDelete'] = repeatOne['isDelete'] && d.isDelete
        }
      });
    }
  }
 
  async queryDictionary() {
    const rsp: any = await getAlarmLevel({});
    if (rsp && rsp.success) {
      this.dictionary = rsp.data;
      // console.log("字典是:", this.dictionary)
 
      //this.dictionary['ALARMLEVEL'].unshift({ name: '撤防', value: "-1" })
    }
  }
  async addBase(item) {
    var param = {
      captureId: item.id,
      tableIds: this.selectWhites.length > 0 ? this.selectWhites : this.selectBlacks
    }
    const rsp: any = await addToBase(param)
    return rsp
  }
 
  // async getMonitorLevel() {
  //   const rsp: any = await getAlarmLevel({});
  //   if (rsp && rsp.success) {
  //     this.monitorLevel = rsp.data.MONITORLEVEL;
  //   }
  // }
}