Jelajahi Sumber

Merge branch 'master' of http://192.168.136.99:3000/servers/ASJPush

peng 2 tahun lalu
induk
melakukan
ed31427e1a
2 mengubah file dengan 16 tambahan dan 25 penghapusan
  1. 7 10
      Controller/DetectController.py
  2. 9 15
      Controller/DetectControllerV2.py

+ 7 - 10
Controller/DetectController.py

@@ -93,7 +93,7 @@ class NotificationView(View):
                 values('token_val', 'app_type', 'appBundleId', 'm_code',
                        'push_type', 'userID_id', 'userID__NickName',
                        'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
-                       'uid_set__channel')
+                       'uid_set__channel', 'uid_set__new_detect_interval')
 
             uid_push_list = []
             for qs in uid_push_qs:
@@ -121,16 +121,12 @@ class NotificationView(View):
             else:
                 detect_med_type = 2  # 为2的话,既推送,又存库
                 # detect_group=0允许全部推送的时候
-                if detect_group == '0' or detect_group == '':
-                    redisObj.set_data(key=dkey, val=1, expire=detect_interval)
-                else:
-                    detect_group_list = detect_group.split(',')
-                    if event_type in detect_group_list:
-                        if detect_interval < 60:
-                            detect_interval = 60
-                        redisObj.set_data(key=dkey, val=1, expire=detect_interval)
+                new_detect_interval = uid_push_list[0]['uid_set__new_detect_interval']
+                detect_interval = new_detect_interval if new_detect_interval > 0 else detect_interval
+                detect_interval = 60 if detect_interval < 60 else detect_interval
+                redisObj.set_data(key=dkey, val=1, expire=detect_interval-5)
                 redisObj.set_data(key=pkey, val=1, expire=60)
-
+        logger.info('APP消息推送V1接口,是否进行APP推送:{},1为不推送,间隔:{}'.format(detect_med_type, detect_interval))
         # 旧模式并且没有pkey,重新创建一个
         if not detect_group and not have_pkey:
             redisObj.set_data(key=pkey, val=1, expire=60)
@@ -209,6 +205,7 @@ class NotificationView(View):
 
             # 推送
             if detect_med_type == 2 or detect_med_type == 0:
+                logger.info('准备推送{}'.format(detect_med_type))
                 try:
                     if push_type == 0:  # ios apns
                         do_apns_code = self.do_apns(**kwag_args)

+ 9 - 15
Controller/DetectControllerV2.py

@@ -84,8 +84,7 @@ class NotificationV2View(View):
             have_ykey = redisObj.get_data(key=ykey)  # uid_set 数据库缓存
             have_pkey = redisObj.get_data(key=pkey)  # 一分钟限制key
             have_dkey = redisObj.get_data(key=dkey)  # 推送消息时间间隔
-            logger.info('ykey:{}, pkey: {}, dkey: {},'.format(have_ykey, have_pkey, have_dkey))
-
+            logger.info('ykey:{}, pkey: {}, dkey: {}'.format(have_ykey, have_pkey, have_dkey))
             # 一分钟内不推送
             if have_pkey:
                 return JsonResponse(status=200, data={'code': 0, 'msg': 'Push again in one minute'})
@@ -95,7 +94,7 @@ class NotificationV2View(View):
             uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1). \
                 values('token_val', 'app_type', 'appBundleId', 'm_code', 'push_type', 'userID_id', 'userID__NickName',
                        'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
-                       'uid_set__channel', 'uid_set__ai_type')
+                       'uid_set__channel', 'uid_set__ai_type', 'uid_set__new_detect_interval')
             if not uid_push_qs.exists():
                 logger.info('uid_push 数据不存在')
                 return JsonResponse(status=200, data={'code': 176, 'msg': 'no uid_push data'})
@@ -109,21 +108,15 @@ class NotificationV2View(View):
 
             nickname = redis_list[0]['uid_set__nickname']
             detect_interval = redis_list[0]['uid_set__detect_interval']
-            detect_group = redis_list[0]['uid_set__detect_group']
-
             if not nickname:
                 nickname = uid
-
             if not have_dkey:
                 # 设置推送消息的时间间隔
-                if detect_group == '0' or detect_group == '':
-                    redisObj.set_data(key=dkey, val=1, expire=detect_interval)
-                else:
-                    detect_group_list = detect_group.split(',')
-                    if event_type in detect_group_list:
-                        if detect_interval < 60:
-                            detect_interval = 60
-                        redisObj.set_data(key=dkey, val=1, expire=detect_interval)
+                new_detect_interval = redis_list[0]['uid_set__new_detect_interval']
+                detect_interval = new_detect_interval if new_detect_interval > 0 else detect_interval
+                detect_interval = 60 if detect_interval < 60 else detect_interval
+                redisObj.set_data(key=dkey, val=1, expire=detect_interval-5)
+                logger.info('APP消息推送间隔:{}s'.format(detect_interval))
 
             if is_st == 1 or is_st == 3:  # 使用aws s3
                 aws_s3_client = s3_client(region=region)
@@ -203,7 +196,7 @@ class NotificationV2View(View):
                 try:
                     # 推送消息
                     if not have_dkey:
-                        logger.info('准备推送:{}, {}'.format(uid, request_dict))
+                        logger.info('APP准备推送:{}, {}'.format(uid, request_dict))
                         if (is_st == 1 or is_st == 3) and (push_type == 0 or push_type == 1):  # 推送显示图片
                             if is_st == 1:
                                 key = '{}/{}/{}.jpeg'.format(uid, channel, n_time)
@@ -321,6 +314,7 @@ class NotificationV2View(View):
         try:
             if ai_type != 47:
                 return event_type
+            logger.info('LOG------算法小店组合类型十进制值:{}'.format(event_type))
             # 如触发一个事件,则匹配已用类型 1替换后变成51代表移动侦测 1:移动侦测,2:人形,4:车型,8:人脸
             event_dict = {
                 1: 51,