|
@@ -247,23 +247,39 @@ class UserBrandInfo(View):
|
|
|
# 品牌统计的接口
|
|
|
def query_deviceSupplier_info(self, request_dict, userID,response):
|
|
|
check_perm = ModelService.check_perm(userID=userID,permID=30)
|
|
|
+ print ('---------------------------------------------------------')
|
|
|
if check_perm is True:
|
|
|
# 按照用户去重复查询
|
|
|
- user_brand_queryset = User_Brand.objects.all().order_by('userID').values_list('userID', flat=True).distinct()
|
|
|
- send_jsons=[]
|
|
|
- counts=0
|
|
|
- for i in user_brand_queryset:
|
|
|
- counts=counts+1
|
|
|
- user_brand_querysetlast = User_Brand.objects.filter(userID=i).order_by('-addTime')[:1]
|
|
|
- user_brand_querysetlast = CommonService.qs_to_dict(user_brand_querysetlast)
|
|
|
- username = ModelService.get_user_name(userID=user_brand_querysetlast["datas"][0]['fields']['userID'])
|
|
|
- user_brand_querysetlast["datas"][0]['fields']['username']=username
|
|
|
- send_jsons.append(user_brand_querysetlast["datas"][0])
|
|
|
- deviceSupplier=[]
|
|
|
- for k, v in enumerate(send_jsons):
|
|
|
- deviceSupplier.append(v['fields']['deviceSupplier'])
|
|
|
+ # user_brand_queryset = User_Brand.objects.all().order_by('userID').values_list('userID', flat=True).distinct()
|
|
|
+ # send_jsons=[]
|
|
|
+ # counts=0
|
|
|
+ # for i in user_brand_queryset:
|
|
|
+ # counts=counts+1
|
|
|
+ # user_brand_querysetlast = User_Brand.objects.filter(userID=i).order_by('-addTime')[:1]
|
|
|
+ # user_brand_querysetlast = CommonService.qs_to_dict(user_brand_querysetlast)
|
|
|
+ # username = ModelService.get_user_name(userID=user_brand_querysetlast["datas"][0]['fields']['userID'])
|
|
|
+ # user_brand_querysetlast["datas"][0]['fields']['username']=username
|
|
|
+ # send_jsons.append(user_brand_querysetlast["datas"][0])
|
|
|
+ # deviceSupplier=[]
|
|
|
+ # for k, v in enumerate(send_jsons):
|
|
|
+ # deviceSupplier.append(v['fields']['deviceSupplier'])
|
|
|
+ # deviceSupplier = Counter(deviceSupplier)
|
|
|
+ # return response.json(0, {'datas': deviceSupplier,'counts':counts})
|
|
|
+
|
|
|
+ ub_qs = User_Brand.objects.filter().values('userID','deviceSupplier').order_by('userID').order_by('userID').distinct()
|
|
|
+ count = ub_qs.count()
|
|
|
+ print (ub_qs)
|
|
|
+ print ('---------------------------------------------------------')
|
|
|
+ deviceSupplier = []
|
|
|
+ ub_ql = CommonService.qs_to_list(ub_qs)
|
|
|
+
|
|
|
+ for v in ub_qs:
|
|
|
+ deviceSupplier.append(v['deviceSupplier'])
|
|
|
+ print (v)
|
|
|
deviceSupplier = Counter(deviceSupplier)
|
|
|
- return response.json(0, {'datas': deviceSupplier,'counts':counts})
|
|
|
+ print(deviceSupplier)
|
|
|
+ print ('---------------------------------------------------------')
|
|
|
+ return response.json(0, {'datas': deviceSupplier, 'counts': count})
|
|
|
else:
|
|
|
return response.json(404)
|
|
|
# 区域统计的接口
|