feat: cal_count_notok 完全合格数有bug
This commit is contained in:
parent
bb9e2f337a
commit
fa221218f9
|
@ -417,6 +417,8 @@ class Mlogb(BaseModel):
|
|||
self.count_notok = count_notok
|
||||
self.count_ok = self.count_real - count_notok
|
||||
self.count_ok_full = self.count_real - count_notok_full
|
||||
if self.count_ok_full < 0:
|
||||
raise ParseError("完全合格数不能小于0")
|
||||
self.save(update_fields=["count_ok", "count_notok", "count_ok_full"])
|
||||
mlog = self.mlog
|
||||
if mlog:
|
||||
|
@ -424,6 +426,8 @@ class Mlogb(BaseModel):
|
|||
count_notok = mqs2.aggregate(total=Sum("count"))["total"] or 0
|
||||
count_notok_full = mqs2.exclude(defect__okcate=10).aggregate(total=Sum("count"))["total"] or 0
|
||||
mlog.count_ok_full = self.count_real - count_notok_full
|
||||
if mlog.count_ok_full < 0:
|
||||
raise ParseError("完全合格数不能小于0")
|
||||
mlog.count_notok = count_notok
|
||||
mlog.count_ok = self.count_real - count_notok
|
||||
mlog.save(update_fields=["count_ok", "count_notok", "count_ok_full"])
|
||||
|
@ -470,7 +474,7 @@ class Mlogbw(BaseModel):
|
|||
def cal_count_notok(cls, mlogb: Mlog):
|
||||
from apps.qm.models import Defect
|
||||
# 锁定mlogb以防止并发修改
|
||||
mlogb = Mlogb.objects.select_for_update().get(pk=mlogb.pk)
|
||||
# mlogb:Mlogb = Mlogb.objects.select_for_update().get(pk=mlogb.pk)
|
||||
count = Mlogbw.objects.filter(mlogb=mlogb).count()
|
||||
if mlogb.material_in:
|
||||
mlogb.count_use = count
|
||||
|
|
|
@ -494,7 +494,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
]
|
||||
if mlogbin_defect_objects:
|
||||
MlogbDefect.objects.bulk_create(mlogbin_defect_objects)
|
||||
minx.cal_count_pn_jgqbl()
|
||||
minx.cal_count_pn_jgqbl()
|
||||
|
||||
# 修改产出
|
||||
if instance.fill_way == Mlog.MLOG_2 and instance.material_out.brothers:
|
||||
|
@ -539,7 +539,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
]
|
||||
if mlogb_defect_objects:
|
||||
MlogbDefect.objects.bulk_create(mlogb_defect_objects)
|
||||
mox.cal_count_notok()
|
||||
mox.cal_count_notok()
|
||||
return instance
|
||||
|
||||
def validate(self, attrs):
|
||||
|
|
Loading…
Reference in New Issue