|
@@ -22,7 +22,7 @@ from pyfcm import FCMNotification
|
|
|
|
|
|
from AnsjerPush.Config.aiConfig import DEVICE_EVENT_TYPE
|
|
|
from AnsjerPush.config import CONFIG_INFO, CONFIG_CN, MULTI_CHANNEL_TYPE_LIST, SYS_EVENT_TYPE_LIST, AWS_ACCESS_KEY_ID, \
|
|
|
- AWS_SECRET_ACCESS_KEY
|
|
|
+ AWS_SECRET_ACCESS_KEY, EVENT_DICT, EVENT_DICT_CN
|
|
|
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, Device_Info
|
|
@@ -171,7 +171,7 @@ class DevicePushService:
|
|
|
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']
|
|
|
+ dealings_type=params['dealings_type'], event_tag=params['event_tag']
|
|
|
)
|
|
|
kwag_args['appBundleId'] = appBundleId
|
|
|
kwag_args['token_val'] = token_val
|
|
@@ -368,15 +368,52 @@ 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,
|
|
|
- device_type=0):
|
|
|
+ def get_event_type_text(lang, event_type, dealings_type):
|
|
|
"""
|
|
|
- 获取推送消息内容
|
|
|
+ 事件类型文案键值查找
|
|
|
+ """
|
|
|
+ if lang == 'cn':
|
|
|
+ if event_type in EVENT_DICT_CN:
|
|
|
+ if isinstance(EVENT_DICT_CN[event_type], dict):
|
|
|
+ msg_type = EVENT_DICT_CN[event_type][dealings_type]
|
|
|
+ else:
|
|
|
+ msg_type = EVENT_DICT_CN[event_type]
|
|
|
+ else:
|
|
|
+ msg_type = '未知事件类型 '
|
|
|
+ return msg_type
|
|
|
+ else:
|
|
|
+ if event_type in EVENT_DICT:
|
|
|
+ if isinstance(EVENT_DICT[event_type], dict):
|
|
|
+ msg_type = EVENT_DICT[event_type][dealings_type]
|
|
|
+ else:
|
|
|
+ msg_type = EVENT_DICT[event_type]
|
|
|
+ else:
|
|
|
+ msg_type = 'Unknown event type'
|
|
|
+ return msg_type
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def get_msg_text(channel, n_time, lang, tz, event_type, electricity='', is_sys=0, dealings_type=0, ai_type=0,
|
|
|
+ device_type=0, event_tag=''):
|
|
|
+ """
|
|
|
+ 获取消息文本
|
|
|
+ @param: channel 通道号
|
|
|
+ @param: n_time 触发事件
|
|
|
+ @param: lang 语言
|
|
|
+ @param: tz 时区
|
|
|
+ @param: event_type 事件类型
|
|
|
+ @param: electricity 电量
|
|
|
+ @param: is_sys 是否系统消息
|
|
|
+ @param: dealings_type 往来类型 1 进 1 离开
|
|
|
+ @param: ai_type 设备本地AI只能算法 事件类型
|
|
|
+ @param: device_type 设备类型
|
|
|
+ @param: event_tag 设备算法事件标签
|
|
|
"""
|
|
|
- n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz, lang=lang)
|
|
|
msg_type = ''
|
|
|
event_type = int(event_type)
|
|
|
device_type = int(device_type)
|
|
|
+ event_list = []
|
|
|
+ if event_tag:
|
|
|
+ event_list = [int(event) for event in event_tag.split(',') if event]
|
|
|
if lang == 'cn':
|
|
|
if event_type == 51:
|
|
|
msg_type = '检测到画面变化'
|
|
@@ -407,19 +444,9 @@ class DevicePushService:
|
|
|
msg_type = '摄像头唤醒'
|
|
|
elif event_type == 606:
|
|
|
msg_type = '有人呼叫,请点击查看'
|
|
|
- elif ai_type > 0:
|
|
|
- if event_type == 1024 and dealings_type == 1:
|
|
|
- msg_type = '有人进入'
|
|
|
- elif event_type == 1024 and dealings_type == 2:
|
|
|
- msg_type = '有人离开'
|
|
|
- elif event_type == 512:
|
|
|
- msg_type = '长时间无人出现'
|
|
|
- elif event_type == 256:
|
|
|
- msg_type = '有人徘徊'
|
|
|
- elif event_type == 128:
|
|
|
- msg_type = '区域离开'
|
|
|
- elif event_type == 64:
|
|
|
- msg_type = '区域闯入'
|
|
|
+ elif ai_type > 0 and event_list:
|
|
|
+ msg_type = ''.join([DevicePushService.get_event_type_text(lang, item, dealings_type)
|
|
|
+ for item in event_list])
|
|
|
if is_sys:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
send_text = '{} 通道:{}'.format(msg_type, channel)
|
|
@@ -427,9 +454,9 @@ class DevicePushService:
|
|
|
send_text = msg_type
|
|
|
else:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
- send_text = '{} 通道:{} 日期:{}'.format(msg_type, channel, n_date)
|
|
|
+ send_text = '{} 通道:{}'.format(msg_type, channel)
|
|
|
else:
|
|
|
- send_text = '{} 日期:{}'.format(msg_type, n_date)
|
|
|
+ send_text = '{}'.format(msg_type)
|
|
|
else:
|
|
|
if event_type == 51:
|
|
|
msg_type = 'Screen change detected'
|
|
@@ -460,19 +487,9 @@ class DevicePushService:
|
|
|
msg_type = 'Camera wake'
|
|
|
elif event_type == 606:
|
|
|
msg_type = 'Someone is calling, please click to view'
|
|
|
- elif ai_type > 0:
|
|
|
- if event_type == 1024 and int(dealings_type) == 1:
|
|
|
- msg_type = 'Someone entered'
|
|
|
- elif event_type == 1024 and int(dealings_type) == 2:
|
|
|
- msg_type = 'Someone left'
|
|
|
- elif event_type == 512:
|
|
|
- msg_type = 'No one shows up for a long time'
|
|
|
- elif event_type == 256:
|
|
|
- msg_type = 'Someone wanders'
|
|
|
- elif event_type == 128:
|
|
|
- msg_type = 'Area departure'
|
|
|
- elif event_type == 64:
|
|
|
- msg_type = 'Area break-in'
|
|
|
+ elif ai_type > 0 and event_list:
|
|
|
+ msg_type = ''.join([DevicePushService.get_event_type_text(lang, item, dealings_type)
|
|
|
+ for item in event_list])
|
|
|
if is_sys:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
send_text = '{} channel:{}'.format(msg_type, channel)
|
|
@@ -480,9 +497,9 @@ class DevicePushService:
|
|
|
send_text = msg_type
|
|
|
else:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
- send_text = '{} channel:{} date:{}'.format(msg_type, channel, n_date)
|
|
|
+ send_text = '{} channel:{}'.format(msg_type, channel)
|
|
|
else:
|
|
|
- send_text = '{} date:{}'.format(msg_type, n_date)
|
|
|
+ send_text = '{}'.format(msg_type)
|
|
|
return send_text
|
|
|
|
|
|
@staticmethod
|