From 1cb4128be206011e1e13436f728ed76ab0c6c56e Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 24 Apr 2025 13:36:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mlogbupdate=E6=97=B6attrs=E9=81=8D?= =?UTF-8?q?=E5=8E=86=E6=97=B6=E4=BF=AE=E6=94=B9=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/serializers.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index ba3fab46..8049813a 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -885,17 +885,17 @@ class MlogbOutUpdateSerializer(CustomModelSerializer): mlogbdefect = attrs.get("mlogbdefect", []) if mlogbdefect: attrs.pop("count_notok_json", None) - for i in attrs: - if 'count_n_' in i: - attrs.pop(i, None) + for k in list(attrs.keys()): + if 'count_n_' in k: + attrs.pop(k, None) else: count_notok_json = attrs.get('count_notok_json', []) # count_notok_json字段处理 if count_notok_json: # 先置0字段 - for i in attrs: - if 'count_n_' in i: - i = 0 + for k in list(attrs.keys()): + if 'count_n_' in k: + attrs[k] = 0 count_notok_dict = {} for item in count_notok_json: notok = item['notok'] @@ -911,11 +911,11 @@ class MlogbOutUpdateSerializer(CustomModelSerializer): attrs[k] = v count_notok = 0 - for i in attrs: - if 'count_n_' in i: - if not hasattr(Mlogb, i): - raise ParseError(f'{i}不存在') - count_notok = count_notok + attrs[i] + for k in list(attrs.keys()): + if 'count_n_' in k: + if not hasattr(Mlogb, k): + raise ParseError(f'{k}不存在') + count_notok = count_notok + attrs[k] attrs['count_notok'] = count_notok if attrs['count_real'] >= attrs['count_ok'] + attrs['count_notok']: pass