yf_yzl 2 лет назад
Родитель
Сommit
3bc15e4ec5
2 измененных файлов с 4 добавлено и 2 удалено
  1. 3 2
      smartfarming/api/views/camera/camera_manage.py
  2. 1 0
      smartfarming/models/device.py

+ 3 - 2
smartfarming/api/views/camera/camera_manage.py

@@ -309,7 +309,7 @@ def add_camera(request):
         elif code == "LV1001":
             # 如直播地址已存在,则需要查询直播地址列表
             live_data = getLive(appId, appSecret, device_id, camera_channel)
-            coverUrl = device_live_data["result"]["data"]["streams"][0]["coverUrl"]
+            coverUrl = live_data["result"]["data"]["streams"][0]["coverUrl"]
             if live_data["result"]["code"] == "0":
                 try:
                     live_path = live_data["result"]["data"]["streams"][0]["hls"]
@@ -347,9 +347,10 @@ def add_camera(request):
         else:
             raise PortError("","Token过期,设备激活失败")
     try:
-        MongoDevice.objects.create(device_id=device_ids,device_type_id=6,addtime=now_time,device_code=1,uptime=now_time)
+        MongoDevice.objects.create(device_id=device_ids,device_type_id=6,addtime=now_time,device_code=1,uptime=now_time, jk_live_img=coverUrl)
         MongoCameraData.objects.create(device_id=device_ids,device_info=device_info,addtime=now_time,camera_playback=camera_playback,account_id=account_id)
     except Exception as e:
+        print(e)
         raise PortError(" ", "添加设备失败")
     return True
 

+ 1 - 0
smartfarming/models/device.py

@@ -48,6 +48,7 @@ class MongoDevice(models.Model):
     water_pump_switch_times = models.CharField(u'下发水泵开关的时间', max_length=10, default=0)  # 此字段针对康亚杰定制灌溉设备
     xy_expire_time = models.IntegerField(default=0)  # 诱芯到期时间
     device_tag = models.IntegerField("标签", default=0)
+    jk_live_img = models.TextField(u'监控封面图片',default='')  # 监控封面图片
     
     class Meta:
         db_table = "sa_device"