Browse Source

合并代码

pengzhibo168 5 years ago
parent
commit
fdae02cc10

+ 2 - 0
Ansjer/config_formal.py

@@ -47,3 +47,5 @@ APNS_CONFIG = {
     }
     }
 }
 }
 APNS_MODE = 'prod'
 APNS_MODE = 'prod'
+
+TUTK_PUSH_DOMAIN = 'http://push.iotcplatform.com/tpns'

+ 2 - 1
Ansjer/config_local.py

@@ -52,4 +52,5 @@ APNS_CONFIG = {
         'pem_path': 'Ansjer/file/apns_pem/accloud-dev.pem',
         'pem_path': 'Ansjer/file/apns_pem/accloud-dev.pem',
     }
     }
 }
 }
-APNS_MODE = 'dev'
+APNS_MODE = 'dev'
+TUTK_PUSH_DOMAIN = 'http://push.iotcplatform.com/tpns'

+ 2 - 1
Ansjer/config_test.py

@@ -55,4 +55,5 @@ APNS_CONFIG = {
         'pem_path': 'Ansjer/file/apns_pem/accloud-dev.pem',
         'pem_path': 'Ansjer/file/apns_pem/accloud-dev.pem',
     }
     }
 }
 }
-APNS_MODE = 'dev'
+APNS_MODE = 'dev'
+TUTK_PUSH_DOMAIN = 'http://push.iotcplatform.com/tpns'

+ 11 - 0
Ansjer/test/kbt.py

@@ -0,0 +1,11 @@
+import requests
+
+data= {
+    'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtX2NvZGUiOiIxMjM0MTMyNDMyMTQiLCJ1c2VyIjoiMTM4MDAxMzgwMDEiLCJleHAiOjE1ODE4MjA2MjcsInVzZXJJRCI6IjE1MTU2NDI2MjMzNzkzOTUxMzgwMDEzODAwMSIsImxhbmciOiJlbiJ9.SuDHinc0xJ5ETclE1SY-9lSEoebBTBje6OZ0r4Plqjw',
+    'm_code':"AN02000080B10000001cd3.zccloud_ab",
+    'os_type':'jiguang',
+    'appid':'com.ansjer.zccloud_ab',
+    'udid':"AN02000080b10000001cd3"
+}
+res = requests.post(url='http://test.dvema.com/v2/account/logout',data=data)
+print(res.text)

+ 6 - 2
Ansjer/urls.py

@@ -7,7 +7,7 @@ from Controller import FeedBack, EquipmentOTA, EquipmentInfo, AdminManage, AppIn
     EquipmentManager, LogManager, PermissionManager, OTAEquipment, shareUserPermission, UidSetController, \
     EquipmentManager, LogManager, PermissionManager, OTAEquipment, shareUserPermission, UidSetController, \
     UserManger, CheckUserData, \
     UserManger, CheckUserData, \
     UserController, CloudVod, OrderContrller, VodBucket, DetectController, DeviceShare, UserBrandController, \
     UserController, CloudVod, OrderContrller, VodBucket, DetectController, DeviceShare, UserBrandController, \
-    StsOssController, UIDPreview, OssCrd, SysMsg, UidUser, EquipmentManagerV2,PushDeploy,VersionControl
+    StsOssController, UIDPreview, OssCrd, SysMsg, UidUser, EquipmentManagerV2, PushDeploy, AppSetController, VersionControl
 
 
 urlpatterns = [
 urlpatterns = [
     url(r'^account/authcode$', UserController.authCodeView.as_view()),
     url(r'^account/authcode$', UserController.authCodeView.as_view()),
@@ -111,6 +111,7 @@ urlpatterns = [
     url(r'^v2/account/resetPwdByCode$', UserController.v2resetPwdByCodeView.as_view()),
     url(r'^v2/account/resetPwdByCode$', UserController.v2resetPwdByCodeView.as_view()),
     # 重置密码验证码校验
     # 重置密码验证码校验
     url(r'^v2/authcode/verify$', UserController.verifyAuthcode.as_view()),
     url(r'^v2/authcode/verify$', UserController.verifyAuthcode.as_view()),
+    url(r'^v2/account/logout$', UserController.V2LogoutView.as_view()),
 
 
     url(r'^detect/add$', DetectController.PushNotificationView.as_view()),
     url(r'^detect/add$', DetectController.PushNotificationView.as_view()),
     url(r'^detect/(?P<operation>.*)$', DetectController.DetectControllerView.as_view()),
     url(r'^detect/(?P<operation>.*)$', DetectController.DetectControllerView.as_view()),
@@ -158,7 +159,7 @@ urlpatterns = [
     # 删除云存视频
     # 删除云存视频
     path('cv/del', CloudVod.deleteVodHls),
     path('cv/del', CloudVod.deleteVodHls),
     url(r'^equipment/judge', EquipmentManager.judgeInterface),
     url(r'^equipment/judge', EquipmentManager.judgeInterface),
-    
+
     # ap模式,新增设备表
     # ap模式,新增设备表
     url(r'^uiduser/add', UidUser.addInterface),
     url(r'^uiduser/add', UidUser.addInterface),
     url(r'^uiduser/query', UidUser.queryInterface),
     url(r'^uiduser/query', UidUser.queryInterface),
@@ -176,6 +177,9 @@ urlpatterns = [
     url(r'^version_control/(?P<operation>.*)$', VersionControl.VersionControlView.as_view()),
     url(r'^version_control/(?P<operation>.*)$', VersionControl.VersionControlView.as_view()),
 
 
     url(r'^oalexa/auth', UserController.alexaAuthView.as_view()),
     url(r'^oalexa/auth', UserController.alexaAuthView.as_view()),
+    url(r'^oalexa/discoveryuid', UserController.alexaUidView.as_view()),
+
+    url(r'^appset/(?P<operation>.*)$', AppSetController.AppSetView.as_view()),
 
 
     # app 设备消息模板
     # app 设备消息模板
     # 路由加参数参考
     # 路由加参数参考

+ 63 - 0
Controller/AppSetController.py

@@ -0,0 +1,63 @@
+#!/usr/bin/env python3  
+# -*- coding: utf-8 -*-  
+"""
+@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
+@AUTHOR: ASJRD018
+@NAME: AnsjerFormal
+@software: PyCharm
+@DATE: 2020/2/27 9:38
+@Version: python3.6
+@MODIFY DECORD:ansjer dev
+@file: AppSetController.py
+@Contact: chanjunkai@163.com
+"""
+
+from django.views.generic.base import View
+
+from Object.ResponseObject import ResponseObject
+
+
+class AppSetView(View):
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation', None)
+        return self.validation(request.GET, operation)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation', None)
+        return self.validation(request.POST, operation)
+
+    def validation(self, request_dict, operation):
+        response = ResponseObject()
+        # token = request_dict.get('token', None)
+        # tko = TokenObject(token)
+        # userID = tko.userID
+        if operation == 'query':
+            return self.do_query(request_dict, response)
+        else:
+            return response.json(414)
+
+    def do_query(self, request_dict, response):
+        appBundleId = request_dict.get('appBundleId', None)
+        if not appBundleId:
+            return response.json(444,'appBundleId')
+        res = {}
+        res['grade'] = 1
+        #     # 用户帮助
+        res['usingHelp'] = 0
+        #     # AP添加方式
+        res['apAdd'] = 1
+        #     # AP工具
+        res['apTool'] = 1
+        #     # 广告模块
+        res['ad_module'] = {
+            "time": 0,
+            "ad_path": [
+                "https://test.dvema.com/web/static/image/default_ad1",
+                "https://test.dvema.com/web/static/image/default_ad2",
+                "https://test.dvema.com/web/static/image/default_ad3",
+            ]
+        }
+        res['init_img'] = 'https://test.dvema.com/web/static/image/default_start'
+        return response.json(0, res)

+ 105 - 89
Controller/DetectController.py

@@ -32,9 +32,12 @@ from Object.UidTokenObject import UidTokenObject
 from Service.CommonService import CommonService
 from Service.CommonService import CommonService
 
 
 '''
 '''
-http://test.dvema.com/detect/changeStatus?push_type=2&token_val=1507bfd3f7ba3bbb551&appBundleId=com.ansjer.zccloud_ab&tz=+08.00&uid=T4AZ3CUKCERH9FZA111A&status=1&m_code=AN020000own000000unkn.zccloud_ab&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzUxOTAxNjksInVzZXJJRCI6IjE1Njc3NTgyMTg2MTkxMzgwMDEzODAwMCIsImxhbmciOiJ0YyIsInVzZXIiOiIxMzExOTY1NzcxMyJ9.rQ11jA3IQPxQofFbZyG0nvLhGVcxOR82N2qQ8i04VuU&lang=tc&app_type=2
 http://test.push.dvema.com/notify/push?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJUNEFaM0NVS0NFUkg5RlpBMTExQSJ9.GtrXeq5gb2Z9M3mKECxi9eNQbPxqC-6PtgJkOOg6PwI&n_time=1598456451&channel=1&event_type=1&is_st=1
 http://test.push.dvema.com/notify/push?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJUNEFaM0NVS0NFUkg5RlpBMTExQSJ9.GtrXeq5gb2Z9M3mKECxi9eNQbPxqC-6PtgJkOOg6PwI&n_time=1598456451&channel=1&event_type=1&is_st=1
 http://push.dvema.com/notify/push?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJUNEFaM0NVS0NFUkg5RlpBMTExQSJ9.GtrXeq5gb2Z9M3mKECxi9eNQbPxqC-6PtgJkOOg6PwI&n_time=1598456451&channel=1&event_type=1&is_st=1
 http://push.dvema.com/notify/push?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJUNEFaM0NVS0NFUkg5RlpBMTExQSJ9.GtrXeq5gb2Z9M3mKECxi9eNQbPxqC-6PtgJkOOg6PwI&n_time=1598456451&channel=1&event_type=1&is_st=1
+
+http://www.dvema.com/detect/changeStatus?push_type=2&token_val=1a0018970a332cca935&appBundleId=com.ansjer.zccloud_ab&tz=+08.00&uid=HLK7EJ2VYLNHHUMG111A&status=1&m_code=AN02000025070000001207.zccloud_ab&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiMTMxMTk2NTc3MTMiLCJsYW5nIjoiZW4iLCJtX2NvZGUiOiIxMjM0MTMyNDMyMTQiLCJ1c2VySUQiOiIxNTQ0ODM4MjMyOTczMTM4MDAxMzgwMDAiLCJleHAiOjE1ODQxNDc0NjN9.NjK91B26jZDtdmq8tW-8hXNQPqqDfo9Zwf_Jg6Uf7co&lang=cn&app_type=2
+
+
 '''
 '''
 
 
 
 
@@ -152,6 +155,7 @@ class DetectControllerView(View):
         return response.json(0, {'datas': res, 'count': count})
         return response.json(0, {'datas': res, 'count': count})
 
 
     def do_change_status1(self, userID, request_dict, response):
     def do_change_status1(self, userID, request_dict, response):
+
         uid = request_dict.get('uid', None)
         uid = request_dict.get('uid', None)
         token_val = request_dict.get('token_val', None)
         token_val = request_dict.get('token_val', None)
         appBundleId = request_dict.get('appBundleId', None)
         appBundleId = request_dict.get('appBundleId', None)
@@ -320,6 +324,10 @@ class DetectControllerView(View):
             uid_set_qs.update(detect_status=status, updTime=nowTime)
             uid_set_qs.update(detect_status=status, updTime=nowTime)
             if status == 0:
             if status == 0:
                 UidPushModel.objects.filter(uid_set__uid=uid).delete()
                 UidPushModel.objects.filter(uid_set__uid=uid).delete()
+                # 状态为0的时候删除redis缓存数据
+                ykey = '{uid}_redis_qs'.format(uid=uid)
+                redisObj = RedisObject(db=6,SERVER_HOST = 'push.dvema.com')
+                redisObj.del_data(key=ykey)
                 return response.json(0)
                 return response.json(0)
             elif status == 1:
             elif status == 1:
                 uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid)
                 uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid)
@@ -351,11 +359,13 @@ class DetectControllerView(View):
                     }
                     }
                     # 绑定设备推送
                     # 绑定设备推送
                     UidPushModel.objects.create(**uid_push_create_dict)
                     UidPushModel.objects.create(**uid_push_create_dict)
-                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)
+                # utko = UidTokenObject()
+                # # right
+                # utko.generate(data={'uid': uid})
+                etkObj = ETkObject(etk='')
+                etk = etkObj.encrypt(uid)
+                detectUrl = "{DETECT_PUSH_DOMAIN}notify/push?etk={etk}". \
+                    format(etk=etk, DETECT_PUSH_DOMAIN=DETECT_PUSH_DOMAIN)
                 return response.json(0, {'detectUrl': detectUrl})
                 return response.json(0, {'detectUrl': detectUrl})
         else:
         else:
             return response.json(14)
             return response.json(14)
@@ -393,17 +403,26 @@ class NotificationView(View):
     def validation(self, request_dict):
     def validation(self, request_dict):
         response = ResponseObject()
         response = ResponseObject()
         uidToken = request_dict.get('uidToken', None)
         uidToken = request_dict.get('uidToken', None)
+        etk = request_dict.get('etk', None)
         channel = request_dict.get('channel', '1')
         channel = request_dict.get('channel', '1')
         n_time = request_dict.get('n_time', None)
         n_time = request_dict.get('n_time', None)
         event_type = request_dict.get('event_type', None)
         event_type = request_dict.get('event_type', None)
         is_st = request_dict.get('is_st', None)
         is_st = request_dict.get('is_st', None)
-        if not all([uidToken, channel, n_time]):
+        if not all([channel, n_time]):
             return JsonResponse(status=200, data={
             return JsonResponse(status=200, data={
                 'code': 444,
                 'code': 444,
                 'msg': 'param is wrong'})
                 'msg': 'param is wrong'})
             # return response.json(444)
             # return response.json(444)
-        utko = UidTokenObject(uidToken)
-        uid = utko.UID
+        if etk:
+            eto = ETkObject(etk)
+            uid = eto.uid
+            if len(uid) != 20:
+                return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
+        else:
+            utko = UidTokenObject(uidToken)
+            uid = utko.UID
+        # utko = UidTokenObject(uidToken)
+        # uid = utko.UID
         redisObj = RedisObject(db=6)
         redisObj = RedisObject(db=6)
         # pkey = '{uid}_{channel}_ptl'.format(uid=uid, channel=channel)
         # pkey = '{uid}_{channel}_ptl'.format(uid=uid, channel=channel)
         pkey = '{uid}_ptl'.format(uid=uid)
         pkey = '{uid}_ptl'.format(uid=uid)
@@ -413,57 +432,53 @@ class NotificationView(View):
         else:
         else:
             # 设置推送间隔60秒一次
             # 设置推送间隔60秒一次
             redisObj.set_data(key=pkey, val=1, expire=60)
             redisObj.set_data(key=pkey, val=1, expire=60)
-        uid_set_qs = UidSetModel.objects.filter(uid=uid, detect_status=1)
-        if uid_set_qs.exists():
-            uid_set_id = uid_set_qs[0].id
-            nickname = uid_set_qs[0].nickname
+        uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid,uid_set__detect_status=1). \
+            values('token_val', 'app_type', 'appBundleId',
+                   'push_type', 'userID_id', 'userID__NickName',
+                   'lang', 'tz', 'uid_set__nickname')
+        if uid_push_qs.exists():
+            nickname = uid_push_qs[0]['uid_set__nickname']
             if not nickname:
             if not nickname:
                 nickname = uid
                 nickname = uid
-            uid_push_qs = UidPushModel.objects.filter(uid_set__id=uid_set_id). \
-                values('token_val', 'app_type', 'appBundleId', 'push_type', 'userID_id', 'userID__NickName', 'lang',
-                       'tz')
-            if uid_push_qs.exists():
-                auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
-                bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
-                for up in uid_push_qs:
-                    push_type = up['push_type']
-                    # ios apns
-                    print(push_type)
-                    if push_type == 0:
-                        self.do_apns(request_dict, up, response, uid, channel, nickname)
-                    # android gcm
-                    elif push_type == 1:
-                        self.do_fcm(request_dict, up, response, uid, channel, nickname)
-                        # self.do_gmc(request_dict, up, response, uid, channel,nickname)
-                    # android jpush
-                    elif push_type == 2:
-                        self.do_jpush(request_dict, up, response, uid, channel, nickname)
-                    # self.do_save_equipment_info(ua, n_time, channel, event_type, is_st)
-                # 需求不一样,所以这么做的
-                self.do_bulk_create_info(uid_push_qs, n_time, channel, event_type, is_st, uid)
-                if is_st == '0' or is_st == '2':
-                    return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
-                elif is_st == '1':
-                    # Endpoint以杭州为例,其它Region请按实际情况填写。
-                    obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
+            auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
+            bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
+            for up in uid_push_qs:
+                push_type = up['push_type']
+                # ios apns
+                print(push_type)
+                if push_type == 0:
+                    self.do_apns(request_dict, up, response, uid, channel, nickname)
+                # android gcm
+                elif push_type == 1:
+                    self.do_fcm(request_dict, up, response, uid, channel, nickname)
+                    # self.do_gmc(request_dict, up, response, uid, channel,nickname)
+                # android jpush
+                elif push_type == 2:
+                    self.do_jpush(request_dict, up, response, uid, channel, nickname)
+                # self.do_save_equipment_info(ua, n_time, channel, event_type, is_st)
+            # 需求不一样,所以这么做的
+            self.do_bulk_create_info(uid_push_qs, n_time, channel, event_type, is_st, uid)
+            if is_st == '0' or is_st == '2':
+                return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
+            elif is_st == '1':
+                # Endpoint以杭州为例,其它Region请按实际情况填写。
+                obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
+                # 设置此签名URL在60秒内有效。
+                url = bucket.sign_url('PUT', obj, 7200)
+                res_data = {'code': 0, 'img_push': url, 'msg': 'success'}
+                return JsonResponse(status=200, data=res_data)
+            elif is_st == '3':
+                # 人形检测带动图
+                # Endpoint以杭州为例,其它Region请按实际情况填写。
+                img_url_list = []
+                for i in range(int(is_st)):
+                    obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
+                        format(uid=uid, channel=channel, filename=n_time, st=i)
                     # 设置此签名URL在60秒内有效。
                     # 设置此签名URL在60秒内有效。
                     url = bucket.sign_url('PUT', obj, 7200)
                     url = bucket.sign_url('PUT', obj, 7200)
-                    res_data = {'code': 0, 'img_push': url, 'msg': 'success'}
-                    return JsonResponse(status=200, data=res_data)
-                elif is_st == '3':
-                    # 人形检测带动图
-                    # Endpoint以杭州为例,其它Region请按实际情况填写。
-                    img_url_list = []
-                    for i in range(int(is_st)):
-                        obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
-                            format(uid=uid, channel=channel, filename=n_time, st=i)
-                        # 设置此签名URL在60秒内有效。
-                        url = bucket.sign_url('PUT', obj, 7200)
-                        img_url_list.append(url)
-                    res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success'}
-                    return JsonResponse(status=200, data=res_data)
-            else:
-                return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
+                    img_url_list.append(url)
+                res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success'}
+                return JsonResponse(status=200, data=res_data)
         else:
         else:
             return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
             return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
 
 
@@ -606,12 +621,16 @@ class NotificationView(View):
         for dv in uaqs:
         for dv in uaqs:
             userID_id = dv["userID_id"]
             userID_id = dv["userID_id"]
             if userID_id not in userID_ids:
             if userID_id not in userID_ids:
+                if dv['uid_set__nickname']:
+                    uid_nickname = dv['uid_set__nickname']
+                else:
+                    uid_nickname = uid
                 add_data = {
                 add_data = {
                     'userID_id': dv["userID_id"],
                     'userID_id': dv["userID_id"],
                     'eventTime': n_time,
                     'eventTime': n_time,
                     'eventType': event_type,
                     'eventType': event_type,
                     'devUid': uid,
                     'devUid': uid,
-                    'devNickName': uid,
+                    'devNickName': uid_nickname,
                     'Channel': channel,
                     'Channel': channel,
                     'alarm': 'Motion \tChannel:{channel}'.format(channel=channel),
                     'alarm': 'Motion \tChannel:{channel}'.format(channel=channel),
                     'is_st': int(is_st),
                     'is_st': int(is_st),
@@ -660,39 +679,32 @@ class PushNotificationView(View):
                 return JsonResponse(status=200, data=res_data)
                 return JsonResponse(status=200, data=res_data)
             else:
             else:
                 redisObj.set_data(key=pkey, val=1, expire=60)
                 redisObj.set_data(key=pkey, val=1, expire=60)
-            uid_set_qs = UidSetModel.objects.filter(uid=uid, detect_status=1)
-            if uid_set_qs.exists():
-                uid_set_id = uid_set_qs[0].id
-                uid_push_qs = UidPushModel.objects.filter(uid_set__id=uid_set_id). \
-                    values('token_val', 'app_type', 'appBundleId', 'push_type',
-                           'userID_id', 'userID__NickName', 'lang', 'tz')
-                if uid_set_qs.exists():
-                    auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
-                    bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
-                    self.do_bulk_create_info(uid_push_qs, n_time, channel, event_type, is_st, uid)
-                    if is_st == '0' or is_st == '2':
-                        return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
-                    elif is_st == '1':
-                        # Endpoint以杭州为例,其它Region请按实际情况填写。
-                        obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
+            uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid,uid_set__detect_status=1).\
+                values('token_val', 'app_type', 'appBundleId', 'push_type','userID_id', 'userID__NickName', 'lang', 'tz', 'uid_set__nickname')
+            if uid_push_qs.exists():
+                auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
+                bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
+                self.do_bulk_create_info(uid_push_qs, n_time, channel, event_type, is_st, uid)
+                if is_st == '0' or is_st == '2':
+                    return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
+                elif is_st == '1':
+                    # Endpoint以杭州为例,其它Region请按实际情况填写。
+                    obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
+                    # 设置此签名URL在60秒内有效。
+                    url = bucket.sign_url('PUT', obj, 7200)
+                    res_data = {'code': 0, 'img_push': url, 'msg': 'success'}
+                    return JsonResponse(status=200, data=res_data)
+                elif is_st == '3':
+                    # 人形检测带动图
+                    img_url_list = []
+                    for i in range(int(is_st)):
+                        obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
+                            format(uid=uid, channel=channel, filename=n_time, st=i)
                         # 设置此签名URL在60秒内有效。
                         # 设置此签名URL在60秒内有效。
                         url = bucket.sign_url('PUT', obj, 7200)
                         url = bucket.sign_url('PUT', obj, 7200)
-                        res_data = {'code': 0, 'img_push': url, 'msg': 'success'}
-                        return JsonResponse(status=200, data=res_data)
-                    elif is_st == '3':
-                        # 人形检测带动图
-                        img_url_list = []
-                        for i in range(int(is_st)):
-                            obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
-                                format(uid=uid, channel=channel, filename=n_time, st=i)
-                            # 设置此签名URL在60秒内有效。
-                            url = bucket.sign_url('PUT', obj, 7200)
-                            img_url_list.append(url)
-                        res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success'}
-                        return JsonResponse(status=200, data=res_data)
-
-                else:
-                    return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
+                        img_url_list.append(url)
+                    res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success'}
+                    return JsonResponse(status=200, data=res_data)
             else:
             else:
                 return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
                 return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
         else:
         else:
@@ -707,12 +719,16 @@ class PushNotificationView(View):
         for dv in uaqs:
         for dv in uaqs:
             userID_id = dv["userID_id"]
             userID_id = dv["userID_id"]
             if userID_id not in userID_ids:
             if userID_id not in userID_ids:
+                if dv['uid_set__nickname']:
+                    uid_nickname = dv['uid_set__nickname']
+                else:
+                    uid_nickname = uid
                 add_data = {
                 add_data = {
                     'userID_id': dv["userID_id"],
                     'userID_id': dv["userID_id"],
                     'eventTime': n_time,
                     'eventTime': n_time,
                     'eventType': event_type,
                     'eventType': event_type,
                     'devUid': uid,
                     'devUid': uid,
-                    'devNickName': uid,
+                    'devNickName': uid_nickname,
                     'Channel': channel,
                     'Channel': channel,
                     'alarm': 'Motion \tChannel:{channel}'.format(channel=channel),
                     'alarm': 'Motion \tChannel:{channel}'.format(channel=channel),
                     'is_st': int(is_st),
                     'is_st': int(is_st),

+ 30 - 53
Controller/EquipmentManager.py

@@ -833,6 +833,7 @@ def update_uid_set(request):
 # test.shadow.dvema.com
 # test.shadow.dvema.com
 # 生产环境
 # 生产环境
 # shadow.dvema.com
 # shadow.dvema.com
+# http://test.dvema.com/deviceShadow/update?etk=JVJWbFpFU0VOV1FsbEVTMFpOU2xKWFFURXhNVUU9Xz0=&ucode=1234&version=1324&p2p_region=CN
 # 设备影子更新
 # 设备影子更新
 def update_device_shadow(request):
 def update_device_shadow(request):
     request.encoding = 'utf-8'
     request.encoding = 'utf-8'
@@ -865,6 +866,7 @@ def update_device_shadow(request):
         push_status = request_dict.get('push_status', None)
         push_status = request_dict.get('push_status', None)
         pwd = request_dict.get('pwd', None)
         pwd = request_dict.get('pwd', None)
         resetTime = request_dict.get('resetTime', None)
         resetTime = request_dict.get('resetTime', None)
+        is_alexa = request_dict.get('is_alexa', None)
 
 
         us_qs = UidSetModel.objects.filter(uid=uid)
         us_qs = UidSetModel.objects.filter(uid=uid)
         # 更新
         # 更新
@@ -873,64 +875,39 @@ def update_device_shadow(request):
         print('-------')
         print('-------')
         print(resetTime)
         print(resetTime)
         print('-------')
         print('-------')
-
+        qs_dict = {
+            'updTime': nowTime,
+            'ip': ip
+        }
+        if channel:
+            qs_dict['channel'] = channel
+        if p2p_region:
+            qs_dict['p2p_region'] = p2p_region
+        if ucode:
+            qs_dict['ucode'] = ucode
+        if version:
+            qs_dict['version'] = version
+        if tz:
+            qs_dict['tz'] = tz
+        if video_code:
+            qs_dict['video_code'] = video_code
+        if cloud_vod:
+            qs_dict['cloud_vod'] = cloud_vod
+        if push_status:
+            qs_dict['detect_status'] = push_status
+        if pwd:
+            qs_dict['pwd'] = pwd
+        if is_alexa:
+            qs_dict['is_alexa'] = is_alexa
         if us_qs.exists():
         if us_qs.exists():
-            update_dict = {
-                'updTime': nowTime,
-                'ip': ip
-            }
-            if channel:
-                update_dict['channel'] = channel
-            if p2p_region:
-                update_dict['p2p_region'] = p2p_region
-            if ucode:
-                update_dict['ucode'] = ucode
-            if version:
-                update_dict['version'] = version
-            if tz:
-                update_dict['tz'] = tz
-            if video_code:
-                update_dict['video'] = video_code
-            if cloud_vod:
-                update_dict['cloud_vod'] = cloud_vod
-            if push_status:
-                update_dict['detect_status'] = push_status
-            if pwd:
-                update_dict['pwd'] = pwd
-            us_qs.update(**update_dict)
+            us_qs.update(**qs_dict)
             # 如果推送状态开启,返回推送url
             # 如果推送状态开启,返回推送url
-            data = {}
-
             return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
             return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
         # 新增
         # 新增
         else:
         else:
-            create_dict = {
-                'uid': uid,
-                'addTime': nowTime,
-                'updTime': nowTime,
-                'ip': ip
-            }
-            if channel:
-                create_dict['channel'] = channel
-            if p2p_region:
-                create_dict['p2p_region'] = p2p_region
-            if ucode:
-                create_dict['ucode'] = ucode
-            if version:
-                create_dict['version'] = version
-            if tz:
-                create_dict['tz'] = tz
-            if video_code:
-                create_dict['video_code'] = video_code
-            if cloud_vod:
-                create_dict['cloud_vod'] = cloud_vod
-            if push_status:
-                create_dict['detect_status'] = push_status
-            if pwd:
-                create_dict['pwd'] = pwd
-            if resetTime:
-                create_dict['resetTime'] = resetTime
-            UidSetModel.objects.create(**create_dict)
+            qs_dict['uid'] = uid
+            qs_dict['addTime'] = nowTime
+            UidSetModel.objects.create(**qs_dict)
             # 如果推送状态开启,返回推送url
             # 如果推送状态开启,返回推送url
             return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
             return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
     else:
     else:

+ 6 - 4
Controller/EquipmentOTA.py

@@ -1,5 +1,4 @@
 import os
 import os
-import base64
 import simplejson as json
 import simplejson as json
 import time
 import time
 from django.utils import timezone
 from django.utils import timezone
@@ -14,8 +13,7 @@ from Object.TokenObject import TokenObject
 from Object.UrlTokenObject import UrlTokenObject
 from Object.UrlTokenObject import UrlTokenObject
 from Service.CommonService import CommonService
 from Service.CommonService import CommonService
 from Service.ModelService import ModelService
 from Service.ModelService import ModelService
-from var_dump import var_dump
-
+from django.db.models import Q
 '''
 '''
 http://192.168.136.45:8077/equipment/OTA?token=test&operation=query&page=1&line=10
 http://192.168.136.45:8077/equipment/OTA?token=test&operation=query&page=1&line=10
 http://192.168.136.45:8077/equipment/OTA?token=test&operation=find&page=1&line=10&content={}
 http://192.168.136.45:8077/equipment/OTA?token=test&operation=find&page=1&line=10&content={}
@@ -367,7 +365,11 @@ class EquipmentVersionView(View):
         if code:
         if code:
             ev_qs = ev_qs.filter(code__contains=code)
             ev_qs = ev_qs.filter(code__contains=code)
         if lang:
         if lang:
-            ev_qs = ev_qs.filter(lang=lang)
+            if lang == 'cn' or lang == 'zh-Hans':
+                ev_qs = ev_qs.filter(Q(lang='cn') | Q(lang='zh-Hans'))
+            else:
+                ev_qs = ev_qs.filter(lang=lang)
+
         count = ev_qs.count()
         count = ev_qs.count()
         ev_qs = ev_qs[(page - 1) * line:page * line].values()
         ev_qs = ev_qs[(page - 1) * line:page * line].values()
         ev_ls = CommonService.qs_to_list(ev_qs)
         ev_ls = CommonService.qs_to_list(ev_qs)

+ 18 - 4
Controller/SysMsg.py

@@ -15,7 +15,7 @@ import time
 
 
 from django.views.generic.base import View
 from django.views.generic.base import View
 
 
-from Model.models import SysMsgModel, FeedBackModel, SysMassModel, UserExModel
+from Model.models import SysMsgModel, FeedBackModel, SysMassModel, UserExModel, UidSetModel
 from Object.ResponseObject import ResponseObject
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Object.TokenObject import TokenObject
 from Service.ModelService import ModelService
 from Service.ModelService import ModelService
@@ -151,10 +151,24 @@ class SysMsgView(View):
             sm_qs = SysMsgModel.objects.filter(userID_id=userID)
             sm_qs = SysMsgModel.objects.filter(userID_id=userID)
             count = sm_qs.count()
             count = sm_qs.count()
             sm_qs = sm_qs[(page - 1) * line:page * line]. \
             sm_qs = sm_qs[(page - 1) * line:page * line]. \
-                values('status', 'id', 'msg', 'addTime', 'updTime')
-            # sm_qs = SysMsgModel.objects.filter(userID_id=userID)[(page - 1) * line:page * line].values('sta')
+                values('status', 'id', 'msg', 'addTime', 'updTime', 'uid', 'eventType')
+            data_res = []
+            uid_list = []
+
+            for sm_q in sm_qs:
+                if sm_q['eventType'] > 0:
+                    uid_list.append(sm_q['uid'])
+                data_res.append(sm_q)
+            if uid_list:
+                uid_set_qs = UidSetModel.objects.filter(uid__in=uid_list).values('uid', 'nickname')
+                data_res = []
+                for sm_q in sm_qs:
+                    for uid_set_q in uid_set_qs:
+                        if uid_set_q['uid'] == sm_q['uid']:
+                            sm_q['devNickName'] = uid_set_q['nickname']
+                    data_res.append(sm_q)
             if sm_qs.exists():
             if sm_qs.exists():
-                return response.json(0, {'data': list(sm_qs), 'count': count})
+                return response.json(0, {'data': data_res, 'count': count})
             else:
             else:
                 return response.json(0, [])
                 return response.json(0, [])
         else:
         else:

+ 130 - 26
Controller/UserController.py

@@ -25,9 +25,9 @@ from django.views.decorators.csrf import csrf_exempt
 from django.views.generic import TemplateView
 from django.views.generic import TemplateView
 from ratelimit.decorators import ratelimit
 from ratelimit.decorators import ratelimit
 
 
-from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CONFIG, FCM_CONFIG
+from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CONFIG, FCM_CONFIG, TUTK_PUSH_DOMAIN
 from Controller.CheckUserData import DataValid, date_handler, RandomStr
 from Controller.CheckUserData import DataValid, date_handler, RandomStr
-from Model.models import Device_User, Role, SysMsgModel, UidPushModel, UserOauth2Model, UserExModel, Device_Info
+from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info,UidSetModel
 from Object.AWS.SesClassObject import SesClassObject
 from Object.AWS.SesClassObject import SesClassObject
 from Object.AliSmsObject import AliSmsObject
 from Object.AliSmsObject import AliSmsObject
 from Object.RedisObject import RedisObject
 from Object.RedisObject import RedisObject
@@ -1265,12 +1265,12 @@ class InitInfoView(View):
         tko = TokenObject(token)
         tko = TokenObject(token)
         if tko.code == 0:
         if tko.code == 0:
             userID = tko.userID
             userID = tko.userID
-            return self.init_uid(request_dict, userID, response)
+            return self.init_info(request_dict, userID, response)
         else:
         else:
             return response.json(tko.code)
             return response.json(tko.code)
 
 
     # 初始化设备token
     # 初始化设备token
-    def init_uid(self, request_dict, userID, response):
+    def init_info(self, request_dict, userID, response):
         # 未读的系统消息
         # 未读的系统消息
         token_val = request_dict.get('token_val', None)
         token_val = request_dict.get('token_val', None)
         m_code = request_dict.get('m_code', None)
         m_code = request_dict.get('m_code', None)
@@ -1278,9 +1278,8 @@ class InitInfoView(View):
         appBundleId = request_dict.get('appBundleId', None)
         appBundleId = request_dict.get('appBundleId', None)
         tz = request_dict.get('tz', '0')
         tz = request_dict.get('tz', '0')
         lang = request_dict.get('lang', '')  # 语言区域
         lang = request_dict.get('lang', '')  # 语言区域
-        # region = request_dict.get('region', '')  # 语言区域
-        nowTime = int(time.time())
-        if all([token_val, push_type, appBundleId]):
+        now_time = int(time.time())
+        if all([token_val, push_type, appBundleId,userID]):
             push_type = int(push_type)
             push_type = int(push_type)
             if push_type == 0:
             if push_type == 0:
                 if appBundleId not in APNS_CONFIG.keys():
                 if appBundleId not in APNS_CONFIG.keys():
@@ -1293,8 +1292,7 @@ class InitInfoView(View):
                     return response.json(904)
                     return response.json(904)
             else:
             else:
                 return response.json(444, 'push_type')
                 return response.json(444, 'push_type')
-            uid_list = ModelService.get_uid_list(userID=userID)
-            if uid_list:
+            if m_code:
                 # 获取设备推送状态
                 # 获取设备推送状态
                 update_dict = {
                 update_dict = {
                     'token_val': token_val,
                     'token_val': token_val,
@@ -1302,32 +1300,28 @@ class InitInfoView(View):
                     'tz': tz,
                     'tz': tz,
                 }
                 }
                 # 更新当前用户推送设备状态
                 # 更新当前用户推送设备状态
-                UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__detect_status=1).update(
-                    **update_dict)
+                UidPushModel.objects.filter(userID_id=userID, m_code=m_code). \
+                    update(**update_dict)
             if appBundleId:
             if appBundleId:
                 user_ex_qs = UserExModel.objects.filter(userID_id=userID)
                 user_ex_qs = UserExModel.objects.filter(userID_id=userID)
                 if user_ex_qs.exists():
                 if user_ex_qs.exists():
                     update_dict = {
                     update_dict = {
-                        'updTime': nowTime,
+                        'updTime': now_time,
                         'appBundleId': appBundleId,
                         'appBundleId': appBundleId,
                         'region': lang
                         'region': lang
-                        # 'is_cn':
                     }
                     }
                     user_ex_qs.update(**update_dict)
                     user_ex_qs.update(**update_dict)
                 else:
                 else:
                     create_dict = {
                     create_dict = {
-                        'addTime': nowTime,
-                        'updTime': nowTime,
+                        'addTime': now_time,
+                        'updTime': now_time,
                         'appBundleId': appBundleId,
                         'appBundleId': appBundleId,
                         'userID_id': userID,
                         'userID_id': userID,
                         'region': lang
                         'region': lang
                     }
                     }
                     UserExModel.objects.create(**create_dict)
                     UserExModel.objects.create(**create_dict)
         # 获取设备是否存在有已被删除
         # 获取设备是否存在有已被删除
-
-        res = {
-            'usmsg': 0,
-        }
+        res = {'usmsg': 0}  # 预留字段, 有版本app该字段去掉会报错
         return response.json(0, res)
         return response.json(0, res)
 
 
 
 
@@ -2029,7 +2023,8 @@ class alexaAuthView(TemplateView):
         return self.valid_login(user_qs, password, response)
         return self.valid_login(user_qs, password, response)
 
 
     def do_name_login(self, username, password, response):
     def do_name_login(self, username, password, response):
-        user_qs = Device_User.objects.filter(Q(username=username) | Q(phone=username) | Q(userEmail=username), is_active=True, user_isValid=True)
+        user_qs = Device_User.objects.filter(Q(username=username) | Q(phone=username) | Q(userEmail=username),
+                                             is_active=True, user_isValid=True)
         return self.valid_login(user_qs, password, response)
         return self.valid_login(user_qs, password, response)
 
 
     def valid_login(self, user_qs, password, response):
     def valid_login(self, user_qs, password, response):
@@ -2039,12 +2034,121 @@ class alexaAuthView(TemplateView):
         if not check_password(password, users['password']):
         if not check_password(password, users['password']):
             return response.json(111)
             return response.json(111)
         userID = users['userID']
         userID = users['userID']
-        uid_qs = Device_Info.objects.filter(userID_id=userID, isExist=1).values('UID', 'NickName','View_Password')
-        uid_arr = []
-        for uid_q in uid_qs:
-            uid_arr.append({'uid': uid_q['UID'], 'nick': uid_q['NickName'],'password':uid_q['View_Password']})
+        # uid_qs = Device_Info.objects.filter(userID_id=userID, isExist=1).values('UID', 'NickName', 'View_Password')
+        # uid_arr = []
+        # for uid_q in uid_qs:
+        #     uid_arr.append({'uid': uid_q['UID'], 'nick': uid_q['NickName'], 'password': uid_q['View_Password']})
         res = {
         res = {
             'userID': userID,
             'userID': userID,
-            'uid_arr': uid_arr
+        #     'uid_arr': uid_arr
         }
         }
-        return response.json(0, res)
+        return response.json(0,res)
+        # return response.json(0, res)
+
+class alexaUidView(TemplateView):
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        # request_dict = json.loads(request.body.decode('utf-8'))
+        request_dict = request.POST
+        response = ResponseObject()
+        return self.validates(request_dict, response)
+
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        request_dict = request.GET
+        response = ResponseObject()
+        return self.validates(request_dict, response)
+
+    def validates1(self, request_dict, response):
+        userID = request_dict.get('alexa_user_id')
+        sid = request_dict.get('sid')
+        sst = request_dict.get('sst')
+        if sid == 'admin' and sst == 'admin':
+            uid_qs = Device_Info.objects.filter(userID_id=userID, isExist=1).values('UID', 'NickName', 'View_Password')
+            uid_arr = []
+            uid_list = []
+            for uid_q in uid_qs:
+                uid_list.append(uid_q['UID'])
+                uid_arr.append({'uid': uid_q['UID'], 'nick': uid_q['NickName'], 'password': uid_q['View_Password']})
+            res = {
+                'uid_arr': uid_arr
+            }
+            return response.json(0,res)
+        else:
+            return response.json(107)
+
+    def validates(self, request_dict, response):
+        userID = request_dict.get('alexa_user_id')
+        sid = request_dict.get('sid')
+        sst = request_dict.get('sst')
+        if sid == 'admin' and sst == 'admin':
+            uid_qs = Device_Info.objects.filter(userID_id=userID, isExist=1).values('UID', 'NickName', 'View_Password')
+            uid_dict = {}
+            uid_list = []
+            for uid_q in uid_qs:
+                uid_list.append(uid_q['UID'])
+                uid_dict[uid_q['UID']] = {'nick': uid_q['NickName'], 'password': uid_q['View_Password']}
+            us_qs = UidSetModel.objects.filter(uid__in=uid_list, is_alexa=1).values('uid')
+            uid_arr = []
+            for us in us_qs:
+                uid = us['uid']
+                # uid_arr.append({'uid': uid, 'nick': uid_dict[uid]['nick'], 'password': uid_dict['uid']['password']})
+                uid_arr.append({'uid': uid, 'nick': uid_dict[uid]['nick'], 'password': uid_dict[uid]['password']})
+            res = {
+                'uid_arr': uid_arr
+            }
+            return response.json(0, res)
+        else:
+            return response.json(107)
+
+# 登出
+class V2LogoutView(TemplateView):
+    @method_decorator(csrf_exempt)
+    def dispatch(self, *args, **kwargs):
+        return super(V2LogoutView, self).dispatch(*args, **kwargs)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        request_dict = request.POST
+        return self.Logout(request_dict)
+
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        request_dict = request.GET
+        return self.Logout(request_dict)
+
+    def Logout(self, request_dict):
+        response = ResponseObject()
+        token = request_dict.get('token')
+        tko = TokenObject(token)
+        userID = tko.userID
+        if tko.code == 0:
+            Device_User.objects.filter(userID=tko.userID).update(online=False)
+
+            redisObj = RedisObject(db=3)
+            redisObj.del_data(key=tko.userID)
+            m_code = request_dict.get('m_code', None)
+            if m_code:
+                try:
+                    UidPushModel.objects.filter(userID_id=userID, m_code=m_code).delete()
+                except Exception as e:
+                    pass
+                else:
+                    pass
+            os_type = request_dict.get('os_type', None)
+            appid = request_dict.get('appid', None)
+            udid = request_dict.get('udid', None)
+            if os_type and appid and udid:
+                tutk_push_url = "{tutk_push_domain}?cmd=mapsync&os={os_type}&appid={appid}&udid={udid}". \
+                    format(os_type=os_type, appid=appid, udid=udid, tutk_push_domain=TUTK_PUSH_DOMAIN)
+                res = requests.get(url=tutk_push_url)
+                res_s = res.text
+                res_s = res_s.rstrip()
+
+                if res_s == '200 Success.':
+                    return response.json(0)
+                else:
+                    return response.json(10, 'not yes')
+            return response.json(0)
+        else:
+            return response.json(tko.code)

+ 4 - 0
Model/models.py

@@ -613,6 +613,8 @@ class SysMsgModel(models.Model):
     status = models.SmallIntegerField(verbose_name='是否已读', default=0)  # 0:否,1:是
     status = models.SmallIntegerField(verbose_name='是否已读', default=0)  # 0:否,1:是
     addTime = models.IntegerField(verbose_name='添加时间', default=0)
     addTime = models.IntegerField(verbose_name='添加时间', default=0)
     updTime = models.IntegerField(verbose_name='更新时间', default=0)
     updTime = models.IntegerField(verbose_name='更新时间', default=0)
+    eventType = models.IntegerField(verbose_name='消息类型', default=0) # 默认系统消息类型,0系统消息,1 ipcamera消息
+    uid = models.CharField(default='', max_length=20, db_index=True, verbose_name='设备UID')
 
 
     class Meta:
     class Meta:
         db_table = 'sys_msg'
         db_table = 'sys_msg'
@@ -642,6 +644,8 @@ class UidSetModel(models.Model):
     pwd = models.CharField(max_length=32, default='', verbose_name=u'设备密码')
     pwd = models.CharField(max_length=32, default='', verbose_name=u'设备密码')
     # 设备重置后第一次启动时间
     # 设备重置后第一次启动时间
     resetTime = models.IntegerField(default=0, verbose_name='设备重置时间')
     resetTime = models.IntegerField(default=0, verbose_name='设备重置时间')
+    is_alexa = models.IntegerField(default=0, verbose_name='会否支持alexa') # 0:否,1:是
+    # is_azpush = models.IntegerField(default=0, verbose_name='会否自家推送服务') # 0:否,1:是
 
 
     class Meta:
     class Meta:
         db_table = 'uid_set'
         db_table = 'uid_set'

+ 1 - 1
Object/RedisObject.py

@@ -25,7 +25,7 @@ db=3  -> 统计在线人数用
 
 
 class RedisObject:
 class RedisObject:
 
 
-    def __init__(self, db=0):
+    def __init__(self, db=0,SERVER_HOST = SERVER_HOST):
         if db == 3:
         if db == 3:
             if SERVER_TYPE != 'Ansjer.formal_settings':
             if SERVER_TYPE != 'Ansjer.formal_settings':
                 db = 4
                 db = 4

+ 6 - 2
Object/TokenObject.py

@@ -60,8 +60,12 @@ class TokenObject:
                 self.code = 309
                 self.code = 309
                 return
                 return
             else:
             else:
-                self.code = 0
-                return res
+                if self.userID:
+                    self.code = 0
+                    return res
+                else:
+                    self.code = 309
+                    return
     # token加密
     # token加密
     def generate(self, data={}):
     def generate(self, data={}):
         try:
         try:

+ 0 - 3
Object/UidTokenObject.py

@@ -56,6 +56,3 @@ class UidTokenObject:
 
 
 # print(utko)
 # print(utko)
 
 
-'''
-
-'''

+ 3 - 0
README.md

@@ -1,3 +1,6 @@
+### 软件版本:V2.0.0.2020-2-10
+    1,自主推送方案 移动侦测,图片推送
+    2,alexa oauth2 rtsp
 ### 软件版本:V1.5.0.2019-2-12
 ### 软件版本:V1.5.0.2019-2-12
     1,云存功能第二版测试完成,功能完善,bug修正,使用公司提供账号
     1,云存功能第二版测试完成,功能完善,bug修正,使用公司提供账号
     2,新版本ota功能(主要未dvr)
     2,新版本ota功能(主要未dvr)

+ 1 - 8
Service/TemplateService.py

@@ -65,14 +65,7 @@ class TemplateService:
             'detect/changeStatus',
             'detect/changeStatus',
             # 'notify/push',
             # 'notify/push',
             'equipment/flowUpdate',
             'equipment/flowUpdate',
-            'wechat/authsign',
-            # 'user/initInfo',
-            'wechat/perfect',
-            'oauth/perfect',
-            'oauth/authcode',
-            'detect/queryInfo',
-            'deviceShadow/update',
-            'uidset/adminDelete'
+            'wechat/authsign'
         ]
         ]
         return apiList
         return apiList
 
 

+ 2 - 5
Service/middleware.py

@@ -28,7 +28,7 @@ class StatisticsUrlMiddleware(MiddlewareMixin):
             else:
             else:
                 adds = request.META.get('REMOTE_ADDR', None)
                 adds = request.META.get('REMOTE_ADDR', None)
                 api_settings.ADDR_URL.append(adds)
                 api_settings.ADDR_URL.append(adds)
-                MiscellService.add_ota_download_log(request=request)
+                # MiscellService.add_ota_download_log(request=request)
                 return 0
                 return 0
 
 
     def _https_statistics_to_close(self, request):
     def _https_statistics_to_close(self, request):
@@ -82,11 +82,8 @@ class StatisticsUrlMiddleware(MiddlewareMixin):
         if request.path !='/favicon.ico':
         if request.path !='/favicon.ico':
             print('process_response', request, response)
             print('process_response', request, response)
             try:
             try:
-                #pass
+                pass
                 # mysql
                 # mysql
-                MiscellService.batch_add_access_log(request=request, status_code=response.status_code)
-
-                # MiscellService.DynamoDB_add_access_log(request=request, status_code=response.status_code)
                 # MiscellService.add_access_log(request=request, status_code=response.status_code)
                 # MiscellService.add_access_log(request=request, status_code=response.status_code)
                 # mongodb版
                 # mongodb版
                 # MiscellService.access_log(request=request, response=response, type=0)
                 # MiscellService.access_log(request=request, response=response, type=0)