Quellcode durchsuchen

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJServer

locky vor 3 Jahren
Ursprung
Commit
453c6acb2a

+ 39 - 7
Controller/SensorGateway/GatewayFamilyMemberController.py

@@ -15,7 +15,7 @@ from django.views.generic.base import View
 
 from Controller.SensorGateway.EquipmentFamilyController import EquipmentFamilyView
 from Model.models import UserFamily, FamilyMemberJoin, FamilyMember, SysMsgModel, FamilyMemberPermission, \
-    Device_User
+    Device_User, FamilyRoomDevice
 from Object.RedisObject import RedisObject
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
@@ -62,6 +62,34 @@ class GatewayFamilyMemberView(View):
             return self.family_created(app_user_id, request_dict, response)
         elif operation == 'del/home':
             return self.del_home(app_user_id, request_dict, response)
+        elif operation == 'join/del':
+            return self.member_join_del(app_user_id, request_dict, response)
+
+    @classmethod
+    def member_join_del(cls, app_user_id, request_dict, response):
+        """
+        删除最近联系人
+        @param app_user_id:
+        @param request_dict:
+        @param response:
+        @return:
+        """
+        join_id = request_dict.get('joinId', None)
+        if not join_id:
+            return response.json()
+        family_member_join_qs = FamilyMemberJoin.objects.filter(id=join_id)
+        if not family_member_join_qs.exists():
+            return response.json(173)
+        is_owner = EquipmentFamilyView.get_family_owner(app_user_id, family_member_join_qs.first().family_id)
+        if not is_owner:
+            return response.json(404)
+        try:
+            with transaction.atomic():
+                family_member_join_qs.delete()
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(177, repr(e))
 
     @classmethod
     def del_home(cls, app_user_id, request_dict, response):
@@ -72,16 +100,19 @@ class GatewayFamilyMemberView(View):
         @param response:
         @return:
         """
-        familyId = request_dict.get('familyId', None)
-        if not familyId:
+        family_id = request_dict.get('familyId', None)
+        if not family_id:
             return response.json(444)
-        is_owner = EquipmentFamilyView.get_family_owner(app_user_id, familyId)
+        is_owner = EquipmentFamilyView.get_family_owner(app_user_id, family_id)
         if not is_owner:
             return response.json(404)
-        familyId = int(familyId)
+        family_id = int(family_id)
         try:
             with transaction.atomic():
-                user_family_qs = UserFamily.objects.filter(id=familyId)
+                family_room_device_qs = FamilyRoomDevice.objects.filter(family_id=family_id)
+                if family_room_device_qs.exists():
+                    family_room_device_qs.delete()
+                user_family_qs = UserFamily.objects.filter(id=family_id)
                 if user_family_qs.exists():
                     user_family_qs.delete()
                     return response.json(0)
@@ -376,7 +407,7 @@ class GatewayFamilyMemberView(View):
         family_id = request_dict.get('familyId', None)
         if not all([page_no, page_size, family_id]):
             return response.json(444)
-        member_join = FamilyMemberJoin.objects.filter(family_id=family_id).values('status', 'user__username',
+        member_join = FamilyMemberJoin.objects.filter(family_id=family_id).values('id', 'status', 'user__username',
                                                                                   'user__userIconUrl', 'user__phone',
                                                                                   'user__userEmail', 'updated_time',
                                                                                   'created_time',
@@ -390,6 +421,7 @@ class GatewayFamilyMemberView(View):
         result = []
         for item in member_join:
             result.append({
+                'joinId': item['id'],
                 'status': item['status'],
                 'userName': item['user__username'],
                 'userIconUrl': item['user__userIconUrl'],

+ 9 - 4
Controller/SerialNumberController.py

@@ -129,7 +129,7 @@ class SerialNumberView(View):
 
     def do_attach_uid(self, request_dict, response, request):
         serial_number = request_dict.get('serial_number', None)
-        country_id = request_dict.get('country_id', None)
+        region_id = request_dict.get('country_id', None)
         company_id = request_dict.get('company_id', None)
         token = request_dict.get('token', None)
         time_stamp = request_dict.get('time_stamp', None)
@@ -150,9 +150,14 @@ class SerialNumberView(View):
             p2p_type = serial_number[9:10]
 
         try:
-            if not country_id:
+            p2p_type = int(p2p_type)
+            if not region_id:
                 # 根据配置信息确定region_id
-                country_id = CommonService.confirm_region_id(request)
+                region_id = CommonService.confirm_region_id(request)
+
+            # 尚云: 地区为亚洲分配美洲的uid
+            if p2p_type == 1 and region_id == 2:
+                region_id = 3
 
             # 判断序列号是否已和企业关联
             company_serial_qs = CompanySerialModel.objects.filter(company__secret=company_id, serial_number=serial)
@@ -177,7 +182,7 @@ class SerialNumberView(View):
                     while count < 3:
                         # 查询是否存在未绑定序列号的uid
                         uid_qs = UIDModel.objects.filter(vpg__company_id=company_serial.company.id,
-                                                         vpg__region_id=country_id, status=0, p2p_type=p2p_type). \
+                                                         vpg__region_id=region_id, status=0, p2p_type=p2p_type). \
                             order_by('id')
                         if not uid_qs.exists():
                             return response.json(375)

+ 1 - 9
Object/IOTCore/IotObject.py

@@ -21,15 +21,7 @@ class IOTClient:
             self.endpoint = 'a250bbr0p9u7as-ats.iot.cn-northwest-1.amazonaws.com.cn'
             self.iotrole = AWS_IOT_SES_ACCESS_CHINA_ROLE
 
-        elif region_id == 2:
-            # 亚太新加坡
-            self.client = boto3.client('iot', region_name=AWS_IOT_SES_ACCESS_FOREIGN_REGION_ASIA,
-                                       aws_access_key_id=AWS_IOT_SES_ACCESS_FOREIGN_ID,
-                                       aws_secret_access_key=AWS_IOT_SES_ACCESS_FOREIGN_SECRET)
-            self.endpoint = 'a2rqy12o004ad8-ats.iot.ap-southeast-1.amazonaws.com'
-            self.iotrole = AWS_IOT_SES_ACCESS_FOREIGN_ROLE
-
-        elif region_id == 3:
+        elif region_id == 2 or region_id == 3:
             # 美东弗吉尼亚
             self.client = boto3.client('iot', region_name=AWS_IOT_SES_ACCESS_FOREIGN_REGION_AMERICA,
                                        aws_access_key_id=AWS_IOT_SES_ACCESS_FOREIGN_ID,