feat: 支持开启服务侧算力监控
This commit is contained in:
parent
ba937ce751
commit
0b1323b41d
|
@ -26,6 +26,7 @@ from threading import Thread
|
|||
from apps.utils.tools import timestamp_to_time
|
||||
from apps.third.tapis import xxapis
|
||||
import logging
|
||||
from datetime import datetime
|
||||
myLogger = logging.getLogger('log')
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
|
||||
|
@ -602,7 +603,15 @@ def get_area_from_point(x: int, y: int, floorNo: str, area_fix_id):
|
|||
def snap_and_analyse(vchannel: TDevice, algo_codes: list, opl: Opl = None):
|
||||
global_img_o = dhClient.snap(vchannel.code, raise_exception=False)
|
||||
happen_time = timezone.now()
|
||||
if global_img_o is None:
|
||||
if global_img_o is None: # 说明视频抓拍失败
|
||||
ckey = 'vchannel_' + vchannel.id
|
||||
cvalue = cache.get(ckey, None)
|
||||
if cvalue:
|
||||
try:
|
||||
cvalue.update({'snap': 'fail', 'snap_time': datetime.strftime("%Y-%m-%d %H:%M:%S")})
|
||||
cache.set(ckey, cvalue)
|
||||
except:
|
||||
pass
|
||||
return
|
||||
ec_codes = ai_analyse_2(algo_codes, global_img=global_img_o) # 算法处理返回的事件结果
|
||||
if ec_codes:
|
||||
|
@ -642,3 +651,4 @@ def snap_and_analyse(vchannel: TDevice, algo_codes: list, opl: Opl = None):
|
|||
})
|
||||
if event:
|
||||
notify_event(event)
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ from apps.ecm.serializers import (AlgoChannelCreateSerializer,
|
|||
from apps.ecm.service import update_remind_read
|
||||
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
||||
from apps.utils.export import export_excel_img
|
||||
from apps.ecm.tasks import monitor_check
|
||||
|
||||
obj_cate_dict = {'people': '人员', 'opl': '作业', 'other': '其他'}
|
||||
mark_dict = {10: '正常', 20: '误报'}
|
||||
|
@ -69,6 +70,16 @@ class AlgoChannelViewSet(CreateModelMixin, DestroyModelMixin, ListModelMixin, Cu
|
|||
})
|
||||
return Response()
|
||||
|
||||
def perform_create(self, serializer):
|
||||
ins = super().perform_create(serializer)
|
||||
if ins.always_on:
|
||||
monitor_check([ins.vchannel.id])
|
||||
|
||||
def perform_destroy(self, instance):
|
||||
monitor_check([instance.vchannel.id])
|
||||
instance.delete()
|
||||
|
||||
|
||||
|
||||
class NotifySettingViewSet(CustomModelViewSet):
|
||||
queryset = NotifySetting.objects.all()
|
||||
|
|
Loading…
Reference in New Issue