fix: correct_mb_count_notok
This commit is contained in:
parent
e8802c09b2
commit
fa3452088f
|
@ -2,7 +2,7 @@ from .models import MaterialBatch, MIOItem
|
|||
from apps.mtm.models import Material, Mgroup
|
||||
from apps.system.models import Dept
|
||||
from rest_framework.exceptions import ParseError
|
||||
from django.db.models import F
|
||||
from django.db.models import F, Sum
|
||||
from django.db import transaction
|
||||
from .services import InmService
|
||||
|
||||
|
@ -37,10 +37,17 @@ def correct_mb_count_notok():
|
|||
)
|
||||
for mi in mis:
|
||||
count_notok = mi.count_n_zw + mi.count_n_tw + mi.count_n_qp + mi.count_n_wq + mi.count_n_dl + mi.count_n_pb + mi.count_n_dxt + mi.count_n_js + mi.count_n_qx + mi.count_n_zz + mi.count_n_ysq + mi.count_n_hs + mi.count_n_b + mi.count_n_qt
|
||||
with transaction.atomic():
|
||||
MIOItem.objects.filter(id=mi.id).update(count_notok=count_notok)
|
||||
# 先处理库存
|
||||
try:
|
||||
with transaction.atomic():
|
||||
MIOItem.objects.filter(id=mi.id).update(count_notok=count_notok)
|
||||
InmService.update_mb_after_test()
|
||||
except ParseError as e:
|
||||
MIOItem.objects.filter(id=mi.id).update(test_date=None)
|
||||
|
||||
|
||||
def correct_material_count():
|
||||
"""
|
||||
矫正现有物料总数量
|
||||
"""
|
||||
res = MaterialBatch.objects.values('material').aggregate(total=Sum('count'))
|
Loading…
Reference in New Issue