|
@@ -30,7 +30,8 @@ from Object.LogUtil import LogUtil
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.UidTokenObject import UidTokenObject
|
|
|
from Service.CommonService import CommonService
|
|
|
-
|
|
|
+from Service.EquipmentInfoService import EquipmentInfoService
|
|
|
+from Object.utils import LocalDateTimeUtil
|
|
|
'''
|
|
|
http://push.dvema.com/notify/push?etk=Y2lTRXhMTjBWS01sWlpURTVJU0ZWTlJ6RXhNVUU9T3o=&n_time=1526845794&channel=1&event_type=704&is_st=0
|
|
|
http://push.dvema.com/deviceShadow/generateUTK?username=debug_user&password=debug_password&uid=VVDHCVBYDKFMJRWA111A
|
|
@@ -50,7 +51,7 @@ class NotificationView(View):
|
|
|
|
|
|
def validation(self, request_dict):
|
|
|
logger = logging.getLogger('info')
|
|
|
- logger.info("进来推送接口了")
|
|
|
+ logger.info("-----旧的进来推送接口了")
|
|
|
logger.info(request_dict)
|
|
|
logger.info(SERVER_TYPE)
|
|
|
uidToken = request_dict.get('uidToken', None)
|
|
@@ -197,6 +198,8 @@ class NotificationView(View):
|
|
|
do_apns_code = ''
|
|
|
do_fcm_code = ''
|
|
|
do_jpush_code = ''
|
|
|
+ new_device_info_list = []
|
|
|
+ local_date_time = ''
|
|
|
for up in redis_list:
|
|
|
push_type = up['push_type']
|
|
|
appBundleId = up['appBundleId']
|
|
@@ -217,6 +220,10 @@ class NotificationView(View):
|
|
|
logger.info('推送要的数据:')
|
|
|
logger.info(kwag_args)
|
|
|
logger.info(detect_med_type)
|
|
|
+ local_date_time = CommonService.get_now_time_str(n_time=n_time, tz=tz, lang='cn')
|
|
|
+ logger.info('<<<<<旧的接口,根据时区计算后日期={},时区={}'.format(local_date_time, tz))
|
|
|
+ local_date_time = local_date_time[0:10]
|
|
|
+ logger.info('<<<<<旧的接口,日期={}'.format(local_date_time))
|
|
|
push_server_status = 0
|
|
|
|
|
|
# 以下是存库
|
|
@@ -235,18 +242,34 @@ class NotificationView(View):
|
|
|
uid=uid,
|
|
|
eventType=event_type))
|
|
|
else:
|
|
|
- eq_list.append(Equipment_Info(
|
|
|
- userID_id=userID_id,
|
|
|
- eventTime=n_time,
|
|
|
- eventType=event_type,
|
|
|
- devUid=uid,
|
|
|
- devNickName=nickname,
|
|
|
- Channel=channel,
|
|
|
+ # eq_list.append(Equipment_Info(
|
|
|
+ # userID_id=userID_id,
|
|
|
+ # eventTime=n_time,
|
|
|
+ # eventType=event_type,
|
|
|
+ # devUid=uid,
|
|
|
+ # devNickName=nickname,
|
|
|
+ # Channel=channel,
|
|
|
+ # alarm='Motion \tChannel:{channel}'.format(channel=channel),
|
|
|
+ # is_st=int_is_st,
|
|
|
+ # receiveTime=n_time,
|
|
|
+ # addTime=now_time,
|
|
|
+ # storage_location=1
|
|
|
+ # ))
|
|
|
+ logger.info('----《旧接口》start------')
|
|
|
+ new_device_info_list.append(EquipmentInfoService.get_equipment_info_obj(
|
|
|
+ local_date_time,
|
|
|
+ device_user_id=userID_id,
|
|
|
+ event_time=n_time,
|
|
|
+ event_type=event_type,
|
|
|
+ device_uid=uid,
|
|
|
+ device_nick_name=nickname,
|
|
|
+ channel=channel,
|
|
|
alarm='Motion \tChannel:{channel}'.format(channel=channel),
|
|
|
- is_st=int_is_st,
|
|
|
- receiveTime=n_time,
|
|
|
- addTime=now_time,
|
|
|
- storage_location=1
|
|
|
+ is_st=is_st,
|
|
|
+ receive_time=n_time,
|
|
|
+ add_time=now_time,
|
|
|
+ storage_location=1,
|
|
|
+ border_coords='',
|
|
|
))
|
|
|
userID_ids.append(userID_id)
|
|
|
|
|
@@ -283,7 +306,12 @@ class NotificationView(View):
|
|
|
if is_sys_msg:
|
|
|
SysMsgModel.objects.bulk_create(sys_msg_list)
|
|
|
else:
|
|
|
- Equipment_Info.objects.bulk_create(eq_list)
|
|
|
+ # Equipment_Info.objects.bulk_create(eq_list)
|
|
|
+ if new_device_info_list and len(new_device_info_list) > 0:
|
|
|
+ # 根据日期获得星期几
|
|
|
+ week = LocalDateTimeUtil.date_to_week(local_date_time)
|
|
|
+ EquipmentInfoService.equipment_info_bulk_create(week, new_device_info_list)
|
|
|
+ logger.info('----《旧接口》设备信息分表批量保存end')
|
|
|
if is_st == '0' or is_st == '2':
|
|
|
print("is_st=0or2")
|
|
|
for up in redis_list:
|