diff --git a/apps/wpm/services.py b/apps/wpm/services.py index f7dd0c0b..7dae7d1e 100644 --- a/apps/wpm/services.py +++ b/apps/wpm/services.py @@ -205,7 +205,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]): for item in m_ins: mbd_qs = MlogbDefect.get_defect_qs_from_mlogb(item) for itemx in mbd_qs: - if itemx.defect: + if itemx.defect and itemx.count > 0: m_ins_bl_list.append((item.material_in, item.batch, itemx.count, itemx.defect, item)) else: m_ins_list = [(material_in, mlog.batch, mlog.count_use, None, mlog)] @@ -284,7 +284,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]): # if item.material_out.tracking == Material.MA_TRACKING_SINGLE: # Mlogbw.cal_count_notok(item) for itemx in mbd_qs: - m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, item)) + if itemx.count > 0: + m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, item)) # # 获取所有主要的不合格项/先暂时保留 # bw_qs = Mlogbw.objects.filter(mlogb=item) # defectIds= Ftest.objects.filter(mlogbw_ftest__in=bw_qs).exclude(defect_main=None).values_list("defect_main__id", flat=True).distinct() @@ -437,7 +438,8 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]): # if item.material_out.tracking == Material.MA_TRACKING_SINGLE: # Mlogbw.cal_count_notok(item) for itemx in mbd_qs: - m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, item)) + if itemx.count > 0: + m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, item)) # if item.material_out.tracking == Material.MA_TRACKING_SINGLE: # # 获取所有主要的不合格项 # bw_qs = Mlogbw.objects.filter(mlogb=item) @@ -532,7 +534,7 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]): for item in m_ins: mbd_qs = MlogbDefect.get_defect_qs_from_mlogb(item) for itemx in mbd_qs: - if itemx.defect: + if itemx.defect and itemx.count > 0: m_ins_bl_list.append((item.material_in, item.batch, itemx.count, itemx.defect, item)) else: m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in, mlog)]