去掉supermarket_material表

This commit is contained in:
sxu 2025-06-30 13:58:59 +08:00
parent 7ab95f37b7
commit 40d400107f
4 changed files with 32 additions and 19 deletions

View File

@ -57,6 +57,10 @@ public class SupermarketMaterial extends BaseEntity {
@ApiModelProperty(value = "类别ids")
private Long[] materialTypeIds;
/** 原料类型(1原料2商品) */
@ApiModelProperty(value = "原料类型(1原料2商品)")
private Long goodsType;
/** 条码 */
@Excel(name = "条码")
@ApiModelProperty(value = "条码")

View File

@ -57,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectCookMaterialList" parameterType="com.bonus.canteen.core.cook.domain.CookMaterial" resultMap="CookMaterialResult">
<include refid="selectCookMaterialVo"/>
<where>
cm.goods_type = 1
<if test="searchValue != null and searchValue != ''">
and (cm.material_name like concat('%', #{searchValue}, '%')
or cm.material_code like concat('%', #{searchValue}, '%'))
@ -74,7 +75,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="nutritionId != null "> and cm.nutrition_id = #{nutritionId}</if>
<if test="materialTypeId != null "> and cm.material_type_id = #{materialTypeId}</if>
<if test="nutritionTypeId != null and nutritionTypeId != ''"> and cm.nutrition_type_id = #{nutritionTypeId}</if>
<if test="goodsType != null "> and cm.goods_type = #{goodsType}</if>
<if test="barCode != null and barCode != ''"> and cm.bar_code = #{barCode}</if>
<if test="unitId != null "> and cm.unit_id = #{unitId}</if>
<if test="salePrice != null "> and cm.sale_price = #{salePrice}</if>
@ -92,18 +92,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectCookMaterialByMaterialId" parameterType="Long" resultMap="CookMaterialResult">
<include refid="selectCookMaterialVo"/>
where cm.material_id = #{materialId}
where cm.goods_type = 1 and cm.material_id = #{materialId}
</select>
<select id="checkIsExistByCode" resultType="java.lang.Integer">
select count(1) from cook_material where material_code = #{materialCode}
select count(1) from cook_material where cm.goods_type = 1 and material_code = #{materialCode}
<if test="materialId != null and materialId != ''"> and material_id != #{materialId}</if>
</select>
<select id="checkIsExistByName" resultType="java.lang.Integer">
select count(1) from cook_material where material_name = #{materialName}
select count(1) from cook_material where cm.goods_type = 1 and material_name = #{materialName}
<if test="materialId != null and materialId != ''"> and material_id != #{materialId}</if>
</select>
<select id="checkIsUse" resultType="java.lang.Integer">
select count(1) from cook_dishes_material where material_id
select count(1) from cook_dishes_material where cm.goods_type = 1 and material_id
in
<foreach item="materialId" collection="materialIds" open="(" separator="," close=")">
#{materialId}

View File

@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="imgUrl" column="img_url" />
<result property="materialTypeId" column="material_type_id" />
<result property="materialTypeName" column="material_type_name" />
<result property="goodsType" column="goods_type" />
<result property="barCode" column="bar_code" />
<result property="unitId" column="unit_id" />
<result property="unitName" column="unit_name" />
@ -33,10 +34,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectSupermarketMaterialVo">
select sm.material_id, sm.area_id, sm.material_name, sm.material_code, sm.img_url, sm.material_type_id,
sm.bar_code, sm.unit_id, sm.sale_price, sm.unit_price, sm.sales_mode, sm.shelf_life_type,
sm.shelf_life_days, sm.pur_price_ceiling, sm.big_category_id, sm.`size`, sm.description,
sm.shelf_life_days, sm.pur_price_ceiling, sm.big_category_id, sm.`size`, sm.description, sm.goods_type,
sm.create_by, sm.create_time, sm.update_by, sm.update_time,
ba.area_name, smt.material_type_name, iu.unit_name
from supermarket_material sm
from cook_material sm
left join basic_area ba on ba.area_id = sm.area_id
left join supermarket_material_type smt on smt.material_type_id = sm.material_type_id
left join ims_unit iu on iu.unit_id = sm.unit_id
@ -44,7 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSupermarketMaterialList" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketMaterial" resultMap="SupermarketMaterialResult">
<include refid="selectSupermarketMaterialVo"/>
<where>
<where>
goods_type = 2
<if test="areaId != null "> and sm.area_id = #{areaId}</if>
<if test="materialName != null and materialName != ''"> and sm.material_name like concat('%', #{materialName}, '%')</if>
<if test="materialCode != null and materialCode != ''"> and sm.material_code like concat('%', #{materialCode}, '%')</if>
@ -71,17 +73,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSupermarketMaterialByMaterialId" parameterType="Long" resultMap="SupermarketMaterialResult">
<include refid="selectSupermarketMaterialVo"/>
where sm.material_id = #{materialId}
where goods_type = 2 and sm.material_id = #{materialId}
</select>
<insert id="insertSupermarketMaterial" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketMaterial" useGeneratedKeys="true" keyProperty="materialId">
insert into supermarket_material
insert into cook_material
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaId != null">area_id,</if>
<if test="materialName != null and materialName != ''">material_name,</if>
<if test="materialCode != null and materialCode != ''">material_code,</if>
<if test="imgUrl != null and imgUrl != ''">img_url,</if>
<if test="materialTypeId != null">material_type_id,</if>
<if test="goodsType != null">goods_type,</if>
<if test="barCode != null">bar_code,</if>
<if test="unitId != null">unit_id,</if>
<if test="salePrice != null">sale_price,</if>
@ -104,6 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialCode != null and materialCode != ''">#{materialCode},</if>
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
<if test="materialTypeId != null">#{materialTypeId},</if>
<if test="goodsType != null">#{goodsType},</if>
<if test="barCode != null">#{barCode},</if>
<if test="unitId != null">#{unitId},</if>
<if test="salePrice != null">#{salePrice},</if>
@ -123,13 +127,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<update id="updateSupermarketMaterial" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketMaterial">
update supermarket_material
update cook_material
<trim prefix="SET" suffixOverrides=",">
<if test="areaId != null">area_id = #{areaId},</if>
<if test="materialName != null and materialName != ''">material_name = #{materialName},</if>
<if test="materialCode != null and materialCode != ''">material_code = #{materialCode},</if>
<if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
<if test="materialTypeId != null">material_type_id = #{materialTypeId},</if>
<if test="goodsType != null">goods_type = #{goodsType},</if>
<if test="barCode != null">bar_code = #{barCode},</if>
<if test="unitId != null">unit_id = #{unitId},</if>
<if test="salePrice != null">sale_price = #{salePrice},</if>
@ -150,11 +155,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteSupermarketMaterialByMaterialId" parameterType="Long">
delete from supermarket_material where material_id = #{materialId}
delete from cook_material where material_id = #{materialId}
</delete>
<delete id="deleteSupermarketMaterialByMaterialIds" parameterType="String">
delete from supermarket_material where material_id in
delete from cook_material where material_id in
<foreach item="materialId" collection="array" open="(" separator="," close=")">
#{materialId}
</foreach>
@ -162,7 +167,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getSupermarketMaterialCountByMaterialTypes" resultType="Integer">
select count(1)
from supermarket_material
from cook_material
where material_type_id in
<foreach item="materialTypeId" collection="array" open="(" separator="," close=")">
#{materialTypeId}

View File

@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sp.pref_price, sp.person_limit, sp.one_day_limit, sp.img_url, sp.inventory_num, sp.create_by,
sp.create_time, sp.update_by, sp.update_time, sm.material_name,smt.material_type_name, iu.unit_name
from supermarket_product sp
left join supermarket_material sm on sm.material_id = sp.material_id
left join cook_material sm on sm.material_id = sp.material_id
left join ims_unit iu on iu.unit_id = sm.unit_id
left join supermarket_material_type smt on smt.material_type_id = sm.material_type_id
</sql>
@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSupermarketProductList" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" resultMap="SupermarketProductResult">
<include refid="selectSupermarketProductVo"/>
<where>
sm.goods_type = 2
<if test="barCode != null"> and sm.bar_code like concat('%', #{barCode}, '%')</if>
<if test="materialName != null"> and sm.material_name like concat('%', #{materialName}, '%')</if>
<if test="supermarketId != null "> and sp.supermarket_id = #{supermarketId}</if>
@ -59,12 +60,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sm.shelf_life_days, sm.pur_price_ceiling, sm.big_category_id, sm.`size`, sm.description,
sm.create_by, sm.create_time, sm.update_by, sm.update_time,
ba.area_name, smt.material_type_name, iu.unit_name
from supermarket_material sm
from cook_material sm
left join basic_area ba on ba.area_id = sm.area_id
left join supermarket_material_type smt on smt.material_type_id = sm.material_type_id
left join ims_unit iu on iu.unit_id = sm.unit_id
left join supermarket_product sp on sm.material_id=sp.material_id
where sp.material_id is null
where sm.goods_type = 2 and sp.material_id is null
<if test="areaId != null and areaId != ''"> and sm.area_id = #{areaId}</if>
<if test="materialName != null and materialName != ''"> and sm.material_name like concat('%', #{materialName}, '%')</if>
<if test="barCode != null and barCode != ''"> and sm.bar_code = #{barCode}</if>
@ -73,12 +74,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSupermarketProductByProductId" parameterType="Long" resultMap="SupermarketProductResult">
<include refid="selectSupermarketProductVo"/>
where sp.product_id = #{productId}
where sm.goods_type = 2 and sp.product_id = #{productId}
</select>
<select id="selectSupermarketProductByMaterialIds" parameterType="String" resultMap="SupermarketProductResult">
<include refid="selectSupermarketProductVo"/>
where sp.material_id in
where sm.goods_type = 2 and sp.material_id in
<foreach item="materialId" collection="array" open="(" separator="," close=")">
#{materialId}
</foreach>