|
|
@@ -26,11 +26,11 @@ from AnsjerPush.MessageConfig import EVENT_CONFIGS, DEFAULT_TEXTS, MSG_CONFIG
|
|
|
from AnsjerPush.config import CONFIG_INFO, CONFIG_CN, MULTI_CHANNEL_TYPE_LIST, SYS_EVENT_TYPE_LIST, \
|
|
|
EVENT_DICT, EVENT_DICT_CN, CONFIG_TEST, \
|
|
|
HUAWEICLOUD_OBS_SERVER, HUAWEICLOUD_PUSH_BUKET, JPUSH_UID_LIST, \
|
|
|
- DATA_PUSH_EVENT_TYPE_LIST, PRIMARY_USERS_PUSH_EVENT_TYPE_LIST
|
|
|
+ DATA_PUSH_EVENT_TYPE_LIST, PRIMARY_USERS_PUSH_EVENT_TYPE_LIST, BASE_STATION_TYPE_LIST
|
|
|
from AnsjerPush.config import XMPUSH_CONFIG, OPPOPUSH_CONFIG, XM_PUSH_CHANNEL_ID, XM_PUSH_CHANNEL_DICT
|
|
|
from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
|
|
|
DeviceChannelUserPermission, UidSetModel, Device_Info, UserAudioVideoPush, PushLog, TimeAlbum, AlbumMedia, \
|
|
|
- AlbumTitle
|
|
|
+ AlbumTitle, UidChannelSetModel
|
|
|
from Object.ETkObject import ETkObject
|
|
|
from Object.OCIObjectStorage import OCIObjectStorage
|
|
|
from Object.RedisObject import RedisObject
|
|
|
@@ -249,6 +249,7 @@ class DevicePushService:
|
|
|
title = cls.get_msg_title(nickname=params['nickname'])
|
|
|
# 生成消息内容
|
|
|
text = cls.get_msg_text_v2(
|
|
|
+ uid=uid,
|
|
|
channel=params['channel'],
|
|
|
n_time=params['n_time'],
|
|
|
lang=lang,
|
|
|
@@ -324,13 +325,13 @@ class DevicePushService:
|
|
|
if user_id not in saved_user_id_list: # 防止同一用户重复写入数据
|
|
|
# 系统消息
|
|
|
if params['is_sys_msg']:
|
|
|
- sys_msg_text = cls.get_msg_text(channel=params['channel'], n_time=params['n_time'], lang=lang,
|
|
|
- tz=tz, is_sys=1, device_type=params['device_type'],
|
|
|
- event_type=params['event_type'],
|
|
|
- electricity=params['electricity'], is_save_msg=1)
|
|
|
- sys_msg_list.append(SysMsgModel(userID_id=user_id, msg=sys_msg_text, addTime=now_time,
|
|
|
- updTime=now_time, uid=uid, eventType=params['event_type'],
|
|
|
- channel=params['channel']))
|
|
|
+ sys_msg_text = cls.get_msg_text(
|
|
|
+ uid=uid, channel=params['channel'], n_time=params['n_time'], lang=lang, tz=tz, is_sys=1,
|
|
|
+ device_type=params['device_type'], event_type=params['event_type'],
|
|
|
+ electricity=params['electricity'], is_save_msg=1)
|
|
|
+ sys_msg_list.append(SysMsgModel(
|
|
|
+ userID_id=user_id, msg=sys_msg_text, addTime=now_time, updTime=now_time, uid=uid,
|
|
|
+ eventType=params['event_type'], channel=params['channel']))
|
|
|
# 保存推送消息
|
|
|
else:
|
|
|
if not save_equipment_info:
|
|
|
@@ -592,9 +593,10 @@ class DevicePushService:
|
|
|
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='', is_save_msg=0):
|
|
|
+ @classmethod
|
|
|
+ def get_msg_text(
|
|
|
+ cls, uid, channel, n_time, lang, tz, event_type, electricity='', is_sys=0, dealings_type=0, ai_type=0,
|
|
|
+ device_type=0, event_tag='', is_save_msg=0):
|
|
|
"""
|
|
|
获取消息文本
|
|
|
@param: channel 通道号
|
|
|
@@ -678,11 +680,19 @@ class DevicePushService:
|
|
|
if is_sys:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
send_text = '{} 通道:{}'.format(msg_type, channel)
|
|
|
+ elif device_type in BASE_STATION_TYPE_LIST:
|
|
|
+ # 基站使用通道名
|
|
|
+ channel_name = cls.get_channel_name(uid, channel)
|
|
|
+ send_text = '{} 通道:{}'.format(msg_type, channel_name)
|
|
|
else:
|
|
|
send_text = msg_type
|
|
|
else:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
send_text = '{} 通道:{}'.format(msg_type, channel)
|
|
|
+ elif device_type in BASE_STATION_TYPE_LIST:
|
|
|
+ # 基站使用通道名
|
|
|
+ channel_name = cls.get_channel_name(uid, channel)
|
|
|
+ send_text = '{} 通道:{}'.format(msg_type, channel_name)
|
|
|
else:
|
|
|
send_text = '{}'.format(msg_type)
|
|
|
else:
|
|
|
@@ -742,18 +752,27 @@ class DevicePushService:
|
|
|
if is_sys:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
send_text = '{} channel:{}'.format(msg_type, channel)
|
|
|
+ elif device_type in BASE_STATION_TYPE_LIST:
|
|
|
+ # 基站使用通道名
|
|
|
+ channel_name = cls.get_channel_name(uid, channel)
|
|
|
+ send_text = '{} channel:{}'.format(msg_type, channel_name)
|
|
|
else:
|
|
|
send_text = msg_type
|
|
|
else:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
send_text = '{} channel:{}'.format(msg_type, channel)
|
|
|
+ elif device_type in BASE_STATION_TYPE_LIST:
|
|
|
+ # 基站使用通道名
|
|
|
+ channel_name = cls.get_channel_name(uid, channel)
|
|
|
+ send_text = '{} channel:{}'.format(msg_type, channel_name)
|
|
|
else:
|
|
|
send_text = '{}'.format(msg_type)
|
|
|
return send_text
|
|
|
|
|
|
- @staticmethod
|
|
|
- def get_msg_text_v2(channel, n_time, lang, tz, event_type, electricity='', is_sys=0, dealings_type=0, ai_type=0,
|
|
|
- device_type=0, event_tag='', is_save_msg=0, redis_obj=None):
|
|
|
+ @classmethod
|
|
|
+ def get_msg_text_v2(
|
|
|
+ cls, uid, channel, n_time, lang, tz, event_type, electricity='', is_sys=0, dealings_type=0, ai_type=0,
|
|
|
+ device_type=0, event_tag='', is_save_msg=0, redis_obj=None):
|
|
|
"""
|
|
|
获取消息文案V2
|
|
|
"""
|
|
|
@@ -808,30 +827,23 @@ class DevicePushService:
|
|
|
if is_sys:
|
|
|
if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
send_text = f'{msg_type} 通道:{channel}' if lang == 'cn' else f'{msg_type} channel:{channel}'
|
|
|
+ elif device_type in BASE_STATION_TYPE_LIST:
|
|
|
+ # 基站使用通道名
|
|
|
+ channel_name = cls.get_channel_name(uid, channel)
|
|
|
+ send_text = f'{msg_type} 通道:{channel_name}' if lang == 'cn' else\
|
|
|
+ f'{msg_type} channel:{channel_name}'
|
|
|
else:
|
|
|
send_text = msg_type
|
|
|
else:
|
|
|
- if device_type in MULTI_CHANNEL_TYPE_LIST: # NVR多通道文案
|
|
|
- channel_dict = {
|
|
|
- 'cn': '通道', # 简体中文
|
|
|
- 'en': 'Channel', # 英语
|
|
|
- 'es': 'Canal', # 西班牙语
|
|
|
- 'fr': 'Canal', # 法语
|
|
|
- 'de': 'Kanal ', # 德语
|
|
|
- 'cn_tw': '通道', # 繁体中文
|
|
|
- 'pt': 'Canal', # 葡萄牙语
|
|
|
- 'ru': 'Канал', # 俄语
|
|
|
- 'ja': 'チャンネル', # 日语
|
|
|
- 'it': 'Canale', # 意大利语
|
|
|
- 'pl': 'Kanał', # 波兰语
|
|
|
- 'nl': 'Kanaal', # 荷兰语
|
|
|
- 'ko': '채널', # 韩语
|
|
|
- 'ar': 'قناة', # 阿拉伯语
|
|
|
- 'vi': 'kênh', # 越南语
|
|
|
- 'th': 'ช่องเสียง' # 泰语
|
|
|
- }
|
|
|
- prefix = channel_dict.get(lang, channel_dict['en'])
|
|
|
- send_text = f'{msg_type} {prefix}:{channel}'
|
|
|
+ # NVR多通道文案
|
|
|
+ if device_type in MULTI_CHANNEL_TYPE_LIST:
|
|
|
+ channel_prefix = cls.get_get_channel_prefix(lang)
|
|
|
+ send_text = f'{msg_type} {channel_prefix}:{channel}'
|
|
|
+ elif device_type in BASE_STATION_TYPE_LIST:
|
|
|
+ # 基站使用通道名
|
|
|
+ channel_prefix = cls.get_get_channel_prefix(lang)
|
|
|
+ channel_name = cls.get_channel_name(uid, channel)
|
|
|
+ send_text = f'{msg_type} {channel_prefix}:{channel_name}'
|
|
|
else:
|
|
|
send_text = f'{msg_type}'
|
|
|
return send_text
|
|
|
@@ -840,6 +852,53 @@ class DevicePushService:
|
|
|
.format(n_time, event_tag, e.__traceback__.tb_lineno, repr(e)))
|
|
|
return msg_type
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def get_get_channel_prefix(lang: str) -> str:
|
|
|
+ """
|
|
|
+ 获取通道
|
|
|
+ @param lang: 语言
|
|
|
+ @return: channel_prefix
|
|
|
+ """
|
|
|
+ channel_dict = {
|
|
|
+ 'cn': '通道', # 简体中文
|
|
|
+ 'en': 'Channel', # 英语
|
|
|
+ 'es': 'Canal', # 西班牙语
|
|
|
+ 'fr': 'Canal', # 法语
|
|
|
+ 'de': 'Kanal ', # 德语
|
|
|
+ 'cn_tw': '通道', # 繁体中文
|
|
|
+ 'pt': 'Canal', # 葡萄牙语
|
|
|
+ 'ru': 'Канал', # 俄语
|
|
|
+ 'ja': 'チャンネル', # 日语
|
|
|
+ 'it': 'Canale', # 意大利语
|
|
|
+ 'pl': 'Kanał', # 波兰语
|
|
|
+ 'nl': 'Kanaal', # 荷兰语
|
|
|
+ 'ko': '채널', # 韩语
|
|
|
+ 'ar': 'قناة', # 阿拉伯语
|
|
|
+ 'vi': 'kênh', # 越南语
|
|
|
+ 'th': 'ช่องเสียง' # 泰语
|
|
|
+ }
|
|
|
+ channel_prefix = channel_dict.get(lang, channel_dict['en'])
|
|
|
+ return channel_prefix
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def get_channel_name(uid: str, channel: int) -> str:
|
|
|
+ """
|
|
|
+ 根据uid和channel查询并返回UidChannelSetModel的channel_name
|
|
|
+ @param uid: 设备uid
|
|
|
+ @param channel: 通道号
|
|
|
+ @return: channel_name或channel
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ uid_channel = UidChannelSetModel.objects.filter(
|
|
|
+ uid__uid=uid, channel=channel).values('channel_name').first()
|
|
|
+ if uid_channel and uid_channel.get('channel_name'):
|
|
|
+ return uid_channel['channel_name']
|
|
|
+ return str(channel)
|
|
|
+ except Exception as e:
|
|
|
+ ERROR_INFO_LOGGER.error('获取通道名异常uid:{},channel:{},error行数:{},内容:{}'.format(
|
|
|
+ uid, channel, e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return str(channel)
|
|
|
+
|
|
|
@staticmethod
|
|
|
def get_event_type_text_v2(lang, event_type, dealings_type, redis_obj):
|
|
|
""" 改造后:优先读缓存,无缓存时读配置并写入 """
|