From c208b104011e0bbdc824960ed025b597d081c78f Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期六, 18 六月 2022 01:56:31 +0800 Subject: [PATCH] 摄像机配置: 修复国标刷底图api --- src/Pool/VideoRuleData.ts | 162 ++++++++++++++++++++++++++--------------------------- 1 files changed, 79 insertions(+), 83 deletions(-) diff --git a/src/Pool/VideoRuleData.ts b/src/Pool/VideoRuleData.ts index 22dface..534be1d 100644 --- a/src/Pool/VideoRuleData.ts +++ b/src/Pool/VideoRuleData.ts @@ -1,164 +1,160 @@ -import { getCameraInfo,getGB28181CameraInfo } from "@/api/camera"; -import { getAllPolygon } from "@/api/polygon"; -import { getDirDetails, findAllFileByStackId } from "@/api/localVedio"; -import { getCameraSceneRule } from '@/api/scene' +import { getCameraInfo, getGB28181CameraInfo } from "@/api/camera" +import { getAllPolygon } from "@/api/polygon" +import { getDirDetails, findAllFileByStackId } from "@/api/localVedio" +import { getCameraSceneRule } 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 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 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 resolutionOption: Array<any> + public selectResolution: string + public hasCtrlC: boolean + public gb28181: boolean - constructor(id: string,isGB:boolean) { - this.loading = false; - this.baseImg = ""; - this.cameraId = id ? id : ""; - this.cameraName = ""; - this.selectTask = []; - this.polygonData = []; + constructor(id: string, isGB: boolean) { + this.loading = false + this.baseImg = "" + this.cameraId = id ? id : "" + this.cameraName = "" + this.selectTask = [] + this.polygonData = [] 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(isGB); + this.update(isGB) } 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 + this.gb28181 = isGB ? isGB : false } public async update(isGB) { - await this.getInfo(isGB); - await this.getSceneRule(); - await this.getPolygon(); + await this.getInfo(isGB) + await this.getSceneRule() + await this.getPolygon() } public async getInfo(isGB) { // 鍒ゆ柇閫変腑鐨勬槸鎽勫儚鏈鸿繕鏄暟鎹爤 if (this.cameraId.indexOf("stack") === -1) { - //澶勭悊鍥芥爣鎽勫儚鏈� - if(isGB) { + if (isGB) { try { - const rsp: any = await getGB28181CameraInfo(this.cameraId); - if (rsp.success) { - this.cameraName = rsp.data.name ? rsp.data.name : ""; - } - } catch { - this.cameraName = ""; - } - } - - else { - try { - const rsp: any = await getCameraInfo(this.cameraId); - if (rsp.success) { - this.cameraName = rsp.data.name ? rsp.data.name : ""; - } + const rsp: any = await getGB28181CameraInfo(this.cameraId) + if (rsp.success) { + this.cameraName = rsp.data.name ? rsp.data.name : "" + } } catch { - this.cameraName = ""; + this.cameraName = "" + } + } else { + try { + const rsp: any = await getCameraInfo(this.cameraId) + if (rsp.success) { + this.cameraName = rsp.data.name ? rsp.data.name : "" + } + } catch { + this.cameraName = "" } } - - } 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 -- Gitblit v1.8.0