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
|
||||
|
|
Loading…
Reference in New Issue