|
@@ -37,7 +37,7 @@ http://push.dvema.com/notify/push?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
|
|
|
|
|
|
http://www.dvema.com/detect/changeStatus?push_type=2&token_val=1a0018970a332cca935&appBundleId=com.ansjer.zccloud_ab&tz=+08.00&uid=HLK7EJ2VYLNHHUMG111A&status=1&m_code=AN02000025070000001207.zccloud_ab&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiMTMxMTk2NTc3MTMiLCJsYW5nIjoiZW4iLCJtX2NvZGUiOiIxMjM0MTMyNDMyMTQiLCJ1c2VySUQiOiIxNTQ0ODM4MjMyOTczMTM4MDAxMzgwMDAiLCJleHAiOjE1ODQxNDc0NjN9.NjK91B26jZDtdmq8tW-8hXNQPqqDfo9Zwf_Jg6Uf7co&lang=cn&app_type=2
|
|
|
|
|
|
-
|
|
|
+http://127.0.0.1:8077/detect/changeStatus?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySUQiOiIxNTg0MzUxODk2MjgyMTM4MDAxMzgwMDAiLCJsYW5nIjoiZW4iLCJ1c2VyIjoiMTM2ODAzMTc1OTYiLCJtX2NvZGUiOiIxMjM0MTMyNDMyMTQiLCJleHAiOjE1ODcyNjEzODN9.H87931EDg6PGZK63EAsvY1FRJov9qo_S70mBKvpZeQM&push_type=2&token_val=token_val&appBundleId=appBundleId&tz=0&uid=158440619973313800138000&status=1&m_code&lang=cn&app_type=0&start_status=1&interval=60&eventType=60
|
|
|
'''
|
|
|
|
|
|
|
|
@@ -65,6 +65,7 @@ class DetectControllerView(View):
|
|
|
userID = tko.userID
|
|
|
# 修改推送设置
|
|
|
if operation == 'changeStatus':
|
|
|
+ print("进入changeStatus")
|
|
|
return self.do_change_status(userID, request_dict, response)
|
|
|
# 查询推送信息
|
|
|
elif operation == 'queryInfo':
|
|
@@ -267,19 +268,22 @@ class DetectControllerView(View):
|
|
|
return response.json(14)
|
|
|
|
|
|
def do_change_status(self, userID, request_dict, response):
|
|
|
- uid = request_dict.get('uid', None)
|
|
|
token_val = request_dict.get('token_val', None)
|
|
|
appBundleId = request_dict.get('appBundleId', None)
|
|
|
app_type = request_dict.get('app_type', None)
|
|
|
push_type = request_dict.get('push_type', None)
|
|
|
status = request_dict.get('status', None)
|
|
|
m_code = request_dict.get('m_code', None)
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
+ detect_group = request_dict.get('eventType', None)
|
|
|
# 设备语言
|
|
|
lang = request_dict.get('lang', 'en')
|
|
|
tz = request_dict.get('tz', '0')
|
|
|
+ start_status = request_dict.get('start_status', None)
|
|
|
# interval = request_dict.get('interval', None)
|
|
|
if not status:
|
|
|
return response.json(444, 'status')
|
|
|
+ print("111")
|
|
|
# 关闭推送
|
|
|
if not all([appBundleId, app_type, token_val, uid, m_code]):
|
|
|
return response.json(444, 'appBundleId,app_type,token_val,uid,m_code')
|
|
@@ -291,11 +295,27 @@ class DetectControllerView(View):
|
|
|
if appBundleId not in FCM_CONFIG.keys():
|
|
|
return response.json(904)
|
|
|
elif push_type == '2':
|
|
|
+ print('push_type==2')
|
|
|
if appBundleId not in JPUSH_CONFIG.keys():
|
|
|
return response.json(904)
|
|
|
else:
|
|
|
return response.json(173)
|
|
|
dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
|
+ # 新增a
|
|
|
+ if start_status == "1":
|
|
|
+ interval = request_dict.get('interval', None)
|
|
|
+ # 设备表,用于判断这台设备是否存在
|
|
|
+ dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
|
+ if dvqs.exists():
|
|
|
+ uid_set_qs = UidSetModel.objects. \
|
|
|
+ filter(uid=uid, uidpushmodel__userID_id=userID)
|
|
|
+ if uid_set_qs.exists():
|
|
|
+ uid_set_qs.update(detect_interval=int(interval))
|
|
|
+ else:
|
|
|
+ return response.json(173)
|
|
|
+ # 移动侦测 evenType为字符串0,将detect_group设置进数据库
|
|
|
+ UidSetModel.objects.filter(uid=uid, uidpushmodel__userID_id=userID).update(detect_group=detect_group)
|
|
|
+ # /新增a
|
|
|
status = int(status)
|
|
|
# 获取用户区域
|
|
|
# ip = self.ip
|
|
@@ -384,7 +404,6 @@ class DetectControllerView(View):
|
|
|
else:
|
|
|
return response.json(0)
|
|
|
|
|
|
-
|
|
|
# http://192.168.136.40:8077/notify/push?uidToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiJUTjdNUEUzMjExVUU3NkFQMTExQSJ9.k501567VdnhFpn_ygzGRDat3Kqlz5CsEA9jAC2dDk_g&obj=12341234&n_time=1234561234
|
|
|
# http://test.dvema.com/notify/push?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJQMldOR0pSRDJFSEE1RVU5MTExQSJ9.xOCI5lerk8JOs5OcAzunrKCfCrtuPIZ3AnkMmnd-bPY&n_time=1526845794&channel=1&event_type=51&is_st=0
|
|
|
# 移动侦测接口
|
|
@@ -423,16 +442,29 @@ class NotificationView(View):
|
|
|
uid = utko.UID
|
|
|
# utko = UidTokenObject(uidToken)
|
|
|
# uid = utko.UID
|
|
|
+ detect_group = UidSetModel.objects.filter(uid=uid). \
|
|
|
+ values('detect_group')
|
|
|
+ event_type = detect_group
|
|
|
+ #新增 移动侦测
|
|
|
+ if event_type == '0':
|
|
|
+ self.detect_group_push(self, request_dict, uid, response, channel, n_time, event_type, is_st)
|
|
|
+ #新增 pir侦测
|
|
|
+ if event_type == '1':
|
|
|
+ self.detect_group_push(self, request_dict, uid, response, channel, n_time, event_type, is_st)
|
|
|
+ #新增 移动侦测和pir侦测
|
|
|
+ if event_type == '01':
|
|
|
+ self.detect_group_push(self, request_dict, uid, response, channel, n_time, event_type, is_st)
|
|
|
+ #新增 把代码封装以便后面分侦测类型
|
|
|
+ def detect_group_push(self, request_dict, uid, response, channel, n_time, event_type, is_st):
|
|
|
redisObj = RedisObject(db=6)
|
|
|
- # pkey = '{uid}_{channel}_ptl'.format(uid=uid, channel=channel)
|
|
|
- pkey = '{uid}_ptl'.format(uid=uid)
|
|
|
+ pkey = '{uid}_{channel}_ptl'.format(uid=uid, channel=channel)
|
|
|
if redisObj.get_data(key=pkey):
|
|
|
res_data = {'code': 0, 'msg': 'success,!'}
|
|
|
return JsonResponse(status=200, data=res_data)
|
|
|
else:
|
|
|
# 设置推送间隔60秒一次
|
|
|
redisObj.set_data(key=pkey, val=1, expire=60)
|
|
|
- uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid,uid_set__detect_status=1). \
|
|
|
+ uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1). \
|
|
|
values('token_val', 'app_type', 'appBundleId',
|
|
|
'push_type', 'userID_id', 'userID__NickName',
|
|
|
'lang', 'tz', 'uid_set__nickname')
|
|
@@ -451,11 +483,11 @@ class NotificationView(View):
|
|
|
# android gcm
|
|
|
elif push_type == 1:
|
|
|
self.do_fcm(request_dict, up, response, uid, channel, nickname)
|
|
|
- # self.do_gmc(request_dict, up, response, uid, channel,nickname)
|
|
|
+ # self.do_gmc(request_dict, up, response, uid, channel,nickname)
|
|
|
# android jpush
|
|
|
elif push_type == 2:
|
|
|
self.do_jpush(request_dict, up, response, uid, channel, nickname)
|
|
|
- # self.do_save_equipment_info(ua, n_time, channel, event_type, is_st)
|
|
|
+ # 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)
|
|
|
if is_st == '0' or is_st == '2':
|