neu_carbon/neu-carbon-mes/src/main/resources/mapper/mes/MesFactoryModelMapper.xml
2024-11-23 22:02:06 +08:00

83 lines
3.6 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.neu.carbon.mes.mapper.MesFactoryModelMapper">
<resultMap type="MesFactoryModel" id="MesFactoryModelResult">
<result property="id" column="id" />
<result property="materialId" column="material_id" />
<result property="productLineName" column="product_line_name" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectMesFactoryModelVo">
select id, material_id, product_line_name, remark from mes_factory_model
</sql>
<select id="selectMesFactoryModelList" parameterType="MesFactoryModel" resultMap="MesFactoryModelResult">
<include refid="selectMesFactoryModelVo"/>
<where>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="productLineName != null and productLineName != ''"> and product_line_name like concat('%', #{productLineName}, '%')</if>
</where>
</select>
<select id="selectMesFactoryModelById" parameterType="Long" resultMap="MesFactoryModelResult">
<include refid="selectMesFactoryModelVo"/>
where id = #{id}
</select>
<insert id="insertMesFactoryModel" parameterType="MesFactoryModel" useGeneratedKeys="true" keyProperty="id">
insert into mes_factory_model
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="materialId != null">material_id,</if>
<if test="productLineName != null">product_line_name,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="materialId != null">#{materialId},</if>
<if test="productLineName != null">#{productLineName},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateMesFactoryModel" parameterType="MesFactoryModel">
update mes_factory_model
<trim prefix="SET" suffixOverrides=",">
<if test="materialId != null">material_id = #{materialId},</if>
<if test="productLineName != null">product_line_name = #{productLineName},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMesFactoryModelById" parameterType="Long">
delete from mes_factory_model where id = #{id}
</delete>
<delete id="deleteMesFactoryModelByIds" parameterType="String">
delete from mes_factory_model where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchMesFactoryModelDetail">
insert into mes_factory_model_detail(product_line_id,equipment_id) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.productLineId},#{item.equipmentId})
</foreach>
</insert>
<delete id="deleteMesFactoryModelDetailByProductLineIds">
delete from mes_factory_model_detail where product_line_id in
<foreach collection="array" item="id" index="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteMesFactoryModelDetailByProductLineId" parameterType="Long">
delete from mes_factory_model_detail where product_line_id = #{productLineId}
</delete>
</mapper>