|
@@ -121,10 +121,6 @@ class AiView(View):
|
|
|
TIME_LOGGER.info(f'uid={uid},用户没有开启AI推送')
|
|
|
return response.json(173)
|
|
|
|
|
|
- redis_obj = RedisObject(db=6)
|
|
|
- APP_NOTIFY_KEY = f'ASJ:NOTIFY:PUSH:{uid}' # 推送间隔缓存KEY
|
|
|
- push_cache_data = redis_obj.get_data(APP_NOTIFY_KEY)
|
|
|
- is_push = False if push_cache_data else True
|
|
|
ai_server = 'sageMaker'
|
|
|
if AiServiceQuery[0]['orders__payType'] == 10: # AI首次体验前半个月调Rekognition
|
|
|
now_time = int(time.time())
|
|
@@ -132,14 +128,11 @@ class AiView(View):
|
|
|
if (now_time - add_time) <= (3600 * 24 * 3):
|
|
|
ai_server = 'rekognition'
|
|
|
|
|
|
- self.add_push_cache(APP_NOTIFY_KEY, redis_obj, push_cache_data,
|
|
|
- uid_push_qs[0]['uid_set__new_detect_interval'])
|
|
|
-
|
|
|
push_thread = threading.Thread(target=self.image_label_detection,
|
|
|
kwargs={'ai_server': ai_server, 'uid': uid, 'file_list': file_list,
|
|
|
'detect_group': detect_group, 'n_time': n_time,
|
|
|
'uid_push_qs': uid_push_qs,
|
|
|
- 'channel': channel, 'is_push': is_push})
|
|
|
+ 'channel': channel})
|
|
|
push_thread.start() # AI识别异步存表&推送
|
|
|
|
|
|
return response.json(0)
|
|
@@ -167,7 +160,7 @@ class AiView(View):
|
|
|
redis_obj.set_data(key=key, val=json.dumps(push_data), expire=push_interval)
|
|
|
|
|
|
def image_label_detection(self, ai_server, uid, file_list, detect_group,
|
|
|
- n_time, uid_push_qs, channel, is_push):
|
|
|
+ n_time, uid_push_qs, channel):
|
|
|
"""
|
|
|
:param ai_server: AI服务类型
|
|
|
:param uid: 用户uid
|
|
@@ -176,11 +169,16 @@ class AiView(View):
|
|
|
:param n_time: 时间戳
|
|
|
:param uid_push_qs: 推送数据
|
|
|
:param channel: 推送通道
|
|
|
- :param is_push: 是否APP提醒推送
|
|
|
:return:
|
|
|
"""
|
|
|
try:
|
|
|
start_time = time.time()
|
|
|
+
|
|
|
+ redis_obj = RedisObject(db=6)
|
|
|
+ APP_NOTIFY_KEY = f'ASJ:NOTIFY:PUSH:{uid}:{channel}' # 推送间隔缓存KEY
|
|
|
+ push_cache_data = redis_obj.get_data(APP_NOTIFY_KEY)
|
|
|
+ is_push = False if push_cache_data else True
|
|
|
+
|
|
|
notify_data = uid_push_qs[0]['uid_set__msg_notify']
|
|
|
|
|
|
# APP推送提醒状态
|
|
@@ -195,6 +193,8 @@ class AiView(View):
|
|
|
return False
|
|
|
# 保存推送消息
|
|
|
sage_maker.save_push_message(uid, n_time, uid_push_qs, channel, res, file_list, notify)
|
|
|
+ self.add_push_cache(APP_NOTIFY_KEY, redis_obj, push_cache_data,
|
|
|
+ uid_push_qs[0]['uid_set__new_detect_interval'])
|
|
|
return True
|
|
|
|
|
|
TIME_LOGGER.info(f'*****现执行Reko,uid={uid}识别类型={ai_server}')
|
|
@@ -250,6 +250,10 @@ class AiView(View):
|
|
|
n_time=n_time, i=i)
|
|
|
self.upload_s3(file_dict, dir_path)
|
|
|
|
|
|
+ # 设置推送间隔缓存
|
|
|
+ self.add_push_cache(APP_NOTIFY_KEY, redis_obj, push_cache_data,
|
|
|
+ uid_push_qs[0]['uid_set__new_detect_interval'])
|
|
|
+
|
|
|
self.save_message_and_push(eventType, uid, n_time, uid_push_qs, channel,
|
|
|
label_str, new_bounding_box_dict, notify)
|
|
|
|