From 535a1a601a312033ae8c1f3972d39c0e58cbed37 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期五, 26 八月 2022 01:43:58 +0800
Subject: [PATCH] 添加运行服务器显示

---
 src/Pool/VideoRuleData.ts |  159 ++++++++++++++++++++++++++---------------------------
 1 files changed, 78 insertions(+), 81 deletions(-)

diff --git a/src/Pool/VideoRuleData.ts b/src/Pool/VideoRuleData.ts
index ee17558..bec1d9b 100644
--- a/src/Pool/VideoRuleData.ts
+++ b/src/Pool/VideoRuleData.ts
@@ -1,82 +1,80 @@
-import { getCameraInfo } from "@/api/camera";
-import { getAllPolygon } from "@/api/polygon";
-import { getDirDetails, findAllFileByStackId } from "@/api/localVedio";
-import { getCameraSceneRule,getLinkSceneRule } from '@/api/scene'
-
+import { getCameraInfo } from "@/api/camera"
+import { getAllPolygon } from "@/api/polygon"
+import { getDirDetails, findAllFileByStackId } from "@/api/localVedio"
+import { getCameraSceneRule, getLinkSceneRule } from "@/api/scene"
 
 export default class VideoRuleData {
-  public selectTask: Array<object>;
-  public rules: Array<object>;
-  public polygonData: Array<object>;
-  public cameraId: string = "";
-  public canvasData: object;
-  public baseImg: string;
-  public cameraName: string;
-  public type:number;
-  public rtsp:string;
-  public camearInfo: object;
+  public selectTask: Array<object>
+  public rules: Array<object>
+  public polygonData: Array<object>
+  public cameraId: string = ""
+  public canvasData: object
+  public baseImg: string
+  public cameraName: string
+  public type: number
+  public rtsp: string
+  public camearInfo: object
 
-  public loading: boolean;
+  public loading: boolean
 
-  public analytics: boolean;
-  public dealWay: boolean;
-  public runServerName: string;
+  public analytics: boolean
+  public dealWay: boolean
+  public runServerName: string
 
-  public resolutionOption: Array<any>;
-  public selectResolution: string;
-  public hasCtrlC: boolean;
-  public allSceneRule:Array<any>;
+  public resolutionOption: Array<any>
+  public selectResolution: string
+  public hasCtrlC: boolean
+  public allSceneRule: Array<any>
 
   constructor(id: string) {
-    this.loading = false;
-    this.baseImg = "";
-    this.cameraId = id ? id : "";
-    this.cameraName = "";
-    this.rtsp = "";
-    this.type = 0;
-    this.selectTask = [];
-    this.polygonData = [];
+    this.loading = false
+    this.baseImg = ""
+    this.cameraId = id ? id : ""
+    this.cameraName = ""
+    this.rtsp = ""
+    this.type = 0
+    this.selectTask = []
+    this.polygonData = []
     this.allSceneRule = []
     this.canvasData = {
       line: [],
       arrow: [],
       polygon: [],
       rect: []
-    };
+    }
 
-    this.camearInfo = {};
-    this.analytics = false;
-    this.dealWay = false;
-    this.runServerName = "";
-    this.rules = [];
+    this.camearInfo = {}
+    this.analytics = false
+    this.dealWay = false
+    this.runServerName = ""
+    this.rules = []
 
     if (id && id !== "") {
-      this.update();
+      this.update()
     }
 
     this.resolutionOption = [
       {
-        value: '1001',
-        label: '1280*720'
+        value: "1001",
+        label: "1280*720"
       },
       {
-        value: '1002',
-        label: '1920*1080'
+        value: "1002",
+        label: "1920*1080"
       },
       {
-        value: '1003',
-        label: '2560*1440'
+        value: "1003",
+        label: "2560*1440"
       }
     ]
-    this.selectResolution = '1002'
+    this.selectResolution = "1002"
     this.hasCtrlC = false
-
   }
 
   public async update() {
-    await this.getInfo();
-    await this.getSceneRule();
-    await this.getPolygon();
+    await this.getInfo()
+    await this.getSceneRule()
+    await this.getPolygon()
     await this.getLinkRule()
   }
 
@@ -84,90 +82,89 @@
     // 鍒ゆ柇閫変腑鐨勬槸鎽勫儚鏈鸿繕鏄暟鎹爤
     if (this.cameraId.indexOf("stack") === -1) {
       try {
-        const rsp: any = await getCameraInfo(this.cameraId);
+        const rsp: any = await getCameraInfo(this.cameraId)
         if (rsp.success) {
-          this.cameraName = rsp.data.name ? rsp.data.name : "";
-          this.rtsp = rsp.data.rtsp ? rsp.data.rtsp : "";
-          this.type = rsp.data.type ? rsp.data.type : 0;
-          this.baseImg =   rsp.data.snapshot_url
+          this.cameraName = rsp.data.name ? rsp.data.name : ""
+          this.rtsp = rsp.data.rtsp ? rsp.data.rtsp : ""
+          this.type = rsp.data.type ? rsp.data.type : 0
+          this.baseImg = rsp.data.snapshot_url
+          this.runServerName = rsp.data.runServerName
         }
       } catch {
-        this.cameraName = "";
+        this.cameraName = ""
         this.type = 0
-        this.rtsp = ''
+        this.rtsp = ""
       }
     } else {
-      const rsp: any = await findAllFileByStackId({ stackId: this.cameraId });
+      const rsp: any = await findAllFileByStackId({ stackId: this.cameraId })
       if (rsp.success && rsp.data.dataList.length) {
-        let snapshots = rsp.data.dataList.map(obj => {
-          return obj.snapshot_url;
+        let snapshots = rsp.data.dataList.map((obj) => {
+          return obj.snapshot_url
         })
 
-        this.baseImg = snapshots[0];
+        this.baseImg = snapshots[0]
         // console.log(snapshots)
       }
     }
-
   }
 
   public async getPolygon() {
-    this.polygonData = [];
+    this.polygonData = []
 
-    const rsp: any = await getAllPolygon({ cameraId: this.cameraId });
+    const rsp: any = await getAllPolygon({ cameraId: this.cameraId })
     if (rsp && rsp.success) {
       this.canvasData = {
         line: rsp.data.line,
         arrow: rsp.data.arrow,
         polygon: rsp.data.polygon,
         rect: rsp.data.rect
-      };
+      }
 
       // 鍙鎽勫儚鏈烘暟鎹簳鍥捐繘琛屽鐞�
       if (this.cameraId.indexOf("stack") < 0) {
-        this.baseImg =  rsp.data.snapshot_url ? rsp.data.snapshot_url : "";
+        this.baseImg = rsp.data.snapshot_url ? rsp.data.snapshot_url : ""
         if (!this.baseImg) {
-          this.loading = true;
+          this.loading = true
         } else {
-          this.loading = false;
+          this.loading = false
         }
       }
 
-      const newObj = item => {
+      const newObj = (item) => {
         return {
           id: item.id,
           name: item.name,
           defence_state: item.defence_state
-        };
-      };
+        }
+      }
 
-      let line = rsp.data.line.map(newObj);
-      let polygon = rsp.data.polygon.map(newObj);
-      let rect = rsp.data.rect.map(newObj);
+      let line = rsp.data.line.map(newObj)
+      let polygon = rsp.data.polygon.map(newObj)
+      let rect = rsp.data.rect.map(newObj)
 
       if (line.length !== 0 || polygon.length !== 0 || rect.length !== 0) {
-        this.polygonData = [...polygon, ...line, ...rect];
+        this.polygonData = [...polygon, ...line, ...rect]
       }
     }
   }
 
   public async getSceneRule() {
-    const rsp: any = await getCameraSceneRule({ cameraId: this.cameraId });
+    const rsp: any = await getCameraSceneRule({ cameraId: this.cameraId })
     if (rsp && rsp.success) {
       let rspData = rsp.data.taskList ? rsp.data.taskList : []
       this.rules = rsp.data.rules ? rsp.data.rules : []
-      this.camearInfo = rsp.data.cameraInfo ? rsp.data.cameraInfo : {};
+      this.camearInfo = rsp.data.cameraInfo ? rsp.data.cameraInfo : {}
       this.analytics = rsp.data.cameraInfo.run_type !== -1 ? true : false
       this.dealWay = rsp.data.cameraInfo.run_type === 1 ? true : false
-      this.runServerName = rsp.data.cameraInfo.runServerName
     }
   }
 
   public async getLinkRule() {
-    const rsp: any = await getLinkSceneRule({ cameraIds: [this.cameraId] });
+    const rsp: any = await getLinkSceneRule({ cameraIds: [this.cameraId] })
     if (rsp && rsp.success) {
-     let rules = rsp.data.rules;
-     
-      rules = rsp.data.rules;
+      let rules = rsp.data.rules
+
+      rules = rsp.data.rules
       this.allSceneRule = this.rules.concat(rules)
     }
   }

--
Gitblit v1.8.0