三方设备接口
This commit is contained in:
parent
c51199c4f4
commit
d89a14975b
|
@ -131,7 +131,7 @@ class TDeviceViewSet(ListModelMixin, UpdateModelMixin, DestroyModelMixin, Custom
|
|||
serializer = self.get_serializer(queryset, many=True)
|
||||
data = serializer.data
|
||||
typex = self.request.query_params.get('type', None)
|
||||
if typex == str(TDevice.DEVICE_BLT): # 如果是定位标签加载三方信息
|
||||
if typex == str(TDevice.DEVICE_BLT): # 如果是定位标签加载实时的三方信息
|
||||
macs = []
|
||||
for i in data:
|
||||
macs.append(i['code'])
|
||||
|
@ -169,6 +169,83 @@ class TDeviceViewSet(ListModelMixin, UpdateModelMixin, DestroyModelMixin, Custom
|
|||
TDevice.objects.get_or_create(code=i['mac'], defaults={"code": i['mac'], "type": TDevice.DEVICE_BLT})
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||
serializer_class=Serializer)
|
||||
@transaction.atomic
|
||||
def blt_speaker(self, request):
|
||||
"""同步喇叭通道
|
||||
|
||||
同步喇叭通道
|
||||
"""
|
||||
params = {
|
||||
"page": 1,
|
||||
"pageSize": 1000
|
||||
}
|
||||
_, res = spClient.request(**spapis['device_list'], params=params)
|
||||
rows = res['rows']
|
||||
for i in rows:
|
||||
td = TDevice.objects.filter(code=i['sn']).first()
|
||||
if td:
|
||||
pass
|
||||
else:
|
||||
td = TDevice(code=i['sn'], type=TDevice.DEVICE_SPEAKER)
|
||||
td.name = i['name']
|
||||
td.third_info = i
|
||||
td.save()
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||
serializer_class=Serializer)
|
||||
@transaction.atomic
|
||||
def blt_vchannel(self, request):
|
||||
"""同步视频通道
|
||||
|
||||
同步视频通道
|
||||
"""
|
||||
json = {
|
||||
"pageNum": 1,
|
||||
"pageSize": 1000,
|
||||
'channelTypeList': ["1"]
|
||||
}
|
||||
_, res = dhClient.request(**dhapis['channel_list'], json=json)
|
||||
if res.get('pageData', None):
|
||||
for i in res['pageData']:
|
||||
td = TDevice.objects.filter(code=i['channelCode']).first()
|
||||
if td:
|
||||
pass
|
||||
else:
|
||||
td = TDevice(code=i['channelCode'], type=TDevice.DEVICE_VCHANNEL)
|
||||
td.name = i['channelName']
|
||||
td.third_info = i
|
||||
td.save()
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||
serializer_class=Serializer)
|
||||
@transaction.atomic
|
||||
def blt_dchannel(self, request):
|
||||
"""同步门禁通道
|
||||
|
||||
同步门禁通道
|
||||
"""
|
||||
json = {
|
||||
"pageNum": 1,
|
||||
"pageSize": 1000,
|
||||
'channelTypeList': ["7"]
|
||||
}
|
||||
_, res = dhClient.request(**dhapis['channel_list'], json=json)
|
||||
if res.get('pageData', None):
|
||||
for i in res['pageData']:
|
||||
td = TDevice.objects.filter(code=i['channelCode']).first()
|
||||
if td:
|
||||
pass
|
||||
else:
|
||||
td = TDevice(code=i['channelCode'], type=TDevice.DEVICE_VCHANNEL)
|
||||
td.name = i['channelName']
|
||||
td.third_info = i
|
||||
td.save()
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': '*'},
|
||||
serializer_class=BltBindCreateSerializer)
|
||||
@transaction.atomic
|
||||
|
|
Loading…
Reference in New Issue