!60 修复通俗重量

Merge pull request !60 from 德仔/develop
This commit is contained in:
德仔
2021-02-09 10:27:08 +08:00
committed by Gitee
27 changed files with 1942 additions and 744 deletions

View File

@ -1,34 +1,42 @@
package com.stdiet.custom.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 菜品对象 sys_dishes
*
*
* @author wonder
* @date 2020-12-28
*/
public class SysDishes extends BaseEntity
{
@Data
public class SysDishes {
private static final long serialVersionUID = 1L;
/** id */
/**
* id
*/
private Long id;
/** 菜品名称 */
/**
* 菜品名称
*/
@Excel(name = "菜品名称")
private String name;
/** 菜品类型 */
/**
* 菜品类型
*/
@Excel(name = "菜品类型")
private String type;
/** 做法 */
/**
* 做法
*/
@Excel(name = "做法")
private String methods;
@ -36,80 +44,36 @@ public class SysDishes extends BaseEntity
private String reviewStatus;
public Integer getIsMain() {
return isMain;
}
/**
* 创建者
*/
private String createBy;
public void setIsMain(Integer isMain) {
this.isMain = isMain;
}
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
public void setReviewStatus(String reviewStatus) {
this.reviewStatus = reviewStatus;
}
/**
* 更新者
*/
private String updateBy;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 备注
*/
private String remark;
public String getReviewStatus() {
return reviewStatus;
}
private List<SysDishesIngredient> igdList;
public void setId(Long id)
{
this.id = id;
}
private List<SysDishesIngredient> detail;
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setMethods(String methods)
{
this.methods = methods;
}
public String getMethods()
{
return methods;
}
public void setIgdList(List<SysDishesIngredient> ingredientList) {
this.igdList = ingredientList;
}
public List<SysDishesIngredient> getIgdList() {
return igdList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("type", getType())
.append("methods", getMethods())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -21,9 +21,9 @@ public class SysDishesIngredient extends SysIngredient {
private Long cusUnit;
private BigDecimal cusWeight;
// private BigDecimal cusWeight;
private Integer cusWei;
private Integer cusWeight;
private BigDecimal weight;

View File

@ -0,0 +1,25 @@
package com.stdiet.custom.domain;
import lombok.Data;
/**
* 食材对象 sys_ingredient
*
* @author wonder
* @date 2020-12-15
*/
@Data
public class SysDishesIngredientInfo {
private static final long serialVersionUID = 1L;
private Long id;
private String cus_unit;
private String cus_weight;
private Integer weight;
private String remark;
}

View File

@ -1,11 +1,11 @@
package com.stdiet.custom.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 食材对象 sys_ingredient
@ -13,12 +13,10 @@ import java.math.BigDecimal;
* @author wonder
* @date 2020-12-15
*/
public class SysIngredient extends BaseEntity {
@Data
public class SysIngredient {
private static final long serialVersionUID = 1L;
private int pageNum;
private int pageSize;
/**
* id
*/
@ -77,131 +75,36 @@ public class SysIngredient extends BaseEntity {
*/
private String reviewStatus;
public void setReviewStatus(String reviewStatus) {
this.reviewStatus = reviewStatus;
}
/**
* 创建者
*/
private String createBy;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 更新者
*/
private String updateBy;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 备注
*/
private String remark;
public String getReviewStatus() {
return reviewStatus;
}
private Long[] recIds;
private Long[] notRecIds;
public Long[] getRecIds() {
return recIds;
}
public Long[] getNotRecIds() {
return notRecIds;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public BigDecimal getProteinRatio() {
return proteinRatio;
}
public void setProteinRatio(BigDecimal proteinRatio) {
this.proteinRatio = proteinRatio;
}
public BigDecimal getFatRatio() {
return fatRatio;
}
public void setFatRatio(BigDecimal fatRatio) {
this.fatRatio = fatRatio;
}
public BigDecimal getCarbonRatio() {
return carbonRatio;
}
public void setCarbonRatio(BigDecimal carbonRatio) {
this.carbonRatio = carbonRatio;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getNotRec() {
return notRec;
}
public void setNotRec(String notRec) {
this.notRec = notRec;
}
public String getRec() {
return rec;
}
public void setRec(String rec) {
this.rec = rec;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageNum() {
return pageNum;
}
public int getPageSize() {
return pageSize;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("type", getType())
.append("proteinRatio", getProteinRatio())
.append("fatRatio", getFatRatio())
.append("carbonRatio", getCarbonRatio())
.append("remark", getRemark())
.append("area", getArea())
.append("notRec", getNotRec())
.append("recommend", getRec())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,47 @@
package com.stdiet.custom.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class SysRecipes {
private static final long serialVersionUID = 1L;
private Long id;
private Integer numDay;
private List<SysDishes> dishes;
private Integer reviewStatus;
/**
* 创建者
*/
private String createBy;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 更新者
*/
private String updateBy;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,10 @@
package com.stdiet.custom.mapper;
import com.stdiet.custom.domain.SysRecipes;
import java.util.List;
public interface SysRecipesMapper {
public List<SysRecipes> selectSysRecipesByRecipesId(Long id);
}

View File

@ -0,0 +1,9 @@
package com.stdiet.custom.service;
import com.stdiet.custom.domain.SysRecipes;
import java.util.List;
public interface ISysRecipesService {
public List<SysRecipes> selectSysRecipesByRecipesId(Long id);
}

View File

@ -0,0 +1,23 @@
package com.stdiet.custom.service.impl;
import com.stdiet.custom.domain.SysRecipes;
import com.stdiet.custom.mapper.SysRecipesMapper;
import com.stdiet.custom.service.ISysRecipesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class SysRecipesServiceImpl implements ISysRecipesService {
@Autowired
private SysRecipesMapper sysRecipesMapper;
@Override
public List<SysRecipes> selectSysRecipesByRecipesId(Long id) {
return sysRecipesMapper.selectSysRecipesByRecipesId(id);
}
}

View File

@ -0,0 +1,56 @@
package com.stdiet.custom.typehandler;
import com.alibaba.fastjson.JSONArray;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Created by lixio on 2019/3/28 20:51
* @description 用以mysql中json格式的字段进行转换的自定义转换器转换为实体类的JSONArray属性
* MappedTypes注解中的类代表此转换器可以自动转换为的java对象
* MappedJdbcTypes注解中设置的是对应的jdbctype
*/
@MappedTypes(JSONArray.class)
@MappedJdbcTypes(JdbcType.VARCHAR)
public class ArrayJsonHandler extends BaseTypeHandler<JSONArray> {
//设置非空参数
@Override
public void setNonNullParameter(PreparedStatement ps, int i, JSONArray parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, String.valueOf(parameter.toJSONString()));
}
//根据列名,获取可以为空的结果
@Override
public JSONArray getNullableResult(ResultSet rs, String columnName) throws SQLException {
String sqlJson = rs.getString(columnName);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
//根据列索引,获取可以为空的结果
@Override
public JSONArray getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String sqlJson = rs.getString(columnIndex);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
@Override
public JSONArray getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String sqlJson = cs.getString(columnIndex);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
}

View File

@ -0,0 +1,57 @@
package com.stdiet.custom.typehandler;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Created by lixio on 2019/3/28 15:44
* @description 用以mysql中json格式的字段进行转换的自定义转换器转换为实体类的JSONObject属性
* MappedTypes注解中的类代表此转换器可以自动转换为的java对象
* MappedJdbcTypes注解中设置的是对应的jdbctype
*/
@MappedTypes(JSONObject.class)
@MappedJdbcTypes(JdbcType.VARCHAR)
public class ObjectJsonHandler extends BaseTypeHandler<JSONObject>{
//设置非空参数
@Override
public void setNonNullParameter(PreparedStatement ps, int i, JSONObject parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, String.valueOf(parameter.toJSONString()));
}
//根据列名,获取可以为空的结果
@Override
public JSONObject getNullableResult(ResultSet rs, String columnName) throws SQLException {
String sqlJson = rs.getString(columnName);
if (null != sqlJson){
return JSONObject.parseObject(sqlJson);
}
return null;
}
//根据列索引,获取可以为空的结果
@Override
public JSONObject getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String sqlJson = rs.getString(columnIndex);
if (null != sqlJson){
return JSONObject.parseObject(sqlJson);
}
return null;
}
@Override
public JSONObject getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String sqlJson = cs.getString(columnIndex);
if (null != sqlJson){
return JSONObject.parseObject(sqlJson);
}
return null;
}
}

View File

@ -28,7 +28,6 @@
<result property="rec" column="rec" />
<result property="notRec" column="not_rec" />
<result property="cusWeight" column="cus_weight" />
<result property="cusWei" column="cus_wei" />
<result property="cusUnit" column="cus_unit" />
<result property="weight" column="weight" />
</resultMap>
@ -49,7 +48,7 @@
<sql id="selectSysIngreditentsByIdVo">
SELECT * FROM(
SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_wei, cus_unit, remark
SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_unit, remark
FROM sys_dishes_ingredient
WHERE dishes_id = #{id}
) dishes
@ -149,9 +148,9 @@
</delete>
<insert id="bashInsertDishesIngredent">
insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_wei, remark) values
insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight, remark) values
<foreach collection="list" separator="," item="item" index="index">
(#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWei}, #{item.remark})
(#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWeight}, #{item.remark})
</foreach>
</insert>

View File

@ -0,0 +1,76 @@
<?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.SysRecipesMapper">
<resultMap type="SysRecipes" id="SysRecipesResult">
<result property="id" column="id"/>
<result property="numDay" column="num_day"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="reviewStatus" column="review_status"/>
<association property="dishes" column="id" select="selectDishesByMenuId"/>
</resultMap>
<resultMap id="SysDishesResult" type="SysDishes">
<result property="id" column="dishes_id"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="methods" column="methods"/>
<result property="isMain" column="is_main"/>
<result property="detail" column="detail" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"
javaType="com.stdiet.custom.domain.SysDishesIngredientInfo"/>
<association property="igdList" column="dishes_id" select="selectIngredientsByDishesId"/>
</resultMap>
<resultMap id="SysIgdsResult" type="SysDishesIngredient">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="proteinRatio" column="protein_ratio"/>
<result property="fatRatio" column="fat_ratio"/>
<result property="carbonRatio" column="carbon_ratio"/>
<result property="area" column="area"/>
<result property="rec" column="rec"/>
<result property="notRec" column="not_rec"/>
</resultMap>
<select id="selectSysRecipesByRecipesId" parameterType="Long" resultMap="SysRecipesResult">
SELECT * FROM sys_customer_daily_menu WHERE recipes_id = #{id}
</select>
<select id="selectDishesByMenuId" parameterType="Long" resultMap="SysDishesResult">
SELECT * FROM (SELECT * FROM sys_customer_menu_dishes WHERE menu_id = #{id}) AS menu
LEFT JOIN sys_dishes ON menu.dishes_id = sys_dishes.id
</select>
<select id="selectIngredientsByDishesId" parameterType="Long" resultMap="SysIgdsResult">
SELECT * FROM(
SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_unit, remark
FROM sys_dishes_ingredient
WHERE dishes_id = #{id}
) dishes
LEFT JOIN (
SELECT id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, not_rec, rec
FROM sys_ingredient igd
LEFT JOIN (
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM(
SELECT physical_signs_id as id, ingredient_id
FROM sys_ingredient_not_rec
) notRec JOIN sys_physical_signs phy USING(id)
GROUP BY id
) notRecT USING(id)
LEFT JOIN (
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM(
SELECT physical_signs_id as id, ingredient_id
FROM sys_ingredient_rec
) rec JOIN sys_physical_signs phy USING(id)
GROUP BY id
) recT USING(id)
) ing USING(id)
</select>
</mapper>