|
@@ -65,6 +65,7 @@ class NotificationView(View):
|
|
is_st = request_dict.get('is_st', None)
|
|
is_st = request_dict.get('is_st', None)
|
|
company_secrete = request_dict.get('company_secrete', None)
|
|
company_secrete = request_dict.get('company_secrete', None)
|
|
region = request_dict.get('region', None)
|
|
region = request_dict.get('region', None)
|
|
|
|
+ electricity = request_dict.get('electricity', None)
|
|
|
|
|
|
if not all([channel, n_time]):
|
|
if not all([channel, n_time]):
|
|
return JsonResponse(status=200, data={
|
|
return JsonResponse(status=200, data={
|
|
@@ -167,7 +168,7 @@ class NotificationView(View):
|
|
msg_title = self.get_msg_title(appBundleId=appBundleId, nickname=nickname)
|
|
msg_title = self.get_msg_title(appBundleId=appBundleId, nickname=nickname)
|
|
# 发送内容
|
|
# 发送内容
|
|
msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
|
|
msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
|
|
- event_type=event_type)
|
|
|
|
|
|
+ event_type=event_type, electricity=electricity)
|
|
kwag_args['appBundleId'] = appBundleId
|
|
kwag_args['appBundleId'] = appBundleId
|
|
kwag_args['token_val'] = token_val
|
|
kwag_args['token_val'] = token_val
|
|
kwag_args['msg_title'] = msg_title
|
|
kwag_args['msg_title'] = msg_title
|
|
@@ -189,7 +190,7 @@ class NotificationView(View):
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
if is_sys_msg:
|
|
if is_sys_msg:
|
|
sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
|
|
sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
|
|
- event_type=event_type, is_sys=1)
|
|
|
|
|
|
+ event_type=event_type, electricity=electricity, is_sys=1)
|
|
sys_msg_list.append(SysMsgModel(
|
|
sys_msg_list.append(SysMsgModel(
|
|
userID_id=userID_id,
|
|
userID_id=userID_id,
|
|
msg=sys_msg_text,
|
|
msg=sys_msg_text,
|
|
@@ -318,12 +319,12 @@ class NotificationView(View):
|
|
return True
|
|
return True
|
|
return False
|
|
return False
|
|
|
|
|
|
- def get_msg_text(self, channel, n_time, lang, tz, event_type, is_sys=0):
|
|
|
|
|
|
+ def get_msg_text(self, channel, n_time, lang, tz, event_type, electricity='', is_sys=0):
|
|
n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz,lang=lang)
|
|
n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz,lang=lang)
|
|
etype = int(event_type)
|
|
etype = int(event_type)
|
|
if lang == 'cn':
|
|
if lang == 'cn':
|
|
if etype == 704:
|
|
if etype == 704:
|
|
- msg_type = '电量过低'
|
|
|
|
|
|
+ msg_type = '剩余电量:' + electricity
|
|
elif etype == 702:
|
|
elif etype == 702:
|
|
msg_type = '摄像头休眠'
|
|
msg_type = '摄像头休眠'
|
|
elif etype == 703:
|
|
elif etype == 703:
|
|
@@ -337,7 +338,7 @@ class NotificationView(View):
|
|
# send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
|
|
# send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
|
|
else:
|
|
else:
|
|
if etype == 704:
|
|
if etype == 704:
|
|
- msg_type = 'Low battery'
|
|
|
|
|
|
+ msg_type = 'Battery remaining:' + electricity
|
|
elif etype == 702:
|
|
elif etype == 702:
|
|
msg_type = 'Camera sleep'
|
|
msg_type = 'Camera sleep'
|
|
elif etype == 703:
|
|
elif etype == 703:
|
|
@@ -667,7 +668,7 @@ class PushNotificationView(View):
|
|
etype = int(event_type)
|
|
etype = int(event_type)
|
|
if lang == 'cn':
|
|
if lang == 'cn':
|
|
if etype == 704:
|
|
if etype == 704:
|
|
- msg_type = '电量过低'
|
|
|
|
|
|
+ msg_type = '剩余电量:'
|
|
elif etype == 702:
|
|
elif etype == 702:
|
|
msg_type = '摄像头休眠'
|
|
msg_type = '摄像头休眠'
|
|
elif etype == 703:
|
|
elif etype == 703:
|
|
@@ -680,7 +681,7 @@ class PushNotificationView(View):
|
|
send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
|
|
send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
|
|
else:
|
|
else:
|
|
if etype == 704:
|
|
if etype == 704:
|
|
- msg_type = 'Low battery'
|
|
|
|
|
|
+ msg_type = 'Battery remaining:'
|
|
elif etype == 702:
|
|
elif etype == 702:
|
|
msg_type = 'Camera sleep'
|
|
msg_type = 'Camera sleep'
|
|
elif etype == 703:
|
|
elif etype == 703:
|
|
@@ -729,7 +730,7 @@ class PWnotificationView(View):
|
|
redis_list.append(qs)
|
|
redis_list.append(qs)
|
|
|
|
|
|
if not redis_list:
|
|
if not redis_list:
|
|
- res_data = {'code': 0, 'msg': 'test: no redis_list success!'}
|
|
|
|
|
|
+ res_data = {'code': 0, 'msg': 'no redis_list success!'}
|
|
return JsonResponse(status=200, data=res_data)
|
|
return JsonResponse(status=200, data=res_data)
|
|
|
|
|
|
nickname = redis_list[0]['uid_set__nickname']
|
|
nickname = redis_list[0]['uid_set__nickname']
|
|
@@ -779,7 +780,7 @@ class PWnotificationView(View):
|
|
userID_id = up["userID_id"]
|
|
userID_id = up["userID_id"]
|
|
if userID_id not in userID_ids:
|
|
if userID_id not in userID_ids:
|
|
sys_msg_text = self.get_msg_text(channel=channel, n_time=now_time, lang=lang, tz=tz,
|
|
sys_msg_text = self.get_msg_text(channel=channel, n_time=now_time, lang=lang, tz=tz,
|
|
- event_type=event_type, is_sys=1, electricity= electricity)
|
|
|
|
|
|
+ event_type=event_type, is_sys=1, electricity=electricity)
|
|
sys_msg_list.append(SysMsgModel(
|
|
sys_msg_list.append(SysMsgModel(
|
|
userID_id=userID_id,
|
|
userID_id=userID_id,
|
|
msg=sys_msg_text,
|
|
msg=sys_msg_text,
|
|
@@ -787,7 +788,6 @@ class PWnotificationView(View):
|
|
updTime=now_time,
|
|
updTime=now_time,
|
|
uid=uid,
|
|
uid=uid,
|
|
eventType=event_type,
|
|
eventType=event_type,
|
|
- electricity=electricity,
|
|
|
|
))
|
|
))
|
|
userID_ids.append(userID_id)
|
|
userID_ids.append(userID_id)
|
|
SysMsgModel.objects.bulk_create(sys_msg_list)
|
|
SysMsgModel.objects.bulk_create(sys_msg_list)
|
|
@@ -826,7 +826,7 @@ class PWnotificationView(View):
|
|
etype = int(event_type)
|
|
etype = int(event_type)
|
|
if lang == 'cn':
|
|
if lang == 'cn':
|
|
if etype == 704:
|
|
if etype == 704:
|
|
- msg_type = '电量已剩:'+electricity+'%'
|
|
|
|
|
|
+ msg_type = '剩余电量:' + electricity
|
|
elif etype == 702:
|
|
elif etype == 702:
|
|
msg_type = '摄像头休眠'
|
|
msg_type = '摄像头休眠'
|
|
elif etype == 703:
|
|
elif etype == 703:
|
|
@@ -840,7 +840,7 @@ class PWnotificationView(View):
|
|
# send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
|
|
# send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
|
|
else:
|
|
else:
|
|
if etype == 704:
|
|
if etype == 704:
|
|
- msg_type = 'Battery is left: '+electricity+'%'
|
|
|
|
|
|
+ msg_type = 'Battery remaining:' + electricity
|
|
elif etype == 702:
|
|
elif etype == 702:
|
|
msg_type = 'Camera sleep'
|
|
msg_type = 'Camera sleep'
|
|
elif etype == 703:
|
|
elif etype == 703:
|