|
@@ -19,8 +19,8 @@ import cv2
|
|
|
from botocore import client
|
|
|
from django.db import transaction
|
|
|
|
|
|
-from Ansjer.config import CONFIG_INFO
|
|
|
from Ansjer.cn_config.config_formal import CONFIG_INFO
|
|
|
+from Ansjer.config import CONFIG_INFO
|
|
|
from Controller.DeviceConfirmRegion import Device_Region
|
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
|
from Object.RedisObject import RedisObject
|
|
@@ -47,7 +47,7 @@ from django.contrib.auth.hashers import make_password # 对密码加密模块
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, AWS_ACCESS_KEY_ID, \
|
|
|
AWS_SECRET_ACCESS_KEY, SERVER_TYPE, AWS_SES_ACCESS_REGION
|
|
|
from Model.models import Order_Model, Store_Meal, DeviceLogModel, VodBucketModel, \
|
|
|
- TestSerialRepetition, UIDCompanySerialModel, CompanySerialModel
|
|
|
+ TestSerialRepetition, UIDCompanySerialModel, CompanySerialModel, LogModel
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
|
from Service.CommonService import CommonService
|
|
@@ -166,7 +166,7 @@ class testView(View):
|
|
|
elif operation == 'getSerialNumberInfo': # 序列号信息查询
|
|
|
return self.getSerialNumberInfo(request_dict, response)
|
|
|
elif operation == 'get-serial-details': # 序列号信息查询
|
|
|
- return self.get_serial_details(request_dict, response)
|
|
|
+ return self.get_serial_details(request_dict, response, request)
|
|
|
else:
|
|
|
return 123
|
|
|
|
|
@@ -872,18 +872,18 @@ class testView(View):
|
|
|
serial_number = serial_number[:6]
|
|
|
try:
|
|
|
uid_user_message = {
|
|
|
- "uid": "",
|
|
|
- "serialNumber": "",
|
|
|
- "userID": "",
|
|
|
- "username": "",
|
|
|
- "primaryUserID": ""
|
|
|
+ "uid": "",
|
|
|
+ "serialNumber": "",
|
|
|
+ "userID": "",
|
|
|
+ "username": "",
|
|
|
+ "primaryUserID": ""
|
|
|
}
|
|
|
data = {
|
|
|
"uid": "",
|
|
|
"serialNumber": serialNumber,
|
|
|
"status": "",
|
|
|
"uid_user_message": uid_user_message
|
|
|
- }
|
|
|
+ }
|
|
|
company_serial_qs = CompanySerialModel.objects.filter(serial_number=serial_number).values('status')
|
|
|
if not company_serial_qs.exists():
|
|
|
return response.json(173)
|
|
@@ -903,7 +903,7 @@ class testView(View):
|
|
|
for uid_company_serial in uid_company_serial_qs:
|
|
|
data['uid'] = uid_company_serial['uid__uid']
|
|
|
data['serialNumber'] = serialNumber
|
|
|
- data['status'] = uid_company_serial['uid__status']
|
|
|
+ data['status'] = uid_company_serial['uid__status']
|
|
|
if company_serial_qs[0]['status'] == 1:
|
|
|
data['status'] = '已分配'
|
|
|
if company_serial_qs[0]['status'] == 2:
|
|
@@ -931,10 +931,17 @@ class testView(View):
|
|
|
return response.json(500)
|
|
|
|
|
|
@classmethod
|
|
|
- def get_serial_details(cls, request_dict, response):
|
|
|
- serial_number = request_dict.get("serialNumber", None)
|
|
|
- results_data = []
|
|
|
- if CONFIG_INFO == 'cn':
|
|
|
+ def get_serial_details(cls, request_dict, response, request):
|
|
|
+ """
|
|
|
+ 根据序列号查询各个服绑定状态
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ serial_number = request_dict.get("serialNumber", None)
|
|
|
+ if not serial_number:
|
|
|
+ return response.json(0)
|
|
|
+ results_data = []
|
|
|
+ if not CONFIG_INFO == 'cn':
|
|
|
+ return response.json(0, results_data)
|
|
|
local_response = cls.getSerialNumberInfo(request_dict, response)
|
|
|
res = json.loads(local_response.content)
|
|
|
res['result']['server'] = 1
|
|
@@ -949,5 +956,32 @@ class testView(View):
|
|
|
results2 = json.loads(res2.text)
|
|
|
results2['result']['server'] = 3
|
|
|
results_data.append(results2['result'])
|
|
|
+ is_ok = True
|
|
|
+ operation = ''
|
|
|
+ status_log = ''
|
|
|
+ for item in results_data:
|
|
|
+ if item['status'] == '绑定uid':
|
|
|
+ is_ok = False
|
|
|
+ operation = '{}序列号已绑定UID'.format(serial_number)
|
|
|
+ LOGGER.info('序列号检测状态已绑定:{}'.format(serial_number))
|
|
|
+ break
|
|
|
+ elif item['status'] == '已占用':
|
|
|
+ status_log = '序列号检测状态已占用:{}'.format(serial_number)
|
|
|
+ if is_ok:
|
|
|
+ LOGGER.info(status_log)
|
|
|
+ LOGGER.info('序列号检测状态正常{}'.format(serial_number))
|
|
|
+ return response.json(0, results_data)
|
|
|
+ log = {
|
|
|
+ 'ip': CommonService.get_ip_address(request),
|
|
|
+ 'user_id': 1,
|
|
|
+ 'status': 200,
|
|
|
+ 'time': int(time.time()),
|
|
|
+ 'operation': operation,
|
|
|
+ 'url': 'testApi/get-serial-details',
|
|
|
+ }
|
|
|
+ LogModel.objects.create(**log)
|
|
|
return response.json(0, results_data)
|
|
|
- return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.info('异常详情,errLine:{}, errMsg:{}'
|
|
|
+ .format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return response.json(500)
|