|
@@ -140,6 +140,8 @@ class DetectControllerView(View):
|
|
|
push_type = request_dict.get('push_type', None)
|
|
|
status = request_dict.get('status', None)
|
|
|
m_code = request_dict.get('m_code', None)
|
|
|
+ # 设备语言
|
|
|
+ lang = request_dict.get('lang', 'en')
|
|
|
# interval = request_dict.get('interval', None)
|
|
|
print('status:' + status)
|
|
|
if not status:
|
|
@@ -160,7 +162,8 @@ class DetectControllerView(View):
|
|
|
'app_type': app_type,
|
|
|
'push_type': push_type,
|
|
|
'token_val': token_val,
|
|
|
- 'updTime': nowTime
|
|
|
+ 'updTime': nowTime,
|
|
|
+ 'lang':lang
|
|
|
}
|
|
|
uid_set_qs.update(detect_status=status, updTime=nowTime)
|
|
|
UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid). \
|
|
@@ -182,7 +185,7 @@ class DetectControllerView(View):
|
|
|
'uid': uid,
|
|
|
'addTime': nowTime,
|
|
|
'updTime': nowTime,
|
|
|
- 'detect_status': status
|
|
|
+ 'detect_status': status,
|
|
|
}
|
|
|
# 添加设备配置
|
|
|
uid_set_qs = UidSetModel.objects.create(**uid_set_create_dict)
|
|
@@ -198,7 +201,8 @@ class DetectControllerView(View):
|
|
|
'token_val': token_val,
|
|
|
'm_code': m_code,
|
|
|
'addTime': nowTime,
|
|
|
- 'updTime': nowTime
|
|
|
+ 'updTime': nowTime,
|
|
|
+ 'lang':lang
|
|
|
}
|
|
|
# 绑定设备推送
|
|
|
UidPushModel.objects.create(**uid_push_create_dict)
|
|
@@ -245,7 +249,7 @@ class NotificationView(View):
|
|
|
def validation(self, request_dict):
|
|
|
response = ResponseObject()
|
|
|
uidToken = request_dict.get('uidToken', None)
|
|
|
- channel = request_dict.get('channel', None)
|
|
|
+ channel = request_dict.get('channel', '1')
|
|
|
n_time = request_dict.get('n_time', None)
|
|
|
event_type = request_dict.get('event_type', None)
|
|
|
is_st = request_dict.get('is_st', None)
|
|
@@ -260,7 +264,7 @@ class NotificationView(View):
|
|
|
if uid_set_qs.exists():
|
|
|
uid_set_id = uid_set_qs[0].id
|
|
|
uid_push_qs = UidPushModel.objects.filter(uid_set__id=uid_set_id). \
|
|
|
- values('token_val', 'app_type', 'appBundleId', 'push_type', 'userID_id', 'userID__NickName')
|
|
|
+ values('token_val', 'app_type', 'appBundleId', 'push_type', 'userID_id', 'userID__NickName','lang')
|
|
|
if uid_set_qs.exists():
|
|
|
redisObj = RedisObject(db=6)
|
|
|
pkey = '{uid}_{channel}_ptl'.format(uid=uid, channel=channel)
|
|
@@ -277,13 +281,13 @@ class NotificationView(View):
|
|
|
push_type = up['push_type']
|
|
|
# ios apns
|
|
|
if push_type == 0:
|
|
|
- self.do_apns(request_dict, up, response, uid)
|
|
|
+ self.do_apns(request_dict, up, response, uid,channel)
|
|
|
# android gcm
|
|
|
elif push_type == 1:
|
|
|
- self.do_gmc(request_dict, up, response, uid)
|
|
|
+ self.do_gmc(request_dict, up, response, uid,channel)
|
|
|
# android jpush
|
|
|
elif push_type == 2:
|
|
|
- self.do_jpush(request_dict, up, response, uid)
|
|
|
+ self.do_jpush(request_dict, up, response, uid,channel)
|
|
|
# self.do_save_equipment_info(ua, n_time, channel, event_type, is_st)
|
|
|
# 需求不一样,所以这么做的
|
|
|
self.do_bulk_create_info(uid_push_qs, n_time, channel, event_type, is_st, uid)
|
|
@@ -301,7 +305,7 @@ class NotificationView(View):
|
|
|
else:
|
|
|
return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
|
|
|
|
|
|
- def do_jpush(self, request_dict, uaql, response, uid):
|
|
|
+ def do_jpush(self, request_dict, uaql, response, uid,channel):
|
|
|
event_type = request_dict.get('event_type', None)
|
|
|
jpush_config = {
|
|
|
'com.ansjer.accloud_ab': {
|
|
@@ -341,6 +345,7 @@ class NotificationView(View):
|
|
|
n_time = request_dict.get('n_time', None)
|
|
|
appBundleId = uaql['appBundleId']
|
|
|
token_val = uaql['token_val']
|
|
|
+ lang = uaql['lang']
|
|
|
|
|
|
response = ResponseObject()
|
|
|
app_key = jpush_config[appBundleId]['Key']
|
|
@@ -354,7 +359,18 @@ class NotificationView(View):
|
|
|
push.audience = jpush.registration_id(token_val)
|
|
|
push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
|
|
|
"received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1"}
|
|
|
- push.message = jpush.message('Motion', extras=push_data, title='KPNS', content_type='text')
|
|
|
+ # push.message = jpush.message('Motion', extras=push_data, title='KPNS', content_type='text')
|
|
|
+ n_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
|
|
|
+ if lang == 'cn':
|
|
|
+ send_text = '{uid} 通道:{channel} 日期:{date}'.format(uid=uid,channel=channel,date=n_date)
|
|
|
+ else:
|
|
|
+ send_text = '{uid} channel:{channel} date:{date}'.format(uid=uid,channel=channel,date=n_date)
|
|
|
+ android = jpush.android(alert="Hello, Android msg", priority=1, style=1, alert_type=1,
|
|
|
+ big_text=send_text,
|
|
|
+ extras=push_data)
|
|
|
+
|
|
|
+ push.notification = jpush.notification(android=android)
|
|
|
+
|
|
|
push.platform = jpush.all_
|
|
|
try:
|
|
|
res = push.send()
|
|
@@ -366,7 +382,7 @@ class NotificationView(View):
|
|
|
else:
|
|
|
return response.json(0)
|
|
|
|
|
|
- def do_gmc(self, request_dict, uaql, response, uid):
|
|
|
+ def do_gmc(self, request_dict, uaql, response, uid,channel):
|
|
|
|
|
|
n_time = request_dict.get('n_time')
|
|
|
appBundleId = uaql['appBundleId']
|
|
@@ -398,7 +414,7 @@ class NotificationView(View):
|
|
|
req = requests.post(url, data, headers=headers)
|
|
|
return response.json(0)
|
|
|
|
|
|
- def do_apns(self, request_dict, uaql, response, uid):
|
|
|
+ def do_apns(self, request_dict, uaql, response, uid,channel):
|
|
|
event_type = request_dict.get('event_type', None)
|
|
|
token_val = uaql['token_val']
|
|
|
n_time = request_dict.get('n_time')
|