|
@@ -19,7 +19,7 @@ import requests
|
|
|
from pyfcm import FCMNotification
|
|
|
|
|
|
from AnsjerPush.Config.aiConfig import DEVICE_EVENT_TYPE
|
|
|
-from AnsjerPush.config import CONFIG_INFO, CONFIG_CN
|
|
|
+from AnsjerPush.config import CONFIG_INFO, CONFIG_CN, MULTI_CHANNEL_TYPE_LIST
|
|
|
from AnsjerPush.config import JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE, XMPUSH_CONFIG, OPPOPUSH_CONFIG
|
|
|
from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
|
|
|
DeviceChannelUserPermission, UidSetModel
|
|
@@ -60,12 +60,12 @@ class DevicePushService:
|
|
|
uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1). \
|
|
|
values('token_val', 'app_type', 'appBundleId', 'm_code', 'push_type', 'userID_id', 'userID__NickName',
|
|
|
'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
|
|
|
- 'uid_set__channel', 'uid_set__ai_type', 'uid_set__new_detect_interval')
|
|
|
+ 'uid_set__channel', 'uid_set__ai_type', 'uid_set__device_type', 'uid_set__new_detect_interval')
|
|
|
else:
|
|
|
uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid). \
|
|
|
values('token_val', 'app_type', 'appBundleId', 'm_code', 'push_type', 'userID_id', 'userID__NickName',
|
|
|
'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
|
|
|
- 'uid_set__channel', 'uid_set__ai_type', 'uid_set__new_detect_interval')
|
|
|
+ 'uid_set__channel', 'uid_set__ai_type', 'uid_set__device_type', 'uid_set__new_detect_interval')
|
|
|
return uid_push_qs
|
|
|
|
|
|
@staticmethod
|
|
@@ -99,10 +99,10 @@ class DevicePushService:
|
|
|
@classmethod
|
|
|
def save_msg_push(cls, uid_set_push_list, **params):
|
|
|
"""
|
|
|
- APP消息推送以及报警消息存库
|
|
|
- @nickname 设备名称
|
|
|
- @channel 通道
|
|
|
- @event_type 事件类型
|
|
|
+ 推送消息,返回推送数据列表
|
|
|
+ @param uid_set_push_list: redis对象
|
|
|
+ @param params: 推送参数
|
|
|
+ @return: dict
|
|
|
"""
|
|
|
new_device_info_list = []
|
|
|
sys_msg_list = []
|
|
@@ -123,10 +123,11 @@ class DevicePushService:
|
|
|
# 发送标题
|
|
|
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'], dealings_type=params['dealings_type'],
|
|
|
- ai_type=params['ai_type'])
|
|
|
+ msg_text = cls.get_msg_text(channel=params['channel'], n_time=params['n_time'], lang=lang, tz=tz,
|
|
|
+ event_type=params['event_type'], ai_type=params['ai_type'],
|
|
|
+ device_type=params['device_type'], electricity=params['electricity'],
|
|
|
+ dealings_type=params['dealings_type']
|
|
|
+ )
|
|
|
kwag_args['appBundleId'] = appBundleId
|
|
|
kwag_args['token_val'] = token_val
|
|
|
kwag_args['msg_title'] = msg_title
|
|
@@ -142,10 +143,10 @@ class DevicePushService:
|
|
|
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,
|
|
|
+ tz=tz, is_sys=1, device_type=params['device_type'],
|
|
|
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']))
|
|
@@ -322,73 +323,79 @@ class DevicePushService:
|
|
|
return nickname
|
|
|
|
|
|
@staticmethod
|
|
|
- def get_msg_text(channel, n_time, lang, tz, event_type, electricity='', is_sys=0, dealings_type=0,
|
|
|
- ai_type=0):
|
|
|
+ def get_msg_text(channel, n_time, lang, tz, event_type, electricity='', is_sys=0, dealings_type=0, ai_type=0,
|
|
|
+ device_type=0):
|
|
|
"""
|
|
|
获取消息文本
|
|
|
"""
|
|
|
n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz, lang=lang)
|
|
|
- etype = int(event_type)
|
|
|
+ msg_type = ''
|
|
|
+ event_type = int(event_type)
|
|
|
+ device_type = int(device_type)
|
|
|
if lang == 'cn':
|
|
|
- if etype == 704:
|
|
|
+ if event_type == 704:
|
|
|
msg_type = '剩余电量 ' + electricity
|
|
|
- elif etype == 702:
|
|
|
+ elif event_type == 702:
|
|
|
msg_type = '摄像头休眠'
|
|
|
- elif etype == 703:
|
|
|
+ elif event_type == 703:
|
|
|
msg_type = '摄像头唤醒'
|
|
|
- elif etype == 606:
|
|
|
+ elif event_type == 606:
|
|
|
msg_type = '有人呼叫,请点击查看'
|
|
|
elif ai_type > 0:
|
|
|
- if etype == 1024 and dealings_type == 1:
|
|
|
+ if event_type == 1024 and dealings_type == 1:
|
|
|
msg_type = '有人进入'
|
|
|
- elif etype == 1024 and dealings_type == 2:
|
|
|
+ elif event_type == 1024 and dealings_type == 2:
|
|
|
msg_type = '有人离开'
|
|
|
- elif etype == 512:
|
|
|
+ elif event_type == 512:
|
|
|
msg_type = '长时间无人出现'
|
|
|
- elif etype == 256:
|
|
|
+ elif event_type == 256:
|
|
|
msg_type = '有人徘徊'
|
|
|
- elif etype == 128:
|
|
|
+ elif event_type == 128:
|
|
|
msg_type = '区域离开'
|
|
|
- elif etype == 64:
|
|
|
+ elif event_type == 64:
|
|
|
msg_type = '区域闯入'
|
|
|
- else:
|
|
|
- msg_type = ''
|
|
|
- else:
|
|
|
- msg_type = ''
|
|
|
if is_sys:
|
|
|
- send_text = '{} 通道:{}'.format(msg_type, channel)
|
|
|
+ if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
+ send_text = '{} 通道:{}'.format(msg_type, channel)
|
|
|
+ else:
|
|
|
+ send_text = msg_type
|
|
|
else:
|
|
|
- send_text = '{} 通道:{} 日期:{}'.format(msg_type, channel, n_date)
|
|
|
+ if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
+ send_text = '{} 通道:{} 日期:{}'.format(msg_type, channel, n_date)
|
|
|
+ else:
|
|
|
+ send_text = '{} 日期:{}'.format(msg_type, channel, n_date)
|
|
|
else:
|
|
|
- if etype == 704:
|
|
|
+ if event_type == 704:
|
|
|
msg_type = 'Battery remaining ' + electricity
|
|
|
- elif etype == 702:
|
|
|
+ elif event_type == 702:
|
|
|
msg_type = 'Camera sleep'
|
|
|
- elif etype == 703:
|
|
|
+ elif event_type == 703:
|
|
|
msg_type = 'Camera wake'
|
|
|
- elif etype == 606:
|
|
|
+ elif event_type == 606:
|
|
|
msg_type = 'Someone is calling, please click to view'
|
|
|
elif ai_type > 0:
|
|
|
- if etype == 1024 and int(dealings_type) == 1:
|
|
|
+ if event_type == 1024 and int(dealings_type) == 1:
|
|
|
msg_type = 'Someone entered'
|
|
|
- elif etype == 1024 and int(dealings_type) == 2:
|
|
|
+ elif event_type == 1024 and int(dealings_type) == 2:
|
|
|
msg_type = 'Someone left'
|
|
|
- elif etype == 512:
|
|
|
+ elif event_type == 512:
|
|
|
msg_type = 'No one shows up for a long time'
|
|
|
- elif etype == 256:
|
|
|
+ elif event_type == 256:
|
|
|
msg_type = 'Someone wanders'
|
|
|
- elif etype == 128:
|
|
|
+ elif event_type == 128:
|
|
|
msg_type = 'Area departure'
|
|
|
- elif etype == 64:
|
|
|
+ elif event_type == 64:
|
|
|
msg_type = 'Area break-in'
|
|
|
- else:
|
|
|
- msg_type = ''
|
|
|
- else:
|
|
|
- msg_type = ''
|
|
|
if is_sys:
|
|
|
- send_text = '{} channel:{}'.format(msg_type, channel)
|
|
|
+ if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
+ send_text = '{} channel:{}'.format(msg_type, channel)
|
|
|
+ else:
|
|
|
+ send_text = msg_type
|
|
|
else:
|
|
|
- send_text = '{} channel:{} date:{}'.format(msg_type, channel, n_date)
|
|
|
+ if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
+ send_text = '{} channel:{} date:{}'.format(msg_type, channel, n_date)
|
|
|
+ else:
|
|
|
+ send_text = '{} date:{}'.format(msg_type, channel, n_date)
|
|
|
return send_text
|
|
|
|
|
|
@staticmethod
|