提交 1d7c2cc6 authored 作者: 蒋代伟's avatar 蒋代伟

智慧门店

上级 7a064fcf
......@@ -41,6 +41,8 @@ import rbac.views as rbac_views
import mes.views as mes_views
import entertainment.views as ent_views
import smartdevice.views as sd_views
#2022-02-16
import extra.views as extra_views
import erp.views as erp_views
......@@ -1031,6 +1033,7 @@ urlpatterns = [
url(r'^sales/lotteryseeds/$', sal_views.lotteryseeds),
url(r'^sales/lottery/$', sal_views.lottery),
url(r'^sales/lotteryseeds/delete/(?P<id>\d+)/$', sal_views.lotteryseeds_delete),
# 布奖批量删除
url(r'^sales/lotteryseeds/batch_delete/$', sal_views.lotteryseeds_batch_delete),
#奖品指定
url(r'^sales/lotterywinnerseeds/$', sal_views.lotterywinnerseeds),
......@@ -1354,6 +1357,19 @@ urlpatterns = [
url(r'^sales/terminal/$',sal_views.terminal),
url(r'^sales/batch/batch_terminal/$',sal_views.batch_terminal),
url(r'^sales/activity/PromotionSeeds_lottery/$', sal_views.PromotionSeeds_lottery),
# 智慧门店 开通/关闭标准流预览
url(r'^smartdevice/hikvision/customization/liveVideo/(?P<channelIds>\d+)/(?P<what>\w+)/$',sd_views.act_liveVideo),
# 智慧门店 通过设备序列号查询通道列表
url(r'^smartdevice/hikvision/customization/getChannels/$',sd_views.getChannels),
# 智慧门店 开通标准流预览
#2023-12-13 智慧门店 海康威视获取视频流
url(r'^smartdevice/hikvision/liveVideoOpen/$',sd_views.liveVideoOpen),
url(r'^smartdevice/hikvision/liveVideoOpen/(?P<company_id>\d+)/$',sd_views.liveVideoOpen),
]
if settings.DEBUG:
......
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class SmartdeviceConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'smartdevice'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
import requests
def get_hik_stoken():
hik_url = "https://api2.hik-cloud.com/oauth/token"
headers = {'ContentType': 'application/x-www-form-urlencoded'}
data= {
"client_id":"7aab6665696b4027879a55332f001b8f",
"client_secret":"3a86ce7109734c7480f1d293e5dc01fe",
"grant_type":"client_credentials",
"scope":"all"
}
res = requests.post(hik_url, headers=headers,data=data)
if res.status_code == 200:
res = res.json()
else:
res = ""
return res;
\ No newline at end of file
import requests
from django.http import JsonResponse
from django.shortcuts import render
from smartdevice.utils import get_hik_stoken
# def get_token(request):
# hik_url = "https://api2.hik-cloud.com/oauth/token"
# headers = {'ContentType': 'application/x-www-form-urlencoded'}
# data= {
# "client_id":"a0b0f6d1f1e5467d8ca1d5aaf978f878",
# "client_secret":"b5fb5a3201e046f386eb387bc2f799eb",
# "grant_type":"client_credentials",
# "scope":"all"
# }
#
#
# res = requests.post(hik_url, headers=headers,data=data)
# print(res.json())
# return JsonResponse(res.json(), safe=False)
def getChannels(request):
deviceSerial = request.GET.get("deviceSerial")
access_token = get_hik_stoken()
if access_token:
video_url = "https://api2.hik-cloud.com/v1/customization/devices/channels/actions/listByDevSerial?deviceSerial=" +deviceSerial
print(video_url)
headers = {"Authorization":"bearer "+access_token['access_token']}
res = requests.get(video_url, headers=headers)
print(res.json())
return JsonResponse(res.json(), safe=False)
else:
return JsonResponse({"e":"获取token校验错误"}, safe=False)
def act_liveVideo(request,channelIds,what=None):
print(what)
access_token = get_hik_stoken()
if access_token:
video_url=""
headers = {'ContentType': 'application/x-www-form-urlencoded',"Authorization":"Bearer "+access_token['access_token']}
if what == 'open':
video_url = "https://api2.hik-cloud.com/v1/customization/liveVideoOpen"
elif what == 'close':
video_url = "https://api2.hik-cloud.com/v1/customization/liveVideoClose"
else:
pass
data = {
"channelIds":"1"
}
res = requests.post(video_url, headers=headers,data=data)
print(res.json())
return JsonResponse(res.json(), safe=False)
else:
return JsonResponse({"e":"获取token校验错误"}, safe=False)
def liveVideoOpen(request,company_id=None):
print(company_id)
hik_url = "https://api2.hik-cloud.com/v1/customization/liveStudio/actions/getLiveAddress"
headers = {'ContentType': 'application/json'}
data = {
"deviceSerial":"DS-2CD2T26WDV3-I320231126AACHAE1254532",
"channelNo":1,
"protocol":2,
"expireTime":3600,
"type":1,
"quality":2
}
res = requests.post(hik_url, headers=headers, data=data)
print(res)
return JsonResponse( res.json())
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论