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: