|
@@ -8,7 +8,7 @@ from django.db import transaction
|
|
|
from django.views import View
|
|
|
|
|
|
from Model.models import SerialNumberModel, CompanySerialModel, UIDCompanySerialModel, CompanyModel, RegionModel, \
|
|
|
- CountryModel, UIDModel
|
|
|
+ CountryModel, UIDModel, RegionCountryModel
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.uidManageResponseObject import uidManageResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -127,8 +127,8 @@ class SerialNumberView(View):
|
|
|
value = redisObject.lpop(key)
|
|
|
count += 1
|
|
|
|
|
|
- if count == 5 and value is False:
|
|
|
- return response.json(5)
|
|
|
+ # if count == 5 and value is False: 暂时注释
|
|
|
+ # return response.json(5)
|
|
|
|
|
|
quantity = int(quantity)
|
|
|
|
|
@@ -140,12 +140,12 @@ class SerialNumberView(View):
|
|
|
# 存在对应的企业
|
|
|
company_serial_qs = company_serial_qs[0:quantity]
|
|
|
|
|
|
- company_serial_qs = company_serial_qs.values('id', 'serial_number__serial_number', 'company__mark')
|
|
|
+ #company_serial_qs = company_serial_qs.values('id', 'serial_number__serial_number', 'company__mark')
|
|
|
data = []
|
|
|
ids = []
|
|
|
for serial in company_serial_qs:
|
|
|
- ids.append(serial['id'])
|
|
|
- data.append(serial['serial_number__serial_number'] + serial['company__mark'])
|
|
|
+ ids.append(serial.id)
|
|
|
+ data.append(serial.serial_number.serial_number + serial.company.mark)
|
|
|
CompanySerialModel.objects.filter(id__in=ids).update(status=1)
|
|
|
redisObject.rpush(key, value)
|
|
|
return response.json(0, data)
|
|
@@ -203,22 +203,22 @@ class SerialNumberView(View):
|
|
|
try:
|
|
|
try:
|
|
|
|
|
|
- # 判断序列号是否已和UID关联
|
|
|
+ # 判断序列号是否已和企业关联
|
|
|
company_serial_qs = CompanySerialModel.objects.filter(company__secret=company_id,
|
|
|
serial_number__serial_number=serial)
|
|
|
if not company_serial_qs.exists():
|
|
|
- uid_company_serial_qs = UIDCompanySerialModel.objects.filter(company_serial__company__mark=mark,
|
|
|
- company_serial__serial_number__serial_number=serial)
|
|
|
-
|
|
|
- uid = uid_company_serial_qs.values('uid__uid', 'uid__mac', 'uid__uid_extra')[0]
|
|
|
-
|
|
|
- res = {
|
|
|
- 'uid': CommonService.encode_data(uid['uid__uid']),
|
|
|
- 'mac': CommonService.encode_data(uid['uid__mac']),
|
|
|
- 'extra': uid['uid__uid_extra']
|
|
|
- }
|
|
|
- return response.json(0, res)
|
|
|
+ return response.json(173)
|
|
|
|
|
|
+ region_country_qs = RegionCountryModel.objects.filter(number=country_id)
|
|
|
+ endpoint = 'a2rqy12o004ad8-ats.iot.us-east-1.amazonaws.com'
|
|
|
+ if region_country_qs.exists():
|
|
|
+ user_region = region_country_qs[0]
|
|
|
+ if user_region.region_id == 1:
|
|
|
+ endpoint = 'a250bbr0p9u7as-ats.iot.cn-northwest-1.amazonaws.com.cn'
|
|
|
+ elif user_region.region_id == 2:
|
|
|
+ endpoint = 'a2rqy12o004ad8-ats.iot.ap-southeast-1.amazonaws.com'
|
|
|
+ elif user_region.region_id == 3:
|
|
|
+ endpoint = 'a2rqy12o004ad8-ats.iot.eu-west-1.amazonaws.com'
|
|
|
|
|
|
# 当序列号已关联UID
|
|
|
company_serial = company_serial_qs[0]
|
|
@@ -262,7 +262,8 @@ class SerialNumberView(View):
|
|
|
res = {
|
|
|
'uid': CommonService.encode_data(uid.uid),
|
|
|
'mac': CommonService.encode_data(uid.mac),
|
|
|
- 'extra': uid.uid_extra
|
|
|
+ 'extra': uid.uid_extra,
|
|
|
+ 'endpoint': endpoint
|
|
|
}
|
|
|
return response.json(0, res)
|
|
|
else:
|
|
@@ -276,7 +277,8 @@ class SerialNumberView(View):
|
|
|
res = {
|
|
|
'uid': CommonService.encode_data(uid['uid__uid']),
|
|
|
'mac': CommonService.encode_data(uid['uid__mac']),
|
|
|
- 'extra': uid['uid__uid_extra']
|
|
|
+ 'extra': uid['uid__uid_extra'],
|
|
|
+ 'endpoint': endpoint
|
|
|
}
|
|
|
return response.json(0, res)
|
|
|
else:
|