130 lines
6.2 KiB
XML
Raw Normal View History

<?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.zhyc.module.produce.bodyManage.mapper.ScBreastRatingMapper">
<resultMap type="com.zhyc.module.produce.bodyManage.domain.ScBreastRating" id="ScBreastRatingResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manageTags"/>
<result property="varietyId" column="varietyId"/>
<result property="varietyName" column="varietyName"/>
<result property="eventType" column="event_type"/>
<result property="eventDate" column="event_date"/>
<result property="sheepfoldId" column="sheepfoldId"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="depth" column="depth"/>
<result property="length" column="length"/>
<result property="position" column="position"/>
<result property="adbere" column="adbere"/>
<result property="spacing" column="spacing"/>
<result property="score" column="score"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectScBreastRatingVo">
select sbr.*,
bs.manage_tags as manageTags,
bsv.id as varietyId,
bsv.variety as varietyName,
'乳房评分' as event_type,
sf.id as sheepfoldId,
sf.sheepfold_name as sheepfoldName,
sbr.event_date
from sc_breast_rating sbr
left join bas_sheep bs on sbr.sheep_id = bs.id
left join bas_sheep_variety bsv on bs.variety_id = bsv.id
left join da_sheepfold sf on bs.sheepfold_id = sf.id
</sql>
<select id="selectScBreastRatingList" parameterType="ScBreastRating" resultMap="ScBreastRatingResult">
<include refid="selectScBreastRatingVo"/>
<where>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="varietyId != null">and bsv.id = #{varietyId}</if>
<if test="sheepfoldId != null">and sf.id = #{sheepfoldId}</if>
<if test="params.beginEventDate != null and params.endEventDate != null">
and sbr.event_date between #{params.beginEventDate} and #{params.endEventDate}
</if>
<if test="params.beginCreateTime != null and params.endCreateTime != null">
and sbr.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
2025-12-04 16:36:16 +08:00
<if test="true">ORDER BY sbr.create_time DESC</if>
</select>
<select id="selectScBreastRatingById" parameterType="Long" resultMap="ScBreastRatingResult">
<include refid="selectScBreastRatingVo"/>
where sbr.id = #{id}
</select>
<insert id="insertScBreastRating" parameterType="ScBreastRating" useGeneratedKeys="true" keyProperty="id">
insert into sc_breast_rating
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="eventDate != null">event_date,</if>
<if test="depth != null">depth,</if>
<if test="length != null">length,</if>
<if test="position != null">position,</if>
<if test="adbere != null">adbere,</if>
<if test="spacing != null">spacing,</if>
<if test="score != null">score,</if>
<if test="comment != null">comment,</if>
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="depth != null">#{depth},</if>
<if test="length != null">#{length},</if>
<if test="position != null">#{position},</if>
<if test="adbere != null">#{adbere},</if>
<if test="spacing != null">#{spacing},</if>
<if test="score != null">#{score},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateScBreastRating" parameterType="ScBreastRating">
update sc_breast_rating
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="eventDate != null">event_date = #{eventDate},</if>
<if test="depth != null">depth = #{depth},</if>
<if test="length != null">length = #{length},</if>
<if test="position != null">position = #{position},</if>
<if test="adbere != null">adbere = #{adbere},</if>
<if test="spacing != null">spacing = #{spacing},</if>
<if test="score != null">score = #{score},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScBreastRatingById" parameterType="Long">
delete
from sc_breast_rating
where id = #{id}
</delete>
<delete id="deleteScBreastRatingByIds" parameterType="String">
delete from sc_breast_rating where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>