|
@@ -459,12 +459,25 @@ class DeviceDataView(View):
|
|
|
})
|
|
|
res['type'] = CommonService.list_sort(type_list)
|
|
|
# 云存版本数量
|
|
|
- res_part = {}
|
|
|
- cloud_qs = deivce_uid_qs.exclude(cloud_vod=2).values('cloud_vod').count()
|
|
|
- res_part['count'] = cloud_qs
|
|
|
- res_part['rate'] = round(cloud_qs / count_part * 100, 2)
|
|
|
- version_list.append(res_part)
|
|
|
- res['version'] = version_list
|
|
|
+ cloud_qs = deivce_uid_qs.exclude(cloud_vod=2).values('uid')
|
|
|
+ cloud_list = [item[key] for item in cloud_qs for key in item]
|
|
|
+ device_info_type_qs = Device_Info.objects.filter(UID__in=cloud_list).distinct()
|
|
|
+ cloud_type_qs = device_info_type_qs.values('Type').annotate(
|
|
|
+ count=Count('Type', distinct=True)).order_by('-count').distinct()
|
|
|
+ type_qs = device_info_type_qs.values('Type')
|
|
|
+ test_list = [item[key] for item in type_qs for key in item]
|
|
|
+ for cloud_type in cloud_type_qs:
|
|
|
+ Type = cloud_type['Type']
|
|
|
+ device_type_qs = DeviceTypeModel.objects.filter(type=Type).values('name')
|
|
|
+ name = device_type_qs[0]['name'] if device_type_qs.exists() else '未知类型'
|
|
|
+ type_count = test_list.count(Type)
|
|
|
+ rate = round(type_count / count_part * 100, 2)
|
|
|
+ version_list.append({
|
|
|
+ 'type': name,
|
|
|
+ 'count': type_count,
|
|
|
+ 'rate': rate
|
|
|
+ })
|
|
|
+ res['version'] = CommonService.list_sort(version_list)
|
|
|
else:
|
|
|
info_dict = {
|
|
|
'startTime': item[0],
|