i国网:一周菜谱

This commit is contained in:
sxu 2025-07-08 14:14:57 +08:00
parent e779c5c94a
commit 9a35ef9a9d
2 changed files with 23 additions and 1 deletions

View File

@ -19,7 +19,7 @@ import javax.validation.Valid;
*/
@Api(tags = "菜谱h5接口")
@RestController
@RequestMapping("/zhhq_cook_recipe")
@RequestMapping("/api/zhhq/cook_recipe")
@Slf4j
public class ZhhqCookRecipeController extends BaseController {
@Autowired

View File

@ -12,6 +12,8 @@ import com.bonus.canteen.core.zhhq.service.IZhhqCookRecipeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.ArrayList;
@ -50,6 +52,26 @@ public class ZhhqCookRecipeServiceImpl implements IZhhqCookRecipeService {
for (WeekRecipeDetailVO detailVO : recipeDetails) {
Long dishesId = detailVO.getDishesId();
List<WeekRecipeIngredientVO> cookMaterials = zhhqCookRecipeMapper.getCookMaterialById(dishesId);
BigDecimal totalCalories = cookMaterials.stream()
.map(WeekRecipeIngredientVO::getCalories)
.filter(amount -> amount != null)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalProtein = cookMaterials.stream()
.map(WeekRecipeIngredientVO::getProtein)
.filter(amount -> amount != null)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalFat = cookMaterials.stream()
.map(WeekRecipeIngredientVO::getFat)
.filter(amount -> amount != null)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalCarbohydrate = cookMaterials.stream()
.map(WeekRecipeIngredientVO::getCarbohydrate)
.filter(amount -> amount != null)
.reduce(BigDecimal.ZERO, BigDecimal::add);
detailVO.setCalories(totalCalories);
detailVO.setProtein(totalProtein);
detailVO.setFat(totalFat);
detailVO.setCarbohydrate(totalCarbohydrate);
detailVO.setIngredients(cookMaterials);
}
//组装原料及营养信息