|
@@ -7,9 +7,9 @@ import requests
|
|
|
from django.db import transaction
|
|
|
from django.views import View
|
|
|
|
|
|
-from Ansjer.config import CRCKey, CONFIG_INFO, CONFIG_US, \
|
|
|
+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, \
|
|
|
- SERVER_DOMAIN_LIST, SERVER_DOMAIN_CN, SERVER_DOMAIN_EUR, RESET_REGION_ID_SERIAL_REDIS_LIST
|
|
|
+ SERVER_DOMAIN_LIST, SERVER_DOMAIN_CN, SERVER_DOMAIN_EUR, RESET_REGION_ID_SERIAL_REDIS_LIST, LOGGER
|
|
|
from Model.models import SerialNumberModel, CompanySerialModel, UIDCompanySerialModel, UIDModel, Device_Info, \
|
|
|
iotdeviceInfoModel, LogModel, UidSetModel, UID_Bucket, \
|
|
|
Unused_Uid_Meal, Order_Model, StsCrdModel, VodHlsModel, ExperienceContextModel, UidUserModel, ExperienceAiModel, \
|
|
@@ -23,8 +23,6 @@ from Service.CommonService import CommonService
|
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
|
from Service.VodHlsService import SplitVodHlsObject
|
|
|
|
|
|
-LOGGER = logging.getLogger('info')
|
|
|
-
|
|
|
|
|
|
class SerialNumberView(View):
|
|
|
|
|
@@ -324,20 +322,28 @@ class SerialNumberView(View):
|
|
|
# 写入已使用序列号redis列表
|
|
|
redis_obj.rpush(USED_SERIAL_REDIS_LIST, serial)
|
|
|
|
|
|
- vpg_id = 1
|
|
|
- if CONFIG_INFO == 'us':
|
|
|
- vpg_id = 3
|
|
|
- elif CONFIG_INFO == 'eur':
|
|
|
- vpg_id = 4
|
|
|
- p2p_type = int(p2p_type)
|
|
|
-
|
|
|
- # 剩余uid数量少于2000邮件提醒
|
|
|
- unused_uid_count = UIDModel.objects.filter(vpg_id=vpg_id, p2p_type=p2p_type, status=0).count()
|
|
|
- warning_count = 2000
|
|
|
- if unused_uid_count < warning_count:
|
|
|
- platform = '尚云' if p2p_type == 1 else 'tutk'
|
|
|
- email_content = '{}服{]的uid数量少于{}个,请及时处理'.format(CONFIG_INFO, platform, warning_count)
|
|
|
- S3Email().faEmail(email_content, 'servers@ansjer.com')
|
|
|
+ redis_obj = RedisObject()
|
|
|
+ time_limit_out = redis_obj.CONN.setnx('uid_count_warning', 1)
|
|
|
+ redis_obj.CONN.expire('uid_count_warning', 60*60*24) # 限制一天提醒一次
|
|
|
+ if time_limit_out:
|
|
|
+ vpg_id = 1
|
|
|
+ if CONFIG_INFO == CONFIG_US:
|
|
|
+ vpg_id = 3
|
|
|
+ elif CONFIG_INFO == CONFIG_EUR:
|
|
|
+ vpg_id = 4
|
|
|
+ p2p_type = int(p2p_type)
|
|
|
+
|
|
|
+ try:
|
|
|
+ # 剩余uid数量少于2000邮件提醒
|
|
|
+ unused_uid_count = UIDModel.objects.filter(vpg_id=vpg_id, p2p_type=p2p_type, status=0).count()
|
|
|
+ LOGGER.info('uid剩余数量:{}'.format(unused_uid_count))
|
|
|
+ warning_count = 2000
|
|
|
+ if unused_uid_count < warning_count:
|
|
|
+ platform = '尚云' if p2p_type == 1 else 'tutk'
|
|
|
+ email_content = '{}服{}的uid数量少于{}个,请及时处理'.format(CONFIG_INFO, platform, warning_count)
|
|
|
+ S3Email().faEmail(email_content, 'servers@ansjer.com')
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.info('发送提醒邮件异常: error_ine:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@staticmethod
|
|
|
def log_and_send_email(request, company_serial_id, serial, now_time):
|