From 24fa17ddb57eeda3a563c9c7e6623de48d7deb64 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 26 Jun 2023 16:29:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=90=8E=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/qm/tasks.py | 6 +++--- apps/qm/views.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/qm/tasks.py b/apps/qm/tasks.py index c4af463b..32769582 100644 --- a/apps/qm/tasks.py +++ b/apps/qm/tasks.py @@ -18,12 +18,12 @@ def cal_quastat(quastatId: str): # 月统计 params = { 'testitem': ins.testitem, - 'product': ins.product, + 'material': ins.material, 'belong_dept': ins.belong_dept, 'year': ins.year, 'month': ins.month } - results_month = QuaStat.objects.filter(**params).values('belong_dept', 'product', + results_month = QuaStat.objects.filter(**params).values('belong_dept', 'material', 'testitem', 'year', 'month').annotate( avg_val_total=Sum(F('avg_val')*F('num_test')), num_test_1=Sum('num_test'), @@ -49,7 +49,7 @@ def cal_quastat(quastatId: str): # 年统计 params.pop('month') - results_year = QuaStat.objects.filter(**params).values('belong_dept', 'product', + results_year = QuaStat.objects.filter(**params).values('belong_dept', 'material', 'testitem', 'year').annotate( avg_val_total=Sum(F('avg_val')*F('num_test')), num_test_1=Sum('num_test'), diff --git a/apps/qm/views.py b/apps/qm/views.py index 312c9fa3..76233863 100644 --- a/apps/qm/views.py +++ b/apps/qm/views.py @@ -28,8 +28,8 @@ class QuaStatViewSet(ListModelMixin, CreateModelMixin, CustomGenericViewSet): """ queryset = QuaStat.objects.all() serializer_class = QuaStatSerializer - filterset_fields = ['type', 'year', 'month', 'day', 'product', 'testitem', 'belong_dept', 'sflog'] - select_related_fields = ['belong_dept', 'product', 'testitem'] + filterset_fields = ['type', 'year', 'month', 'day', 'material', 'testitem', 'belong_dept', 'sflog'] + select_related_fields = ['belong_dept', 'material', 'testitem'] def perform_create(self, serializer): ins = serializer.save()