外食计算优化,添加详情功能
This commit is contained in:
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -79,5 +79,5 @@ public interface ISysCustomerHeatStatisticsService
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public NutritionalCalories getNutritionalCaloriesByCustomer(Long id);
|
||||
public NutritionalCalories getNutritionalCaloriesByCustomerHeatId(Long id);
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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>
|
||||
<if test="customerId != null "> and customer_id = #{customerId}</if>
|
||||
</where>
|
||||
order by id desc
|
||||
<include refid="selectSysCustomerHeatStatisticsVo"/> where del_flag = 0
|
||||
<if test="customerId != null "> and customer_id = #{customerId}</if>
|
||||
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>
|
||||
|
Reference in New Issue
Block a user