|
@@ -76,14 +76,15 @@ class NotificationView(View):
|
|
res_data = {'code': 0, 'msg': 'success!'}
|
|
res_data = {'code': 0, 'msg': 'success!'}
|
|
return JsonResponse(status=200, data=res_data)
|
|
return JsonResponse(status=200, data=res_data)
|
|
else:
|
|
else:
|
|
- if redisObj.get_data(key=ykey):
|
|
|
|
- redis_list = eval(redisObj.get_data(key=ykey))
|
|
|
|
|
|
+ redis_data = redisObj.get_data(key=ykey)
|
|
|
|
+ if redis_data:
|
|
|
|
+ redis_list = eval(redis_data)
|
|
else:
|
|
else:
|
|
# 设置推送时间为60秒一次
|
|
# 设置推送时间为60秒一次
|
|
redisObj.set_data(key=pkey, val=1, expire=60)
|
|
redisObj.set_data(key=pkey, val=1, expire=60)
|
|
print("从数据库查到数据")
|
|
print("从数据库查到数据")
|
|
# 从数据库查询出来
|
|
# 从数据库查询出来
|
|
- uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid,uid_set__detect_status=1). \
|
|
|
|
|
|
+ uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1). \
|
|
values('token_val', 'app_type', 'appBundleId',
|
|
values('token_val', 'app_type', 'appBundleId',
|
|
'push_type', 'userID_id', 'userID__NickName',
|
|
'push_type', 'userID_id', 'userID__NickName',
|
|
'lang', 'tz', 'uid_set__nickname')
|
|
'lang', 'tz', 'uid_set__nickname')
|
|
@@ -114,7 +115,7 @@ class NotificationView(View):
|
|
self.do_jpush(request_dict, up, response, uid, channel, nickname)
|
|
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_save_equipment_info(ua, n_time, channel, event_type, is_st)
|
|
# 需求不一样,所以这么做的
|
|
# 需求不一样,所以这么做的
|
|
- self.do_bulk_create_info(redis_list, n_time, channel, event_type, is_st, uid,nickname)
|
|
|
|
|
|
+ self.do_bulk_create_info(redis_list, n_time, channel, event_type, is_st, uid, nickname)
|
|
if is_st == '0' or is_st == '2':
|
|
if is_st == '0' or is_st == '2':
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
|
|
elif is_st == '1':
|
|
elif is_st == '1':
|
|
@@ -268,7 +269,7 @@ class NotificationView(View):
|
|
print(repr(e))
|
|
print(repr(e))
|
|
return response.json(10, repr(e))
|
|
return response.json(10, repr(e))
|
|
|
|
|
|
- def do_bulk_create_info(self, uaqs, n_time, channel, event_type, is_st, uid,nickname):
|
|
|
|
|
|
+ def do_bulk_create_info(self, uaqs, n_time, channel, event_type, is_st, uid, nickname):
|
|
#
|
|
#
|
|
qs_list = []
|
|
qs_list = []
|
|
nowTime = int(time.time())
|
|
nowTime = int(time.time())
|
|
@@ -324,18 +325,37 @@ class PushNotificationView(View):
|
|
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)
|
|
|
|
+
|
|
if redisObj.get_data(key=pkey):
|
|
if redisObj.get_data(key=pkey):
|
|
res_data = {'code': 0, 'msg': 'success,!'}
|
|
res_data = {'code': 0, 'msg': 'success,!'}
|
|
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_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():
|
|
|
|
|
|
+ ykey = '{uid}_redis_qs'.format(uid=uid)
|
|
|
|
+ ##############
|
|
|
|
+ redis_data = redisObj.get_data(key=ykey)
|
|
|
|
+ if redis_data:
|
|
|
|
+ redis_list = eval(redis_data)
|
|
|
|
+ else:
|
|
|
|
+ # 设置推送时间为60秒一次
|
|
|
|
+ redisObj.set_data(key=pkey, val=1, expire=60)
|
|
|
|
+ print("从数据库查到数据")
|
|
|
|
+ # 从数据库查询出来
|
|
|
|
+ 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')
|
|
|
|
+ # 新建一个list接收数据
|
|
|
|
+ redis_list = []
|
|
|
|
+ # 把数据库数据追加进redis_list
|
|
|
|
+ for qs in uid_push_qs:
|
|
|
|
+ redis_list.append(qs)
|
|
|
|
+ # 修改redis数据,并设置过期时间为10分钟
|
|
|
|
+ redisObj.set_data(key=ykey, val=str(redis_list), expire=600)
|
|
|
|
+ if redis_list:
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
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)
|
|
|
|
|
|
+ self.do_bulk_create_info(redis_list, n_time, channel, event_type, is_st, uid)
|
|
if is_st == '0' or is_st == '2':
|
|
if is_st == '0' or is_st == '2':
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
|
|
elif is_st == '1':
|
|
elif is_st == '1':
|