全部在线标签列表信息
This commit is contained in:
parent
aab3f6d63c
commit
5cf9c2edf0
|
@ -1,5 +1,5 @@
|
||||||
from apps.third.models import TDevice, Tlog
|
from apps.third.models import TDevice, Tlog
|
||||||
from apps.third.serializers import BindAreaSerializer, LabelLocationSerializer, TDeviceSerializer, TlogSerializer
|
from apps.third.serializers import BindAreaSerializer, BltSerializer, LabelLocationSerializer, TDeviceSerializer, TlogSerializer
|
||||||
from apps.utils.viewsets import CustomGenericViewSet
|
from apps.utils.viewsets import CustomGenericViewSet
|
||||||
from rest_framework.mixins import ListModelMixin, CreateModelMixin
|
from rest_framework.mixins import ListModelMixin, CreateModelMixin
|
||||||
from apps.third.clients import xxClient, dhClient, spClient
|
from apps.third.clients import xxClient, dhClient, spClient
|
||||||
|
@ -51,20 +51,39 @@ class BltViewSet(CustomGenericViewSet):
|
||||||
macs = []
|
macs = []
|
||||||
for i in blt_list:
|
for i in blt_list:
|
||||||
macs.append(i['mac'])
|
macs.append(i['mac'])
|
||||||
qs = self.queryset.exclude(employee=None, code__in=macs)
|
qs = self.queryset.filter().exclude(employee=None, code__in=macs)
|
||||||
ret['total'] = qs.count()
|
ret['total'] = qs.count()
|
||||||
ret['count_employee'] = qs.filter(employee__type='employee').count()
|
ret['count_employee'] = qs.filter(employee__type='employee').count()
|
||||||
ret['count_remployee'] = qs.filter(employee__type='remployee').count()
|
ret['count_remployee'] = qs.filter(employee__type='remployee').count()
|
||||||
ret['count_visitor'] = qs.filter(employee__type='visitor').count()
|
ret['count_visitor'] = qs.filter(employee__type='visitor').count()
|
||||||
return Response(ret)
|
return Response(ret)
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, perms_map={'post': '*'})
|
@action(methods=['get'], detail=False, perms_map={'get': '*'})
|
||||||
def query(self, request):
|
def all(self, request):
|
||||||
"""标签列表复杂查询
|
"""全部在线标签列表信息
|
||||||
|
|
||||||
标签列表复杂查询
|
全部在线标签列表信息
|
||||||
"""
|
"""
|
||||||
pass
|
json = {
|
||||||
|
"pageNum": 1,
|
||||||
|
"numPerPage": 2000,
|
||||||
|
"online": "online"
|
||||||
|
}
|
||||||
|
_, res = xxClient.request(**xxapis['blt_list'], json=json)
|
||||||
|
blt_list = res['recordList']
|
||||||
|
macs = []
|
||||||
|
for i in blt_list:
|
||||||
|
macs.append(i['mac'])
|
||||||
|
qs = self.queryset.filter(code__in=macs).exclude(employee=None)
|
||||||
|
qs_data = list(BltSerializer(instance=qs, many=True).data)
|
||||||
|
qs_dict = {}
|
||||||
|
for i in qs_data:
|
||||||
|
qs_dict[i['code']] = i
|
||||||
|
for i in blt_list:
|
||||||
|
i['my_info'] = {}
|
||||||
|
if i['mac'] in qs_dict:
|
||||||
|
i['my_info'] = qs_dict[i['mac']]
|
||||||
|
return Response(blt_list)
|
||||||
|
|
||||||
|
|
||||||
class TDeviceViewSet(ListModelMixin, CustomGenericViewSet):
|
class TDeviceViewSet(ListModelMixin, CustomGenericViewSet):
|
||||||
|
|
Loading…
Reference in New Issue