fix: Ð޸´Ԥ¾¯ÉèÖÃÖÐãÐֵΪ null µ¼Öºó¶Ë 500 ±ÀÀ£µÄÎÊÌ⣬²¢Ôö¼Óǰºó¶˰²ȫУÑé

This commit is contained in:
DXC
2026-03-11 17:06:19 +08:00
parent 25fbb293df
commit 6b932f79a8
2 changed files with 21 additions and 8 deletions

View File

@ -371,18 +371,21 @@ def batch_set_warning():
# 更新现有记录
if 'isEnabled' in item:
warning.is_enabled = bool(item['isEnabled'])
if 'yellowThreshold' in item:
warning.yellow_threshold = item['yellowThreshold']
if 'redThreshold' in item:
warning.red_threshold = item['redThreshold']
# 安全转换阈值None 默认转为 0
yellow_val = item.get('yellowThreshold')
red_val = item.get('redThreshold')
warning.yellow_threshold = float(yellow_val) if yellow_val is not None else 0
warning.red_threshold = float(red_val) if red_val is not None else 0
updated_count += 1
else:
# 创建新记录
yellow_val = item.get('yellowThreshold')
red_val = item.get('redThreshold')
warning = MaterialWarningSetting(
base_id=base_id,
is_enabled=item.get('isEnabled', False),
yellow_threshold=item.get('yellowThreshold'),
red_threshold=item.get('redThreshold')
yellow_threshold=float(yellow_val) if yellow_val is not None else 0,
red_threshold=float(red_val) if red_val is not None else 0
)
db.session.add(warning)
created_count += 1