|
@@ -9,7 +9,6 @@
|
|
|
|
|
|
from django.db.models import Q, Count, Sum
|
|
from django.db.models import Q, Count, Sum
|
|
from django.views.generic.base import View
|
|
from django.views.generic.base import View
|
|
-from Ansjer.config import DEVICE_TYPE
|
|
|
|
import datetime
|
|
import datetime
|
|
import requests
|
|
import requests
|
|
|
|
|
|
@@ -126,8 +125,8 @@ class ServiceDataView(View):
|
|
# device_qs = Device_Info.objects.filter(UID__in=uid_list).values('Type').annotate(
|
|
# device_qs = Device_Info.objects.filter(UID__in=uid_list).values('Type').annotate(
|
|
# count=Count('Type', distinct=True)).order_by('-count')
|
|
# count=Count('Type', distinct=True)).order_by('-count')
|
|
for k, v in uid_type_dict.items():
|
|
for k, v in uid_type_dict.items():
|
|
- type_name = DEVICE_TYPE.get(k, '未知类型')
|
|
|
|
- type_name = type_name if type_name != 'UNKOWN' else '未知类型'
|
|
|
|
|
|
+ type_qs = DeviceTypeModel.objects.filter(type=k).values('name')
|
|
|
|
+ type_name = type_qs[0]['name'] if type_qs.exists() else '未知类型'
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
if count:
|
|
if count:
|
|
type_rate = round(device_count / count * 100, 2)
|
|
type_rate = round(device_count / count * 100, 2)
|
|
@@ -227,7 +226,7 @@ class ServiceDataView(View):
|
|
time_list = CommonService.cutting_time(start_time, end_time, time_unit)
|
|
time_list = CommonService.cutting_time(start_time, end_time, time_unit)
|
|
# 转化率
|
|
# 转化率
|
|
if store_meal_type == 0:
|
|
if store_meal_type == 0:
|
|
- uidset_count = uidset_qs.filter(is_vod=1).count()
|
|
|
|
|
|
+ uidset_count = uidset_qs.filter(~Q(cloud_vod=2)).count()
|
|
elif store_meal_type == 1:
|
|
elif store_meal_type == 1:
|
|
uidset_count = uidset_qs.filter(is_ai=1).count()
|
|
uidset_count = uidset_qs.filter(is_ai=1).count()
|
|
else:
|
|
else:
|
|
@@ -278,8 +277,8 @@ class ServiceDataView(View):
|
|
uid_dict[device_type].append(item['UID'])
|
|
uid_dict[device_type].append(item['UID'])
|
|
|
|
|
|
for k, v in uid_dict.items():
|
|
for k, v in uid_dict.items():
|
|
- type_name = DEVICE_TYPE.get(k, '未知类型')
|
|
|
|
- type_name = type_name if type_name != 'UNKOWN' else '未知类型'
|
|
|
|
|
|
+ type_qs = DeviceTypeModel.objects.filter(type=k).values('name')
|
|
|
|
+ type_name = type_qs[0]['name'] if type_qs.exists() else '未知类型'
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
if count:
|
|
if count:
|
|
type_rate = round(device_count / count * 100, 2)
|
|
type_rate = round(device_count / count * 100, 2)
|
|
@@ -378,8 +377,8 @@ class ServiceDataView(View):
|
|
uid_dict[device_type] = []
|
|
uid_dict[device_type] = []
|
|
uid_dict[device_type].append(item['UID'])
|
|
uid_dict[device_type].append(item['UID'])
|
|
for k, v in uid_dict.items():
|
|
for k, v in uid_dict.items():
|
|
- type_name = DEVICE_TYPE.get(k, '未知类型')
|
|
|
|
- type_name = type_name if type_name != 'UNKOWN' else '未知类型'
|
|
|
|
|
|
+ type_qs = DeviceTypeModel.objects.filter(type=k).values('name')
|
|
|
|
+ type_name = type_qs[0]['name'] if type_qs.exists() else '未知类型'
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
if count:
|
|
if count:
|
|
type_rate = round(device_count / count * 100, 2)
|
|
type_rate = round(device_count / count * 100, 2)
|
|
@@ -481,8 +480,8 @@ class ServiceDataView(View):
|
|
uid_dict[device_type] = []
|
|
uid_dict[device_type] = []
|
|
uid_dict[device_type].append(item['UID'])
|
|
uid_dict[device_type].append(item['UID'])
|
|
for k, v in uid_dict.items():
|
|
for k, v in uid_dict.items():
|
|
- type_name = DEVICE_TYPE.get(k, '未知类型')
|
|
|
|
- type_name = type_name if type_name != 'UNKOWN' else '未知类型'
|
|
|
|
|
|
+ type_qs = DeviceTypeModel.objects.filter(type=k).values('name')
|
|
|
|
+ type_name = type_qs[0]['name'] if type_qs.exists() else '未知类型'
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
if count:
|
|
if count:
|
|
if count:
|
|
if count:
|