|
@@ -5,13 +5,16 @@ import com.etotem.cfc.dto.HealthAnalysisResult;
|
|
|
import com.etotem.cfc.dto.ParsedDiseaseRisk;
|
|
import com.etotem.cfc.dto.ParsedDiseaseRisk;
|
|
|
import com.etotem.cfc.dto.ParsedGutFlora;
|
|
import com.etotem.cfc.dto.ParsedGutFlora;
|
|
|
import com.etotem.cfc.dto.ParsedIndicator;
|
|
import com.etotem.cfc.dto.ParsedIndicator;
|
|
|
|
|
+import com.etotem.cfc.dto.ParsedFoodSuitability;
|
|
|
import com.etotem.cfc.dto.ParsedReportResult;
|
|
import com.etotem.cfc.dto.ParsedReportResult;
|
|
|
|
|
+import com.etotem.cfc.entity.Food;
|
|
|
import com.etotem.cfc.entity.HealthDiseaseRisk;
|
|
import com.etotem.cfc.entity.HealthDiseaseRisk;
|
|
|
import com.etotem.cfc.entity.HealthGutFlora;
|
|
import com.etotem.cfc.entity.HealthGutFlora;
|
|
|
import com.etotem.cfc.entity.HealthIndicator;
|
|
import com.etotem.cfc.entity.HealthIndicator;
|
|
|
import com.etotem.cfc.entity.HealthReport;
|
|
import com.etotem.cfc.entity.HealthReport;
|
|
|
import com.etotem.cfc.entity.NutritionDeficiencyRecord;
|
|
import com.etotem.cfc.entity.NutritionDeficiencyRecord;
|
|
|
import com.etotem.cfc.entity.NutritionIndicatorMapping;
|
|
import com.etotem.cfc.entity.NutritionIndicatorMapping;
|
|
|
|
|
+import com.etotem.cfc.mapper.FoodMapper;
|
|
|
import com.etotem.cfc.service.ChildNutritionProfileService;
|
|
import com.etotem.cfc.service.ChildNutritionProfileService;
|
|
|
import com.etotem.cfc.service.HealthAnalysisService;
|
|
import com.etotem.cfc.service.HealthAnalysisService;
|
|
|
import com.etotem.cfc.service.HealthReportService;
|
|
import com.etotem.cfc.service.HealthReportService;
|
|
@@ -59,6 +62,9 @@ public class HealthReportController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private HealthAnalysisService healthAnalysisService;
|
|
private HealthAnalysisService healthAnalysisService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private FoodMapper foodMapper;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 创建健康报告(含指标明细)
|
|
* 创建健康报告(含指标明细)
|
|
|
*/
|
|
*/
|
|
@@ -367,7 +373,32 @@ public class HealthReportController {
|
|
|
// 9. 创建完整报告
|
|
// 9. 创建完整报告
|
|
|
HealthReport created = healthReportService.createReport(report, indicators, gutFloraList, diseaseRiskList);
|
|
HealthReport created = healthReportService.createReport(report, indicators, gutFloraList, diseaseRiskList);
|
|
|
|
|
|
|
|
- // 10. 返回详情(包含匹配信息)
|
|
|
|
|
|
|
+ // 10. 保存食材推荐数据
|
|
|
|
|
+ if (parsed.getFoodSuitability() != null && !parsed.getFoodSuitability().isEmpty()) {
|
|
|
|
|
+ int sortOrder = 0;
|
|
|
|
|
+ for (ParsedFoodSuitability pfs : parsed.getFoodSuitability()) {
|
|
|
|
|
+ Food food = new Food();
|
|
|
|
|
+ food.setReportId(created.getId());
|
|
|
|
|
+ food.setName(pfs.getFoodName());
|
|
|
|
|
+ food.setCategory(pfs.getCategory());
|
|
|
|
|
+ food.setScore(pfs.getScore());
|
|
|
|
|
+ food.setEnergyKj(pfs.getEnergyKj());
|
|
|
|
|
+ food.setProtein(pfs.getProtein());
|
|
|
|
|
+ food.setFat(pfs.getFat());
|
|
|
|
|
+ food.setCarbs(pfs.getCarbs());
|
|
|
|
|
+ food.setStarch(pfs.getStarch());
|
|
|
|
|
+ food.setFiber(pfs.getFiber());
|
|
|
|
|
+ food.setCholesterol(pfs.getCholesterol());
|
|
|
|
|
+ food.setStatus("recommended");
|
|
|
|
|
+ food.setSortOrder(sortOrder++);
|
|
|
|
|
+ food.setCreatedAt(new Date());
|
|
|
|
|
+ food.setUpdatedAt(new Date());
|
|
|
|
|
+ foodMapper.insert(food);
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("已保存{}条食材推荐", parsed.getFoodSuitability().size());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 11. 返回详情(包含匹配信息)
|
|
|
Map<String, Object> detail = healthReportService.getReportDetail(created.getId());
|
|
Map<String, Object> detail = healthReportService.getReportDetail(created.getId());
|
|
|
detail.put("matchedMemberName", matchedMemberName);
|
|
detail.put("matchedMemberName", matchedMemberName);
|
|
|
detail.put("extractedReportNumber", parsed.getReportNumber());
|
|
detail.put("extractedReportNumber", parsed.getReportNumber());
|