|
@@ -1,4 +1,5 @@
|
|
|
import json
|
|
|
+import threading
|
|
|
import time
|
|
|
|
|
|
import oss2
|
|
@@ -6,7 +7,7 @@ from django.db import transaction
|
|
|
from django.views.generic.base import View
|
|
|
|
|
|
from Ansjer.config import ACCESS_KEY_ID, SECRET_ACCESS_KEY, REGION_NAME, PUSH_BUCKET, PUSH_INACCURATE_BUCKET
|
|
|
-from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
|
|
|
+from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, LOGGER
|
|
|
from Model.models import FeedBackModel, StatResModel, PushInaccurateFeedback
|
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
|
from Object.ResponseObject import ResponseObject
|
|
@@ -343,17 +344,26 @@ class FeedBackView(View):
|
|
|
tag = request_dict.get('tag', '')
|
|
|
if not all([equipment_info_id, uid, is_st, event_type, event_time, channel]):
|
|
|
return response.json(444)
|
|
|
+ try:
|
|
|
+ thread = threading.Thread(target=FeedBackView.asyn_push_inaccurate,
|
|
|
+ args=(
|
|
|
+ equipment_info_id, uid, channel, user_id, event_type, event_time, int(is_st),
|
|
|
+ tag,))
|
|
|
+ thread.start()
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ return response.json(500, repr(e))
|
|
|
|
|
|
- now_time = int(time.time())
|
|
|
- is_st = int(is_st)
|
|
|
+ @staticmethod
|
|
|
+ def asyn_push_inaccurate(equipment_info_id, uid, channel, user_id, event_type, event_time, is_st, tag):
|
|
|
try:
|
|
|
# 默认查询近七天内数据
|
|
|
- end_time = int(time.time())
|
|
|
- start_time = LocalDateTimeUtil.get_before_days_timestamp(end_time, 7)
|
|
|
+ now_time = int(time.time())
|
|
|
+ start_time = LocalDateTimeUtil.get_before_days_timestamp(now_time, 7)
|
|
|
uid_list = uid.split(',')
|
|
|
equipment_info_qs, count = EquipmentInfoService. \
|
|
|
- union_equipment_info(user_id, uid_list, event_type, start_time, end_time, 1, 10)
|
|
|
- identify_type = 1 if equipment_info_qs[0]['event_tag'] else 0
|
|
|
+ union_equipment_info(user_id, uid_list, event_type, start_time, now_time, 1, 10, event_time)
|
|
|
+ identify_type = 1 if equipment_info_qs[0]['eventTag'] else 0
|
|
|
s3 = AmazonS3Util(
|
|
|
aws_access_key_id=ACCESS_KEY_ID,
|
|
|
secret_access_key=SECRET_ACCESS_KEY,
|
|
@@ -376,6 +386,5 @@ class FeedBackView(View):
|
|
|
event_type=event_type, uid=uid, channel=channel,
|
|
|
add_time=now_time, tag=tag, is_st=is_st, event_time=event_time,
|
|
|
identify_type=identify_type)
|
|
|
- return response.json(0)
|
|
|
except Exception as e:
|
|
|
- return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ LOGGER.info('asyn_push_inaccurate, errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|