feat: tdevice 视频通道查询带third_info
This commit is contained in:
parent
03ac2a5b1b
commit
2d2f171c32
|
@ -16,6 +16,7 @@ from rest_framework.exceptions import ParseError
|
|||
from django.db import transaction
|
||||
from rest_framework.mixins import ListModelMixin, CreateModelMixin, DestroyModelMixin, UpdateModelMixin
|
||||
from apps.utils.serializers import PkSerializer
|
||||
from django.core.cache import cache
|
||||
|
||||
|
||||
class BltViewSet(CustomGenericViewSet):
|
||||
|
@ -162,23 +163,54 @@ class TDeviceViewSet(ListModelMixin, UpdateModelMixin, DestroyModelMixin, Custom
|
|||
macs_dict[i['mac']] = i
|
||||
for i in data:
|
||||
i['third_info'] = macs_dict.get(i['code'], {})
|
||||
elif typex == str(TDevice.DEVICE_VCHANNEL):
|
||||
codes = [i['code'] for i in data]
|
||||
json = {
|
||||
'unitTypeList': ["1"],
|
||||
'includeSubOwnerCodeFlag': True,
|
||||
'channelCodeList': codes,
|
||||
'pageSize': len(codes)
|
||||
}
|
||||
_, res = dhClient.request(**dhapis['channel_list'], json=json)
|
||||
codes_dict = {}
|
||||
for i in res['pageData']:
|
||||
codes_dict[i['channelCode']] = i
|
||||
for i in data:
|
||||
i['third_info'] = codes_dict.get(i['code'], {})
|
||||
if page is not None:
|
||||
return self.get_paginated_response(data)
|
||||
else:
|
||||
return Response(data)
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||
serializer_class=PkSerializer)
|
||||
def start_mtask(self, request):
|
||||
"""开启视频算法监控
|
||||
# @action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||
# serializer_class=PkSerializer)
|
||||
# def start_mtask(self, request):
|
||||
# """开启视频算法监控
|
||||
|
||||
开启视频算法监控
|
||||
"""
|
||||
request_data = request.data
|
||||
pks = request_data.get('pks', [])
|
||||
from apps.ecm.tasks import monitor_check
|
||||
monitor_check(pks)
|
||||
return Response()
|
||||
# 开启视频算法监控
|
||||
# """
|
||||
# sr = PkSerializer(data=request.data)
|
||||
# sr.is_valid(raise_exception=True)
|
||||
# vdata = sr.validated_data
|
||||
# from apps.ecm.tasks import monitor_check
|
||||
# monitor_check(vdata)
|
||||
# return Response()
|
||||
|
||||
# @action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||
# serializer_class=PkSerializer)
|
||||
# def stop_mtask(self, request):
|
||||
# """停止视频算法监控
|
||||
|
||||
# 停止视频算法监控
|
||||
# """
|
||||
# sr = PkSerializer(data=request.data)
|
||||
# sr.is_valid(raise_exception=True)
|
||||
# vdata = sr.validated_data
|
||||
# vcids = TDevice.objects.filter(id__in=vdata, type=TDevice.DEVICE_VCHANNEL).values_list('id', flat=True)
|
||||
# for id in vcids:
|
||||
# ckey = 'vchannel_' + id
|
||||
# cache.delete(ckey)
|
||||
# return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||
serializer_class=Serializer)
|
||||
|
|
Loading…
Reference in New Issue