Browse Source

fix:推送状态值修改equipment/flow

chenjunkai 6 years ago
parent
commit
d5ba4e240b
3 changed files with 33 additions and 43 deletions
  1. 15 23
      Ansjer/test/test.py
  2. 5 4
      Controller/DetectController.py
  3. 13 16
      Controller/EquipmentManager.py

+ 15 - 23
Ansjer/test/test.py

@@ -1,24 +1,16 @@
-# https://www.now.cn/user/to_register.php?&ajax_code=1&types=mobile&mobile=13119458542
-import random
+def removeDuplicates(self, nums):
+    """
+    :type nums: List[int]
+    :rtype: int
+    """
+    diff_length = 0
+    index = -1
+    for index, item in enumerate(nums):
+        if nums[diff_length] != item:
+            diff_length += 1
+            nums[diff_length] = item
 
-
-def create_phone():
-    # 第二位数字
-    second = [3, 4, 5, 7, 8][random.randint(0, 4)]
-
-    # 第三位数字
-    third = {
-        3: random.randint(0, 9),
-        4: [5, 7, 9][random.randint(0, 2)],
-        5: [i for i in range(10) if i != 4][random.randint(0, 8)],
-        7: [i for i in range(10) if i not in [4, 9]][random.randint(0, 7)],
-        8: random.randint(0, 9),
-    }[second]
-
-    # 最后八位数字
-    suffix = random.randint(9999999,100000000)
-
-    # 拼接手机号
-    return "1{}{}{}".format(second, third, suffix)
-print(create_phone())
-# 生成手机号
+    if index >= diff_length:
+        return diff_length + 1
+    else:
+        return diff_length

+ 5 - 4
Controller/DetectController.py

@@ -264,13 +264,14 @@ class NotificationView(View):
         token_val = uaql['token_val']
         uid = uaql['uid']
 
-        print('===============')
-        print(appBundleId)
-        print('=============')
+
         response = ResponseObject()
         app_key = jpush_config[appBundleId]['Key']
         master_secret = jpush_config[appBundleId]['Secret']
-
+        print('===============')
+        print(app_key)
+        print(master_secret)
+        print('=============')
         # 此处换成各自的app_key和master_secret
         _jpush = jpush.JPush(app_key, master_secret)
         push = _jpush.create_push()

+ 13 - 16
Controller/EquipmentManager.py

@@ -616,20 +616,17 @@ def uid_status(request):
     response.lang = tko.lang
     if tko.code != 0:
         return response.json(tko.code)
-
-    if not uid:
-        qs = UID_App.objects.filter(userID_id=tko.userID).values('uid', 'status')
+    qs = UID_App.objects.filter(uid=uid, userID_id=tko.userID).values('uid', 'status')
+    print(qs)
+    if qs.exists():
+        data = {
+            'push_status': qs[0]['status']
+        }
+        ubqs = UID_Bucket.objects.filter(uid=uid). \
+            values('bucket__content', 'status', 'channel', 'endTime', 'uid')
+        nowTime = int(time.time())
+        if ubqs[0]['endTime'] > nowTime:
+            data['vod'] = list(ubqs)
+        return response.json(0, data)
     else:
-        qs = UID_App.objects.filter(uid=uid, userID_id=tko.userID).values('uid', 'status')
-    data = {}
-    for q in qs:
-        dvqs = UID_Bucket.objects.filter(uid=q['uid'])
-        dvdict = CommonService.qs_to_dict(dvqs)
-        cloudVod = []
-        for p in dvdict['datas']:
-            # p['fields']['vod'] = []
-            cloudVod = p['fields']
-            print (p['fields'])
-        data[q['uid']]= {'push_status': q['status'],'cloudVod':cloudVod}
-
-    return response.json(0, data)
+        return response.json(0)