|
@@ -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, RegionCountryModel
|
|
|
+ CountryModel, UIDModel, RegionCountryModel, Device_Info, iotdeviceInfoModel
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.uidManageResponseObject import uidManageResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -115,7 +115,7 @@ class SerialNumberView(View):
|
|
|
now_time = int(time.time())
|
|
|
distance = now_time - time_stamp
|
|
|
|
|
|
- if token != time_stamp or distance > 300 or distance < 0:
|
|
|
+ if token != time_stamp or distance > 60000 or distance < 0:
|
|
|
return response.json(404)
|
|
|
|
|
|
redisObject = RedisObject()
|
|
@@ -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)
|
|
|
|
|
@@ -337,21 +337,26 @@ class SerialNumberView(View):
|
|
|
return response.json(444)
|
|
|
|
|
|
def do_detach_uid(self, userID, request_dict, response):
|
|
|
- uid = request_dict.get('uid', None)
|
|
|
+ serial_number = request_dict.get('serial_number', None)
|
|
|
|
|
|
- if uid:
|
|
|
- uid = CommonService.decode_data(uid)
|
|
|
- uid_serial_qs = UIDCompanySerialModel.objects.filter(uid__uid=uid)
|
|
|
+ if serial_number:
|
|
|
+ serial = serial_number[0:6]
|
|
|
+
|
|
|
+ uid_serial_qs = UIDCompanySerialModel.objects.filter(company_serial__serial_number=serial)
|
|
|
if uid_serial_qs.exists():
|
|
|
uid_serial = uid_serial_qs[0]
|
|
|
|
|
|
+ Device_Info.objects.filter(UID=uid_serial.uid).update(endpoint='',
|
|
|
+ token_iot_number='')
|
|
|
+ iotdeviceInfoModel.objects.filter(uid=uid_serial.uid).delete()
|
|
|
+
|
|
|
company_serial_qs = CompanySerialModel.objects.filter(id=uid_serial.company_serial.id)
|
|
|
if company_serial_qs.exists():
|
|
|
company_serial = company_serial_qs[0]
|
|
|
company_serial.status = 1
|
|
|
company_serial.save()
|
|
|
|
|
|
- uid_qs = UIDModel.objects.filter(uid=uid)
|
|
|
+ uid_qs = UIDModel.objects.filter(uid=uid_serial.uid)
|
|
|
if uid_qs.exists():
|
|
|
uid = uid_qs[0]
|
|
|
uid.status = 0
|