|
@@ -11,13 +11,15 @@ from django.views import View
|
|
from Ansjer.config import CRCKey, CONFIG_INFO, CONFIG_US, CONFIG_EUR, \
|
|
from Ansjer.config import CRCKey, CONFIG_INFO, CONFIG_US, CONFIG_EUR, \
|
|
CONFIG_CN, USED_SERIAL_REDIS_LIST, UNUSED_SERIAL_REDIS_LIST, SERVER_DOMAIN_US, REGION_ID_LIST, SERVER_DOMAIN_TEST, \
|
|
CONFIG_CN, USED_SERIAL_REDIS_LIST, UNUSED_SERIAL_REDIS_LIST, SERVER_DOMAIN_US, REGION_ID_LIST, SERVER_DOMAIN_TEST, \
|
|
SERVER_DOMAIN_LIST, SERVER_DOMAIN_CN, SERVER_DOMAIN_EUR, RESET_REGION_ID_SERIAL_REDIS_LIST, LOGGER
|
|
SERVER_DOMAIN_LIST, SERVER_DOMAIN_CN, SERVER_DOMAIN_EUR, RESET_REGION_ID_SERIAL_REDIS_LIST, LOGGER
|
|
|
|
+from Controller.UnicomCombo.UnicomComboController import UnicomComboView
|
|
from Model.models import SerialNumberModel, CompanySerialModel, UIDCompanySerialModel, UIDModel, Device_Info, \
|
|
from Model.models import SerialNumberModel, CompanySerialModel, UIDCompanySerialModel, UIDModel, Device_Info, \
|
|
iotdeviceInfoModel, LogModel, UidSetModel, UID_Bucket, \
|
|
iotdeviceInfoModel, LogModel, UidSetModel, UID_Bucket, \
|
|
Unused_Uid_Meal, Order_Model, StsCrdModel, VodHlsModel, ExperienceContextModel, UidUserModel, ExperienceAiModel, \
|
|
Unused_Uid_Meal, Order_Model, StsCrdModel, VodHlsModel, ExperienceContextModel, UidUserModel, ExperienceAiModel, \
|
|
- AiService, DeviceDomainRegionModel, RegionModel, UidPushModel
|
|
|
|
|
|
+ AiService, DeviceDomainRegionModel, RegionModel, UidPushModel, UnicomDeviceInfo
|
|
from Object.AWS.S3Email import S3Email
|
|
from Object.AWS.S3Email import S3Email
|
|
from Object.RedisObject import RedisObject
|
|
from Object.RedisObject import RedisObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
|
|
+from Object.UnicomObject import UnicomObjeect
|
|
from Object.uidManageResponseObject import uidManageResponseObject
|
|
from Object.uidManageResponseObject import uidManageResponseObject
|
|
from Service.AlgorithmService import AlgorithmBaseOn35
|
|
from Service.AlgorithmService import AlgorithmBaseOn35
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
@@ -594,6 +596,7 @@ class SerialNumberView(View):
|
|
|
|
|
|
try:
|
|
try:
|
|
if company_serial.status == 0 or company_serial.status == 1: # 未使用
|
|
if company_serial.status == 0 or company_serial.status == 1: # 未使用
|
|
|
|
+ self.is_4g_device(serial_number, request_dict, request)
|
|
return response.json(173)
|
|
return response.json(173)
|
|
elif company_serial.status == 2: # 返回uid
|
|
elif company_serial.status == 2: # 返回uid
|
|
res = self.get_uid_info_by_serial(company_serial.id)
|
|
res = self.get_uid_info_by_serial(company_serial.id)
|
|
@@ -884,3 +887,33 @@ class SerialNumberView(View):
|
|
except Exception as e:
|
|
except Exception as e:
|
|
LOGGER.info('{}同步iot异常,errLine:{}, errMsg:{}'.format(serial_number, e.__traceback__.tb_lineno, repr(e)))
|
|
LOGGER.info('{}同步iot异常,errLine:{}, errMsg:{}'.format(serial_number, e.__traceback__.tb_lineno, repr(e)))
|
|
return False
|
|
return False
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def is_4g_device(serial_number, request_dict, request):
|
|
|
|
+ """
|
|
|
|
+ 判断是否4G设备
|
|
|
|
+ """
|
|
|
|
+ try:
|
|
|
|
+ serial_no = serial_number[0:9]
|
|
|
|
+ key = f'ASJ:UNICOM:CARD:ACTIVATE:{serial_no}'
|
|
|
|
+ redis = RedisObject()
|
|
|
|
+ if redis.get_data(key):
|
|
|
|
+ return True
|
|
|
|
+ # 根据序列号查询联通iccid
|
|
|
|
+ unicom_qs = UnicomDeviceInfo.objects.filter(serial_no=serial_no, status=1, card_type=0) \
|
|
|
|
+ .values('iccid', 'status')
|
|
|
|
+ if not unicom_qs.exists():
|
|
|
|
+ return False
|
|
|
|
+ unicom_qs = unicom_qs.first()
|
|
|
|
+ unicom_api = UnicomObjeect()
|
|
|
|
+ unicom_api.change_device_to_activate(unicom_qs['iccid'])
|
|
|
|
+ redis.CONN.setnx(key, str(unicom_qs['iccid']))
|
|
|
|
+ redis.CONN.expire(key, 7200) # 已调用过激活两个小时内不可调用
|
|
|
|
+ ip = CommonService.get_ip_address(request)
|
|
|
|
+ describe = '{}获取uid请求激活4G卡,{}'.format(serial_no, unicom_qs['iccid'])
|
|
|
|
+ UnicomComboView().create_operation_log('serialNumber/get-uid', ip, request_dict, describe)
|
|
|
|
+ return True
|
|
|
|
+ except Exception as e:
|
|
|
|
+ LOGGER.info('{}判断是否4G设备异常,errLine:{}, errMsg:{}'.format(serial_number, e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
+ return False
|
|
|
|
+
|