feat(material): 物料列表接口返回预警邮箱字段,弹窗打开时可正确回显

This commit is contained in:
DXC
2026-05-12 14:59:31 +08:00
parent 8356774a8a
commit d4bf7c5e99
2 changed files with 11 additions and 3 deletions

View File

@ -187,7 +187,9 @@ class MaterialBaseService:
inner_sub.c.total_avail,
MaterialWarningSetting.is_enabled.label('warning_enabled'),
MaterialWarningSetting.yellow_threshold.label('warning_yellow'),
MaterialWarningSetting.red_threshold.label('warning_red')
MaterialWarningSetting.red_threshold.label('warning_red'),
MaterialWarningSetting.red_emails.label('warning_red_emails'),
MaterialWarningSetting.yellow_emails.label('warning_yellow_emails')
).outerjoin(inner_sub, MaterialBase.id == inner_sub.c.base_id) \
.outerjoin(MaterialWarningSetting, MaterialBase.id == MaterialWarningSetting.base_id)
@ -441,6 +443,8 @@ class MaterialBaseService:
warning_enabled = row[3] if len(row) > 3 else False
warning_yellow = row[4] if len(row) > 4 else 0
warning_red = row[5] if len(row) > 5 else 0
warning_red_emails = row[6] if len(row) > 6 else None
warning_yellow_emails = row[7] if len(row) > 7 else None
# 安全兜底
if not hasattr(item, 'to_dict'):
@ -455,6 +459,8 @@ class MaterialBaseService:
item_dict['warningEnabled'] = bool(warning_enabled) if warning_enabled is not None else False
item_dict['warningYellow'] = float(warning_yellow) if warning_yellow is not None else None
item_dict['warningRed'] = float(warning_red) if warning_red is not None else None
item_dict['warningRedEmails'] = warning_red_emails or ''
item_dict['warningYellowEmails'] = warning_yellow_emails or ''
# 计算预警状态
if warning_enabled: