diff --git a/apps/inm/services.py b/apps/inm/services.py index 3b968010..f4039b7b 100644 --- a/apps/inm/services.py +++ b/apps/inm/services.py @@ -160,9 +160,9 @@ def do_in(item: MIOItem): for i in mias_list: material, batch, rate = i new_count = rate * item.count # 假设 item.count 存在 - action_list.append([material, batch, new_count, None]) + action_list.append([material, batch, new_count, None, None]) else: - action_list = [[item.material, item.batch, item.count, defect]] + action_list = [[item.material, item.batch, item.count, defect, item.wm]] production_dept = None @@ -170,28 +170,31 @@ def do_in(item: MIOItem): if is_zhj: xbatchs = [item.batch] for al in action_list: - xmaterial, xbatch, xcount, defect = al + xmaterial, xbatch, xcount, defect, xwm = al if xcount <= 0: raise ParseError("存在非正数!") xbatchs.append(xbatch) if material.into_wm: - wm_qs = WMaterial.objects.filter( - batch=xbatch, - material=xmaterial, - belong_dept=belong_dept, - mgroup=mgroup, - defect=defect, - state=WMaterial.WM_OK) - count_x = wm_qs.count() - if count_x == 1: - wm = wm_qs.first() - elif count_x == 0: - raise ParseError( - f'{str(xmaterial)}-{xbatch}-批次库存不存在!') + if xwm: + wm = xwm else: - raise ParseError( - f'{str(xmaterial)}-{xbatch}-存在多个相同批次!') + wm_qs = WMaterial.objects.filter( + batch=xbatch, + material=xmaterial, + belong_dept=belong_dept, + mgroup=mgroup, + defect=defect, + state=WMaterial.WM_OK) + count_x = wm_qs.count() + if count_x == 1: + wm = wm_qs.first() + elif count_x == 0: + raise ParseError( + f'{str(xmaterial)}-{xbatch}-批次库存不存在!') + else: + raise ParseError( + f'{str(xmaterial)}-{xbatch}-存在多个相同批次!') # 扣减车间库存 new_count = wm.count - xcount