feat: 返工可选择不合格品/根据工艺路线决定返工后是合格不合格还是返修完成
This commit is contained in:
parent
9179803fda
commit
896be043f5
|
@ -35,6 +35,10 @@ class Process(CommonBModel):
|
||||||
verbose_name = '工序'
|
verbose_name = '工序'
|
||||||
ordering = ['sort', 'create_time']
|
ordering = ['sort', 'create_time']
|
||||||
|
|
||||||
|
def get_canout_mat_ids(self):
|
||||||
|
"""获取可产出的materialIds
|
||||||
|
"""
|
||||||
|
return list(Route.objects.filter(process=self).values_list("material_out__id", flat=True).distinct())
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class Material(CommonAModel):
|
class Material(CommonAModel):
|
||||||
|
|
|
@ -48,7 +48,7 @@ class WMaterialFilter(filters.FilterSet):
|
||||||
mgroup = self.data.get("mgroup", None)
|
mgroup = self.data.get("mgroup", None)
|
||||||
if mgroup:
|
if mgroup:
|
||||||
process = Mgroup.objects.get(id=mgroup).process
|
process = Mgroup.objects.get(id=mgroup).process
|
||||||
matoutIds = list(Route.objects.filter(process=process).values_list("material_out__id", flat=True).distinct())
|
matoutIds = process.get_canout_mat_ids()
|
||||||
if value == "todo":
|
if value == "todo":
|
||||||
qs = queryset.exclude(material__id__in=matoutIds)|queryset.filter(state=WMaterial.WM_REPAIR)
|
qs = queryset.exclude(material__id__in=matoutIds)|queryset.filter(state=WMaterial.WM_REPAIR)
|
||||||
return qs
|
return qs
|
||||||
|
|
|
@ -687,15 +687,10 @@ class MlogbInSerializer(CustomModelSerializer):
|
||||||
if wm_in is None:
|
if wm_in is None:
|
||||||
raise ParseError("请选择相应车间库存!")
|
raise ParseError("请选择相应车间库存!")
|
||||||
if is_fix: # 返修或复检
|
if is_fix: # 返修或复检
|
||||||
if wm_in.state in [WMaterial.WM_NOTOK, WMaterial.WM_REPAIR, WMaterial.WM_REPAIRED]:
|
if wm_in.state in [WMaterial.WM_REPAIR, WMaterial.WM_NOTOK]:
|
||||||
pass
|
raise ParseError('返修或复检需使用返修品/不合格品')
|
||||||
else:
|
|
||||||
raise ParseError('返修或复检不可使用该物料')
|
|
||||||
elif wm_in.state != WMaterial.WM_OK:
|
elif wm_in.state != WMaterial.WM_OK:
|
||||||
raise ParseError('非合格品不可使用')
|
raise ParseError('非合格品不可使用')
|
||||||
if wm_in.state in [WMaterial.WM_OK, WMaterial.WM_REPAIR, WMaterial.WM_REPAIRED]:
|
|
||||||
if is_fix and wm_in.state not in [WMaterial.WM_REPAIR, WMaterial.WM_REPAIRED]:
|
|
||||||
raise ParseError('需要使用返修品')
|
|
||||||
if mtask and mlog.route != mtask.route:
|
if mtask and mlog.route != mtask.route:
|
||||||
raise ParseError('工序不匹配')
|
raise ParseError('工序不匹配')
|
||||||
route = mlog.route
|
route = mlog.route
|
||||||
|
|
|
@ -167,6 +167,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
m_ins_list = []
|
m_ins_list = []
|
||||||
m_ins_bl_list = []
|
m_ins_bl_list = []
|
||||||
|
|
||||||
|
if is_fix:
|
||||||
|
can_matoutIds = process.get_canout_mat_ids()
|
||||||
# 建立关系链
|
# 建立关系链
|
||||||
m_outs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
m_outs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
||||||
for item in m_outs:
|
for item in m_outs:
|
||||||
|
@ -291,9 +293,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
if mo_count <= 0:
|
if mo_count <= 0:
|
||||||
continue
|
continue
|
||||||
if is_fix:
|
if is_fix:
|
||||||
if process.type == Process.PRO_PROD:
|
wm_state = WMaterial.WM_REPAIRED
|
||||||
wm_state = WMaterial.WM_REPAIRED # 返修只有返修完成品
|
if mo_ma.id in can_matoutIds:
|
||||||
elif process.type == Process.PRO_TEST:
|
|
||||||
wm_state = WMaterial.WM_OK if notok_sign_or_defect is None or (
|
wm_state = WMaterial.WM_OK if notok_sign_or_defect is None or (
|
||||||
isinstance(notok_sign_or_defect, Defect) and notok_sign_or_defect.okcate in [Defect.DEFECT_OK, Defect.DEFECT_OK_B]
|
isinstance(notok_sign_or_defect, Defect) and notok_sign_or_defect.okcate in [Defect.DEFECT_OK, Defect.DEFECT_OK_B]
|
||||||
) else WMaterial.WM_NOTOK
|
) else WMaterial.WM_NOTOK
|
||||||
|
@ -382,6 +383,9 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
stored_notok = mlog.stored_notok
|
stored_notok = mlog.stored_notok
|
||||||
stored_mgroup = mlog.stored_mgroup
|
stored_mgroup = mlog.stored_mgroup
|
||||||
is_fix = mlog.is_fix
|
is_fix = mlog.is_fix
|
||||||
|
|
||||||
|
if is_fix:
|
||||||
|
can_matoutIds = process.get_canout_mat_ids()
|
||||||
# 先回退产物
|
# 先回退产物
|
||||||
if material_out or is_fix: # 产物退回
|
if material_out or is_fix: # 产物退回
|
||||||
# 有多个产物的情况
|
# 有多个产物的情况
|
||||||
|
@ -430,9 +434,8 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
if mo_count == 0:
|
if mo_count == 0:
|
||||||
continue
|
continue
|
||||||
if is_fix:
|
if is_fix:
|
||||||
if process.type == Process.PRO_PROD:
|
wm_state = WMaterial.WM_REPAIRED
|
||||||
wm_state = WMaterial.WM_REPAIRED
|
if mo_ma.id in can_matoutIds:
|
||||||
else: # 检验工序正常生成
|
|
||||||
wm_state = WMaterial.WM_OK if notok_sign_or_defect is None or (
|
wm_state = WMaterial.WM_OK if notok_sign_or_defect is None or (
|
||||||
isinstance(notok_sign_or_defect, Defect) and notok_sign_or_defect.okcate in [Defect.DEFECT_OK, Defect.DEFECT_OK_B]
|
isinstance(notok_sign_or_defect, Defect) and notok_sign_or_defect.okcate in [Defect.DEFECT_OK, Defect.DEFECT_OK_B]
|
||||||
) else WMaterial.WM_NOTOK
|
) else WMaterial.WM_NOTOK
|
||||||
|
|
Loading…
Reference in New Issue