新增食谱制作时按病症筛选功能

This commit is contained in:
huangdeliang 2021-04-27 11:55:11 +08:00
parent a45060a87c
commit a24a9e8674
20 changed files with 275 additions and 174 deletions

View File

@ -37,16 +37,7 @@ public class SysDishesController extends BaseController {
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysDishes sysDishes) { public TableDataInfo list(SysDishes sysDishes) {
startPage(); startPage();
List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes); return getDataTable(sysDishesService.selectSysDishesList(sysDishes));
for (SysDishes dishes : list) {
List<SysDishesIngredient> ingredients = sysDishesService.selectSysIngreditentsById(dishes.getId());
if (StringUtils.isNull(ingredients)) {
dishes.setIgdList(new ArrayList<>());
} else {
dishes.setIgdList(ingredients);
}
}
return getDataTable(list);
} }
/** /**

View File

@ -89,4 +89,10 @@ public class SysDishes {
private Integer[] dishClass; private Integer[] dishClass;
private Long[] notRecIds;
private Long[] recIds;
private String physical;
} }

View File

@ -31,5 +31,8 @@ public class SysDishesIngredient extends SysIngredient {
private String cus_weight; private String cus_weight;
private String recIdsStr;
private String notRecIdsStr;
} }

View File

@ -101,7 +101,6 @@ public class SysIngredient {
*/ */
private String remark; private String remark;
private Long[] recIds; private Long[] recIds;
private Long[] notRecIds; private Long[] notRecIds;

View File

@ -1,30 +0,0 @@
package com.stdiet.custom.domain;
public class SysIngredientNotRec {
private Long ingredientId;
private Long notRecommandId;
public Long getIngredientId() {
return ingredientId;
}
public void setIngredientId(Long ingredientId) {
this.ingredientId = ingredientId;
}
public Long getRecommandId() {
return notRecommandId;
}
public void setRecommandId(Long recommandId) {
this.notRecommandId = recommandId;
}
@Override
public String toString() {
return "SysIngredientRec{" +
"ingredientId=" + ingredientId +
", notRecommandId=" + notRecommandId +
'}';
}
}

View File

@ -1,30 +0,0 @@
package com.stdiet.custom.domain;
public class SysIngredientRec {
private Long ingredientId;
private Long recommandId;
public Long getIngredientId() {
return ingredientId;
}
public void setIngredientId(Long ingredientId) {
this.ingredientId = ingredientId;
}
public Long getRecommandId() {
return recommandId;
}
public void setRecommandId(Long recommandId) {
this.recommandId = recommandId;
}
@Override
public String toString() {
return "SysIngredientRec{" +
"ingredientId=" + ingredientId +
", recommandId=" + recommandId +
'}';
}
}

View File

@ -1,9 +1,7 @@
package com.stdiet.custom.domain; package com.stdiet.custom.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.stdiet.common.annotation.Excel; import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity; import lombok.Data;
/** /**
* 体征对象 sys_physical_signs * 体征对象 sys_physical_signs
@ -11,56 +9,27 @@ import com.stdiet.common.core.domain.BaseEntity;
* @author wonder * @author wonder
* @date 2020-12-23 * @date 2020-12-23
*/ */
public class SysPhysicalSigns extends BaseEntity @Data
{ public class SysPhysicalSigns {
private static final long serialVersionUID = 1L; /**
* id
/** id */ */
private Long id; private Long id;
/** 体征名称 */ /**
* 体征名称
*/
@Excel(name = "体征名称") @Excel(name = "体征名称")
private String name; private String name;
/** 体征类别 */ /**
@Excel(name = "体征类别") * 体征类别
*/
private Long typeId; private Long typeId;
public void setId(Long id) @Excel(name = "体征类别")
{ private String typeName;
this.id = id;
}
public Long getId() private String remark;
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setTypeId(Long typeId)
{
this.typeId = typeId;
}
public Long getTypeId()
{
return typeId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("typeId", getTypeId())
.append("remark", getRemark())
.toString();
}
} }

View File

@ -0,0 +1,11 @@
package com.stdiet.custom.domain;
import lombok.Data;
@Data
public class SysPhysicalSignsObj {
Long targetId;
Long physicalSignsId;
}

View File

@ -1,23 +1,22 @@
package com.stdiet.custom.mapper; package com.stdiet.custom.mapper;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import com.stdiet.custom.domain.SysDishes; import com.stdiet.custom.domain.SysDishes;
import com.stdiet.custom.domain.SysDishesIngredient; import com.stdiet.custom.domain.SysDishesIngredient;
import com.stdiet.custom.domain.SysIngredient; import com.stdiet.custom.domain.SysPhysicalSignsObj;
import java.util.ArrayList;
import java.util.List;
/** /**
* 菜品Mapper接口 * 菜品Mapper接口
* *
* @author wonder * @author wonder
* @date 2020-12-28 * @date 2020-12-28
*/ */
public interface SysDishesMapper public interface SysDishesMapper {
{
/** /**
* 查询菜品 * 查询菜品
* *
* @param id 菜品ID * @param id 菜品ID
* @return 菜品 * @return 菜品
*/ */
@ -27,7 +26,7 @@ public interface SysDishesMapper
/** /**
* 查询菜品列表 * 查询菜品列表
* *
* @param sysDishes 菜品 * @param sysDishes 菜品
* @return 菜品集合 * @return 菜品集合
*/ */
@ -35,7 +34,7 @@ public interface SysDishesMapper
/** /**
* 新增菜品 * 新增菜品
* *
* @param sysDishes 菜品 * @param sysDishes 菜品
* @return 结果 * @return 结果
*/ */
@ -43,7 +42,7 @@ public interface SysDishesMapper
/** /**
* 修改菜品 * 修改菜品
* *
* @param sysDishes 菜品 * @param sysDishes 菜品
* @return 结果 * @return 结果
*/ */
@ -51,7 +50,7 @@ public interface SysDishesMapper
/** /**
* 删除菜品 * 删除菜品
* *
* @param id 菜品ID * @param id 菜品ID
* @return 结果 * @return 结果
*/ */
@ -59,7 +58,7 @@ public interface SysDishesMapper
/** /**
* 批量删除菜品 * 批量删除菜品
* *
* @param ids 需要删除的数据ID * @param ids 需要删除的数据ID
* @return 结果 * @return 结果
*/ */
@ -72,4 +71,13 @@ public interface SysDishesMapper
public int bashInsertDishesIngredent(List<SysDishesIngredient> sysDishesIngredients); public int bashInsertDishesIngredent(List<SysDishesIngredient> sysDishesIngredients);
String getDishesMenuTypeById(Long id); String getDishesMenuTypeById(Long id);
int batchInsertDishesRec(List<SysPhysicalSignsObj> sysPhysicalSignsObj);
int batchInsertDishesNotRec(List<SysPhysicalSignsObj> sysPhysicalSignsObj);
int deleteDishesRecByDishesId(Long dishesId);
int deleteDishesNotRecByDishesId(Long dishesId);
} }

View File

@ -2,8 +2,7 @@ package com.stdiet.custom.mapper;
import com.stdiet.custom.domain.SysIngredentFile; import com.stdiet.custom.domain.SysIngredentFile;
import com.stdiet.custom.domain.SysIngredient; import com.stdiet.custom.domain.SysIngredient;
import com.stdiet.custom.domain.SysIngredientNotRec; import com.stdiet.custom.domain.SysPhysicalSignsObj;
import com.stdiet.custom.domain.SysIngredientRec;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -63,9 +62,9 @@ public interface SysIngredientMapper {
*/ */
// int deleteSysIngredientByIds(Long[] ids); // int deleteSysIngredientByIds(Long[] ids);
int batchIngredientRec(List<SysIngredientRec> ingredientRecList); int batchIngredientRec(List<SysPhysicalSignsObj> ingredientRecList);
int batchIngredientNotRec(List<SysIngredientNotRec> ingredientNotRecList); int batchIngredientNotRec(List<SysPhysicalSignsObj> ingredientNotRecList);
int deleteIngredientRecByIngredientId(Long recId); int deleteIngredientRecByIngredientId(Long recId);

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.stdiet.custom.domain.SysDishes; import com.stdiet.custom.domain.SysDishes;
import com.stdiet.custom.domain.SysDishesIngredient; import com.stdiet.custom.domain.SysDishesIngredient;
import com.stdiet.custom.domain.SysIngredient; import com.stdiet.custom.domain.SysIngredient;
import com.stdiet.custom.domain.SysPhysicalSignsObj;
/** /**
* 菜品Service接口 * 菜品Service接口
@ -64,4 +65,5 @@ public interface ISysDishesService
public int deleteSysDishesById(Long id); public int deleteSysDishesById(Long id);
public String getDishesMenuTypeById(Long id); public String getDishesMenuTypeById(Long id);
} }

View File

@ -2,8 +2,7 @@ package com.stdiet.custom.service.impl;
import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils; import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.SysDishes; import com.stdiet.custom.domain.*;
import com.stdiet.custom.domain.SysDishesIngredient;
import com.stdiet.custom.mapper.SysDishesMapper; import com.stdiet.custom.mapper.SysDishesMapper;
import com.stdiet.custom.service.ISysDishesService; import com.stdiet.custom.service.ISysDishesService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -71,6 +70,10 @@ public class SysDishesServiceImpl implements ISysDishesService {
sysDishes.setCreateTime(DateUtils.getNowDate()); sysDishes.setCreateTime(DateUtils.getNowDate());
int rows = sysDishesMapper.insertSysDishes(sysDishes); int rows = sysDishesMapper.insertSysDishes(sysDishes);
// //
insertRecommand(sysDishes);
//
insertNotRecommand(sysDishes);
//
insertDishesIngredient(sysDishes); insertDishesIngredient(sysDishes);
return rows; return rows;
} }
@ -96,11 +99,61 @@ public class SysDishesServiceImpl implements ISysDishesService {
public int updateSysDishes(SysDishes sysDishes) { public int updateSysDishes(SysDishes sysDishes) {
sysDishes.setUpdateTime(DateUtils.getNowDate()); sysDishes.setUpdateTime(DateUtils.getNowDate());
Long dishesId = sysDishes.getId(); Long dishesId = sysDishes.getId();
//
sysDishesMapper.deleteDishesRecByDishesId(dishesId);
insertRecommand(sysDishes);
//
sysDishesMapper.deleteDishesNotRecByDishesId(dishesId);
insertNotRecommand(sysDishes);
//
sysDishesMapper.deleteIngredientById(dishesId); sysDishesMapper.deleteIngredientById(dishesId);
insertDishesIngredient(sysDishes); insertDishesIngredient(sysDishes);
//
return sysDishesMapper.updateSysDishes(sysDishes); return sysDishesMapper.updateSysDishes(sysDishes);
} }
/**
* 新增推荐标签
*
* @param sysDishes
*/
public void insertRecommand(SysDishes sysDishes) {
Long[] recIds = sysDishes.getRecIds();
if (StringUtils.isNotNull(recIds)) {
List<SysPhysicalSignsObj> list = new ArrayList<>();
for (Long recId : recIds) {
SysPhysicalSignsObj rec = new SysPhysicalSignsObj();
rec.setTargetId(sysDishes.getId());
rec.setPhysicalSignsId(recId);
list.add(rec);
}
if (list.size() > 0) {
sysDishesMapper.batchInsertDishesRec(list);
}
}
}
/**
* 新增不推荐标签
*
* @param sysDishes
*/
public void insertNotRecommand(SysDishes sysDishes) {
Long[] notRecIds = sysDishes.getNotRecIds();
if (StringUtils.isNotNull(notRecIds)) {
List<SysPhysicalSignsObj> list = new ArrayList<>();
for (Long recId : notRecIds) {
SysPhysicalSignsObj notRec = new SysPhysicalSignsObj();
notRec.setTargetId(sysDishes.getId());
notRec.setPhysicalSignsId(recId);
list.add(notRec);
}
if (list.size() > 0) {
sysDishesMapper.batchInsertDishesNotRec(list);
}
}
}
/** /**
* 批量删除菜品 * 批量删除菜品
* *
@ -129,4 +182,5 @@ public class SysDishesServiceImpl implements ISysDishesService {
public String getDishesMenuTypeById(Long id) { public String getDishesMenuTypeById(Long id) {
return sysDishesMapper.getDishesMenuTypeById(id); return sysDishesMapper.getDishesMenuTypeById(id);
} }
} }

View File

@ -6,8 +6,7 @@ import com.stdiet.common.utils.StringUtils;
import com.stdiet.common.utils.oss.AliyunOSSUtils; import com.stdiet.common.utils.oss.AliyunOSSUtils;
import com.stdiet.custom.domain.SysIngredentFile; import com.stdiet.custom.domain.SysIngredentFile;
import com.stdiet.custom.domain.SysIngredient; import com.stdiet.custom.domain.SysIngredient;
import com.stdiet.custom.domain.SysIngredientNotRec; import com.stdiet.custom.domain.SysPhysicalSignsObj;
import com.stdiet.custom.domain.SysIngredientRec;
import com.stdiet.custom.mapper.SysIngredientMapper; import com.stdiet.custom.mapper.SysIngredientMapper;
import com.stdiet.custom.service.ISysIngredientService; import com.stdiet.custom.service.ISysIngredientService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -96,11 +95,11 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
public void insertRecommand(SysIngredient ingredient) { public void insertRecommand(SysIngredient ingredient) {
Long[] recIds = ingredient.getRecIds(); Long[] recIds = ingredient.getRecIds();
if (StringUtils.isNotNull(recIds)) { if (StringUtils.isNotNull(recIds)) {
List<SysIngredientRec> list = new ArrayList<SysIngredientRec>(); List<SysPhysicalSignsObj> list = new ArrayList<SysPhysicalSignsObj>();
for (Long recId : recIds) { for (Long recId : recIds) {
SysIngredientRec rec = new SysIngredientRec(); SysPhysicalSignsObj rec = new SysPhysicalSignsObj();
rec.setIngredientId(ingredient.getId()); rec.setTargetId(ingredient.getId());
rec.setRecommandId(recId); rec.setPhysicalSignsId(recId);
list.add(rec); list.add(rec);
} }
if (list.size() > 0) { if (list.size() > 0) {
@ -117,11 +116,11 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
public void insertNotRecommand(SysIngredient ingredient) { public void insertNotRecommand(SysIngredient ingredient) {
Long[] notRecIds = ingredient.getNotRecIds(); Long[] notRecIds = ingredient.getNotRecIds();
if (StringUtils.isNotNull(notRecIds)) { if (StringUtils.isNotNull(notRecIds)) {
List<SysIngredientNotRec> list = new ArrayList<SysIngredientNotRec>(); List<SysPhysicalSignsObj> list = new ArrayList<SysPhysicalSignsObj>();
for (Long recId : notRecIds) { for (Long recId : notRecIds) {
SysIngredientNotRec notRec = new SysIngredientNotRec(); SysPhysicalSignsObj notRec = new SysPhysicalSignsObj();
notRec.setIngredientId(ingredient.getId()); notRec.setTargetId(ingredient.getId());
notRec.setRecommandId(recId); notRec.setPhysicalSignsId(recId);
list.add(notRec); list.add(notRec);
} }
if (list.size() > 0) { if (list.size() > 0) {
@ -160,12 +159,16 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
public int updateSysIngredient(SysIngredient sysIngredient) { public int updateSysIngredient(SysIngredient sysIngredient) {
sysIngredient.setUpdateTime(DateUtils.getNowDate()); sysIngredient.setUpdateTime(DateUtils.getNowDate());
Long ingredientId = sysIngredient.getId(); Long ingredientId = sysIngredient.getId();
//
sysIngredientMapper.deleteIngredientNotRecByIngredientId(ingredientId); sysIngredientMapper.deleteIngredientNotRecByIngredientId(ingredientId);
insertNotRecommand(sysIngredient); insertNotRecommand(sysIngredient);
//
sysIngredientMapper.deleteIngredientRecByIngredientId(ingredientId); sysIngredientMapper.deleteIngredientRecByIngredientId(ingredientId);
insertRecommand(sysIngredient); insertRecommand(sysIngredient);
//
sysIngredientMapper.deleteIngredientImageById(ingredientId); sysIngredientMapper.deleteIngredientImageById(ingredientId);
insertImageFiles(sysIngredient); insertImageFiles(sysIngredient);
//
return sysIngredientMapper.updateSysIngredient(sysIngredient); return sysIngredientMapper.updateSysIngredient(sysIngredient);
} }

View File

@ -21,6 +21,7 @@
<!-- 非持久化字段 --> <!-- 非持久化字段 -->
<result property="bigClassName" column="bigClassName"/> <result property="bigClassName" column="bigClassName"/>
<result property="smallClassName" column="smallClassName"/> <result property="smallClassName" column="smallClassName"/>
<association property="igdList" column="id" select="selectSysIngreditentsById"/>
</resultMap> </resultMap>
<resultMap type="SysDishesIngredient" id="SysDishesIngredientResult"> <resultMap type="SysDishesIngredient" id="SysDishesIngredientResult">
@ -32,7 +33,9 @@
<result property="carbonRatio" column="carbon_ratio"/> <result property="carbonRatio" column="carbon_ratio"/>
<result property="area" column="area"/> <result property="area" column="area"/>
<result property="rec" column="rec"/> <result property="rec" column="rec"/>
<result property="recIdsStr" column="rec_ids"/>
<result property="notRec" column="not_rec"/> <result property="notRec" column="not_rec"/>
<result property="notRecIdsStr" column="not_rec_ids"/>
<result property="cusWeight" column="cus_weight"/> <result property="cusWeight" column="cus_weight"/>
<result property="cusUnit" column="cus_unit"/> <result property="cusUnit" column="cus_unit"/>
<result property="weight" column="weight"/> <result property="weight" column="weight"/>
@ -47,6 +50,9 @@
<where> <where>
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''">and FIND_IN_SET(#{type}, type)</if> <if test="type != null and type != ''">and FIND_IN_SET(#{type}, type)</if>
<if test="physical != null and physical != ''">
and id in(SELECT DISTINCT(dishes_id) FROM sys_dishes_rec WHERE physical_signs_id = #{physical})
</if>
<if test="bigClass != null">and big_class = #{bigClass}</if> <if test="bigClass != null">and big_class = #{bigClass}</if>
<if test="smallClass != null">and small_class = #{smallClass}</if> <if test="smallClass != null">and small_class = #{smallClass}</if>
<if test="reviewStatus != null and type != ''">and review_status = #{reviewStatus}</if> <if test="reviewStatus != null and type != ''">and review_status = #{reviewStatus}</if>
@ -63,17 +69,17 @@
WHERE dishes_id = #{id} WHERE dishes_id = #{id}
) dishes ) dishes
LEFT JOIN ( LEFT JOIN (
SELECT id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, not_rec, rec SELECT id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, not_rec, not_rec_ids, rec, rec_ids
FROM sys_ingredient igd FROM sys_ingredient igd
LEFT JOIN ( LEFT JOIN (
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM( SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec, GROUP_CONCAT(notRec.id SEPARATOR ',') not_rec_ids FROM(
SELECT physical_signs_id as id, ingredient_id SELECT physical_signs_id as id, ingredient_id
FROM sys_ingredient_not_rec FROM sys_ingredient_not_rec
) notRec JOIN sys_physical_signs phy USING(id) ) notRec JOIN sys_physical_signs phy USING(id)
GROUP BY id GROUP BY id
) notRecT USING(id) ) notRecT USING(id)
LEFT JOIN ( LEFT JOIN (
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM( SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec, GROUP_CONCAT(rec.id SEPARATOR ',') rec_ids FROM(
SELECT physical_signs_id as id, ingredient_id SELECT physical_signs_id as id, ingredient_id
FROM sys_ingredient_rec FROM sys_ingredient_rec
) rec JOIN sys_physical_signs phy USING(id) ) rec JOIN sys_physical_signs phy USING(id)
@ -175,4 +181,27 @@
select type from sys_dishes where id=#{id} select type from sys_dishes where id=#{id}
</select> </select>
<!-- 推荐,不推荐-->
<insert id="batchInsertDishesRec">
insert into sys_dishes_rec(dishes_id, physical_signs_id) values
<foreach collection="list" separator="," item="item" index="index">
(#{item.targetId},#{item.physicalSignsId})
</foreach>
</insert>
<insert id="batchInsertDishesNotRec">
insert into sys_dishes_not_rec(dishes_id, physical_signs_id) values
<foreach collection="list" separator="," item="item" index="index">
(#{item.targetId},#{item.physicalSignsId})
</foreach>
</insert>
<delete id="deleteDishesRecByDishesId" parameterType="Long">
delete from sys_dishes_rec where dishes_id=#{dishesId}
</delete>
<delete id="deleteDishesNotRecByDishesId" parameterType="Long">
delete from sys_dishes_not_rec where dishes_id=#{dishesId}
</delete>
</mapper> </mapper>

View File

@ -149,14 +149,14 @@
<insert id="batchIngredientRec"> <insert id="batchIngredientRec">
insert into sys_ingredient_rec(ingredient_id, physical_signs_id) values insert into sys_ingredient_rec(ingredient_id, physical_signs_id) values
<foreach collection="list" separator="," item="item" index="index"> <foreach collection="list" separator="," item="item" index="index">
(#{item.ingredientId},#{item.recommandId}) (#{item.targetId},#{item.physicalSignsId})
</foreach> </foreach>
</insert> </insert>
<insert id="batchIngredientNotRec"> <insert id="batchIngredientNotRec">
insert into sys_ingredient_not_rec(ingredient_id, physical_signs_id) values insert into sys_ingredient_not_rec(ingredient_id, physical_signs_id) values
<foreach collection="list" separator="," item="item" index="index"> <foreach collection="list" separator="," item="item" index="index">
(#{item.ingredientId},#{item.notRecommandId}) (#{item.targetId},#{item.physicalSignsId})
</foreach> </foreach>
</insert> </insert>

View File

@ -5,27 +5,30 @@
<mapper namespace="com.stdiet.custom.mapper.SysPhysicalSignsMapper"> <mapper namespace="com.stdiet.custom.mapper.SysPhysicalSignsMapper">
<resultMap type="SysPhysicalSigns" id="SysPhysicalSignsResult"> <resultMap type="SysPhysicalSigns" id="SysPhysicalSignsResult">
<result property="id" column="id" /> <result property="id" column="id"/>
<result property="name" column="name" /> <result property="name" column="name"/>
<result property="typeId" column="type_id" /> <result property="typeId" column="type_id"/>
<result property="remark" column="remark" /> <result property="typeName" column="type_name"/>
<result property="remark" column="remark"/>
</resultMap> </resultMap>
<sql id="selectSysPhysicalSignsVo"> <sql id="selectSysPhysicalSignsVo">
select id, name, type_id, remark from sys_physical_signs SELECT name, id, sdd.dict_label AS type_name, type_id FROM sys_physical_signs
LEFT JOIN (SELECT * FROM sys_dict_data WHERE dict_type = 'cus_signs_type') AS sdd ON sdd.dict_value = type_id
</sql> </sql>
<select id="selectSysPhysicalSignsList" parameterType="SysPhysicalSigns" resultMap="SysPhysicalSignsResult"> <select id="selectSysPhysicalSignsList" parameterType="SysPhysicalSigns" resultMap="SysPhysicalSignsResult">
<include refid="selectSysPhysicalSignsVo"/> <include refid="selectSysPhysicalSignsVo"/>
<where> <where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="typeId != null "> and type_id = #{typeId}</if> <if test="typeId != null ">and type_id = #{typeId}</if>
</where> </where>
ORDER BY type_id ASC
</select> </select>
<select id="selectSysPhysicalSignsById" parameterType="Long" resultMap="SysPhysicalSignsResult"> <select id="selectSysPhysicalSignsById" parameterType="Long" resultMap="SysPhysicalSignsResult">
<include refid="selectSysPhysicalSignsVo"/> <include refid="selectSysPhysicalSignsVo"/>
where id = #{id} where sps.id = #{id}
</select> </select>
<insert id="insertSysPhysicalSigns" parameterType="SysPhysicalSigns" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSysPhysicalSigns" parameterType="SysPhysicalSigns" useGeneratedKeys="true" keyProperty="id">
@ -63,4 +66,5 @@
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

View File

@ -14,6 +14,7 @@ import { getRecipesPlan, updateRecipesPlan } from "@/api/custom/recipesPlan";
import { getDicts } from "@/api/system/dict/data"; import { getDicts } from "@/api/system/dict/data";
import { addShortCut } from "@/utils/shortCutUtils"; import { addShortCut } from "@/utils/shortCutUtils";
import { messageTypes } from "@/utils"; import { messageTypes } from "@/utils";
import { listPhysicalSigns } from "@/api/custom/physicalSigns";
const oriState = { const oriState = {
cusId: undefined, cusId: undefined,
@ -46,6 +47,7 @@ const oriState = {
notRecIgds: [], notRecIgds: [],
avoidFoodIds: [], avoidFoodIds: [],
igdTypeOptions: [], igdTypeOptions: [],
physicalSignsOptions: [],
// //
curShortCutObj: {} curShortCutObj: {}
}; };
@ -175,6 +177,31 @@ const actions = {
getDicts("cus_ing_type").then(response => { getDicts("cus_ing_type").then(response => {
commit("updateStateData", { igdTypeOptions: response.data }); commit("updateStateData", { igdTypeOptions: response.data });
}); });
listPhysicalSigns().then(response => {
commit("updateStateData", {
physicalSignsOptions: response.rows.reduce((arr, cur) => {
const tarTypeObj = arr.find(obj => obj.value === cur.typeId);
if (!tarTypeObj) {
arr.push({
value: cur.typeId,
label: cur.typeName,
children: [
{
value: cur.id,
label: cur.name
}
]
});
} else {
tarTypeObj.children.push({
value: cur.id,
label: cur.name
});
}
return arr;
}, [])
});
});
return new Promise((res, rej) => { return new Promise((res, rej) => {
// 健康数据 // 健康数据

View File

@ -149,7 +149,10 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" size="mini" @click="handleOnDelete(scope.row)" <el-button
type="text"
size="mini"
@click="handleOnDelete(scope.row)"
>删除</el-button >删除</el-button
> >
</template> </template>
@ -252,6 +255,8 @@ export default {
// //
selRec: [], selRec: [],
selNotRec: [], selNotRec: [],
selRecIds: [],
selNotRecIds: [],
}; };
}, },
props: [ props: [
@ -265,24 +270,41 @@ export default {
"form.igdList": function (val) { "form.igdList": function (val) {
const selRec = []; const selRec = [];
const selNotRec = []; const selNotRec = [];
const selRecIds = [];
const selNotRecIds = [];
val.forEach((obj) => { val.forEach((obj) => {
if (obj.rec) { if (obj.rec) {
obj.rec.split(",").forEach((rec) => { obj.rec
if (!selRec.includes(rec)) { .split(",")
selRec.push(rec); .forEach((rec) => !selRec.includes(rec) && selRec.push(rec));
}
});
} }
if (obj.notRec) { if (obj.notRec) {
obj.notRec.split(",").forEach((notRec) => { obj.notRec
if (!selNotRec.includes(notRec)) { .split(",")
selNotRec.push(notRec); .forEach(
} (notRec) => !selNotRec.includes(notRec) && selNotRec.push(notRec)
}); );
}
if (obj.recIdsStr) {
obj.recIdsStr
.split(",")
.forEach(
(recId) => !selRecIds.includes(recId) && selRecIds.push(recId)
);
}
if (obj.notRecIdsStr) {
obj.notRecIdsStr
.split(",")
.forEach(
(notRecId) =>
!selNotRecIds.includes(notRecId) && selNotRecIds.push(notRecId)
);
} }
}); });
this.selRec = selRec; this.selRec = selRec;
this.selNotRec = selNotRec; this.selNotRec = selNotRec;
this.selRecIds = selRecIds;
this.selNotRecIds = selNotRecIds;
}, },
showNotRec() { showNotRec() {
@ -362,6 +384,8 @@ export default {
const data = JSON.parse(JSON.stringify(this.form)); const data = JSON.parse(JSON.stringify(this.form));
// console.log({ data }); // console.log({ data });
data.type = data.type.join(","); data.type = data.type.join(",");
data.recIds = this.selRecIds;
data.notRecIds = this.selNotRecIds;
if (data.id != null) { if (data.id != null) {
updateDishes(data).then((response) => { updateDishes(data).then((response) => {
if (response.code === 200) { if (response.code === 200) {

View File

@ -137,7 +137,11 @@
<autohideinfo :data="scope.row.notRecTags" /> <autohideinfo :data="scope.row.notRecTags" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="做法" align="center" prop="methods" /> <el-table-column label="做法" align="center" prop="methods">
<template slot-scope="scope">
<auto-hide-message :data="scope.row.methods" :maxLength="20" />
</template>
</el-table-column>
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
@ -188,12 +192,14 @@
<script> <script>
import { delDishes, exportDishes, listDishes } from "@/api/custom/dishes"; import { delDishes, exportDishes, listDishes } from "@/api/custom/dishes";
import AutoHideInfo from "@/components/AutoHideInfo"; import AutoHideInfo from "@/components/AutoHideInfo";
import AutoHideMessage from "@/components/AutoHideMessage";
import EditDishesDrawer from "./EditDishesDrawer"; import EditDishesDrawer from "./EditDishesDrawer";
export default { export default {
name: "Dishes", name: "Dishes",
components: { components: {
autohideinfo: AutoHideInfo, autohideinfo: AutoHideInfo,
AutoHideMessage,
EditDishesDrawer, EditDishesDrawer,
}, },
data() { data() {
@ -374,7 +380,7 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$confirm('是否确认删除菜品「' + row.name + '」的数据项?', "警告", { this.$confirm("是否确认删除菜品「" + row.name + "」的数据项?", "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",

View File

@ -52,6 +52,20 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6">
<el-form-item label="推荐体征" prop="physical">
<el-cascader
:disabled="lockType"
v-model="queryParams.physical"
placeholder="请选择推荐体征"
clearable
:options="physicalSignsOptions"
size="mini"
width="120px"
@change="handleOnPhysicalSignsChange"
/>
</el-form-item>
</el-col>
<el-form-item> <el-form-item>
<el-button <el-button
type="cyan" type="cyan"
@ -71,7 +85,7 @@
v-loading="loading" v-loading="loading"
size="mini" size="mini"
:data="dishesList" :data="dishesList"
height="600" height="550"
highlight-current-row highlight-current-row
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
> >
@ -141,6 +155,7 @@ export default {
smallClass: null, smallClass: null,
bigClass: null, bigClass: null,
reviewStatus: "yes", reviewStatus: "yes",
physical: null,
}, },
// //
dishClassQueryParam: [], dishClassQueryParam: [],
@ -155,6 +170,7 @@ export default {
"typeOptions", "typeOptions",
"dishBigClassOptions", "dishBigClassOptions",
"dishSmallClassOptions", "dishSmallClassOptions",
"physicalSignsOptions",
]), ]),
...mapGetters(["dishClassOptions"]), ...mapGetters(["dishClassOptions"]),
}, },
@ -174,7 +190,13 @@ export default {
this.queryParams.smallClass = null; this.queryParams.smallClass = null;
} }
this.loading = true; this.loading = true;
listDishes(this.queryParams).then((result) => { const qParams = {
...this.queryParams,
};
if (this.queryParams.physical) {
qParams.physical = this.queryParams.physical[1];
}
listDishes(qParams).then((result) => {
this.dishesList = result.rows.map((d) => { this.dishesList = result.rows.map((d) => {
const recTags = [], const recTags = [],
notRecTags = []; notRecTags = [];
@ -249,6 +271,10 @@ export default {
} }
return ""; return "";
}, },
handleOnPhysicalSignsChange(val) {
const [typeId, id] = val;
console.log(val);
},
}, },
}; };
</script> </script>