fix: mlogbupdate时attrs遍历时修改的bug

This commit is contained in:
caoqianming 2025-04-24 13:36:18 +08:00
parent 0f728d8b29
commit 1cb4128be2
1 changed files with 11 additions and 11 deletions

View File

@ -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