外食计算器功能优化修改

This commit is contained in:
xiezhijun
2021-02-20 19:38:17 +08:00
parent afdee0abdf
commit 3f3fcda862
15 changed files with 822 additions and 108 deletions

View File

@ -0,0 +1,57 @@
package com.stdiet.custom.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 外食热量统计对象 sys_customer_heat_statistics
*
* @author xzj
* @date 2021-02-20
*/
@Data
public class SysCustomerHeatStatistics extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 客户ID */
@Excel(name = "客户ID")
private Long customerId;
/** 日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date edibleDate;
/** 最大可摄入量 */
@Excel(name = "最大可摄入量")
private Integer maxHeatValue;
/** 当天食材总热量 */
@Excel(name = "当天食材总热量")
private Integer heatValue;
/** 当天热量缺口 */
@Excel(name = "当天热量缺口")
private Integer heatGap;
/** 删除标识 0未删除 1已删除 */
private Integer delFlag;
//食材热量ID
private Long[] foodHeatIdList;
//食材热量
private Integer[] foodHeatList;
//具体食材集合
private List<SysFoodHeatStatistics> foodHeatStatisticsList;
}

View File

@ -1,7 +1,5 @@
package com.stdiet.custom.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
@ -20,9 +18,9 @@ public class SysFoodHeatStatistics extends BaseEntity
/** $column.columnComment */
private Long id;
/** 客户ID */
@Excel(name = "客户ID")
private Long customerId;
/** 客户热量统计ID */
@Excel(name = "客户热量统计ID")
private Long customerHeatId;
/** 食材 */
@Excel(name = "食材")
@ -42,11 +40,6 @@ public class SysFoodHeatStatistics extends BaseEntity
@Excel(name = "具体质量,单位:克")
private Integer quantity;
/** 食用日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "食用日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date edibleDate;
/** 类型0早 1中 2晚 */
@Excel(name = "类型0早 1中 2晚")
private Integer edibleType;
@ -55,11 +48,9 @@ public class SysFoodHeatStatistics extends BaseEntity
@Excel(name = "热量数值")
private Integer heatValue;
/** 热量缺口 */
@Excel(name = "热量缺口")
private Integer heatGap;
/** 删除标识 0未删除 1已删除 */
private Integer delFlag;
}

View File

@ -0,0 +1,68 @@
package com.stdiet.custom.mapper;
import java.util.List;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
/**
* 外食热量统计Mapper接口
*
* @author xzj
* @date 2021-02-20
*/
public interface SysCustomerHeatStatisticsMapper
{
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
public SysCustomerHeatStatistics selectSysCustomerHeatStatisticsById(Long id);
/**
* 查询外食热量统计列表
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 外食热量统计集合
*/
public List<SysCustomerHeatStatistics> selectSysCustomerHeatStatisticsList(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 新增外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
public int insertSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 修改外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
public int updateSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 删除外食热量统计
*
* @param id 外食热量统计ID
* @return 结果
*/
public int deleteSysCustomerHeatStatisticsById(Long id);
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysCustomerHeatStatisticsByIds(Long[] ids);
/**
* 根据客户ID、日期查询客户热量统计数据
* @param sysCustomerHeatStatistics
* @return
*/
public SysCustomerHeatStatistics getCustomerHeatStatisticsByDate(SysCustomerHeatStatistics sysCustomerHeatStatistics);
}

View File

@ -0,0 +1,68 @@
package com.stdiet.custom.service;
import java.util.List;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
/**
* 外食热量统计Service接口
*
* @author xzj
* @date 2021-02-20
*/
public interface ISysCustomerHeatStatisticsService
{
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
public SysCustomerHeatStatistics selectSysCustomerHeatStatisticsById(Long id);
/**
* 查询外食热量统计列表
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 外食热量统计集合
*/
public List<SysCustomerHeatStatistics> selectSysCustomerHeatStatisticsList(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 新增外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
public int insertSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 修改外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
public int updateSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的外食热量统计ID
* @return 结果
*/
public int deleteSysCustomerHeatStatisticsByIds(Long[] ids);
/**
* 删除外食热量统计信息
*
* @param id 外食热量统计ID
* @return 结果
*/
public int deleteSysCustomerHeatStatisticsById(Long id);
/**
* 更新食材热量并计算当天总热量
* @param sysCustomerHeatStatistics
* @return
*/
public int calculateCustomerHeat(SysCustomerHeatStatistics sysCustomerHeatStatistics);
}

View File

@ -0,0 +1,154 @@
package com.stdiet.custom.service.impl;
import java.util.List;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.HealthyUtils;
import com.stdiet.custom.domain.SysCustomerHealthy;
import com.stdiet.custom.domain.SysCustomerPhysicalSigns;
import com.stdiet.custom.domain.SysFoodHeatStatistics;
import com.stdiet.custom.mapper.SysFoodHeatStatisticsMapper;
import com.stdiet.custom.service.ISysCustomerHealthyService;
import com.stdiet.custom.service.ISysCustomerPhysicalSignsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysCustomerHeatStatisticsMapper;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
import com.stdiet.custom.service.ISysCustomerHeatStatisticsService;
import org.springframework.transaction.annotation.Transactional;
/**
* 外食热量统计Service业务层处理
*
* @author xzj
* @date 2021-02-20
*/
@Service
@Transactional
public class SysCustomerHeatStatisticsServiceImpl implements ISysCustomerHeatStatisticsService
{
@Autowired
private SysCustomerHeatStatisticsMapper sysCustomerHeatStatisticsMapper;
@Autowired
private SysFoodHeatStatisticsMapper sysFoodHeatStatisticsMapper;
@Autowired
private ISysCustomerPhysicalSignsService sysCustomerPhysicalSignsService;
@Autowired
private ISysCustomerHealthyService sysCustomerHealthyService;
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
@Override
public SysCustomerHeatStatistics selectSysCustomerHeatStatisticsById(Long id)
{
return sysCustomerHeatStatisticsMapper.selectSysCustomerHeatStatisticsById(id);
}
/**
* 查询外食热量统计列表
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 外食热量统计
*/
@Override
public List<SysCustomerHeatStatistics> selectSysCustomerHeatStatisticsList(SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
return sysCustomerHeatStatisticsMapper.selectSysCustomerHeatStatisticsList(sysCustomerHeatStatistics);
}
/**
* 新增外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
@Override
public int insertSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
sysCustomerHeatStatistics.setCreateTime(DateUtils.getNowDate());
return sysCustomerHeatStatisticsMapper.insertSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}
/**
* 修改外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
@Override
public int updateSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
sysCustomerHeatStatistics.setUpdateTime(DateUtils.getNowDate());
return sysCustomerHeatStatisticsMapper.updateSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的外食热量统计ID
* @return 结果
*/
@Override
public int deleteSysCustomerHeatStatisticsByIds(Long[] ids)
{
return sysCustomerHeatStatisticsMapper.deleteSysCustomerHeatStatisticsByIds(ids);
}
/**
* 删除外食热量统计信息
*
* @param id 外食热量统计ID
* @return 结果
*/
@Override
public int deleteSysCustomerHeatStatisticsById(Long id)
{
return sysCustomerHeatStatisticsMapper.deleteSysCustomerHeatStatisticsById(id);
}
/**
* 更新食材热量并计算当天总热量
* @param sysCustomerHeatStatistics
* @return
*/
@Override
public int calculateCustomerHeat(SysCustomerHeatStatistics sysCustomerHeatStatistics){
Long[] foodHeatId = sysCustomerHeatStatistics.getFoodHeatIdList();
Integer[] foodHeat = sysCustomerHeatStatistics.getFoodHeatList();
if(foodHeatId != null && foodHeatId.length > 0 && foodHeat != null && foodHeat.length == foodHeatId.length){
SysFoodHeatStatistics sysFoodHeatStatistics = new SysFoodHeatStatistics();
int totalHeatCalue = 0;
for (int i = 0; i < foodHeatId.length; i++) {
sysFoodHeatStatistics.setId(foodHeatId[i]);
sysFoodHeatStatistics.setHeatValue(foodHeat[i]);
sysFoodHeatStatisticsMapper.updateSysFoodHeatStatistics(sysFoodHeatStatistics);
totalHeatCalue += foodHeat[i];
}
sysCustomerHeatStatistics.setHeatValue(totalHeatCalue);
Long maxHeatValue = getMaxHeatValue(sysCustomerHeatStatistics.getCustomerId());
sysCustomerHeatStatistics.setMaxHeatValue(maxHeatValue.intValue());
sysCustomerHeatStatistics.setHeatGap(maxHeatValue.intValue() - totalHeatCalue);
return sysCustomerHeatStatisticsMapper.updateSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}
return 0;
}
public long getMaxHeatValue(Long customerId){
SysCustomerHealthy sysCustomerHealthy = sysCustomerHealthyService.selectSysCustomerHealthyByCustomerId(customerId);
if(sysCustomerHealthy != null){
return HealthyUtils.calculateMaxHeatEveryDay(sysCustomerHealthy.getAge().intValue(),sysCustomerHealthy.getTall(),sysCustomerHealthy.getWeight().doubleValue());
}
//查询体征信息
SysCustomerPhysicalSigns sysCustomerPhysicalSigns = sysCustomerPhysicalSignsService.selectSysCustomerPhysicalSignsByCusId(customerId);
if(sysCustomerPhysicalSigns != null){
return HealthyUtils.calculateMaxHeatEveryDay(sysCustomerPhysicalSigns.getAge().intValue(),sysCustomerPhysicalSigns.getTall(),sysCustomerPhysicalSigns.getWeight().doubleValue());
}
return 0;
}
}

View File

@ -1,21 +1,23 @@
package com.stdiet.custom.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.common.utils.sign.AesUtils;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
import com.stdiet.custom.dto.request.FoodHeatCalculatorRequest;
import com.stdiet.custom.mapper.SysCustomerHeatStatisticsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysFoodHeatStatisticsMapper;
import com.stdiet.custom.domain.SysFoodHeatStatistics;
import com.stdiet.custom.service.ISysFoodHeatStatisticsService;
import org.springframework.transaction.annotation.Transactional;
/**
* 外食热量统计Service业务层处理
@ -24,11 +26,15 @@ import com.stdiet.custom.service.ISysFoodHeatStatisticsService;
* @date 2021-02-19
*/
@Service
@Transactional
public class SysFoodHeatStatisticsServiceImpl implements ISysFoodHeatStatisticsService
{
@Autowired
private SysFoodHeatStatisticsMapper sysFoodHeatStatisticsMapper;
@Autowired
private SysCustomerHeatStatisticsMapper sysCustomerHeatStatisticsMapper;
/**
* 查询外食热量统计
*
@ -115,13 +121,25 @@ public class SysFoodHeatStatisticsServiceImpl implements ISysFoodHeatStatisticsS
if(StringUtils.isEmpty(customerId)){
return 0;
}
List<SysFoodHeatStatistics> list = new ArrayList<>();
if(StringUtils.isNotEmpty(foodHeatCalculatorRequest.getIngredientArray())){
List<HashMap> foodHeatList = JSON.parseArray(foodHeatCalculatorRequest.getIngredientArray(), HashMap.class);
for(HashMap map : foodHeatList){
map.put("customerId", customerId);
//先判断该日期下是否已存在
SysCustomerHeatStatistics sysCustomerHeatStatistics = new SysCustomerHeatStatistics();
sysCustomerHeatStatistics.setCustomerId(Long.parseLong(customerId));
sysCustomerHeatStatistics.setEdibleDate(new Date());
SysCustomerHeatStatistics customerHeatResult = sysCustomerHeatStatisticsMapper.getCustomerHeatStatisticsByDate(sysCustomerHeatStatistics);
if(customerHeatResult == null){
sysCustomerHeatStatisticsMapper.insertSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}else{
sysCustomerHeatStatistics.setId(customerHeatResult.getId());
}
if(sysCustomerHeatStatistics.getId() != null){
List<SysFoodHeatStatistics> list = new ArrayList<>();
if(StringUtils.isNotEmpty(foodHeatCalculatorRequest.getIngredientArray())){
List<HashMap> foodHeatList = JSON.parseArray(foodHeatCalculatorRequest.getIngredientArray(), HashMap.class);
for(HashMap map : foodHeatList){
map.put("customerHeatId", sysCustomerHeatStatistics.getId());
}
return sysFoodHeatStatisticsMapper.insertFoodHeatBatch(foodHeatList);
}
return sysFoodHeatStatisticsMapper.insertFoodHeatBatch(foodHeatList);
}
return 0;
}

View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stdiet.custom.mapper.SysCustomerHeatStatisticsMapper">
<resultMap type="SysCustomerHeatStatistics" id="SysCustomerHeatStatisticsResult">
<result property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="edibleDate" column="edible_date" />
<result property="maxHeatValue" column="max_heat_value" />
<result property="heatValue" column="heat_value" />
<result property="heatGap" column="heat_gap" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
</resultMap>
<resultMap type="SysCustomerHeatStatistics" id="SysCustomerHeatStatisticsResultExtended">
<result property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="edibleDate" column="edible_date" />
<result property="maxHeatValue" column="max_heat_value" />
<result property="heatValue" column="heat_value" />
<result property="heatGap" column="heat_gap" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
<!-- column是传的参数, select是调用的查询 -->
<association property="foodHeatStatisticsList" column="id" select="selectSysFoodHeatStatisticsList"/>
</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
</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
</select>
<select id="selectSysCustomerHeatStatisticsById" parameterType="Long" resultMap="SysCustomerHeatStatisticsResultExtended">
<include refid="selectSysCustomerHeatStatisticsVo"/>
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysCustomerHeatStatistics" parameterType="SysCustomerHeatStatistics" useGeneratedKeys="true" keyProperty="id">
insert into sys_customer_heat_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerId != null">customer_id,</if>
<if test="edibleDate != null">edible_date,</if>
<if test="maxHeatValue != null">max_heat_value,</if>
<if test="heatValue != null">heat_value,</if>
<if test="heatGap != null">heat_gap,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="customerId != null">#{customerId},</if>
<if test="edibleDate != null">#{edibleDate},</if>
<if test="maxHeatValue != null">#{maxHeatValue},</if>
<if test="heatValue != null">#{heatValue},</if>
<if test="heatGap != null">#{heatGap},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateSysCustomerHeatStatistics" parameterType="SysCustomerHeatStatistics">
update sys_customer_heat_statistics
<trim prefix="SET" suffixOverrides=",">
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="edibleDate != null">edible_date = #{edibleDate},</if>
<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="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</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>
</trim>
where id = #{id}
</update>
<update id="deleteSysCustomerHeatStatisticsById" parameterType="Long">
update sys_customer_heat_statistics set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysCustomerHeatStatisticsByIds" parameterType="String">
update sys_customer_heat_statistics set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 根据日期、客户ID查询是否存在热量统计 -->
<select id="getCustomerHeatStatisticsByDate" parameterType="SysCustomerHeatStatistics" resultMap="SysCustomerHeatStatisticsResult">
select id from sys_customer_heat_statistics where del_flag = 0 and customer_id = #{customerId}
<if test="edibleDate != null">and date_format(edible_date,'%y%m%d') = date_format(#{edibleDate},'%y%m%d')</if>
limit 1
</select>
<resultMap type="SysFoodHeatStatistics" id="SysFoodHeatStatisticsResult">
<result property="id" column="id" />
<result property="customerHeatId" column="customer_heat_id" />
<result property="ingredient" column="ingredient" />
<result property="unit" column="unit" />
<result property="number" column="number" />
<result property="quantity" column="quantity" />
<result property="edibleType" column="edible_type" />
<result property="heatValue" column="heat_value" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
<result property="unitName" column="unitName"></result>
</resultMap>
<select id="selectSysFoodHeatStatisticsList" parameterType="Long" resultMap="SysFoodHeatStatisticsResult">
select sfhs.id, sfhs.customer_heat_id, sfhs.ingredient, sfhs.unit, sfhs.number, sfhs.quantity, sfhs.edible_type, sfhs.heat_value,cusUnit.dict_label as unitName
from sys_food_heat_statistics as sfhs
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_cus_unit') AS cusUnit ON cusUnit.dict_value = sfhs.unit
where sfhs.del_flag = 0 and customer_heat_id = #{id}
</select>
</mapper>

View File

@ -6,15 +6,13 @@
<resultMap type="SysFoodHeatStatistics" id="SysFoodHeatStatisticsResult">
<result property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="customerHeatId" column="customer_heat_id" />
<result property="ingredient" column="ingredient" />
<result property="unit" column="unit" />
<result property="number" column="number" />
<result property="quantity" column="quantity" />
<result property="edibleDate" column="edible_date" />
<result property="edibleType" column="edible_type" />
<result property="heatValue" column="heat_value" />
<result property="heatGap" column="heat_gap" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
@ -25,15 +23,14 @@
</resultMap>
<sql id="selectSysFoodHeatStatisticsVo">
select id, customer_id, ingredient, unit, number, quantity, edible_date, edible_type, heat_value, heat_gap, create_time, create_by, update_time, update_by, del_flag from sys_food_heat_statistics
select id, customer_heat_id, ingredient, unit, number, quantity, edible_type, heat_value, create_time, create_by, update_time, update_by, del_flag from sys_food_heat_statistics
</sql>
<select id="selectSysFoodHeatStatisticsList" parameterType="SysFoodHeatStatistics" resultMap="SysFoodHeatStatisticsResult">
select sfhs.id, sfhs.customer_id, sfhs.ingredient, sfhs.unit, sfhs.number, sfhs.quantity, sfhs.edible_date, sfhs.edible_type, sfhs.heat_value, sfhs.heat_gap,cusUnit.dict_label as unitName
select sfhs.id, sfhs.customer_heat_id, sfhs.ingredient, sfhs.unit, sfhs.number, sfhs.quantity, sfhs.edible_type, sfhs.heat_value,cusUnit.dict_label as unitName
from sys_food_heat_statistics as sfhs
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_cus_unit') AS cusUnit ON cusUnit.dict_value = sfhs.unit
where sfhs.del_flag = 0
<if test="customerId != null "> and sfhs.customer_id = #{customerId}</if>
</select>
<select id="selectSysFoodHeatStatisticsById" parameterType="Long" resultMap="SysFoodHeatStatisticsResult">
@ -44,15 +41,13 @@
<insert id="insertSysFoodHeatStatistics" parameterType="SysFoodHeatStatistics" useGeneratedKeys="true" keyProperty="id">
insert into sys_food_heat_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerId != null">customer_id,</if>
<if test="customerHeatId != null">customer_heat_id,</if>
<if test="ingredient != null">ingredient,</if>
<if test="unit != null">unit,</if>
<if test="number != null">number,</if>
<if test="quantity != null">quantity,</if>
<if test="edibleDate != null">edible_date,</if>
<if test="edibleType != null">edible_type,</if>
<if test="heatValue != null">heat_value,</if>
<if test="heatGap != null">heat_gap,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
@ -60,15 +55,13 @@
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="customerId != null">#{customerId},</if>
<if test="customerHeatId != null">#{customerHeatId},</if>
<if test="ingredient != null">#{ingredient},</if>
<if test="unit != null">#{unit},</if>
<if test="number != null">#{number},</if>
<if test="quantity != null">#{quantity},</if>
<if test="edibleDate != null">#{edibleDate},</if>
<if test="edibleType != null">#{edibleType},</if>
<if test="heatValue != null">#{heatValue},</if>
<if test="heatGap != null">#{heatGap},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -80,15 +73,13 @@
<update id="updateSysFoodHeatStatistics" parameterType="SysFoodHeatStatistics">
update sys_food_heat_statistics
<trim prefix="SET" suffixOverrides=",">
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="customerHeatId != null">customer_heat_id = #{customerHeatId},</if>
<if test="ingredient != null">ingredient = #{ingredient},</if>
<if test="unit != null">unit = #{unit},</if>
<if test="number != null">number = #{number},</if>
<if test="quantity != null">quantity = #{quantity},</if>
<if test="edibleDate != null">edible_date = #{edibleDate},</if>
<if test="edibleType != null">edible_type = #{edibleType},</if>
<if test="heatValue != null">heat_value = #{heatValue},</if>
<if test="heatGap != null">heat_gap = #{heatGap},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
@ -110,9 +101,9 @@
</update>
<insert id="insertFoodHeatBatch" parameterType="java.util.List">
insert into sys_food_heat_statistics(customer_id,ingredient,unit,number,quantity) values
insert into sys_food_heat_statistics(customer_heat_id,ingredient,unit,number,quantity) values
<foreach collection ="list" item="food" index= "index" separator =",">
(#{food.customerId}, #{food.ingredient},#{food.unit},#{food.number},#{food.quantity})
(#{food.customerHeatId}, #{food.ingredient},#{food.unit},#{food.number},#{food.quantity})
</foreach >
</insert>