外食计算优化,添加详情功能

This commit is contained in:
xiezhijun 2021-02-23 15:35:50 +08:00
parent 473ccef008
commit c1a937adf4
12 changed files with 382 additions and 82 deletions

View File

@ -6,14 +6,7 @@ import com.stdiet.custom.domain.SysCustomerHeatStatistics;
import com.stdiet.custom.service.ISysCustomerHeatStatisticsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.stdiet.common.annotation.Log;
import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult;
@ -111,4 +104,14 @@ public class SysFoodHeatStatisticsController extends BaseController
{
return toAjax(sysCustomerHeatStatisticsService.calculateCustomerHeat(sysCustomerHeatStatistics));
}
/**
* 查看外食热量统计详细信息
*/
@PreAuthorize("@ss.hasPermi('custom:foodHeatStatistics:query')")
@GetMapping(value = "/getNutritionalCalories")
public AjaxResult getNutritionalCalories(@RequestParam("id") Long id)
{
return AjaxResult.success(sysCustomerHeatStatisticsService.getNutritionalCaloriesByCustomerHeatId(id));
}
}

View File

@ -23,7 +23,7 @@ public class HealthyUtils {
* @param weight 体重
* @return
*/
public static long calculateMaxHeatEveryDay(Integer age, Integer tall, Double weight){
public static Long calculateMaxHeatEveryDay(Integer age, Integer tall, Double weight){
age = age == null ? 0 : age;
tall = tall == null ? 0 : tall;
weight = weight == null ? 0.0 : weight;
@ -47,8 +47,8 @@ public class HealthyUtils {
* @param weight 体重
* @return
*/
public static double calculateHeatRateByWeight(long metabolizeHeat, double weight){
return NumberUtils.getNumberByRoundHalfUp(metabolizeHeat/weight*2, 2).doubleValue();
public static Long calculateHeatRateByWeight(Integer metabolizeHeat, Double weight){
return Math.round(metabolizeHeat/weight*2);
}
/**
@ -56,8 +56,8 @@ public class HealthyUtils {
* @param heatRateByWeight 每公斤体重占比千卡/公斤
* @return
*/
public static double[] calculateHeatTargetRate(double heatRateByWeight){
double[] heatArray = new double[2];
public static Long[] calculateHeatTargetRate(Long heatRateByWeight){
Long[] heatArray = new Long[2];
heatArray[0] = heatRateByWeight - 10;
heatArray[1] = heatRateByWeight - 5;
return heatArray;
@ -66,13 +66,13 @@ public class HealthyUtils {
/**
* 计算减脂热量控制范围(千卡
* @param heatTargetRateArray 每公斤体重占比目标范围
* @param fatRateWeight 每公斤体重脂肪占比(/公斤)
* @param weight 体重
* @return
*/
public static long[] calculateStandardHeatScopeRate(double[] heatTargetRateArray, double fatRateWeight){
long[] heatArray = new long[2];
heatArray[0] = Math.round(heatTargetRateArray[0] * fatRateWeight / 2);
heatArray[1] = Math.round(heatTargetRateArray[1] * fatRateWeight / 2);
public static Long[] calculateStandardHeatScopeRate(Long[] heatTargetRateArray, Double weight){
Long[] heatArray = new Long[2];
heatArray[0] = Math.round(heatTargetRateArray[0] * weight / 2);
heatArray[1] = Math.round(heatTargetRateArray[1] * weight / 2);
return heatArray;
}
@ -121,12 +121,12 @@ public class HealthyUtils {
* @return
*/
public static double calculateStandardWeight(int tall){
return (tall-107.5)*2;
return NumberUtils.getNumberByRoundHalfUp((tall-107.5)*2, 1).doubleValue();
}
/**
* 返回蛋白质脂肪碳水对应热量质量
* @param metabolizeHeat
* @param metabolizeHeat 摄入热量
* @return
*/
public static Integer[][] calculateNutritionHeatAndQuality(int metabolizeHeat){
@ -134,7 +134,7 @@ public class HealthyUtils {
Integer[] qualityArray = new Integer[3];
heatArray[0] = Math.round(nutritionRate[0] * metabolizeHeat /100);
heatArray[1] = Math.round(nutritionRate[1] * metabolizeHeat /100);
heatArray[2] = Math.round(nutritionRate[2] * metabolizeHeat /100);
heatArray[2] = Math.round(metabolizeHeat - heatArray[0] - heatArray[1]);
qualityArray[0] = (int)Math.round(Double.parseDouble(heatArray[0]+"")/proteinHeat);
qualityArray[1] = (int)Math.round(Double.parseDouble(heatArray[1]+"")/fatHeat);
qualityArray[2] = (int)Math.round(Double.parseDouble(heatArray[2]+"")/carbonWaterHeat);
@ -142,4 +142,19 @@ public class HealthyUtils {
return result;
}
/**
* 计算每公斤体重占比(/公斤)
* @param nutritionQuality 蛋白质脂肪碳水对应质量
* @param weight 体重
* @return
*/
public static final Double[] calculateNutritionEveryWeight(Integer[] nutritionQuality, double weight){
Double[] nutritionEveryWeight = new Double[3];
nutritionEveryWeight[0] = NumberUtils.getNumberByRoundHalfUp(nutritionQuality[0]/weight*2,2).doubleValue();
nutritionEveryWeight[1] = NumberUtils.getNumberByRoundHalfUp(nutritionQuality[1]/weight*2,2).doubleValue();
nutritionEveryWeight[2] = NumberUtils.getNumberByRoundHalfUp(nutritionQuality[2]/weight*2, 2).doubleValue();
return nutritionEveryWeight;
}
}

View File

@ -39,6 +39,18 @@ public class SysCustomerHeatStatistics extends BaseEntity
@Excel(name = "当天食材总热量")
private Integer heatValue;
/** 当天摄入蛋白质热量 */
@Excel(name = "当天摄入蛋白质热量")
private Integer proteinHeat;
/** 当天摄入脂肪热量 */
@Excel(name = "当天摄入脂肪热量")
private Integer fatHeat;
/** 当天摄入碳水热量 */
@Excel(name = "当天摄入碳水热量")
private Integer carbonWaterHeat;
/** 当天热量缺口 */
@Excel(name = "当天热量缺口")
private Integer heatGap;

View File

@ -56,6 +56,12 @@ public class SysFoodHeatStatistics extends BaseEntity
@Excel(name = "碳水质量,克")
private Integer carbonWaterQuality;
private Integer proteinHeat;
private Integer fatHeat;
private Integer carbonWaterHeat;
/** 热量数值 */
@Excel(name = "热量数值")
private Integer heatValue;

View File

@ -13,43 +13,43 @@ public class NutritionalCalories implements Serializable {
public String name;
//实际体重
public double weight;
public Double weight;
//实际身高(厘米)
public int tall;
public Integer tall;
//年龄
public int age;
public Integer age;
//标准体重
public double standardWeight;
public Double standardWeight;
//超重
public double overWeight;
public Double overWeight;
//活动因子
public double activityFactor;
public Double activityFactor;
//基础代谢BMR(千卡
public int metabolizeHeat;
public Integer metabolizeHeat;
//减脂最大摄入量(千卡
public int maxIntakeHeat;
public Long maxIntakeHeat;
//不运动总热量(千卡
public int withoutExerciseHeat;
public Integer withoutExerciseHeat;
//运动总热量(千卡
public int exerciseHeat;
public Integer exerciseHeat;
//每公斤体重占比(千卡/公斤
public double everyWeightHeat;
public Long everyWeightHeat;
//目标范围千卡/公斤
public double[] targetEveryWeightHeat;
public Long[] targetEveryWeightHeat;
//减脂热量标准范围千卡/公斤
public double[] standardEveryWeightHeat;
public Long[] standardEveryWeightHeat;
//蛋白质脂肪碳水比例
public Integer[] nutritionalRate;
@ -61,7 +61,7 @@ public class NutritionalCalories implements Serializable {
public Integer[] nutritionalQuality;
//每公斤体重对应蛋白质脂肪碳水占比(/公斤)
public double[] weightNutritionalRate;
public Double[] weightNutritionalRate;
//蛋白质脂肪碳水已摄入热量千卡
public Integer[] ingestedNutritionalHeat;

View File

@ -79,5 +79,5 @@ public interface ISysCustomerHeatStatisticsService
* @param id
* @return
*/
public NutritionalCalories getNutritionalCaloriesByCustomer(Long id);
public NutritionalCalories getNutritionalCaloriesByCustomerHeatId(Long id);
}

View File

@ -11,6 +11,7 @@ import com.stdiet.custom.dto.response.NutritionalCalories;
import com.stdiet.custom.service.ISysCustomerHealthyService;
import com.stdiet.custom.service.ISysCustomerPhysicalSignsService;
import com.stdiet.custom.service.ISysFoodHeatStatisticsService;
import com.stdiet.custom.utils.NutritionalUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysCustomerHeatStatisticsMapper;
@ -134,20 +135,29 @@ public class SysCustomerHeatStatisticsServiceImpl implements ISysCustomerHeatSta
Integer[] foodHeat = sysCustomerHeatStatistics.getFoodHeatList();
if(foodHeatId != null && foodHeatId.length > 0){
SysFoodHeatStatistics sysFoodHeatStatistics = new SysFoodHeatStatistics();
int totalHeatCalue = 0;
int totalProteinHeat = 0;
int totalFatHeat = 0;
int totalCarbonWaterHeat = 0;
for (int i = 0; i < foodHeatId.length; i++) {
sysFoodHeatStatistics.setId(foodHeatId[i]);
sysFoodHeatStatistics.setProteinQuality(sysCustomerHeatStatistics.getProteinQualityList()[i]);
sysFoodHeatStatistics.setFatQuality(sysCustomerHeatStatistics.getFatQualityList()[i]);
sysFoodHeatStatistics.setCarbonWaterQuality(sysCustomerHeatStatistics.getCarbonWaterQualityList()[i]);
//根据蛋白质脂肪碳水计算热量
sysFoodHeatStatistics.setHeatValue(HealthyUtils.calculateTotalHeatByProteinFatCarbonWater(sysCustomerHeatStatistics.getProteinQualityList()[i],
sysCustomerHeatStatistics.getFatQualityList()[i], sysCustomerHeatStatistics.getCarbonWaterQualityList()[i]));
sysFoodHeatStatistics.setProteinHeat(HealthyUtils.calculateHeatByProteinQuality(sysCustomerHeatStatistics.getProteinQualityList()[i]));
sysFoodHeatStatistics.setFatHeat(HealthyUtils.calculateHeatByFatQuality(sysCustomerHeatStatistics.getFatQualityList()[i]));
sysFoodHeatStatistics.setCarbonWaterHeat(HealthyUtils.calculateHeatByCarbonWaterQuality(sysCustomerHeatStatistics.getCarbonWaterQualityList()[i]));
sysFoodHeatStatistics.setHeatValue(sysFoodHeatStatistics.getProteinHeat()+sysFoodHeatStatistics.getFatHeat()+sysFoodHeatStatistics.getCarbonWaterHeat());
sysFoodHeatStatisticsService.updateSysFoodHeatStatistics(sysFoodHeatStatistics);
totalHeatCalue += sysFoodHeatStatistics.getHeatValue();
totalProteinHeat += sysFoodHeatStatistics.getProteinHeat();
totalFatHeat += sysFoodHeatStatistics.getFatHeat();
totalCarbonWaterHeat += sysFoodHeatStatistics.getCarbonWaterHeat();
}
sysCustomerHeatStatistics.setHeatValue(totalHeatCalue);
sysCustomerHeatStatistics.setHeatGap(sysCustomerHeatStatistics.getMaxHeatValue() - totalHeatCalue);
sysCustomerHeatStatistics.setHeatValue(totalProteinHeat + totalFatHeat + totalCarbonWaterHeat);
sysCustomerHeatStatistics.setProteinHeat(totalProteinHeat);
sysCustomerHeatStatistics.setFatHeat(totalFatHeat);
sysCustomerHeatStatistics.setCarbonWaterHeat(totalCarbonWaterHeat);
sysCustomerHeatStatistics.setHeatGap(sysCustomerHeatStatistics.getMaxHeatValue() - sysCustomerHeatStatistics.getHeatValue());
return sysCustomerHeatStatisticsMapper.updateSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}
return 0;
@ -158,29 +168,24 @@ public class SysCustomerHeatStatisticsServiceImpl implements ISysCustomerHeatSta
* @param id
* @return
*/
public NutritionalCalories getNutritionalCaloriesByCustomer(Long id){
NutritionalCalories nutritionalCalories = new NutritionalCalories();
@Override
public NutritionalCalories getNutritionalCaloriesByCustomerHeatId(Long id){
NutritionalCalories nutritionalCalories = null;
SysCustomerHeatStatistics sysCustomerHeatStatistics = sysCustomerHeatStatisticsMapper.selectSysCustomerHeatStatisticsById(id);
if(sysCustomerHeatStatistics != null){
SysCustomerHealthy sysCustomerHealthy = getSysCustomerHealthy(sysCustomerHeatStatistics.getCustomerId());
if(sysCustomerHealthy != null){
nutritionalCalories.setName(sysCustomerHealthy.getName());
nutritionalCalories.setAge(sysCustomerHealthy.getAge().intValue());
nutritionalCalories.setTall(sysCustomerHealthy.getTall());
nutritionalCalories.setWeight(sysCustomerHealthy.getWeight().doubleValue());
nutritionalCalories.setStandardWeight(HealthyUtils.calculateStandardWeight(nutritionalCalories.getTall()));
double overHeight = nutritionalCalories.getWeight() - nutritionalCalories.getStandardWeight();
overHeight = overHeight > 0 ? overHeight : 0;
nutritionalCalories.setOverWeight(overHeight);
nutritionalCalories.setMetabolizeHeat(HealthyUtils.calculateMetabolizeHeat(nutritionalCalories.getAge(), nutritionalCalories.getTall(), nutritionalCalories.getWeight()).intValue());
nutritionalCalories.setMaxIntakeHeat(sysCustomerHeatStatistics.getMaxHeatValue());
nutritionalCalories.setEveryWeightHeat(HealthyUtils.calculateHeatRateByWeight(nutritionalCalories.getMetabolizeHeat(), nutritionalCalories.getWeight()));
nutritionalCalories.setTargetEveryWeightHeat(HealthyUtils.calculateHeatTargetRate(nutritionalCalories.getEveryWeightHeat()));
//nutritionalCalories.setStandardEveryWeightHeat(HealthyUtils.calculateHeatTargetRate() );
nutritionalCalories.setNutritionalRate(HealthyUtils.nutritionRate);
Integer[][] nutritionalHeatAndQuality = HealthyUtils.calculateNutritionHeatAndQuality(nutritionalCalories.getMetabolizeHeat());
nutritionalCalories.setNutritionalHeat(nutritionalHeatAndQuality[0]);
nutritionalCalories.setNutritionalQuality(nutritionalHeatAndQuality[1]);
nutritionalCalories = NutritionalUtils.getNutritionalCaloriesData(sysCustomerHealthy);
Integer[] ingestedNutritionalHeat = new Integer[3];
ingestedNutritionalHeat[0] = sysCustomerHeatStatistics.getProteinHeat();
ingestedNutritionalHeat[1] = sysCustomerHeatStatistics.getFatHeat();
ingestedNutritionalHeat[2] = sysCustomerHeatStatistics.getCarbonWaterHeat();
nutritionalCalories.setIngestedNutritionalHeat(ingestedNutritionalHeat);
Integer[] surplusNutritionalHeat = new Integer[3];
surplusNutritionalHeat[0] = nutritionalCalories.getNutritionalHeat()[0] - ingestedNutritionalHeat[0];
surplusNutritionalHeat[1] = nutritionalCalories.getNutritionalHeat()[1] - ingestedNutritionalHeat[1];
surplusNutritionalHeat[2] = nutritionalCalories.getNutritionalHeat()[2] - ingestedNutritionalHeat[2];
nutritionalCalories.setSurplusNutritionalHeat(surplusNutritionalHeat);
}
}
return nutritionalCalories;
@ -207,6 +212,4 @@ public class SysCustomerHeatStatisticsServiceImpl implements ISysCustomerHeatSta
}
return sysCustomerHealthy;
}
}

View File

@ -0,0 +1,38 @@
package com.stdiet.custom.utils;
import com.stdiet.common.utils.HealthyUtils;
import com.stdiet.custom.domain.SysCustomerHealthy;
import com.stdiet.custom.dto.response.NutritionalCalories;
public class NutritionalUtils {
/**
* 根据客户健康信息获营养热量成分比例
* @param sysCustomerHealthy
* @return
*/
public static final NutritionalCalories getNutritionalCaloriesData(SysCustomerHealthy sysCustomerHealthy){
NutritionalCalories nutritionalCalories = new NutritionalCalories();
if(sysCustomerHealthy != null){
nutritionalCalories.setName(sysCustomerHealthy.getName());
nutritionalCalories.setAge(sysCustomerHealthy.getAge().intValue());
nutritionalCalories.setTall(sysCustomerHealthy.getTall());
nutritionalCalories.setWeight(sysCustomerHealthy.getWeight().doubleValue());
nutritionalCalories.setStandardWeight(HealthyUtils.calculateStandardWeight(nutritionalCalories.getTall()));
double overHeight = nutritionalCalories.getWeight() - nutritionalCalories.getStandardWeight();
overHeight = overHeight > 0 ? overHeight : 0;
nutritionalCalories.setOverWeight(overHeight);
nutritionalCalories.setMetabolizeHeat(HealthyUtils.calculateMetabolizeHeat(nutritionalCalories.getAge(), nutritionalCalories.getTall(), nutritionalCalories.getWeight()).intValue());
nutritionalCalories.setMaxIntakeHeat(HealthyUtils.calculateMaxHeatEveryDay(sysCustomerHealthy.getAge().intValue(), sysCustomerHealthy.getTall(), sysCustomerHealthy.getWeight().doubleValue()));
nutritionalCalories.setEveryWeightHeat(HealthyUtils.calculateHeatRateByWeight(nutritionalCalories.getMetabolizeHeat(), nutritionalCalories.getWeight()));
nutritionalCalories.setTargetEveryWeightHeat(HealthyUtils.calculateHeatTargetRate(nutritionalCalories.getEveryWeightHeat()));
nutritionalCalories.setStandardEveryWeightHeat(HealthyUtils.calculateStandardHeatScopeRate(nutritionalCalories.getTargetEveryWeightHeat(), nutritionalCalories.getWeight()));
nutritionalCalories.setNutritionalRate(HealthyUtils.nutritionRate);
Integer[][] nutritionalHeatAndQuality = HealthyUtils.calculateNutritionHeatAndQuality(nutritionalCalories.getMaxIntakeHeat().intValue());
nutritionalCalories.setNutritionalHeat(nutritionalHeatAndQuality[0]);
nutritionalCalories.setNutritionalQuality(nutritionalHeatAndQuality[1]);
nutritionalCalories.setWeightNutritionalRate(HealthyUtils.calculateNutritionEveryWeight(nutritionalHeatAndQuality[1], nutritionalCalories.getWeight()));
}
return nutritionalCalories;
}
}

View File

@ -10,6 +10,9 @@
<result property="edibleDate" column="edible_date" />
<result property="maxHeatValue" column="max_heat_value" />
<result property="heatValue" column="heat_value" />
<result property="proteinHeat" column="protein_heat" />
<result property="fatHeat" column="fat_heat" />
<result property="carbonWaterHeat" column="carbon_water_heat" />
<result property="heatGap" column="heat_gap" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
@ -24,6 +27,9 @@
<result property="edibleDate" column="edible_date" />
<result property="maxHeatValue" column="max_heat_value" />
<result property="heatValue" column="heat_value" />
<result property="proteinHeat" column="protein_heat" />
<result property="fatHeat" column="fat_heat" />
<result property="carbonWaterHeat" column="carbon_water_heat" />
<result property="heatGap" column="heat_gap" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
@ -36,15 +42,13 @@
</resultMap>
<sql id="selectSysCustomerHeatStatisticsVo">
select id, customer_id, edible_date, max_heat_value, heat_value, heat_gap, create_time, create_by, update_time, update_by, del_flag from sys_customer_heat_statistics
select id, customer_id, edible_date, max_heat_value, heat_value, protein_heat,fat_heat,carbon_water_heat,heat_gap, create_time, create_by, update_time, update_by, del_flag from sys_customer_heat_statistics
</sql>
<select id="selectSysCustomerHeatStatisticsList" parameterType="SysCustomerHeatStatistics" resultMap="SysCustomerHeatStatisticsResult">
<include refid="selectSysCustomerHeatStatisticsVo"/>
<where>
<include refid="selectSysCustomerHeatStatisticsVo"/> where del_flag = 0
<if test="customerId != null "> and customer_id = #{customerId}</if>
</where>
order by id desc
order by edible_date desc
</select>
<select id="selectSysCustomerHeatStatisticsById" parameterType="Long" resultMap="SysCustomerHeatStatisticsResultExtended">
@ -60,8 +64,11 @@
<if test="maxHeatValue != null">max_heat_value,</if>
<if test="heatValue != null">heat_value,</if>
<if test="heatGap != null">heat_gap,</if>
<if test="proteinHeat != null">protein_heat,</if>
<if test="createTime != null">create_time,</if>
<if test="fatHeat != null">fat_heat,</if>
<if test="createBy != null">create_by,</if>
<if test="carbonWaterHeat != null">carbon_water_heat,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
@ -72,8 +79,11 @@
<if test="maxHeatValue != null">#{maxHeatValue},</if>
<if test="heatValue != null">#{heatValue},</if>
<if test="heatGap != null">#{heatGap},</if>
<if test="proteinHeat != null">#{proteinHeat},</if>
<if test="createTime != null">#{createTime},</if>
<if test="fatHeat != null">#{fatHeat},</if>
<if test="createBy != null">#{createBy},</if>
<if test="carbonWaterHeat != null">#{carbonWaterHeat},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
@ -88,8 +98,11 @@
<if test="maxHeatValue != null">max_heat_value = #{maxHeatValue},</if>
<if test="heatValue != null">heat_value = #{heatValue},</if>
<if test="heatGap != null">heat_gap = #{heatGap},</if>
<if test="proteinHeat != null">protein_heat = #{proteinHeat},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="fatHeat != null">fat_heat = #{fatHeat},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="carbonWaterHeat != null">carbon_water_heat = #{carbonWaterHeat},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>

View File

@ -61,3 +61,14 @@ export function addFoodHeatData(data) {
})
}
// 获取热量比例分析详情
export function getNutritionalCalories(id) {
return request({
url: '/custom/foodHeatStatistics/getNutritionalCalories',
method: 'get',
params: {"id": id}
})
}

View File

@ -0,0 +1,194 @@
<template>
<!-- 热量分析 -->
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body >
<div v-show="showFlag" >
<div style="margin-top: -30px">
<h3 class="blue-color">基础信息</h3>
</div>
<el-table :show-header="false" :data="baseData" border :cell-style="baseColumnStyle" >
<el-table-column width="200" prop="name_one">
</el-table-column>
<el-table-column prop="value_one">
<template slot-scope="scope">
{{scope.row.value_one}}
</template>
</el-table-column>
<el-table-column width="200" prop="name_two">
</el-table-column>
<el-table-column prop="value_two">
<template slot-scope="scope">
{{scope.row.value_two}}
</template>
</el-table-column>
</el-table>
<div>
<h3 class="blue-color">热量分析</h3>
</div>
<el-table :show-header="false" :data="heatData" border :cell-style="baseColumnStyle" >
<el-table-column width="200" prop="name_one">
</el-table-column>
<el-table-column prop="value_one">
<template slot-scope="scope">
{{scope.row.value_one}}
</template>
</el-table-column>
<el-table-column width="200" prop="name_two">
</el-table-column>
<el-table-column prop="value_two">
<template slot-scope="scope">
{{scope.row.value_two}}
</template>
</el-table-column>
</el-table>
<div>
<h3 class="blue-color">营养热量定量结果</h3>
</div>
<el-table :show-header="false" :data="nutritData" border :cell-style="nutritColumnStyle" >
<el-table-column width="200" prop="name">
</el-table-column>
<el-table-column prop="value[0]">
<template slot-scope="scope">
{{scope.row.value[0]}}
</template>
</el-table-column>
<el-table-column prop="value[1]">
<template slot-scope="scope">
{{scope.row.value[1]}}
</template>
</el-table-column>
<el-table-column prop="value[2]">
<template slot-scope="scope">
{{scope.row.value[2]}}
</template>
</el-table-column>
</el-table>
</div>
<div v-show="!showFlag">
<p style="font-size: 20px;text-align:center;">暂无数据</p>
</div>
</el-dialog>
</template>
<script>
import { getNutritionalCalories } from "@/api/custom/foodHeatStatistics";
export default {
name: "index",
components: {
},
props: {},
data() {
return {
showFlag: true,
//
title: "",
//
open: false,
nutritionalData:null,
baseData: [],
baseTitleData:[["姓名","体重(斤)"],["身高(CM)","年龄(岁)"],["标准体重(斤)","超重(斤)"]],
baseValueData:[["name","weight"],["tall","age"],["standardWeight","overWeight"]],
heatData:[],
heatTitleData:[["基础代谢BMR(千卡)","减脂最大摄入量(千卡)"],["每公斤体重占比(千卡)","目标(千卡)"],["减脂热量控制范围(千卡)",""]],
heatValueData:[["metabolizeHeat","maxIntakeHeat"],["everyWeightHeat","targetEveryWeightHeat"],["standardEveryWeightHeat",""]],
nutritData:[],
nutritTitleData:["比例","热量(千卡)","质量(克)","每公斤体重占比(克/公斤)","今日已摄入量(千卡)","今日剩余可摄入量(千卡)"],
nutritValueData:["nutritionalRate","nutritionalHeat","nutritionalQuality","weightNutritionalRate","ingestedNutritionalHeat","surplusNutritionalHeat"],
};
},
created() {
},
methods: {
showDialog(data, customerName) {
this.title = customerName+"「"+ data.edibleDate+"」减脂营养热量计算";
this.reset();
this.getNutritionalDetail(data.id);
},
getNutritionalDetail(id){
getNutritionalCalories(id).then((response) => {
this.open = true;
this.nutritionalData = response.data;
if(this.nutritionalData == null || this.nutritionalData == undefined){
this.showFlag = false;
return;
}
this.baseValueData.forEach((item,index) => {
var obj = {};
obj["name_one"] = this.baseTitleData[index][0];
obj["value_one"] = this.nutritionalData[item[0]];
obj["name_two"] = this.baseTitleData[index][1];
obj["value_two"] = this.nutritionalData[item[1]];
this.baseData.push(obj);
});
this.heatValueData.forEach((item,index) => {
var obj = {};
obj["name_one"] = this.heatTitleData[index][0];
obj["value_one"] = this.getHeatValue(item[0]);
obj["name_two"] = this.heatTitleData[index][1];
obj["value_two"] = this.getHeatValue(item[1]);
this.heatData.push(obj);
});
this.nutritData.push({"name": "营养","value":["蛋白质","脂肪","碳水"]});
this.nutritValueData.forEach((item,index) => {
var obj = {};
obj["name"] = this.nutritTitleData[index];
obj["value"] = this.getNutritValue(item);
this.nutritData.push(obj);
});
});
},
getHeatValue(item){
if(item == "targetEveryWeightHeat" || item == "standardEveryWeightHeat"){
return this.nutritionalData[item][0]+"-"+this.nutritionalData[item][1];
}else{
return item != "" ? this.nutritionalData[item] : "";
}
},
getNutritValue(item){
if(item == "nutritionalRate"){
this.nutritionalData[item][0] += "%";
this.nutritionalData[item][1] += "%";
this.nutritionalData[item][2] += "%";
}
return this.nutritionalData[item];
},
reset(){
this.showFlag = true;
this.baseData = [];
this.heatData = [];
this.nutritData = [];
},
//
cancel() {
this.open = false;
},
//
baseColumnStyle({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 0 || columnIndex == 2) {
//23
return "background:#f3f6fc;font-weight:bold";
}else{
return "background:#ffffff;";
}
},
//
nutritColumnStyle({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 0 || rowIndex == 0) {
//23
return "background:#f3f6fc;font-weight:bold";
}else{
return "background:#ffffff;";
}
}
}
};
</script>
<style scoped>
.blue-color {
font-size: 18px;
font-weight: bold;
}
</style>

View File

@ -32,13 +32,12 @@
<el-table-column label="热量缺口" align="center" prop="heatGap" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!--<el-button
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:foodHeatStatistics:edit']"
>修改</el-button>-->
@click="handleDetail(scope.row)"
v-hasPermi="['custom:foodHeatStatistics:query']"
>详情</el-button>
<el-button
size="mini"
type="text"
@ -65,6 +64,7 @@
/>
<heatStatisticsCalculate ref="heatStatisticsCalculateRef"></heatStatisticsCalculate>
<heatStatisticsDetail ref="heatStatisticsDetailRef"></heatStatisticsDetail>
</div>
</el-drawer>
@ -74,10 +74,12 @@
import { listFoodHeatStatistics, getFoodHeatStatistics, delFoodHeatStatistics, addFoodHeatStatistics, updateFoodHeatStatistics, exportFoodHeatStatistics } from "@/api/custom/foodHeatStatistics";
import Clipboard from 'clipboard';
import HeatStatisticsCalculate from "@/components/HeatStatisticsCalculate";
import HeatStatisticsDetail from "@/components/HeatStatisticsDetail";
export default {
name: "HeatStatisticsDrawer",
components: {
'heatStatisticsCalculate':HeatStatisticsCalculate
'heatStatisticsCalculate':HeatStatisticsCalculate,
'heatStatisticsDetail': HeatStatisticsDetail
},
data() {
return {
@ -152,6 +154,9 @@ export default {
this.$refs.heatStatisticsCalculateRef.showDialog(data,() => {
this.fetchHeatList();
});
},
handleDetail(data){
this.$refs.heatStatisticsDetailRef.showDialog(data, this.data.name);
}
},
};