|
@@ -95,10 +95,12 @@ 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__channel', 'uid_set__ai_type')
|
|
|
if not uid_push_qs.exists():
|
|
|
logger.info('uid_push 数据不存在')
|
|
|
return JsonResponse(status=200, data={'code': 176, 'msg': 'no uid_push data'})
|
|
|
+ ai_type = uid_push_qs.first()['uid_set__ai_type']
|
|
|
+ event_type = self.get_combo_msg_type(ai_type, event_type)
|
|
|
redis_list = []
|
|
|
for qs in uid_push_qs:
|
|
|
redis_list.append(qs)
|
|
@@ -202,7 +204,7 @@ class NotificationV2View(View):
|
|
|
# 推送消息
|
|
|
if not have_dkey:
|
|
|
logger.info('准备推送:{}, {}'.format(uid, request_dict))
|
|
|
- if (is_st == 1 or is_st == 3) and (push_type == 0 or push_type == 1): # 推送显示图片
|
|
|
+ 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)
|
|
|
else:
|
|
@@ -310,6 +312,46 @@ class NotificationV2View(View):
|
|
|
}
|
|
|
return JsonResponse(status=200, data=json.dumps(data), safe=False)
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def get_combo_msg_type(cls, ai_type, event_type):
|
|
|
+ """
|
|
|
+ 获取组合类型,ai_type == 47 支持算法小店,需判断组合类型
|
|
|
+ """
|
|
|
+ logger = logging.getLogger('info')
|
|
|
+ try:
|
|
|
+ if ai_type != 47:
|
|
|
+ return event_type
|
|
|
+ # 如触发一个事件,则匹配已用类型 1替换后变成51代表移动侦测 1:移动侦测,2:人形,4:车型,8:人脸
|
|
|
+ event_dict = {
|
|
|
+ 1: 51,
|
|
|
+ 2: 57,
|
|
|
+ 4: 58,
|
|
|
+ 8: 60
|
|
|
+ }
|
|
|
+ event_val = event_dict.get(event_type, 0)
|
|
|
+ # event_val == 0 没有匹配到单个值则认为组合类型
|
|
|
+ # 如是3,则转为二进制11,代表(1+2)触发了移动侦测+人形侦测
|
|
|
+ if event_val == 0:
|
|
|
+ val = cls.dec_to_bin(event_type)
|
|
|
+ return int(val)
|
|
|
+ else:
|
|
|
+ return int(event_val)
|
|
|
+ except Exception as e:
|
|
|
+ logger.info('推送错误异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return event_type
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def dec_to_bin(num):
|
|
|
+ """
|
|
|
+ 十进制转二进制
|
|
|
+ """
|
|
|
+ result = ""
|
|
|
+ while num != 0:
|
|
|
+ ret = num % 2
|
|
|
+ num //= 2
|
|
|
+ result = str(ret) + result
|
|
|
+ return result
|
|
|
+
|
|
|
def push_thread_test(self, push_type, aws_s3_client, bucket, key, uid, appBundleId, token_val, event_type, n_time,
|
|
|
msg_title, msg_text, channel):
|
|
|
logger = logging.getLogger('info')
|