fix: 初始化检测录入rate_pass, create_by, belong_dept需要有
This commit is contained in:
parent
eef4beebb4
commit
edd2dc5600
|
@ -80,7 +80,12 @@ class SfLogViewSet(UpdateModelMixin, ListModelMixin, DestroyModelMixin, CustomGe
|
|||
end_time_local = localtime(obj.end_time)
|
||||
params = {'type': 'sflog', 'material': material, 'testitem': testitem, 'sflog': obj}
|
||||
params_default = params.update({'year_s': end_time_local.year, 'month_s': end_time_local.month, 'day_s': end_time_local.day})
|
||||
QuaStat.objects.get_or_create(**params, defaults=params_default)
|
||||
ins, _ = QuaStat.objects.get_or_create(**params, defaults=params_default)
|
||||
ins.rate_pass = ins.num_ok / ins.num_test
|
||||
if ins.create_by is None:
|
||||
ins.create_by = request.user
|
||||
ins.belong_dept = obj.mgroup.belong_dept
|
||||
ins.save()
|
||||
qs = QuaStat.objects.filter(type='sflog', sflog=obj)
|
||||
sr = QuaStatSerializer(instance=qs, many=True)
|
||||
return Response(sr.data)
|
||||
|
|
Loading…
Reference in New Issue