feat: ftestwork支持对materialbatch检查
This commit is contained in:
parent
9d1c5415e1
commit
31d0dc4829
|
@ -46,8 +46,8 @@ class FtestWorkFilter(filters.FilterSet):
|
||||||
fields = {
|
fields = {
|
||||||
"material__process__name": ["exact", "contains"],
|
"material__process__name": ["exact", "contains"],
|
||||||
"material": ["exact"],
|
"material": ["exact"],
|
||||||
"wm": ["exact"],
|
"wm": ["exact", "isnull"],
|
||||||
"mb": ["exact"],
|
"mb": ["exact", "isnull"],
|
||||||
"batch": ["exact"],
|
"batch": ["exact"],
|
||||||
"type": ["exact"],
|
"type": ["exact"],
|
||||||
"type2": ["exact"],
|
"type2": ["exact"],
|
||||||
|
|
|
@ -6,6 +6,7 @@ from django.utils import timezone
|
||||||
from apps.wf.models import Ticket
|
from apps.wf.models import Ticket
|
||||||
from apps.qm.models import NotOkOption, Defect
|
from apps.qm.models import NotOkOption, Defect
|
||||||
from apps.wpm.services_2 import ana_batch_thread
|
from apps.wpm.services_2 import ana_batch_thread
|
||||||
|
from apps.inm.models import MaterialBatch
|
||||||
|
|
||||||
def ftestwork_submit_validate(ins: FtestWork):
|
def ftestwork_submit_validate(ins: FtestWork):
|
||||||
wm:WMaterial = ins.wm
|
wm:WMaterial = ins.wm
|
||||||
|
@ -124,6 +125,32 @@ def ftestwork_submit(ins:FtestWork, user: User):
|
||||||
if not new_create:
|
if not new_create:
|
||||||
wmx.count = wmx.count + item.count
|
wmx.count = wmx.count + item.count
|
||||||
wmx.save()
|
wmx.save()
|
||||||
|
|
||||||
|
if ins.mb:
|
||||||
|
mb:MaterialBatch = ins.mb
|
||||||
|
for item in FtestworkDefect.objects.filter(ftestwork=ins):
|
||||||
|
item:FtestworkDefect = item
|
||||||
|
if item.count > 0:
|
||||||
|
mb.count = mb.count - item.count
|
||||||
|
if mb.count < 0:
|
||||||
|
raise ParseError("数量不足,扣减失败")
|
||||||
|
mb.save()
|
||||||
|
mbstate = WMaterial.WM_OK
|
||||||
|
if item.defect.okcate == Defect.DEFECT_NOTOK:
|
||||||
|
mbstate = WMaterial.WM_NOTOK
|
||||||
|
mbx, new_create = MaterialBatch.objects.get_or_create(
|
||||||
|
material=mb.material,
|
||||||
|
warehouse=mb.warehouse,
|
||||||
|
batch=mb.batch,
|
||||||
|
defect=item.defect,
|
||||||
|
state=mbstate,
|
||||||
|
defaults={
|
||||||
|
'count': item.count,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if not new_create:
|
||||||
|
mbx.count = mbx.count + item.count
|
||||||
|
mbx.save()
|
||||||
ins.submit_user = user
|
ins.submit_user = user
|
||||||
ins.submit_time = timezone.now()
|
ins.submit_time = timezone.now()
|
||||||
ins.save()
|
ins.save()
|
||||||
|
|
Loading…
Reference in New Issue