src/Pool/VideoTaskData.ts
@@ -1,4 +1,4 @@
import { getCameraTask,getCameraTaskTwo, initTaskData,initTaskDataTwo, monitorRealTimeTaskData } from "@/api/task";
import { getCameraTask,getCameraTaskTwo,getCameraTaskThree, initTaskData,initTaskDataTwo, monitorRealTimeTaskData } from "@/api/task";
export default class VideoTaskData {
  public tasks: Array<any> = [];
@@ -6,25 +6,77 @@
  public cameras: Array<string> = [];
  public activeIndex: number;
  public separateRulesTasks: object = [];
  public taskNameList = [];//预警数据新增接口用
  constructor() {
    this.tasks = [];
    this.taskNameList = [];
    this.taskCard = [];
    this.cameras = [];
    this.activeIndex = 0;
    this.separateRulesTasks = [];
  }
  // public async fetchTasks() {
  //   // 根据选中摄像机,查找任务,去重
  //   // const rsp: any = await getCameraTask({
  //   //   cameraIds: this.cameras
  //   // });
  //   const rsp: any = await getCameraTaskTwo({
  //     videoIds: this.cameras
  //   });
  //   if (rsp && rsp.success) {
  //     //let taskIds = []
  //     let taskNames = [];
  //     this.tasks = [];
  //     let resq = rsp.data.map(item => ({
  //       id: item.taskId,
  //       name: item.taskName,
  //       isDelete: false,
  //     }))
  //     // rsp.data.forEach((d: any) => {
  //     //   if (d.tasks) {
  //     //     d.tasks.forEach((t: any) => {
  //     //       if (taskIds.indexOf(t.taskid) < 0) {
  //     //         taskIds.push(t.taskid)
  //     //         if (t.taskname == "人脸测温") {
  //     //           this.tasks.unshift({
  //     //             taskName: t.taskname,
  //     //             taskId: t.taskid
  //     //           })
  //     //         } else {
  //     //           this.tasks.push({
  //     //             taskName: t.taskname,
  //     //             taskId: t.taskid
  //     //           })
  //     //         }
  //     //       }
  //     //     })
  //     //   }
  //     // })
  //     resq.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;
  //       }
  //     });
  //     this.tasks = this.tasks.filter((d: any) => !d.isDelete)
  //     console.log(this.tasks);
  //     // 初始化第一任务的信息
  //     this.initTaskList()
  //   }
  // }
  public async fetchTasks() {
    // 根据选中摄像机,查找任务,去重
    // const rsp: any = await getCameraTask({
    //   cameraIds: this.cameras
    // });
    const rsp: any = await getCameraTaskTwo({
      videoIds: this.cameras
    });
    if (rsp && rsp.success) {
      //let taskIds = []
    const rsp: any = await getCameraTaskThree();
    if (rsp && rsp.status === 200) {
      let taskNames = [];
      this.tasks = [];
@@ -33,30 +85,14 @@
        name: item.taskName,
        isDelete: false,
      }))
      // rsp.data.forEach((d: any) => {
      //   if (d.tasks) {
      //     d.tasks.forEach((t: any) => {
      //       if (taskIds.indexOf(t.taskid) < 0) {
      //         taskIds.push(t.taskid)
      //         if (t.taskname == "人脸测温") {
      //           this.tasks.unshift({
      //             taskName: t.taskname,
      //             taskId: t.taskid
      //           })
      //         } else {
      //           this.tasks.push({
      //             taskName: t.taskname,
      //             taskId: t.taskid
      //           })
      //         }
      //       }
      //     })
      //   }
      // })
      resq.forEach((d: any) => {
        if (taskNames.indexOf(d.name) < 0) {
          taskNames.push(d.name);
          this.tasks.push(d)
          this.taskNameList.push(d.name);
          this.tasks.push({
            value:d.name,
            label:d.name,
          })
        } else {
          let repeatOne = this.tasks.find((one: any) => one.name == d.name);
          repeatOne.id += `,${d.id}`;
@@ -133,4 +169,27 @@
      }
    }
  }
  public async monitorTaskDataTwo() {//2025.07.30 右侧预警数据不再与播放的实时监控绑定
    if (!this.tasks[this.activeIndex]) {
      return;
    }
    const rsp: any = await monitorRealTimeTaskData({
      warning:1,
      taskName: this.taskNameList
    });
    if (rsp && rsp.success) {
      if (rsp.data.list.datalist && rsp.data.list.datalist.length > 0) {
        rsp.data.list.datalist.reverse().forEach(element => {
          let rt = this.taskCard.filter((c: any) => {
            return c.activeObject.id === element.activeObject.id
          })
          if (rt.length < 1) {
            this.taskCard.unshift(element)
          }
        });
        this.taskCard.splice(20, this.taskCard.length - 20)
      }
    }
  }
}