💖💖作者:计算机毕业设计江挽 💙💙个人简介:曾长期从事计算机专业培训教学,本人也热爱上课教学,语言擅长Java、微信小程序、Python、Golang、安卓Android等,开发项目包括大数据、深度学习、网站、小程序、安卓、算法。平常会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 深度学习实战项目
基于Android开发的健康饮食推荐系统介绍
健康饮食推荐系统是基于SpringBoot+微信小程序+安卓的跨平台应用,采用C/S+B/S混合架构设计,为用户提供全方位的健康饮食管理服务。系统后端采用SpringBoot框架构建RESTful API接口,集成Spring+SpringMVC+MyBatis技术栈,确保数据处理的高效性和稳定性,数据存储采用MySQL关系型数据库管理用户信息、食谱数据、饮食记录等核心业务数据。前端通过uni-app框架实现一套代码多端部署,同时支持微信小程序和安卓应用两个平台,为用户提供便捷的移动端访问体验。系统功能模块包括系统首页展示、用户注册登录管理、适宜人群分类、健康食谱浏览推荐、个人饮食记录追踪、健康数据统计分析、违规内容举报处理、论坛分类管理、饮食交流论坛、系统后台管理以及个人中心设置等完整业务流程。整个系统通过跨平台技术实现了Web端和移动端的无缝对接,用户可以在不同设备间同步使用,既满足了桌面端的管理需求,又提供了移动端的便携性,为用户的日常健康饮食管理提供了全面的技术支持和服务保障。
基于Android开发的健康饮食推荐系统演示视频
基于Android开发的健康饮食推荐系统演示图片
基于Android开发的健康饮食推荐系统代码展示
import org.apache.spark.sql.SparkSession;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
SparkSession spark = SparkSession.builder().appName("HealthDietRecommendation").config("spark.sql.adaptive.enabled", "true").getOrCreate();
@PostMapping("/api/recipe/recommend")
public ResponseEntity<Map<String, Object>> recommendRecipes(@RequestBody Map<String, Object> requestData) {
Integer userId = (Integer) requestData.get("userId");
List<String> healthConditions = (List<String>) requestData.get("healthConditions");
String ageGroup = (String) requestData.get("ageGroup");
User user = userService.getUserById(userId);
List<Recipe> allRecipes = recipeService.getAllActiveRecipes();
List<Recipe> filteredRecipes = new ArrayList<>();
Map<String, Double> conditionWeights = new HashMap<>();
conditionWeights.put("diabetes", 0.8);
conditionWeights.put("hypertension", 0.7);
conditionWeights.put("obesity", 0.9);
conditionWeights.put("normal", 1.0);
for (Recipe recipe : allRecipes) {
double baseScore = recipe.getNutritionScore();
double adjustedScore = baseScore;
for (String condition : healthConditions) {
if (conditionWeights.containsKey(condition)) {
adjustedScore *= conditionWeights.get(condition);
}
}
if ("elderly".equals(ageGroup)) {
adjustedScore *= (recipe.getCalories() < 500 ? 1.2 : 0.8);
} else if ("young".equals(ageGroup)) {
adjustedScore *= (recipe.getProtein() > 20 ? 1.1 : 0.9);
}
recipe.setRecommendScore(adjustedScore);
if (adjustedScore > 0.6) {
filteredRecipes.add(recipe);
}
}
filteredRecipes.sort((r1, r2) -> Double.compare(r2.getRecommendScore(), r1.getRecommendScore()));
List<Recipe> topRecipes = filteredRecipes.subList(0, Math.min(20, filteredRecipes.size()));
Map<String, Object> response = new HashMap<>();
response.put("recommendations", topRecipes);
response.put("totalCount", topRecipes.size());
return ResponseEntity.ok(response);
}
@PostMapping("/api/diet/record")
public ResponseEntity<Map<String, Object>> recordDietData(@RequestBody Map<String, Object> requestData) {
Integer userId = (Integer) requestData.get("userId");
List<Map<String, Object>> foodItems = (List<Map<String, Object>>) requestData.get("foodItems");
String recordDate = (String) requestData.get("recordDate");
DietRecord dietRecord = new DietRecord();
dietRecord.setUserId(userId);
dietRecord.setRecordDate(LocalDate.parse(recordDate, DateTimeFormatter.ISO_LOCAL_DATE));
double totalCalories = 0.0;
double totalProtein = 0.0;
double totalCarbs = 0.0;
double totalFat = 0.0;
List<DietItem> dietItems = new ArrayList<>();
for (Map<String, Object> foodItem : foodItems) {
String foodName = (String) foodItem.get("foodName");
Double quantity = (Double) foodItem.get("quantity");
Food food = foodService.getFoodByName(foodName);
if (food != null) {
DietItem dietItem = new DietItem();
dietItem.setFoodId(food.getId());
dietItem.setFoodName(foodName);
dietItem.setQuantity(quantity);
dietItem.setCalories(food.getCaloriesPerUnit() * quantity);
dietItem.setProtein(food.getProteinPerUnit() * quantity);
dietItem.setCarbs(food.getCarbsPerUnit() * quantity);
dietItem.setFat(food.getFatPerUnit() * quantity);
dietItems.add(dietItem);
totalCalories += dietItem.getCalories();
totalProtein += dietItem.getProtein();
totalCarbs += dietItem.getCarbs();
totalFat += dietItem.getFat();
}
}
dietRecord.setTotalCalories(totalCalories);
dietRecord.setTotalProtein(totalProtein);
dietRecord.setTotalCarbs(totalCarbs);
dietRecord.setTotalFat(totalFat);
dietRecord.setDietItems(dietItems);
User user = userService.getUserById(userId);
double recommendedCalories = calculateRecommendedCalories(user);
String nutritionStatus = "normal";
if (totalCalories < recommendedCalories * 0.8) {
nutritionStatus = "insufficient";
} else if (totalCalories > recommendedCalories * 1.2) {
nutritionStatus = "excessive";
}
dietRecord.setNutritionStatus(nutritionStatus);
dietRecordService.saveDietRecord(dietRecord);
Map<String, Object> response = new HashMap<>();
response.put("recordId", dietRecord.getId());
response.put("nutritionSummary", createNutritionSummary(dietRecord));
response.put("recommendations", generateDietRecommendations(nutritionStatus));
return ResponseEntity.ok(response);
}
@GetMapping("/api/health/analysis/{userId}")
public ResponseEntity<Map<String, Object>> analyzeHealthData(@PathVariable Integer userId, @RequestParam String startDate, @RequestParam String endDate) {
LocalDate start = LocalDate.parse(startDate, DateTimeFormatter.ISO_LOCAL_DATE);
LocalDate end = LocalDate.parse(endDate, DateTimeFormatter.ISO_LOCAL_DATE);
List<DietRecord> dietRecords = dietRecordService.getDietRecordsByUserAndDateRange(userId, start, end);
List<HealthData> healthData = healthDataService.getHealthDataByUserAndDateRange(userId, start, end);
Map<LocalDate, Double> dailyCalories = new HashMap<>();
Map<LocalDate, Double> dailyProtein = new HashMap<>();
Map<LocalDate, Double> dailyWeight = new HashMap<>();
for (DietRecord record : dietRecords) {
dailyCalories.put(record.getRecordDate(), record.getTotalCalories());
dailyProtein.put(record.getRecordDate(), record.getTotalProtein());
}
for (HealthData health : healthData) {
dailyWeight.put(health.getRecordDate(), health.getWeight());
}
double avgCalories = dailyCalories.values().stream().mapToDouble(Double::doubleValue).average().orElse(0.0);
double avgProtein = dailyProtein.values().stream().mapToDouble(Double::doubleValue).average().orElse(0.0);
List<LocalDate> sortedDates = dailyWeight.keySet().stream().sorted().collect(toList());
double weightTrend = 0.0;
if (sortedDates.size() >= 2) {
double startWeight = dailyWeight.get(sortedDates.get(0));
double endWeight = dailyWeight.get(sortedDates.get(sortedDates.size() - 1));
weightTrend = endWeight - startWeight;
}
String healthStatus = "stable";
if (Math.abs(weightTrend) > 2.0) {
healthStatus = weightTrend > 0 ? "gaining" : "losing";
}
List<String> suggestions = generateHealthSuggestions(avgCalories, avgProtein, weightTrend);
Map<String, Object> analysisResult = new HashMap<>();
analysisResult.put("avgCalories", Math.round(avgCalories * 100.0) / 100.0);
analysisResult.put("avgProtein", Math.round(avgProtein * 100.0) / 100.0);
analysisResult.put("weightTrend", Math.round(weightTrend * 100.0) / 100.0);
analysisResult.put("healthStatus", healthStatus);
analysisResult.put("suggestions", suggestions);
analysisResult.put("dataPoints", dietRecords.size());
return ResponseEntity.ok(analysisResult);
}
基于Android开发的健康饮食推荐系统文档展示
💖💖作者:计算机毕业设计江挽 💙💙个人简介:曾长期从事计算机专业培训教学,本人也热爱上课教学,语言擅长Java、微信小程序、Python、Golang、安卓Android等,开发项目包括大数据、深度学习、网站、小程序、安卓、算法。平常会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 深度学习实战项目