浏览代码

尚云地区为亚洲分配美洲的uid

locky 3 年之前
父节点
当前提交
61be231724
共有 2 个文件被更改,包括 10 次插入13 次删除
  1. 9 4
      Controller/SerialNumberController.py
  2. 1 9
      Object/IOTCore/IotObject.py

+ 9 - 4
Controller/SerialNumberController.py

@@ -129,7 +129,7 @@ class SerialNumberView(View):
 
 
     def do_attach_uid(self, request_dict, response, request):
     def do_attach_uid(self, request_dict, response, request):
         serial_number = request_dict.get('serial_number', None)
         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)
         company_id = request_dict.get('company_id', None)
         token = request_dict.get('token', None)
         token = request_dict.get('token', None)
         time_stamp = request_dict.get('time_stamp', None)
         time_stamp = request_dict.get('time_stamp', None)
@@ -150,9 +150,14 @@ class SerialNumberView(View):
             p2p_type = serial_number[9:10]
             p2p_type = serial_number[9:10]
 
 
         try:
         try:
-            if not country_id:
+            p2p_type = int(p2p_type)
+            if not region_id:
                 # 根据配置信息确定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)
             company_serial_qs = CompanySerialModel.objects.filter(company__secret=company_id, serial_number=serial)
@@ -177,7 +182,7 @@ class SerialNumberView(View):
                     while count < 3:
                     while count < 3:
                         # 查询是否存在未绑定序列号的uid
                         # 查询是否存在未绑定序列号的uid
                         uid_qs = UIDModel.objects.filter(vpg__company_id=company_serial.company.id,
                         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')
                             order_by('id')
                         if not uid_qs.exists():
                         if not uid_qs.exists():
                             return response.json(375)
                             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.endpoint = 'a250bbr0p9u7as-ats.iot.cn-northwest-1.amazonaws.com.cn'
             self.iotrole = AWS_IOT_SES_ACCESS_CHINA_ROLE
             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,
             self.client = boto3.client('iot', region_name=AWS_IOT_SES_ACCESS_FOREIGN_REGION_AMERICA,
                                        aws_access_key_id=AWS_IOT_SES_ACCESS_FOREIGN_ID,
                                        aws_access_key_id=AWS_IOT_SES_ACCESS_FOREIGN_ID,