Kaynağa Gözat

修改测试服region_id为5

locky 2 yıl önce
ebeveyn
işleme
4cfff78e5c

+ 2 - 0
Ansjer/config.py

@@ -18,6 +18,8 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 # 序列号redis列表
 USED_SERIAL_REDIS_LIST = 'used_serial_redis_list'
 UNUSED_SERIAL_REDIS_LIST = 'unused_serial_redis_list'
+# 地区id列表
+REGION_ID_LIST = [1, 2, 3, 4, 5]
 
 # 亚马逊的数据库DynamoDB的密钥
 AWS_DynamoDB_REGION = 'us-west-1'

+ 6 - 8
Controller/IotCoreController.py

@@ -6,14 +6,12 @@ import time
 import uuid
 from collections import OrderedDict
 
-import requests
 from django.views import View
 
 from Ansjer.config import AWS_IOT_GETS3_PULL_CHINA_ID, AWS_IOT_GETS3_PULL_CHINA_SECRET, \
     AWS_IOT_GETS3_PULL_FOREIGN_ID, AWS_IOT_GETS3_PULL_FOREIGN_SECRET, AWS_ARN, AWS_IOT_SES_ACCESS_CHINA_REGION, \
     AWS_IOT_SES_ACCESS_FOREIGN_REGION_ASIA, AWS_IOT_SES_ACCESS_FOREIGN_REGION_EUROPE, \
-    AWS_IOT_SES_ACCESS_FOREIGN_REGION_AMERICA, CONFIG_INFO, CONFIG_TEST, CONFIG_CN
-from Controller.DeviceConfirmRegion import Device_Region
+    AWS_IOT_SES_ACCESS_FOREIGN_REGION_AMERICA, REGION_ID_LIST
 from Model.models import Device_Info, iotdeviceInfoModel, SerialNumberModel, UidSetModel
 from Object.IOTCore.IotObject import IOTClient
 from Object.ResponseObject import ResponseObject
@@ -39,13 +37,13 @@ class IotCoreView(View):
         response = ResponseObject()
         lang = request_dict.get('lang', 'en')
         response.lang = lang
-        if operation == 'createKeysAndCertificate':     # 设备注册到IoT core
+        if operation == 'createKeysAndCertificate':  # 设备注册到IoT core
             return self.create_key_and_certificate(request_dict, response)
         elif operation == 'requestPublishMessage':
             return self.request_publish_message(request_dict, response)
         elif operation == 'getS3PullKey':
             return self.get_s3_pull_key(request_dict, response, request)
-        elif operation == 'thingRegroup':   # OTA升级成功重新分组
+        elif operation == 'thingRegroup':  # OTA升级成功重新分组
             return self.thing_regroup(request_dict, response)
         elif operation == 'pcGetIotInfo':
             return self.pcGetIotInfo(request_dict, response)
@@ -131,7 +129,7 @@ class IotCoreView(View):
             else:
                 # 获取并判断region_id是否有效
                 region_id = CommonService.confirm_region_id()
-                if region_id not in [1, 2, 3, 4]:
+                if region_id not in REGION_ID_LIST:
                     return response.json(444, {'invalid region_id': region_id})
 
                 iotClient = IOTClient(region_id)
@@ -198,7 +196,7 @@ class IotCoreView(View):
 
         # 获取并判断region_id是否有效
         region_id = CommonService.confirm_region_id()
-        if region_id not in [1, 2, 3, 4]:
+        if region_id not in REGION_ID_LIST:
             return response.json(444, {'invalid region_id': region_id})
 
         company_mark = '11A'
@@ -271,7 +269,7 @@ class IotCoreView(View):
             return response.json(444)
 
         try:
-            thing_name = CommonService.query_serial_with_uid(UID)   # 存在序列号则为使用序列号作为物品名
+            thing_name = CommonService.query_serial_with_uid(UID)  # 存在序列号则为使用序列号作为物品名
             topic_name = 'ansjer/generic/{}'.format(thing_name)
             msg = OrderedDict(
                 [

+ 2 - 2
Controller/SerialNumberController.py

@@ -7,7 +7,7 @@ from django.db import transaction
 from django.views import View
 
 from Ansjer.config import CRCKey, CONFIG_INFO, CONFIG_TEST, CONFIG_US, \
-    CONFIG_CN, USED_SERIAL_REDIS_LIST, UNUSED_SERIAL_REDIS_LIST, SERVER_DOMAIN_US
+    CONFIG_CN, USED_SERIAL_REDIS_LIST, UNUSED_SERIAL_REDIS_LIST, SERVER_DOMAIN_US, REGION_ID_LIST
 from Model.models import SerialNumberModel, CompanySerialModel, UIDCompanySerialModel, UIDModel, Device_Info, \
     iotdeviceInfoModel, LogModel, UidSetModel, UID_Bucket, \
     Unused_Uid_Meal, Order_Model, StsCrdModel, VodHlsModel, ExperienceContextModel, UidUserModel, ExperienceAiModel, \
@@ -131,7 +131,7 @@ class SerialNumberView(View):
 
                 # 获取并判断region_id
                 region_id = CommonService.confirm_region_id()
-                if region_id not in [1, 2, 3, 4]:
+                if region_id not in REGION_ID_LIST:
                     return response.json(444, {'invalid region_id': region_id})
 
                 p2p_type = request_dict.get('p2ptype', 1)

+ 1 - 1
Object/IOTCore/IotObject.py

@@ -12,7 +12,7 @@ from Ansjer.config import AWS_IOT_SES_ACCESS_CHINA_REGION, AWS_IOT_SES_ACCESS_CH
 
 class IOTClient:
     def __init__(self, region_id=1):
-        if region_id == 1:
+        if region_id == 1 or region_id == 5:
             # 中国宁夏
             self.client = boto3.client('iot', region_name=AWS_IOT_SES_ACCESS_CHINA_REGION,
                                        aws_access_key_id=AWS_IOT_SES_ACCESS_CHINA_ID,

+ 5 - 3
Service/CommonService.py

@@ -631,12 +631,14 @@ GCqvlyw5dfxNA+EtxNE2wCW/LW7ENJlACgcfgPlBZtpLheWoZB/maw4=
         @return: region_id
         """
         region_id = 3
-        if CONFIG_INFO == CONFIG_TEST or CONFIG_INFO == CONFIG_CN:  # 测试&中国
-            region_id = 1
-        elif CONFIG_INFO == CONFIG_US:      # 美洲
+        if CONFIG_INFO == CONFIG_US:        # 美洲
             region_id = 3
         elif CONFIG_INFO == CONFIG_EUR:     # 欧洲
             region_id = 4
+        elif CONFIG_INFO == CONFIG_CN:      # 中国
+            region_id = 1
+        elif CONFIG_INFO == CONFIG_TEST:    # 测试
+            region_id = 5
         return region_id
 
     @staticmethod