111 lines
5.5 KiB
XML
111 lines
5.5 KiB
XML
|
<?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.ruoyi.material.mapper.CMaterialMapper">
|
||
|
|
||
|
<resultMap type="CMaterial" id="CMaterialResult">
|
||
|
<result property="materialId" column="material_id" />
|
||
|
<result property="materialXingh" column="material_xingh" />
|
||
|
<result property="materialGuig" column="material_guig" />
|
||
|
<result property="materialDiany" column="material_diany" />
|
||
|
<result property="materialDw" column="material_dw" />
|
||
|
</resultMap>
|
||
|
|
||
|
<resultMap id="CMaterialCMaterialCostResult" type="CMaterial" extends="CMaterialResult">
|
||
|
<collection property="cMaterialCostList" notNullColumn="sub_cost_id" javaType="java.util.List" resultMap="CMaterialCostResult" />
|
||
|
</resultMap>
|
||
|
|
||
|
<resultMap type="CMaterialCost" id="CMaterialCostResult">
|
||
|
<result property="costId" column="sub_cost_id" />
|
||
|
<result property="costMaterialId" column="sub_cost_material_id" />
|
||
|
<result property="costClId" column="sub_cost_cl_id" />
|
||
|
<result property="costClQty" column="sub_cost_cl_qty" />
|
||
|
<result property="costClQty2" column="sub_cost_cl_qty_2" />
|
||
|
<result property="materialPrice" column="sub_material_price" />
|
||
|
<result property="materialName" column="sub_material_name" />
|
||
|
|
||
|
</resultMap>
|
||
|
|
||
|
<sql id="selectCMaterialVo">
|
||
|
select material_id, material_xingh, material_guig, material_diany, material_dw from c_material
|
||
|
</sql>
|
||
|
|
||
|
<select id="selectCMaterialList" parameterType="CMaterial" resultMap="CMaterialResult">
|
||
|
<include refid="selectCMaterialVo"/>
|
||
|
<where>
|
||
|
<if test="materialXingh != null and materialXingh != ''"> and material_xingh like concat('%', #{materialXingh}, '%')</if>
|
||
|
<if test="materialGuig != null and materialGuig != ''"> and material_guig like concat('%', #{materialGuig}, '%')</if>
|
||
|
<if test="materialDiany != null and materialDiany != ''"> and material_diany like concat('%', #{materialDiany}, '%')</if>
|
||
|
</where>
|
||
|
</select>
|
||
|
|
||
|
<select id="selectCMaterialByMaterialId" parameterType="Long" resultMap="CMaterialCMaterialCostResult">
|
||
|
select a.material_id, a.material_xingh, a.material_guig, a.material_diany, a.material_dw,
|
||
|
b.cost_id as sub_cost_id, b.cost_material_id as sub_cost_material_id, b.cost_cl_id as sub_cost_cl_id,
|
||
|
b.cost_cl_qty as sub_cost_cl_qty, b.cost_cl_qty_2 as sub_cost_cl_qty_2,
|
||
|
c.material_price as sub_material_price,c.material_name as sub_material_name
|
||
|
from c_material a
|
||
|
left join c_material_cost b on b.cost_material_id = a.material_id
|
||
|
left join c_yl_material c on c.material_no = b.cost_cl_id
|
||
|
where a.material_id = #{materialId}
|
||
|
ORDER BY c.material_no ASC
|
||
|
</select>
|
||
|
|
||
|
<insert id="insertCMaterial" parameterType="CMaterial">
|
||
|
insert into c_material
|
||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
|
<if test="materialXingh != null and materialXingh != ''">material_xingh,</if>
|
||
|
<if test="materialGuig != null and materialGuig != ''">material_guig,</if>
|
||
|
<if test="materialDiany != null">material_diany,</if>
|
||
|
<if test="materialDw != null">material_dw,</if>
|
||
|
</trim>
|
||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
|
<if test="materialXingh != null and materialXingh != ''">#{materialXingh},</if>
|
||
|
<if test="materialGuig != null and materialGuig != ''">#{materialGuig},</if>
|
||
|
<if test="materialDiany != null">#{materialDiany},</if>
|
||
|
<if test="materialDw != null">#{materialDw},</if>
|
||
|
</trim>
|
||
|
</insert>
|
||
|
|
||
|
<update id="updateCMaterial" parameterType="CMaterial">
|
||
|
update c_material
|
||
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
<if test="materialXingh != null and materialXingh != ''">material_xingh = #{materialXingh},</if>
|
||
|
<if test="materialGuig != null and materialGuig != ''">material_guig = #{materialGuig},</if>
|
||
|
<if test="materialDiany != null">material_diany = #{materialDiany},</if>
|
||
|
<if test="materialDw != null">material_dw = #{materialDw},</if>
|
||
|
</trim>
|
||
|
where material_id = #{materialId}
|
||
|
</update>
|
||
|
|
||
|
<delete id="deleteCMaterialByMaterialId" parameterType="Long">
|
||
|
delete from c_material where material_id = #{materialId}
|
||
|
</delete>
|
||
|
|
||
|
<delete id="deleteCMaterialByMaterialIds" parameterType="String">
|
||
|
delete from c_material where material_id in
|
||
|
<foreach item="materialId" collection="array" open="(" separator="," close=")">
|
||
|
#{materialId}
|
||
|
</foreach>
|
||
|
</delete>
|
||
|
|
||
|
<delete id="deleteCMaterialCostByCostMaterialIds" parameterType="String">
|
||
|
delete from c_material_cost where cost_material_id in
|
||
|
<foreach item="costMaterialId" collection="array" open="(" separator="," close=")">
|
||
|
#{costMaterialId}
|
||
|
</foreach>
|
||
|
</delete>
|
||
|
|
||
|
<delete id="deleteCMaterialCostByCostMaterialId" parameterType="Long">
|
||
|
delete from c_material_cost where cost_material_id = #{costMaterialId}
|
||
|
</delete>
|
||
|
|
||
|
<insert id="batchCMaterialCost">
|
||
|
insert into c_material_cost( cost_material_id, cost_cl_id, cost_cl_qty, cost_cl_qty_2) values
|
||
|
<foreach item="item" index="index" collection="list" separator=",">
|
||
|
( #{item.costMaterialId}, #{item.costClId}, #{item.costClQty}, #{item.costClQty2})
|
||
|
</foreach>
|
||
|
</insert>
|
||
|
</mapper>
|