fix: 修改字段后的bug

This commit is contained in:
caoqianming 2023-06-26 16:29:51 +08:00
parent 0145beb63f
commit 24fa17ddb5
2 changed files with 5 additions and 5 deletions

View File

@ -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'),

View File

@ -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()