|
@@ -341,9 +341,9 @@ class DeviceDataView(View):
|
|
count_part = len(part_only_list)
|
|
count_part = len(part_only_list)
|
|
rate = round(count_part / count_all * 100, 2)
|
|
rate = round(count_part / count_all * 100, 2)
|
|
info_dict = {
|
|
info_dict = {
|
|
- 'count': len(part_only_list),
|
|
|
|
'startTime': item[0],
|
|
'startTime': item[0],
|
|
'endTime': item[1],
|
|
'endTime': item[1],
|
|
|
|
+ 'count': len(part_only_list),
|
|
'rate': rate
|
|
'rate': rate
|
|
}
|
|
}
|
|
info_list.append(info_dict)
|
|
info_list.append(info_dict)
|
|
@@ -366,7 +366,6 @@ class DeviceDataView(View):
|
|
'countryName': country_name,
|
|
'countryName': country_name,
|
|
'count': country_count,
|
|
'count': country_count,
|
|
'rate': rate
|
|
'rate': rate
|
|
- # 'rate': rate
|
|
|
|
}
|
|
}
|
|
region_list.append(country_dict)
|
|
region_list.append(country_dict)
|
|
res['region'] = CommonService.list_sort(region_list)
|
|
res['region'] = CommonService.list_sort(region_list)
|
|
@@ -381,7 +380,6 @@ class DeviceDataView(View):
|
|
type_qs = device_info_qs.filter(UID__in=part_only_list).values('UID').order_by(
|
|
type_qs = device_info_qs.filter(UID__in=part_only_list).values('UID').order_by(
|
|
'UID').distinct().values(
|
|
'UID').distinct().values(
|
|
'Type')
|
|
'Type')
|
|
- # rate = round(total / count_unique * 100, 2) # count_unique 有误,跟device_info_type_qs 总数合不上 (可以看151行)
|
|
|
|
test_list = [item[key] for item in type_qs for key in item]
|
|
test_list = [item[key] for item in type_qs for key in item]
|
|
type_count = test_list.count(type)
|
|
type_count = test_list.count(type)
|
|
rate = round(type_count / count_part * 100, 2)
|
|
rate = round(type_count / count_part * 100, 2)
|
|
@@ -389,33 +387,33 @@ class DeviceDataView(View):
|
|
'type': name,
|
|
'type': name,
|
|
'count': type_count,
|
|
'count': type_count,
|
|
'rate': rate
|
|
'rate': rate
|
|
- # 'rate': rate
|
|
|
|
}
|
|
}
|
|
type_list.append(type_dict)
|
|
type_list.append(type_dict)
|
|
res['type'] = CommonService.list_sort(type_list)
|
|
res['type'] = CommonService.list_sort(type_list)
|
|
# 统计设备版本数量
|
|
# 统计设备版本数量
|
|
order_model_qs = Order_Model.objects.filter(UID__in=part_only_list).values('UID').annotate(
|
|
order_model_qs = Order_Model.objects.filter(UID__in=part_only_list).values('UID').annotate(
|
|
count=Count('UID', distinct=True))
|
|
count=Count('UID', distinct=True))
|
|
- order_uid_qs = list(order_model_qs.values('UID').order_by('UID').distinct())
|
|
|
|
- order_list = []
|
|
|
|
- order_model_qs = order_model_qs.values('order_type').order_by('order_type')
|
|
|
|
- # count = order_model_qs.count()
|
|
|
|
|
|
+ order_model_qs = order_model_qs.filter(order_type=order_type).values('order_type', 'UID').order_by(
|
|
|
|
+ 'UID')
|
|
order_type_list = []
|
|
order_type_list = []
|
|
for order_model in order_model_qs:
|
|
for order_model in order_model_qs:
|
|
- orderType = order_model['order_type']
|
|
|
|
|
|
+ orderType = order_model['UID']
|
|
order_type_list.append(orderType)
|
|
order_type_list.append(orderType)
|
|
res_part = {}
|
|
res_part = {}
|
|
- if order_type == 0:
|
|
|
|
- res_part['name'] = '云存'
|
|
|
|
- elif order_type == 1:
|
|
|
|
- res_part['name'] = 'AI'
|
|
|
|
- elif order_type == 2:
|
|
|
|
- res_part['name'] = '联通4G'
|
|
|
|
- res_part['total'] = order_type_list.count(order_type)
|
|
|
|
- res_part['rate'] = round(res_part['total'] / count_part * 100, 2)
|
|
|
|
- version_list.append(res_part)
|
|
|
|
- res['version'] = version_list
|
|
|
|
-
|
|
|
|
|
|
+ device_info_type_qs = device_info_qs.filter(UID__in=order_type_list).values('Type').annotate(
|
|
|
|
+ count=Count('Type', distinct=True)).order_by('-count').distinct()
|
|
|
|
+ for device_type in device_info_type_qs:
|
|
|
|
+ type = device_type['Type']
|
|
|
|
+ name = DEVICE_TYPE.get(type, '未知类型')
|
|
|
|
+ res_part['name'] = name if name != 'UNKOWN' else '未知类型'
|
|
|
|
+ type_qs = device_info_qs.filter(UID__in=order_type_list).values('UID').order_by(
|
|
|
|
+ 'UID').distinct().values(
|
|
|
|
+ 'Type')
|
|
|
|
+ test_list = [item[key] for item in type_qs for key in item]
|
|
|
|
+ res_part['count'] = test_list.count(type)
|
|
|
|
+ res_part['rate'] = round(res_part['count'] / count_part * 100, 2)
|
|
|
|
+ version_list.append(res_part)
|
|
|
|
+ res['version'] = version_list
|
|
return response.json(0, res)
|
|
return response.json(0, res)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
print(e)
|
|
print(e)
|