Pārlūkot izejas kodu

新增挑选视频监控查询/视频表结构

baoyubo 10 mēneši atpakaļ
vecāks
revīzija
49d5490fd8

+ 2 - 1
models/__init__.py

@@ -9,4 +9,5 @@ from .ry_sys_base import *
 from .knowledge_base import *
 from .yjya_base import *
 from .event_base import *
-from .taskRegistration_base import *
+from .taskRegistration_base import *
+from .video_base import *

+ 74 - 0
models/video_base.py

@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+from sqlalchemy import String, Column, Integer,DateTime,Text,BigInteger,Boolean,PrimaryKeyConstraint,Index,UniqueConstraint,CHAR,LargeBinary,TIMESTAMP,Double
+from sqlalchemy.dialects.mysql import TINYINT
+from sqlalchemy.sql import func
+from database import Base
+from datetime import datetime
+
+
+
+class TpVideoLog(Base):
+    __tablename__ = 'tp_video_log'
+
+    name = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+    area = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+    ip = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+    status = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+    status_lifetime = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+    record_status = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+    inspection_datetime = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+    video_code_int = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+    video_code = Column(String(255, collation='utf8mb4_bin'), nullable=True, default=None)
+
+    class Config:
+        orm_mode = True
+
+
+class TpVideoBase(Base):
+    __tablename__ = 'tp_video_base'
+
+    cameraid = Column(String(100), nullable=True)
+    indexcode = Column(String(100), nullable=True)
+    name = Column(String(255), nullable=True)
+    manufacturer = Column(String(50), nullable=True)
+    model = Column(String(50), nullable=True)
+    owner = Column(String(50), nullable=True)
+    civilcode = Column(String(255), nullable=True)
+    block = Column(String(100), nullable=True)
+    address = Column(String(255), nullable=True)
+    parental = Column(String(2), nullable=True)
+    parentid = Column(String(255), nullable=True)
+    safetyway = Column(String(2), nullable=True)
+    registerway = Column(String(2), nullable=True)
+    certnum = Column(String(2), nullable=True)
+    certifiable = Column(String(2), nullable=True)
+    errorcode = Column(String(10), nullable=True)
+    endtime = Column(String(255), nullable=True)
+    secrecy = Column(String(2), nullable=True)
+    ipaddress = Column(String(255), nullable=True)
+    port = Column(String(10), nullable=True)
+    password = Column(String(10), nullable=True)
+    status = Column(String(10), nullable=True)
+    recordpos = Column(String(10), nullable=True)
+    cameratype = Column(String(2), nullable=True)
+    decodetag = Column(String(10), nullable=True)
+    longitude = Column(Double, nullable=True)
+    latitude = Column(Double, nullable=True)
+    elevation = Column(String(5), nullable=True)
+    targettype = Column(String(2), nullable=True)
+    targetsubtype = Column(String(2), nullable=True)
+    cascadeid = Column(String(10), nullable=True)
+    cascadecode = Column(String(100), nullable=True)
+    querystatus = Column(String(2), nullable=True)
+    privilege = Column(String(5), nullable=True)
+    updatatime = Column(String(255), nullable=True)
+    elseex = Column(String(255), nullable=True)
+    recordstate = Column(String(2), nullable=True)
+    extrafield = Column(String(255), nullable=True)
+    internalindexcode = Column(String(255), nullable=True)
+    positioncode = Column(String(10), nullable=True)
+    bstandard = Column(String(2), nullable=True)
+    pushpath = Column(String(255), nullable=True)
+
+    class Config:
+        orm_mode = True

+ 2 - 0
routers/api/videoResource/__init__.py

@@ -2,7 +2,9 @@
 # -*- coding: utf-8 -*-
 from fastapi import APIRouter
 from .hkvideo import router as hkvideo_router
+from .videoinfo import router as videoinfo_router
 
 router = APIRouter()
 
 router.include_router(hkvideo_router, prefix="/hkvideo")
+router.include_router(videoinfo_router, prefix="/videoinfo")

+ 54 - 0
routers/api/videoResource/videoinfo.py

@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+from fastapi import APIRouter, Request, Depends,Query
+from database import get_db
+from sqlalchemy.orm import Session
+from sqlalchemy import case
+from utils import *
+from utils.ry_system_util import *
+from common.security import valid_access_token
+
+router = APIRouter()
+
+@router.get('/get_video_list_by_user')
+async def get_video_url_by_id(
+
+    db: Session = Depends(get_db),
+    body=Depends(remove_xss_json),
+    user_id=Depends(valid_access_token),
+    page: int = Query(1, gt=0, description='页码'),
+    pageSize: int = Query(10, gt=0, description='每页条目数量')
+):
+    videoIds = user_id_get_user_videoIds(db, user_id)
+    video_list = [i.video_code_int for i in videoIds]
+
+    query = db.query(TpVideoLog)
+    total_items = query.count()
+
+    query = query.order_by(
+        case([(TpVideoLog.video_code_int == video_code_int, 0) for video_code_int in video_list], else_=1),
+        TpVideoLog.area.asc()
+    )
+    videos = query.offset((page - 1) * pageSize).limit(pageSize).all()
+    video_list = [{
+            "name": video.name,
+            "invideoIds":video.video_code_int in video_list,
+            "area": video.area,
+            "ip": video.ip,
+            "status": video.status,
+            "status_lifetime": video.status_lifetime,
+            "record_status": video.record_status,
+            "inspection_datetime": video.inspection_datetime,
+            "video_code_int": video.video_code_int,
+            "video_code": video.video_code
+        } for video in videos]
+
+    return {
+            "code": 200,
+            "msg": "操作成功",
+            "rows": video_list,
+            "total": total_items,
+            "page": page,
+            "pageSize": pageSize,
+            "totalPages": (total_items + pageSize - 1) // pageSize
+        }

+ 6 - 1
routers/prod_api/system/user/__init__.py

@@ -321,10 +321,15 @@ async def get_user_video_points(
         user_id = Depends(valid_access_token)):
     try:
         videoIds = user_id_get_user_videoIds(db,user_id)
+        video_list = [i.video_code_int for i in videoIds]
+        query = db.query(TpVideoLog)
+        query = query.filter(TpVideoLog.video_code_int.in_(video_list))
+        video_info = query.all()
         return {
             "code": 200,
             "msg": "成功",
-            "data": [i.video_code_int for i in videoIds]
+            "data": {"videoIds":[i.video_code_int for i in videoIds],
+                     "videoInfos":[{"name":info.name,"video_code_int":info.video_code_int} for info in video_info]}
         }
     except Exception as e:
         traceback.print_exc()