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 django.db import transaction
|
||||||
from rest_framework.mixins import ListModelMixin, CreateModelMixin, DestroyModelMixin, UpdateModelMixin
|
from rest_framework.mixins import ListModelMixin, CreateModelMixin, DestroyModelMixin, UpdateModelMixin
|
||||||
from apps.utils.serializers import PkSerializer
|
from apps.utils.serializers import PkSerializer
|
||||||
|
from django.core.cache import cache
|
||||||
|
|
||||||
|
|
||||||
class BltViewSet(CustomGenericViewSet):
|
class BltViewSet(CustomGenericViewSet):
|
||||||
|
@ -162,23 +163,54 @@ class TDeviceViewSet(ListModelMixin, UpdateModelMixin, DestroyModelMixin, Custom
|
||||||
macs_dict[i['mac']] = i
|
macs_dict[i['mac']] = i
|
||||||
for i in data:
|
for i in data:
|
||||||
i['third_info'] = macs_dict.get(i['code'], {})
|
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:
|
if page is not None:
|
||||||
return self.get_paginated_response(data)
|
return self.get_paginated_response(data)
|
||||||
else:
|
else:
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, perms_map={'post': '*'},
|
# @action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||||
serializer_class=PkSerializer)
|
# serializer_class=PkSerializer)
|
||||||
def start_mtask(self, request):
|
# def start_mtask(self, request):
|
||||||
"""开启视频算法监控
|
# """开启视频算法监控
|
||||||
|
|
||||||
开启视频算法监控
|
# 开启视频算法监控
|
||||||
"""
|
# """
|
||||||
request_data = request.data
|
# sr = PkSerializer(data=request.data)
|
||||||
pks = request_data.get('pks', [])
|
# sr.is_valid(raise_exception=True)
|
||||||
from apps.ecm.tasks import monitor_check
|
# vdata = sr.validated_data
|
||||||
monitor_check(pks)
|
# from apps.ecm.tasks import monitor_check
|
||||||
return Response()
|
# 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': '*'},
|
@action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||||
serializer_class=Serializer)
|
serializer_class=Serializer)
|
||||||
|
|
Loading…
Reference in New Issue