|
@@ -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,11 +344,21 @@ 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:
|
|
|
# 默认查询近七天内数据
|
|
|
+ now_time = int(time.time())
|
|
|
start_time = LocalDateTimeUtil.get_before_days_timestamp(now_time, 7)
|
|
|
uid_list = uid.split(',')
|
|
|
equipment_info_qs, count = EquipmentInfoService. \
|
|
@@ -375,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, repr(e))
|
|
|
+ LOGGER.info('asyn_push_inaccurate, errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|