Browse Source

添加设备增加推送信息

peng 2 years ago
parent
commit
b506cc6045
1 changed files with 43 additions and 1 deletions
  1. 43 1
      Controller/EquipmentManagerV3.py

+ 43 - 1
Controller/EquipmentManagerV3.py

@@ -19,7 +19,7 @@ from Controller.SensorGateway.EquipmentFamilyController import EquipmentFamilyVi
 from Controller.UnicomCombo.UnicomComboController import UnicomComboView
 from Model.models import Device_Info, UID_Bucket, UID_Preview, UidSetModel, UidChannelSetModel, \
     Device_User, iotdeviceInfoModel, UIDCompanySerialModel, UnicomDeviceInfo, CountryModel, \
-    DeviceCloudPhotoInfo
+    DeviceCloudPhotoInfo, UidPushModel
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Service.CommonService import CommonService
@@ -92,12 +92,24 @@ class EquipmentManagerV3(View):
         family_id = request_dict.get('familyId', None)
         room_id = request_dict.get('roomId', None)
 
+        m_code = request_dict.get('m_code', None)
+        appBundleId = request_dict.get('appBundleId', None)
+        app_type = request_dict.get('app_type', None)
+        push_type = request_dict.get('push_type', None)
+        token_val = request_dict.get('token_val', None)
+        lang = request_dict.get('lang', 'en')
+        tz = request_dict.get('tz', '0')
+
         if not NickName:
             NickName = UID[:6]
 
         if not all([UID, NickName, View_Account, Type, ChannelIndex]):  # Type和ChannelIndex可能为0
             return response.json(444, {'param': 'UID, NickName, View_Account, Type, ChannelIndex'})
 
+        if tz == '':
+            tz = 0
+        else:
+            tz = tz.replace("GMT", "")
         Type = int(Type)
         ChannelIndex = int(ChannelIndex)
 
@@ -209,6 +221,36 @@ class EquipmentManagerV3(View):
                 UidSet = UidSetModel.objects.create(**uid_set_create_dict)
                 UidSet_id = UidSet.id
 
+            if all([token_val, m_code, appBundleId, app_type]):
+                uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=UID)
+                if uid_push_qs.exists():
+                    uid_push_update_dict = {
+                        'appBundleId': appBundleId,
+                        'app_type': app_type,
+                        'push_type': push_type,
+                        'token_val': token_val,
+                        'updTime': nowTime,
+                        'lang': lang,
+                        'tz': tz
+                    }
+                    uid_push_qs.update(**uid_push_update_dict)
+                else:
+                    uid_push_create_dict = {
+                        'uid_set_id': UidSet_id,
+                        'userID_id': userID,
+                        'appBundleId': appBundleId,
+                        'app_type': app_type,
+                        'push_type': push_type,
+                        'token_val': token_val,
+                        'm_code': m_code,
+                        'addTime': nowTime,
+                        'updTime': nowTime,
+                        'lang': lang,
+                        'tz': tz
+                    }
+                    # 绑定设备推送
+                    UidPushModel.objects.create(**uid_push_create_dict)
+
             # 查询uid_channel表有无该uid的数据
             uid_channel_set = UidChannelSetModel.objects.filter(uid_id=UidSet_id)
             if not uid_channel_set.exists():