From c02bb6d3db301a63cbbd1a7aa8ec2b361a6d2480 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 13 Jun 2025 09:03:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mlog=20=E6=95=B0=E5=80=BC=E8=AE=A1?= =?UTF-8?q?=E7=AE=97bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/models.py | 2 +- apps/wpm/serializers.py | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/wpm/models.py b/apps/wpm/models.py index fdbe51d9..a1920d26 100644 --- a/apps/wpm/models.py +++ b/apps/wpm/models.py @@ -316,7 +316,7 @@ class Mlog(CommonADModel): 通过mlogb计算mlog count 合计 """ mlog = self - if mlog.fill_way == Mlog.MLOG_23: + if mlog.fill_way in [Mlog.MLOG_23, Mlog.MLOG_12]: a_dict = { "total_count_use": Sum('count_use'), "total_count_break": Sum('count_break'), diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 0873e902..ab7eb67a 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -579,20 +579,21 @@ class MlogSerializer(CustomModelSerializer): supplier = attrs.get('supplier', None) if not supplier: raise ParseError('外协必须选择外协单位') + mtask = attrs.get('mtask', None) - count_notok = 0 - for i in attrs: - if 'count_n_' in i: - if attrs[i] < 0: - raise ParseError(f'{attrs[i]}不能小于0') - count_notok = count_notok + attrs[i] - attrs['count_notok'] = count_notok + mlogdefect = attrs.get('mlogdefect', None) + if mlogdefect is None: + count_notok = 0 + for i in attrs: + if 'count_n_' in i: + if attrs[i] < 0: + raise ParseError(f'{attrs[i]}不能小于0') + count_notok = count_notok + attrs[i] + attrs['count_notok'] = count_notok if attrs['count_ok'] < 0: raise ParseError('合格数量不能小于0') - if attrs['count_real'] >= attrs['count_ok'] + attrs['count_notok']: - pass - else: - raise ParseError('生产数量不能小于合格数量') + if attrs['count_real'] != attrs['count_ok'] + attrs['count_notok']: + raise ParseError('生产数量需等于合格数量+不合格数量') if mtask: if mtask.start_date == mtask.end_date: attrs['handle_date'] = mtask.start_date