From 9e4e5a28c61eb2b5361f6b98aebba1789b0bd516 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sat, 19 Apr 2025 21:11:45 +0800 Subject: [PATCH] =?UTF-8?q?fix::=20=E4=BA=A4=E6=8E=A5=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=97=B6=E6=A0=A1=E9=AA=8Ccount>0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/serializers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 66c75bdb..f90c6596 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -564,8 +564,12 @@ class MlogSerializer(CustomModelSerializer): 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: @@ -991,6 +995,10 @@ class HandoverSerializer(CustomModelSerializer): t_count = 0 tracking = attrs["material"].tracking for ind, item in enumerate(attrs['handoverb']): + if item["count"] > 0: + pass + else: + raise ParseError(f'第{ind+1}行-交接数量必须大于0') wm = item["wm"] if mtype == Handover.H_MERGE: if new_state is None: