From ab0c962053dd9ce124c8b7c27a80ece8413be93b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 13 Jun 2025 16:22:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mlogbin=E8=81=94=E5=8A=A8mlogbout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/serializers.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 5eafc17f..0406caeb 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -788,14 +788,20 @@ class MlogbInUpdateSerializer(CustomModelSerializer): ] if mlogb_defect_objects: MlogbDefect.objects.bulk_create(mlogb_defect_objects) - ins.cal_count_notok(cal_mlog=False) # 只有普通工序的才可联动 - # route:Route = mlog.route - # if route and route.process and route.process.mtype == Process.PRO_NORMAL: - # mlogbout_qs = Mlogb.objects.filter(mlog=ins.mlog, mlogb_from=ins) - # if mlogbout_qs.count() == 1: - # mlogbout = mlogbout_qs.first() - # mlogbout.count_real = ins.count_use - ins.count_pn_jgqbl + route:Route = mlog.route + if route and route.process and route.process.mtype == Process.PRO_NORMAL: + mlogbout_qs = Mlogb.objects.filter(mlog=ins.mlog, mlogb_from=ins) + if mlogbout_qs.count() == 1: + mlogbout = mlogbout_qs.first() + mlogbout.count_real = ins.count_use - ins.count_pn_jgqbl - ins.count_break + mlogbout.count_ok = mlogbout.count_real - mlogbout.count_notok + if mlogbout.count_real < 0 or mlogbout.count_ok < 0: + raise ParseError("对应的产出数异常") + mlogbout.save(update_fields=["count_real", "count_ok"]) + mlogbout.cal_count_notok(cal_mlog=False) + ins.cal_count_notok(cal_mlog=False) + return ins