|
@@ -45,7 +45,7 @@ from django.contrib.auth.hashers import make_password # 对密码加密模块
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_ARN, AWS_ACCESS_KEY_ID, \
|
|
|
AWS_SECRET_ACCESS_KEY, SERVER_TYPE, AWS_SES_ACCESS_REGION
|
|
|
from Model.models import Order_Model, Store_Meal, DeviceLogModel, VodBucketModel, \
|
|
|
- UIDCompanySerialModel, CompanySerialModel
|
|
|
+ UIDCompanySerialModel, CompanySerialModel, LogModel
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
|
from Service.CommonService import CommonService
|
|
@@ -903,10 +903,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
|
|
@@ -921,5 +928,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)
|