2025-07-09 14:31:05 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
<!DOCTYPE mapper
|
2025-07-12 17:56:28 +08:00
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2025-07-18 15:27:22 +08:00
|
|
|
<mapper namespace="com.zhyc.module.produce.other.mapper.ScCastrateMapper">
|
2025-07-12 17:56:28 +08:00
|
|
|
|
2025-07-09 14:31:05 +08:00
|
|
|
<resultMap type="ScCastrate" id="ScCastrateResult">
|
2025-07-12 17:56:28 +08:00
|
|
|
<result property="id" column="id"/>
|
|
|
|
<result property="sheepId" column="sheep_id"/>
|
2025-07-22 14:55:18 +08:00
|
|
|
<result property="manageTags" column="manageTags"/> <!-- 新增耳号映射 -->
|
2025-07-12 17:56:28 +08:00
|
|
|
<result property="sheepfold" column="sheepfold"/>
|
2025-07-22 14:55:18 +08:00
|
|
|
<result property="sheepfoldName" column="sheepfoldName"/>
|
2025-07-17 09:58:44 +08:00
|
|
|
<result property="varietyId" column="variety_id"/>
|
2025-07-22 14:55:18 +08:00
|
|
|
<result property="varietyName" column="varietyName"/>
|
|
|
|
<result property="comment" column="comment"/>
|
2025-07-12 17:56:28 +08:00
|
|
|
<result property="technician" column="technician"/>
|
|
|
|
<result property="createBy" column="create_by"/>
|
|
|
|
<result property="createTime" column="create_time"/>
|
2025-07-09 14:31:05 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<sql id="selectScCastrateVo">
|
2025-07-12 17:56:28 +08:00
|
|
|
select sc.id,
|
|
|
|
sc.sheep_id,
|
2025-07-22 14:55:18 +08:00
|
|
|
bs.manage_tags as manageTags, -- 关联羊只表的耳号
|
2025-07-12 17:56:28 +08:00
|
|
|
sc.sheepfold,
|
|
|
|
sf.sheepfold_name as sheepfoldName,
|
2025-07-17 09:58:44 +08:00
|
|
|
sc.variety_id,
|
2025-07-22 14:55:18 +08:00
|
|
|
bv.variety as varietyName,
|
2025-07-12 17:56:28 +08:00
|
|
|
sc.comment,
|
|
|
|
sc.technician,
|
|
|
|
sc.create_by,
|
|
|
|
sc.create_time
|
|
|
|
from sc_castrate sc
|
2025-07-22 14:55:18 +08:00
|
|
|
left join bas_sheep bs on sc.sheep_id = bs.id -- 关联羊只表获取耳号
|
2025-07-12 17:56:28 +08:00
|
|
|
left join da_sheepfold sf on sc.sheepfold = sf.id
|
2025-07-17 09:58:44 +08:00
|
|
|
left join bas_sheep_variety bv on sc.variety_id = bv.id
|
2025-07-09 14:31:05 +08:00
|
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="selectScCastrateList" parameterType="ScCastrate" resultMap="ScCastrateResult">
|
|
|
|
<include refid="selectScCastrateVo"/>
|
2025-07-12 17:56:28 +08:00
|
|
|
<where>
|
2025-07-22 14:55:18 +08:00
|
|
|
<!-- 替换原sheepId条件为耳号条件 -->
|
|
|
|
<if test="manageTags != null and manageTags != ''">
|
|
|
|
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
2025-07-17 09:58:44 +08:00
|
|
|
</if>
|
2025-07-22 14:55:18 +08:00
|
|
|
<if test="sheepfold != null ">and sc.sheepfold = #{sheepfold}</if>
|
|
|
|
<if test="varietyId != null">and sc.variety_id = #{varietyId}</if>
|
|
|
|
<if test="technician != null and technician != ''">and sc.technician like concat('%', #{technician}, '%')</if>
|
|
|
|
<if test="params.beginCreateTime != null and params.endCreateTime != null">
|
|
|
|
and sc.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
2025-07-12 17:56:28 +08:00
|
|
|
</if>
|
2025-07-09 14:31:05 +08:00
|
|
|
</where>
|
|
|
|
</select>
|
2025-07-12 17:56:28 +08:00
|
|
|
|
2025-07-09 14:31:05 +08:00
|
|
|
<select id="selectScCastrateById" parameterType="Long" resultMap="ScCastrateResult">
|
|
|
|
<include refid="selectScCastrateVo"/>
|
2025-07-12 17:56:28 +08:00
|
|
|
where sc.id = #{id}
|
2025-07-09 14:31:05 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<insert id="insertScCastrate" parameterType="ScCastrate" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
insert into sc_castrate
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="sheepId != null">sheep_id,</if>
|
|
|
|
<if test="sheepfold != null">sheepfold,</if>
|
2025-07-17 09:58:44 +08:00
|
|
|
<if test="varietyId != null">variety_id,</if>
|
2025-07-09 14:31:05 +08:00
|
|
|
<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>
|
2025-07-12 17:56:28 +08:00
|
|
|
</trim>
|
2025-07-09 14:31:05 +08:00
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="sheepId != null">#{sheepId},</if>
|
|
|
|
<if test="sheepfold != null">#{sheepfold},</if>
|
2025-07-17 09:58:44 +08:00
|
|
|
<if test="varietyId != null">#{varietyId},</if>
|
2025-07-09 14:31:05 +08:00
|
|
|
<if test="comment != null">#{comment},</if>
|
|
|
|
<if test="technician != null">#{technician},</if>
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
2025-07-12 17:56:28 +08:00
|
|
|
</trim>
|
2025-07-09 14:31:05 +08:00
|
|
|
</insert>
|
|
|
|
|
|
|
|
<update id="updateScCastrate" parameterType="ScCastrate">
|
|
|
|
update sc_castrate
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
|
|
|
<if test="sheepfold != null">sheepfold = #{sheepfold},</if>
|
2025-07-17 09:58:44 +08:00
|
|
|
<if test="varietyId != null">variety_id = #{varietyId},</if>
|
2025-07-09 14:31:05 +08:00
|
|
|
<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="deleteScCastrateById" parameterType="Long">
|
2025-07-12 17:56:28 +08:00
|
|
|
delete
|
|
|
|
from sc_castrate
|
|
|
|
where id = #{id}
|
2025-07-09 14:31:05 +08:00
|
|
|
</delete>
|
|
|
|
|
|
|
|
<delete id="deleteScCastrateByIds" parameterType="String">
|
2025-07-12 17:56:28 +08:00
|
|
|
delete from sc_castrate where id in
|
2025-07-09 14:31:05 +08:00
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
</mapper>
|