|
@@ -6,8 +6,11 @@ import threading
|
|
|
import time
|
|
import time
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
|
|
|
|
|
|
+from django.db.models.functions import Substr, Length
|
|
|
|
|
+
|
|
|
from AnsjerPush.config import CONFIG_INFO, CONFIG_TEST, CONFIG_CN, XM_PUSH_CHANNEL_ID
|
|
from AnsjerPush.config import CONFIG_INFO, CONFIG_TEST, CONFIG_CN, XM_PUSH_CHANNEL_ID
|
|
|
-from Model.models import DeviceTypeModel, Device_Info, GatewayPush, CountryModel, SysMsgModel, UserEmailSubscriptions
|
|
|
|
|
|
|
+from Model.models import DeviceTypeModel, Device_Info, GatewayPush, CountryModel, SysMsgModel, UserEmailSubscriptions, \
|
|
|
|
|
+ AppDeviceType, UidSetModel
|
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
|
from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
|
|
from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
|
|
|
from Service.PushService import PushObject
|
|
from Service.PushService import PushObject
|
|
@@ -26,18 +29,32 @@ class CustomizedPushObject:
|
|
|
@param register_period: 用户注册年限
|
|
@param register_period: 用户注册年限
|
|
|
@return: uid_id_list
|
|
@return: uid_id_list
|
|
|
"""
|
|
"""
|
|
|
- # 设备型号和国家
|
|
|
|
|
- device_name_list = device_name.split(',')
|
|
|
|
|
- device_type_list = DeviceTypeModel.objects.filter(name__in=device_name_list).values_list('type', flat=True)
|
|
|
|
|
- # 测试和国内服推给所有用户
|
|
|
|
|
- if CONFIG_INFO in [CONFIG_TEST, CONFIG_CN]:
|
|
|
|
|
- device_info_qs = Device_Info.objects.filter(Type__in=device_type_list)
|
|
|
|
|
|
|
+ # 查询云存设备
|
|
|
|
|
+ if device_name == 'cloud_storage':
|
|
|
|
|
+ ipc_types = list(AppDeviceType.objects.filter(model=2).values_list('type', flat=True).distinct())
|
|
|
|
|
+ uid_list = (UidSetModel.objects.annotate(ucode_char=Substr('ucode', Length('ucode') - 3, 1)).
|
|
|
|
|
+ filter(device_type__in=ipc_types, ucode_char__in=['4', '5']).values_list('uid', flat=True))
|
|
|
|
|
+ device_info_qs = Device_Info.objects.filter(UID__in=list(uid_list))
|
|
|
|
|
+ # 国外服推给指定国家用户
|
|
|
|
|
+ if CONFIG_INFO not in [CONFIG_TEST, CONFIG_CN]:
|
|
|
|
|
+ country_name_list = country.split(',')
|
|
|
|
|
+ country_id_list = CountryModel.objects.filter(country_name__in=country_name_list). \
|
|
|
|
|
+ values_list('id', flat=True)
|
|
|
|
|
+ device_info_qs = device_info_qs.filter(userID__region_country__in=country_id_list)
|
|
|
else:
|
|
else:
|
|
|
- country_name_list = country.split(',')
|
|
|
|
|
- country_id_list = CountryModel.objects.filter(country_name__in=country_name_list).\
|
|
|
|
|
- values_list('id', flat=True)
|
|
|
|
|
- device_info_qs = Device_Info.objects.filter(Type__in=device_type_list,
|
|
|
|
|
- userID__region_country__in=country_id_list)
|
|
|
|
|
|
|
+ # 设备型号和国家
|
|
|
|
|
+ device_name_list = device_name.split(',')
|
|
|
|
|
+ device_type_list = DeviceTypeModel.objects.filter(name__in=device_name_list).values_list('type', flat=True)
|
|
|
|
|
+ # 测试和国内服推给所有用户
|
|
|
|
|
+ if CONFIG_INFO in [CONFIG_TEST, CONFIG_CN]:
|
|
|
|
|
+ device_info_qs = Device_Info.objects.filter(Type__in=device_type_list)
|
|
|
|
|
+ else:
|
|
|
|
|
+ country_name_list = country.split(',')
|
|
|
|
|
+ country_id_list = CountryModel.objects.filter(country_name__in=country_name_list).\
|
|
|
|
|
+ values_list('id', flat=True)
|
|
|
|
|
+ device_info_qs = Device_Info.objects.filter(Type__in=device_type_list,
|
|
|
|
|
+ userID__region_country__in=country_id_list)
|
|
|
|
|
+
|
|
|
# 获取时间范围
|
|
# 获取时间范围
|
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
|
|
|
|