|
@@ -144,6 +144,13 @@ class SerialNumberView(View):
|
|
if serial_unbind_uid_qs.exists():
|
|
if serial_unbind_uid_qs.exists():
|
|
return response.json(5)
|
|
return response.json(5)
|
|
|
|
|
|
|
|
+ # redis加锁,防止同一个序列号重复绑定
|
|
|
|
+ key = serial + 'do_attach_uid'
|
|
|
|
+ is_lock = redisObj.CONN.setnx(key, 1)
|
|
|
|
+ if not is_lock:
|
|
|
|
+ return response.json(5)
|
|
|
|
+ redisObj.CONN.expire(key, 60)
|
|
|
|
+
|
|
# 判断序列号是否已和企业关联
|
|
# 判断序列号是否已和企业关联
|
|
company_serial_qs = CompanySerialModel.objects.filter(company__secret=company_secret, serial_number=serial)
|
|
company_serial_qs = CompanySerialModel.objects.filter(company__secret=company_secret, serial_number=serial)
|
|
if not company_serial_qs.exists():
|
|
if not company_serial_qs.exists():
|
|
@@ -164,13 +171,6 @@ class SerialNumberView(View):
|
|
return response.json(5)
|
|
return response.json(5)
|
|
region_country = app_scanned_serial_qs[0]['region_country']
|
|
region_country = app_scanned_serial_qs[0]['region_country']
|
|
|
|
|
|
- # redis加锁,防止同一个序列号重复绑定
|
|
|
|
- key = serial + 'do_attach_uid'
|
|
|
|
- is_lock = redisObj.CONN.setnx(key, 1)
|
|
|
|
- if not is_lock:
|
|
|
|
- return response.json(5)
|
|
|
|
- redisObj.CONN.expire(key, 60)
|
|
|
|
-
|
|
|
|
# 获取并判断region_id
|
|
# 获取并判断region_id
|
|
region_id = CommonService.confirm_region_id(region_country)
|
|
region_id = CommonService.confirm_region_id(region_country)
|
|
if region_id not in REGION_ID_LIST:
|
|
if region_id not in REGION_ID_LIST:
|
|
@@ -218,10 +218,6 @@ class SerialNumberView(View):
|
|
company_serial.update_time = now_time
|
|
company_serial.update_time = now_time
|
|
company_serial.save()
|
|
company_serial.save()
|
|
|
|
|
|
- dev = Device_Info.objects.filter(UID=uid.uid)
|
|
|
|
- if dev.exists():
|
|
|
|
- dev.update(serial_number=full_serial)
|
|
|
|
-
|
|
|
|
full_uid_code = uid.full_uid_code
|
|
full_uid_code = uid.full_uid_code
|
|
if uid.platform in CRCKey.keys():
|
|
if uid.platform in CRCKey.keys():
|
|
full_uid_code += ':' + CRCKey[uid.platform]
|
|
full_uid_code += ':' + CRCKey[uid.platform]
|
|
@@ -284,9 +280,7 @@ class SerialNumberView(View):
|
|
return response.json(10042)
|
|
return response.json(10042)
|
|
return response.json(0, self.get_uid_info_by_serial(company_serial.id))
|
|
return response.json(0, self.get_uid_info_by_serial(company_serial.id))
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- djangoLogger = logging.getLogger('django')
|
|
|
|
- djangoLogger.exception(repr(e))
|
|
|
|
- return response.json(176, str(e))
|
|
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def get_uid_info_by_serial(cls, company_serial_id):
|
|
def get_uid_info_by_serial(cls, company_serial_id):
|