fix: mlog submit中提交wprbug
This commit is contained in:
parent
aca5cd8a63
commit
88535650a7
|
|
@ -238,8 +238,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
# 获取所有主要的不合格项
|
# 获取所有主要的不合格项
|
||||||
bw_qs = Mlogbw.objects.filter(mlogb=item)
|
bw_qs = Mlogbw.objects.filter(mlogb=item)
|
||||||
defect_qs = FtestDefect.objects.filter(ftest__is_ok=False,
|
defect_qs = FtestDefect.objects.filter(ftest__is_ok=False,
|
||||||
ftest__mlogbw_ftest__mlogb=item, is_main=True).values_list(
|
ftest__mlogbw_ftest__mlogb=item, is_main=True).values(
|
||||||
"defect", flat=True).distinct()
|
"defect").distinct()
|
||||||
for defect in defect_qs:
|
for defect in defect_qs:
|
||||||
xcount = bw_qs.filter(ftest__defects_ftest__defect=defect).count()
|
xcount = bw_qs.filter(ftest__defects_ftest__defect=defect).count()
|
||||||
if xcount > 0:
|
if xcount > 0:
|
||||||
|
|
@ -259,6 +259,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
|
|
||||||
for mo in m_outs_list:
|
for mo in m_outs_list:
|
||||||
mo_ma, mo_batch, mo_count, mo_count_eweight, notok_sign_or_defect, mlog_or_b = mo
|
mo_ma, mo_batch, mo_count, mo_count_eweight, notok_sign_or_defect, mlog_or_b = mo
|
||||||
|
if mo_count <= 0:
|
||||||
|
continue
|
||||||
wm_state = WMaterial.WM_OK if notok_sign_or_defect is None else WMaterial.WM_NOTOK
|
wm_state = WMaterial.WM_OK if notok_sign_or_defect is None else WMaterial.WM_NOTOK
|
||||||
lookup = {'batch': mo_batch, 'material': mo_ma, 'mgroup': None,
|
lookup = {'batch': mo_batch, 'material': mo_ma, 'mgroup': None,
|
||||||
'notok_sign': None, 'defect': None, 'state': wm_state}
|
'notok_sign': None, 'defect': None, 'state': wm_state}
|
||||||
|
|
@ -271,7 +273,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
stored_mgroup = True
|
stored_mgroup = True
|
||||||
else:
|
else:
|
||||||
lookup['belong_dept'] = belong_dept
|
lookup['belong_dept'] = belong_dept
|
||||||
if mo_count > 0:
|
|
||||||
wm, is_create2 = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept})
|
wm, is_create2 = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept})
|
||||||
wm.count = wm.count + mo_count
|
wm.count = wm.count + mo_count
|
||||||
wm.count_eweight = mo_count_eweight
|
wm.count_eweight = mo_count_eweight
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue