Browse Source

Merge branch 'pzb' of http://192.168.136.45:3000/SERVER/AnsjerServer into pzb

pzb 6 years ago
parent
commit
d2164095e7
1 changed files with 16 additions and 12 deletions
  1. 16 12
      Controller/DetectController.py

+ 16 - 12
Controller/DetectController.py

@@ -229,7 +229,7 @@ class NotificationView(View):
         appBundleId = uaql['appBundleId']
         appBundleId = uaql['appBundleId']
         uid = uaql['uid']
         uid = uaql['uid']
         apns_config = {
         apns_config = {
-            'appbundleId': {'pem_path': 'xxxx', 'topic': 'topic'}
+            'appbundleId': {'pem_path': 'xxxx', 'topic': 'topic','password':'password'}
         }
         }
         try:
         try:
             # daytime = time.strftime("%Y%m%d%H%M", time.localtime(1547256103))
             # daytime = time.strftime("%Y%m%d%H%M", time.localtime(1547256103))
@@ -243,7 +243,7 @@ class NotificationView(View):
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
             res = cli.push(n=n, device_token=token_val, topic=apns_config[appBundleId]['pem_path'])
             res = cli.push(n=n, device_token=token_val, topic=apns_config[appBundleId]['pem_path'])
             # assert res.status_code == 200, res.reason
             # assert res.status_code == 200, res.reason
-            # assert res.apns_id
+            # assert res.apns_id 
             if res.status_code == 200:
             if res.status_code == 200:
                 self.do_save_equipment_info(uaql, n_time)
                 self.do_save_equipment_info(uaql, n_time)
                 return response.json(0)
                 return response.json(0)
@@ -253,13 +253,17 @@ class NotificationView(View):
             return response.json(10, repr(e))
             return response.json(10, repr(e))
 
 
     def do_save_equipment_info(self, uaql, n_time):
     def do_save_equipment_info(self, uaql, n_time):
-        Equipment_Info.objects.create(
-            userID_id=uaql['userID_id'],
-            eventTime=n_time,
-            eventType=1,
-            devUid=uaql['uid'],
-            devNickName=uaql['devNickName'],
-            Channel='0',
-            alarm='xxx',
-            receiveTime=n_time)
-        return True
+        try:
+            Equipment_Info.objects.create(
+                userID_id=uaql['userID_id'],
+                eventTime=n_time,
+                eventType=1,
+                devUid=uaql['uid'],
+                devNickName=uaql['devNickName'],
+                Channel='0',
+                alarm='0',
+                receiveTime=n_time)
+        except Exception as e:
+            return False
+        else:
+            return True