Merge pull request 'dev_cqm' (#7) from dev_cqm into master
Reviewed-on: http://gitea.xxhhcty.xyz:8080/zcdsj/factory/pulls/7
This commit is contained in:
commit
92c3fd60ca
|
|
@ -0,0 +1,16 @@
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wpm', '0130_handover_clear_defect'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='mlog',
|
||||
name='clear_defect',
|
||||
field=models.BooleanField(default=False, verbose_name='合格B类缺陷不拆批'),
|
||||
),
|
||||
]
|
||||
|
|
@ -242,6 +242,7 @@ class Mlog(CommonADModel):
|
|||
reminder_interval_list = models.JSONField('提醒间隔', default=list, blank=True)
|
||||
stored_mgroup = models.BooleanField('入库到工段', default=False)
|
||||
stored_notok = models.BooleanField('不合格品是否已入库', default=False)
|
||||
clear_defect = models.BooleanField('合格B类缺陷不拆批', default=False)
|
||||
route = models.ForeignKey(Route, verbose_name='生产路线', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
mtask = models.ForeignKey(
|
||||
Mtask, verbose_name='关联任务', on_delete=models.CASCADE, null=True, blank=True, related_name='mlog_mtask')
|
||||
|
|
|
|||
|
|
@ -731,7 +731,7 @@ class MlogInitSerializer(CustomModelSerializer):
|
|||
class MlogChangeSerializer(CustomModelSerializer):
|
||||
class Meta:
|
||||
model = Mlog
|
||||
fields = ['id', 'work_start_time', 'work_end_time', 'handle_user', 'note', 'oinfo_json', 'test_file', 'test_user', 'test_time', 'equipment', "team"]
|
||||
fields = ['id', 'work_start_time', 'work_end_time', 'handle_user', 'note', 'oinfo_json', 'test_file', 'test_user', 'test_time', 'equipment', "team", "clear_defect"]
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
work_start_time = validated_data.get('work_start_time', None)
|
||||
|
|
|
|||
|
|
@ -282,9 +282,13 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
|
||||
|
||||
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
||||
clear_defect = bool(mlog.clear_defect)
|
||||
if mlogb_out_qs.exists():
|
||||
mlogb_out_qs = mlogb_out_qs.filter(need_inout=True)
|
||||
m_outs_list = [(mo.material_out, mo.batch if mo.batch else mlog.batch, mo.count_ok_full if mo.count_ok_full is not None else mo.count_ok, mlog.count_real_eweight, None, mo) for mo in mlogb_out_qs.all()]
|
||||
if clear_defect:
|
||||
m_outs_list = [(mo.material_out, mo.batch if mo.batch else mlog.batch, mo.count_ok, mlog.count_real_eweight, None, mo) for mo in mlogb_out_qs.all()]
|
||||
else:
|
||||
m_outs_list = [(mo.material_out, mo.batch if mo.batch else mlog.batch, mo.count_ok_full if mo.count_ok_full is not None else mo.count_ok, mlog.count_real_eweight, None, mo) for mo in mlogb_out_qs.all()]
|
||||
if stored_notok:
|
||||
for item in mlogb_out_qs:
|
||||
mbd_qs = MlogbDefect.get_defect_qs_from_mlogb(item)
|
||||
|
|
@ -293,6 +297,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
# Mlogbw.cal_count_notok(item)
|
||||
for itemx in mbd_qs:
|
||||
if itemx.count > 0:
|
||||
if clear_defect and itemx.defect and itemx.defect.okcate == Defect.DEFECT_OK_B:
|
||||
continue
|
||||
m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, item))
|
||||
# # 获取所有主要的不合格项/先暂时保留
|
||||
# bw_qs = Mlogbw.objects.filter(mlogb=item)
|
||||
|
|
@ -435,11 +441,17 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
# 有多个产物的情况
|
||||
# 需要考虑不合格品退回的情况
|
||||
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
||||
clear_defect = bool(mlog.clear_defect)
|
||||
if mlogb_out_qs.exists():
|
||||
mlogb_out_qs = mlogb_out_qs.filter(need_inout=True)
|
||||
m_outs_list = [
|
||||
(mo.material_out, mo.batch if mo.batch else mlog.batch, mo.count_ok_full if mo.count_ok_full is not None else mo.count_ok, mlog.count_real_eweight, None, mo)
|
||||
for mo in mlogb_out_qs.all()]
|
||||
if clear_defect:
|
||||
m_outs_list = [
|
||||
(mo.material_out, mo.batch if mo.batch else mlog.batch, mo.count_ok, mlog.count_real_eweight, None, mo)
|
||||
for mo in mlogb_out_qs.all()]
|
||||
else:
|
||||
m_outs_list = [
|
||||
(mo.material_out, mo.batch if mo.batch else mlog.batch, mo.count_ok_full if mo.count_ok_full is not None else mo.count_ok, mlog.count_real_eweight, None, mo)
|
||||
for mo in mlogb_out_qs.all()]
|
||||
if stored_notok:
|
||||
for item in mlogb_out_qs:
|
||||
mbd_qs = MlogbDefect.get_defect_qs_from_mlogb(item)
|
||||
|
|
@ -448,6 +460,8 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
# Mlogbw.cal_count_notok(item)
|
||||
for itemx in mbd_qs:
|
||||
if itemx.count > 0:
|
||||
if clear_defect and itemx.defect and itemx.defect.okcate == Defect.DEFECT_OK_B:
|
||||
continue
|
||||
m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, item))
|
||||
# if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||
# # 获取所有主要的不合格项
|
||||
|
|
|
|||
Loading…
Reference in New Issue