2025-07-12 17:56:28 +08:00
|
|
|
<?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">
|
|
|
|
|
2025-07-18 15:27:22 +08:00
|
|
|
<mapper namespace="com.zhyc.module.produce.manage_sheep.mapper.ScAddSheepMapper">
|
2025-07-17 09:58:44 +08:00
|
|
|
|
|
|
|
<!-- 1. 结果映射:包含羊舍名称、品种名称 -->
|
2025-07-18 15:27:22 +08:00
|
|
|
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScAddSheep" id="ScAddSheepResult">
|
2025-07-17 09:58:44 +08:00
|
|
|
<result property="id" column="id"/>
|
|
|
|
<result property="earNumber" column="ear_number"/>
|
|
|
|
<result property="sheepfold" column="sheepfold"/>
|
|
|
|
<result property="sheepfoldName" column="sheepfoldName"/>
|
|
|
|
<result property="father" column="father"/>
|
|
|
|
<result property="mother" column="mother"/>
|
|
|
|
<result property="bornWeight" column="born_weight"/>
|
|
|
|
<result property="birthday" column="birthday"/>
|
|
|
|
<result property="gender" column="gender"/>
|
|
|
|
<result property="parity" column="parity"/>
|
|
|
|
<result property="varietyId" column="variety_id"/>
|
|
|
|
<result property="varietyName" column="varietyName"/>
|
|
|
|
<result property="joinDate" column="join_date"/>
|
|
|
|
<result property="comment" column="comment"/>
|
|
|
|
<result property="technician" column="technician"/>
|
|
|
|
<result property="createBy" column="create_by"/>
|
|
|
|
<result property="createTime" column="create_time"/>
|
2025-07-12 17:56:28 +08:00
|
|
|
</resultMap>
|
|
|
|
|
2025-07-17 09:58:44 +08:00
|
|
|
<!-- 2. 查询列表:支持按品种筛选 -->
|
2025-07-12 17:56:28 +08:00
|
|
|
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
|
2025-07-15 18:40:22 +08:00
|
|
|
SELECT
|
|
|
|
sas.*,
|
2025-07-17 09:58:44 +08:00
|
|
|
sf.sheepfold_name AS sheepfoldName,
|
|
|
|
bv.variety AS varietyName
|
2025-07-15 18:40:22 +08:00
|
|
|
FROM sc_add_sheep sas
|
2025-07-17 09:58:44 +08:00
|
|
|
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
|
|
|
|
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
|
2025-07-12 17:56:28 +08:00
|
|
|
<where>
|
2025-07-15 18:40:22 +08:00
|
|
|
<if test="earNumber != null and earNumber != ''">
|
|
|
|
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
|
|
|
|
</if>
|
2025-07-17 09:58:44 +08:00
|
|
|
<if test="sheepfold != null">
|
|
|
|
AND sas.sheepfold = #{sheepfold}
|
|
|
|
</if>
|
|
|
|
<if test="varietyId != null">
|
|
|
|
AND sas.variety_id = #{varietyId}
|
|
|
|
</if>
|
2025-07-12 17:56:28 +08:00
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
2025-07-17 09:58:44 +08:00
|
|
|
<!-- 3. 根据耳号精确查询 -->
|
|
|
|
<select id="selectByEarNumber" parameterType="string" resultMap="ScAddSheepResult">
|
|
|
|
SELECT * FROM sc_add_sheep WHERE ear_number = #{earNumber}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 4. 插入 -->
|
|
|
|
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
INSERT INTO sc_add_sheep
|
|
|
|
(ear_number, sheepfold, father, mother, born_weight, birthday,
|
|
|
|
gender, parity, variety_id, join_date, comment, technician,
|
|
|
|
create_by, create_time)
|
|
|
|
VALUES
|
|
|
|
(#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight},
|
|
|
|
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{joinDate},
|
|
|
|
#{comment}, #{technician}, #{createBy}, #{createTime})
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 5. 更新 -->
|
2025-07-12 17:56:28 +08:00
|
|
|
<update id="updateScAddSheep" parameterType="ScAddSheep">
|
|
|
|
UPDATE sc_add_sheep
|
|
|
|
<set>
|
2025-07-17 09:58:44 +08:00
|
|
|
ear_number = #{earNumber},
|
|
|
|
sheepfold = #{sheepfold},
|
|
|
|
father = #{father},
|
|
|
|
mother = #{mother},
|
|
|
|
born_weight = #{bornWeight},
|
|
|
|
birthday = #{birthday},
|
|
|
|
gender = #{gender},
|
|
|
|
parity = #{parity},
|
|
|
|
variety_id = #{varietyId},
|
|
|
|
join_date = #{joinDate},
|
|
|
|
comment = #{comment},
|
|
|
|
technician = #{technician},
|
|
|
|
update_by = #{updateBy},
|
|
|
|
update_time = NOW()
|
2025-07-12 17:56:28 +08:00
|
|
|
</set>
|
|
|
|
WHERE id = #{id}
|
|
|
|
</update>
|
|
|
|
|
2025-07-17 09:58:44 +08:00
|
|
|
<!-- 6. 批量删除 -->
|
2025-07-12 17:56:28 +08:00
|
|
|
<delete id="deleteScAddSheepByIds">
|
|
|
|
DELETE FROM sc_add_sheep WHERE id IN
|
|
|
|
<foreach collection="array" item="id" open="(" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
</mapper>
|