chenjunkai 5 vuotta sitten
vanhempi
commit
c97db1fe85
2 muutettua tiedostoa jossa 117 lisäystä ja 115 poistoa
  1. 2 1
      Ansjer/test/.cache/v/cache/lastfailed
  2. 115 114
      Controller/DetectController.py

+ 2 - 1
Ansjer/test/.cache/v/cache/lastfailed

@@ -1,3 +1,4 @@
 {
-  "mqtt_client.py::test": true
+  "mqtt_client.py::test": true,
+  "s3sts.py": true
 }

+ 115 - 114
Controller/DetectController.py

@@ -123,7 +123,7 @@ class DetectControllerView(View):
                 # 列表装载回放时间戳标记
                 vodqs = VodHlsModel.objects.filter(uid=devUid, channel=channel, time=int(eventTime)) \
                     .values("bucket__bucket", "bucket__endpoint")
-                print(vodqs)
+                # print(vodqs)
                 if vodqs.exists():
                     bucket_name = vodqs[0]['bucket__bucket']
                     endpoint = vodqs[0]['bucket__endpoint']
@@ -134,124 +134,125 @@ class DetectControllerView(View):
                     thumb2 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_2000,w_700'})
                     # thumb3 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_3000,w_700'})
                     p['img_list'] = [thumb0, thumb1, thumb2]
-            if devUid in uid_type_dict.keys():
+            try:
                 p['uid_type'] = uid_type_dict[devUid]['type']
                 p['devNickName'] = uid_type_dict[devUid]['NickName']
-            else:
+            except Exception as e:
                 p['uid_type'] = ''
+                p['devNickName'] = devUid
             res.append(p)
         return response.json(0, {'datas': res, 'count': count})
-
-    def do_change_status1(self, userID, request_dict, response):
-        uid = request_dict.get('uid', None)
-        token_val = request_dict.get('token_val', None)
-        appBundleId = request_dict.get('appBundleId', None)
-        app_type = request_dict.get('app_type', None)
-        push_type = request_dict.get('push_type', None)
-        status = request_dict.get('status', None)
-        m_code = request_dict.get('m_code', None)
-        # 设备语言
-        lang = request_dict.get('lang', 'en')
-        tz = request_dict.get('tz', '0')
-        # interval = request_dict.get('interval', None)
-        if not status:
-            return response.json(444, 'status')
-        # 关闭推送
-        if not all([appBundleId, app_type, token_val, uid, m_code]):
-            return response.json(444, 'appBundleId,app_type,token_val,uid,m_code')
-        # 判断推送类型对应key是否存在
-        if push_type == '0':
-            if appBundleId not in APNS_CONFIG.keys():
-                return response.json(904)
-        elif push_type == '1':
-            if appBundleId not in FCM_CONFIG.keys():
-                return response.json(904)
-        elif push_type == '2':
-            if appBundleId not in JPUSH_CONFIG.keys():
-                return response.json(904)
-        else:
-            return response.json(173)
-        dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
-        status = int(status)
-        if dvqs.exists():
-            # 获取用户区域
-            # ip = self.ip
-            # ipInfo = CommonService.getIpIpInfo(ip=ip, lang='EN')
-            # area = ipInfo['country_name']
-            # if area == 'China':
-            #     DETECT_PUSH_DOMAIN = 'cn.push.dvema.com'
-            # else:
-            #     DETECT_PUSH_DOMAIN = 'en.push.dvema.com'
-            nowTime = int(time.time())
-            uid_set_qs = UidSetModel.objects. \
-                filter(uid=uid, uidpushmodel__userID_id=userID, uidpushmodel__m_code=m_code)
-            # 判断是否有曾经开启过
-            if uid_set_qs.exists():
-                uid_push_update_dict = {
-                    'appBundleId': appBundleId,
-                    'app_type': app_type,
-                    'push_type': push_type,
-                    'token_val': token_val,
-                    'updTime': nowTime,
-                    'lang': lang,
-                    'tz': tz
-                }
-                uid_set_qs.update(detect_status=status, updTime=nowTime)
-                UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid). \
-                    update(**uid_push_update_dict)
-                if status == 0:
-                    # 关闭成功
-                    return response.json(0)
-                utko = UidTokenObject()
-                # right
-                utko.generate(data={'uid': uid})
-                detectUrl = "{DETECT_PUSH_DOMAIN}notify/push?uidToken={uidToken}". \
-                    format(uidToken=utko.token, DETECT_PUSH_DOMAIN=DETECT_PUSH_DOMAIN)
-                return response.json(0, {'detectUrl': detectUrl})
-            else:
-                uid_set_qs = UidSetModel.objects.filter(uid=uid)
-                # 判断uid push是否绑定
-                if not uid_set_qs.exists():
-                    uid_set_create_dict = {
-                        'uid': uid,
-                        'addTime': nowTime,
-                        'updTime': nowTime,
-                        'detect_status': status,
-                    }
-                    # 添加设备配置
-                    uid_set_qs = UidSetModel.objects.create(**uid_set_create_dict)
-                    uid_set_id = uid_set_qs.id
-                else:
-                    update_dict = {
-                        'updTime': nowTime,
-                        'detect_status': status,
-                    }
-                    uid_set_qs.update(**update_dict)
-                    uid_set_id = uid_set_qs[0].id
-                uid_push_create_dict = {
-                    'uid_set_id': uid_set_id,
-                    'userID_id': userID,
-                    'appBundleId': appBundleId,
-                    'app_type': app_type,
-                    'push_type': push_type,
-                    'token_val': token_val,
-                    'm_code': m_code,
-                    'addTime': nowTime,
-                    'updTime': nowTime,
-                    'lang': lang,
-                    'tz': tz
-                }
-                # 绑定设备推送
-                UidPushModel.objects.create(**uid_push_create_dict)
-                if status == 0:
-                    return response.json(0)
-                utko = UidTokenObject()
-                utko.generate(data={'uid': uid})
-                detectUrl = "{DETECT_PUSH_DOMAIN}notify/push?uidToken={uidToken}". \
-                    format(uidToken=utko.token, DETECT_PUSH_DOMAIN=DETECT_PUSH_DOMAIN)
-                return response.json(0, {'detectUrl': detectUrl})
-        else:
-            return response.json(14)
+    #
+    # def do_change_status1(self, userID, request_dict, response):
+    #     uid = request_dict.get('uid', None)
+    #     token_val = request_dict.get('token_val', None)
+    #     appBundleId = request_dict.get('appBundleId', None)
+    #     app_type = request_dict.get('app_type', None)
+    #     push_type = request_dict.get('push_type', None)
+    #     status = request_dict.get('status', None)
+    #     m_code = request_dict.get('m_code', None)
+    #     # 设备语言
+    #     lang = request_dict.get('lang', 'en')
+    #     tz = request_dict.get('tz', '0')
+    #     # interval = request_dict.get('interval', None)
+    #     if not status:
+    #         return response.json(444, 'status')
+    #     # 关闭推送
+    #     if not all([appBundleId, app_type, token_val, uid, m_code]):
+    #         return response.json(444, 'appBundleId,app_type,token_val,uid,m_code')
+    #     # 判断推送类型对应key是否存在
+    #     if push_type == '0':
+    #         if appBundleId not in APNS_CONFIG.keys():
+    #             return response.json(904)
+    #     elif push_type == '1':
+    #         if appBundleId not in FCM_CONFIG.keys():
+    #             return response.json(904)
+    #     elif push_type == '2':
+    #         if appBundleId not in JPUSH_CONFIG.keys():
+    #             return response.json(904)
+    #     else:
+    #         return response.json(173)
+    #     dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
+    #     status = int(status)
+    #     if dvqs.exists():
+    #         # 获取用户区域
+    #         # ip = self.ip
+    #         # ipInfo = CommonService.getIpIpInfo(ip=ip, lang='EN')
+    #         # area = ipInfo['country_name']
+    #         # if area == 'China':
+    #         #     DETECT_PUSH_DOMAIN = 'cn.push.dvema.com'
+    #         # else:
+    #         #     DETECT_PUSH_DOMAIN = 'en.push.dvema.com'
+    #         nowTime = int(time.time())
+    #         uid_set_qs = UidSetModel.objects. \
+    #             filter(uid=uid, uidpushmodel__userID_id=userID, uidpushmodel__m_code=m_code)
+    #         # 判断是否有曾经开启过
+    #         if uid_set_qs.exists():
+    #             uid_push_update_dict = {
+    #                 'appBundleId': appBundleId,
+    #                 'app_type': app_type,
+    #                 'push_type': push_type,
+    #                 'token_val': token_val,
+    #                 'updTime': nowTime,
+    #                 'lang': lang,
+    #                 'tz': tz
+    #             }
+    #             uid_set_qs.update(detect_status=status, updTime=nowTime)
+    #             UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid). \
+    #                 update(**uid_push_update_dict)
+    #             if status == 0:
+    #                 # 关闭成功
+    #                 return response.json(0)
+    #             utko = UidTokenObject()
+    #             # right
+    #             utko.generate(data={'uid': uid})
+    #             detectUrl = "{DETECT_PUSH_DOMAIN}notify/push?uidToken={uidToken}". \
+    #                 format(uidToken=utko.token, DETECT_PUSH_DOMAIN=DETECT_PUSH_DOMAIN)
+    #             return response.json(0, {'detectUrl': detectUrl})
+    #         else:
+    #             uid_set_qs = UidSetModel.objects.filter(uid=uid)
+    #             # 判断uid push是否绑定
+    #             if not uid_set_qs.exists():
+    #                 uid_set_create_dict = {
+    #                     'uid': uid,
+    #                     'addTime': nowTime,
+    #                     'updTime': nowTime,
+    #                     'detect_status': status,
+    #                 }
+    #                 # 添加设备配置
+    #                 uid_set_qs = UidSetModel.objects.create(**uid_set_create_dict)
+    #                 uid_set_id = uid_set_qs.id
+    #             else:
+    #                 update_dict = {
+    #                     'updTime': nowTime,
+    #                     'detect_status': status,
+    #                 }
+    #                 uid_set_qs.update(**update_dict)
+    #                 uid_set_id = uid_set_qs[0].id
+    #             uid_push_create_dict = {
+    #                 'uid_set_id': uid_set_id,
+    #                 'userID_id': userID,
+    #                 'appBundleId': appBundleId,
+    #                 'app_type': app_type,
+    #                 'push_type': push_type,
+    #                 'token_val': token_val,
+    #                 'm_code': m_code,
+    #                 'addTime': nowTime,
+    #                 'updTime': nowTime,
+    #                 'lang': lang,
+    #                 'tz': tz
+    #             }
+    #             # 绑定设备推送
+    #             UidPushModel.objects.create(**uid_push_create_dict)
+    #             if status == 0:
+    #                 return response.json(0)
+    #             utko = UidTokenObject()
+    #             utko.generate(data={'uid': uid})
+    #             detectUrl = "{DETECT_PUSH_DOMAIN}notify/push?uidToken={uidToken}". \
+    #                 format(uidToken=utko.token, DETECT_PUSH_DOMAIN=DETECT_PUSH_DOMAIN)
+    #             return response.json(0, {'detectUrl': detectUrl})
+    #     else:
+    #         return response.json(14)
 
     def do_change_status(self, userID, request_dict, response):
         uid = request_dict.get('uid', None)