|
@@ -18,21 +18,17 @@ import jpush as jpush
|
|
import requests
|
|
import requests
|
|
from pyfcm import FCMNotification
|
|
from pyfcm import FCMNotification
|
|
|
|
|
|
-from AnsjerPush.config import JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE, APP_BUNDLE_DICT, \
|
|
|
|
- XMPUSH_CONFIG, VIVOPUSH_CONFIG, OPPOPUSH_CONFIG, MEIZUPUSH_CONFIG
|
|
|
|
|
|
+from AnsjerPush.config import JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE, XMPUSH_CONFIG, OPPOPUSH_CONFIG
|
|
from AnsjerPush.config import SERVER_TYPE
|
|
from AnsjerPush.config import SERVER_TYPE
|
|
from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
|
|
from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
|
|
DeviceChannelUserPermission
|
|
DeviceChannelUserPermission
|
|
from Object.ETkObject import ETkObject
|
|
from Object.ETkObject import ETkObject
|
|
-from Object.RedisObject import RedisObject
|
|
|
|
from Object.UidTokenObject import UidTokenObject
|
|
from Object.UidTokenObject import UidTokenObject
|
|
from Object.utils import LocalDateTimeUtil
|
|
from Object.utils import LocalDateTimeUtil
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
|
|
from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
|
|
from Service.PushService import PushObject
|
|
from Service.PushService import PushObject
|
|
-from Service.VivoPushService.push_admin.APIMessage import PushMessage
|
|
|
|
-from Service.VivoPushService.push_admin.APISender import APISender
|
|
|
|
|
|
|
|
LOGGING = logging.getLogger('info')
|
|
LOGGING = logging.getLogger('info')
|
|
|
|
|
|
@@ -108,56 +104,60 @@ class DevicePushService:
|
|
code_data = {'do_apns_code': '', 'do_fcm_code': '', 'do_jpush_code': ''}
|
|
code_data = {'do_apns_code': '', 'do_fcm_code': '', 'do_jpush_code': ''}
|
|
local_date_time = ''
|
|
local_date_time = ''
|
|
push_permission = True
|
|
push_permission = True
|
|
- for up in uid_set_push_list:
|
|
|
|
- appBundleId = up['appBundleId']
|
|
|
|
- token_val = up['token_val']
|
|
|
|
- lang = up['lang']
|
|
|
|
- tz = up['tz']
|
|
|
|
- if tz is None or tz == '':
|
|
|
|
- tz = 0
|
|
|
|
- # 发送标题
|
|
|
|
- msg_title = cls.get_msg_title(nickname=params['nickname'])
|
|
|
|
- # 发送内容
|
|
|
|
- msg_text = cls.get_msg_text(channel=params['channel'], n_time=params['n_time'], lang=lang,
|
|
|
|
- tz=tz, event_type=params['event_type'],
|
|
|
|
- electricity=params['electricity'])
|
|
|
|
- kwag_args['appBundleId'] = appBundleId
|
|
|
|
- kwag_args['token_val'] = token_val
|
|
|
|
- kwag_args['msg_title'] = msg_title
|
|
|
|
- kwag_args['msg_text'] = msg_text
|
|
|
|
- LOGGING.info('推送要的数据: {}'.format(kwag_args))
|
|
|
|
- local_date_time = CommonService.get_now_time_str(n_time=params['n_time'], tz=tz, lang='cn')
|
|
|
|
- LOGGING.info('<<<<<根据时区计算后日期={},时区={}'.format(local_date_time, tz))
|
|
|
|
- local_date_time = local_date_time[0:10]
|
|
|
|
- LOGGING.info('<<<<<切片后的日期={}'.format(local_date_time))
|
|
|
|
- # 以下是存库
|
|
|
|
- userID_id = up["userID_id"]
|
|
|
|
- if userID_id not in userID_ids:
|
|
|
|
- now_time = int(time.time())
|
|
|
|
- if params['is_sys_msg']:
|
|
|
|
- sys_msg_text = cls.get_msg_text(channel=params['channel'], n_time=params['n_time'], lang=lang,
|
|
|
|
- tz=tz,
|
|
|
|
- event_type=params['event_type'], electricity=params['electricity'],
|
|
|
|
- is_sys=1)
|
|
|
|
- sys_msg_list.append(SysMsgModel(userID_id=userID_id, msg=sys_msg_text, addTime=now_time,
|
|
|
|
- updTime=now_time, uid=params['uid'],
|
|
|
|
- eventType=params['event_type']))
|
|
|
|
- else:
|
|
|
|
- LOGGING.info('分表存数据start------')
|
|
|
|
- params['userID_id'] = userID_id
|
|
|
|
- push_permission = DevicePushService.check_share_permission(userID_id, params['channel'],
|
|
|
|
- params['uid'])
|
|
|
|
- if push_permission:
|
|
|
|
- new_device_info_list.append(cls.created_device_vo(local_date_time, **params))
|
|
|
|
- userID_ids.append(userID_id)
|
|
|
|
- params['appBundleId'] = appBundleId
|
|
|
|
- params['token_val'] = token_val
|
|
|
|
- params['lang'] = lang
|
|
|
|
- params['tz'] = tz
|
|
|
|
- params['kwag_args'] = kwag_args
|
|
|
|
- code_data = cls.send_app_msg_push(up['push_type'], **params) if push_permission else code_data
|
|
|
|
- return {'code_date': code_data, 'new_device_info_list': new_device_info_list, 'sys_msg_list': sys_msg_list,
|
|
|
|
- 'local_date_time': local_date_time}
|
|
|
|
|
|
+ try:
|
|
|
|
+ for up in uid_set_push_list:
|
|
|
|
+ appBundleId = up['appBundleId']
|
|
|
|
+ token_val = up['token_val']
|
|
|
|
+ lang = up['lang']
|
|
|
|
+ tz = up['tz']
|
|
|
|
+ if tz is None or tz == '':
|
|
|
|
+ tz = 0
|
|
|
|
+ # 发送标题
|
|
|
|
+ msg_title = cls.get_msg_title(nickname=params['nickname'])
|
|
|
|
+ # 发送内容
|
|
|
|
+ msg_text = cls.get_msg_text(channel=params['channel'], n_time=params['n_time'], lang=lang,
|
|
|
|
+ tz=tz, event_type=params['event_type'],
|
|
|
|
+ electricity=params['electricity'])
|
|
|
|
+ kwag_args['appBundleId'] = appBundleId
|
|
|
|
+ kwag_args['token_val'] = token_val
|
|
|
|
+ kwag_args['msg_title'] = msg_title
|
|
|
|
+ kwag_args['msg_text'] = msg_text
|
|
|
|
+ LOGGING.info('推送要的数据: {}'.format(kwag_args))
|
|
|
|
+ local_date_time = CommonService.get_now_time_str(n_time=params['n_time'], tz=tz, lang='cn')
|
|
|
|
+ LOGGING.info('<<<<<根据时区计算后日期={},时区={}'.format(local_date_time, tz))
|
|
|
|
+ local_date_time = local_date_time[0:10]
|
|
|
|
+ LOGGING.info('<<<<<切片后的日期={}'.format(local_date_time))
|
|
|
|
+ # 以下是存库
|
|
|
|
+ userID_id = up["userID_id"]
|
|
|
|
+ if userID_id not in userID_ids:
|
|
|
|
+ now_time = int(time.time())
|
|
|
|
+ if params['is_sys_msg']:
|
|
|
|
+ sys_msg_text = cls.get_msg_text(channel=params['channel'], n_time=params['n_time'], lang=lang,
|
|
|
|
+ tz=tz,
|
|
|
|
+ event_type=params['event_type'],
|
|
|
|
+ electricity=params['electricity'],
|
|
|
|
+ is_sys=1)
|
|
|
|
+ sys_msg_list.append(SysMsgModel(userID_id=userID_id, msg=sys_msg_text, addTime=now_time,
|
|
|
|
+ updTime=now_time, uid=params['uid'],
|
|
|
|
+ eventType=params['event_type']))
|
|
|
|
+ else:
|
|
|
|
+ LOGGING.info('分表存数据start------')
|
|
|
|
+ params['userID_id'] = userID_id
|
|
|
|
+ push_permission = DevicePushService.check_share_permission(userID_id, params['channel'],
|
|
|
|
+ params['uid'])
|
|
|
|
+ if push_permission:
|
|
|
|
+ new_device_info_list.append(cls.created_device_vo(local_date_time, **params))
|
|
|
|
+ userID_ids.append(userID_id)
|
|
|
|
+ params['appBundleId'] = appBundleId
|
|
|
|
+ params['token_val'] = token_val
|
|
|
|
+ params['lang'] = lang
|
|
|
|
+ params['tz'] = tz
|
|
|
|
+ params['kwag_args'] = kwag_args
|
|
|
|
+ code_data = cls.send_app_msg_push(up['push_type'], **params) if push_permission else code_data
|
|
|
|
+ return {'code_date': code_data, 'new_device_info_list': new_device_info_list, 'sys_msg_list': sys_msg_list,
|
|
|
|
+ 'local_date_time': local_date_time}
|
|
|
|
+ except Exception as e:
|
|
|
|
+ LOGGING.info('推送消息或存表异常: errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def send_app_msg_push(cls, push_type, **param):
|
|
def send_app_msg_push(cls, push_type, **param):
|
|
@@ -264,12 +264,14 @@ class DevicePushService:
|
|
msg_type = '摄像头休眠'
|
|
msg_type = '摄像头休眠'
|
|
elif etype == 703:
|
|
elif etype == 703:
|
|
msg_type = '摄像头唤醒'
|
|
msg_type = '摄像头唤醒'
|
|
|
|
+ elif etype == 606:
|
|
|
|
+ msg_type = '有人呼叫,请点击查看'
|
|
else:
|
|
else:
|
|
msg_type = ''
|
|
msg_type = ''
|
|
if is_sys:
|
|
if is_sys:
|
|
- send_text = '{msg_type} 通道:{channel}'.format(msg_type=msg_type, channel=channel)
|
|
|
|
|
|
+ send_text = '{} 通道:{}'.format(msg_type, channel)
|
|
else:
|
|
else:
|
|
- send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
|
|
|
|
|
|
+ send_text = '{} 通道:{} 日期:{}'.format(msg_type, channel, n_date)
|
|
else:
|
|
else:
|
|
if etype == 704:
|
|
if etype == 704:
|
|
msg_type = 'Battery remaining ' + electricity
|
|
msg_type = 'Battery remaining ' + electricity
|
|
@@ -277,14 +279,14 @@ class DevicePushService:
|
|
msg_type = 'Camera sleep'
|
|
msg_type = 'Camera sleep'
|
|
elif etype == 703:
|
|
elif etype == 703:
|
|
msg_type = 'Camera wake'
|
|
msg_type = 'Camera wake'
|
|
|
|
+ elif etype == 606:
|
|
|
|
+ msg_type = 'Someone is calling, please click to view'
|
|
else:
|
|
else:
|
|
msg_type = ''
|
|
msg_type = ''
|
|
if is_sys:
|
|
if is_sys:
|
|
- send_text = '{msg_type} channel:{channel}'. \
|
|
|
|
- format(msg_type=msg_type, channel=channel)
|
|
|
|
|
|
+ send_text = '{} channel:{}'.format(msg_type, channel)
|
|
else:
|
|
else:
|
|
- send_text = '{msg_type} channel:{channel} date:{date}'. \
|
|
|
|
- format(msg_type=msg_type, channel=channel, date=n_date)
|
|
|
|
|
|
+ send_text = '{} channel:{} date:{}'.format(msg_type, channel, n_date)
|
|
return send_text
|
|
return send_text
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|