v3 增加并优化了人工评价逻辑,增加了运动量(PAL)判断
This commit is contained in:
1 parent
86567eece5
commit
2e69000c5b
22 files changed
+2250
-332
No files matched your search
+25
-8
@@ -121,7 +121,7 @@ class NutritionPDFBuilder:
|
||||
|
||||
[
|
||||
Paragraph("总能量", normal),
|
||||
Paragraph(f"{n['energy']['value']} kcal/day", normal),
|
||||
Paragraph(self._format_energy_intake(n["energy"]), normal),
|
||||
Paragraph(n["energy"]["evaluation"], normal)
|
||||
],
|
||||
|
||||
@@ -138,16 +138,26 @@ class NutritionPDFBuilder:
|
||||
],
|
||||
]
|
||||
|
||||
# ===== 解读(适中间距)=====
|
||||
interpretation = []
|
||||
# ===== 解读 =====
|
||||
if data.get("interpretation"):
|
||||
text = "<br/>".join(
|
||||
line.strip()
|
||||
for line in data["interpretation"].splitlines()
|
||||
if line.strip()
|
||||
)
|
||||
else:
|
||||
interpretation = []
|
||||
|
||||
if n["energy"]["evaluation"] == "不足":
|
||||
interpretation.append("能量摄入不足,应增加碳水化合物摄入")
|
||||
if n["energy"]["evaluation"] == "不足":
|
||||
interpretation.append("能量摄入不足,应增加碳水化合物摄入")
|
||||
|
||||
if n["calcium"]["evaluation"] == "不足":
|
||||
interpretation.append("钙摄入不足,应增加奶制品摄入")
|
||||
if n["energy"]["evaluation"] == "偏高":
|
||||
interpretation.append("能量摄入偏高,应适当控制总能量摄入")
|
||||
|
||||
text = "<br/>".join(interpretation)
|
||||
if n["calcium"]["evaluation"] == "不足":
|
||||
interpretation.append("钙摄入不足,应增加奶制品摄入")
|
||||
|
||||
text = "<br/>".join(interpretation)
|
||||
|
||||
energy_table.append([
|
||||
Paragraph("解读", normal),
|
||||
@@ -180,6 +190,13 @@ class NutritionPDFBuilder:
|
||||
|
||||
doc.build(story)
|
||||
|
||||
def _format_energy_intake(self, energy_info):
|
||||
value = energy_info.get("value", "-")
|
||||
standard = energy_info.get("standard")
|
||||
if standard:
|
||||
return f"{value} kcal/day<br/>(标准 {standard} kcal)"
|
||||
return f"{value} kcal/day"
|
||||
|
||||
# ================= 图片 =================
|
||||
def _get_image(self, category):
|
||||
|
||||
|
||||
Reference in new issue
Block a user