157 lines
8.2 KiB
XML
Raw Normal View History

2025-08-06 15:37:17 +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">
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScSheepDeathMapper">
<resultMap type="ScSheepDeath" id="ScSheepDeathResult">
<result property="id" column="id" />
<result property="sheepId" column="sheep_id" />
<result property="manageTags" column="manage_tags" />
<result property="eventType" column="event_type" />
<result property="deathDate" column="death_date" />
<result property="diseaseTypeId" column="disease_type_id" />
<result property="diseaseSubtypeId" column="disease_subtype_id" />
<result property="disposalDirection" column="disposal_direction" />
<result property="technician" column="technician" />
<result property="handler" column="handler" />
<result property="workGroup" column="work_group" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="comment" column="comment" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="isDelete" column="is_delete" />
</resultMap>
<sql id="selectScSheepDeathVo">
select id, sheep_id, manage_tags, event_type, death_date, disease_type_id, disease_subtype_id, disposal_direction, technician, handler, work_group, create_by, create_time, comment, update_by, update_time, is_delete from sc_sheep_death
</sql>
<select id="selectScSheepDeathList" parameterType="ScSheepDeath" resultMap="ScSheepDeathResult">
<include refid="selectScSheepDeathVo"/>
<where>
<if test="sheepId != null "> and sheep_id = #{sheepId}</if>
<if test="manageTags != null and manageTags != ''"> and manage_tags = #{manageTags}</if>
<if test="eventType != null and eventType != ''"> and event_type = #{eventType}</if>
<if test="deathDate != null "> and death_date = #{deathDate}</if>
<if test="diseaseTypeId != null "> and disease_type_id = #{diseaseTypeId}</if>
<if test="diseaseSubtypeId != null "> and disease_subtype_id = #{diseaseSubtypeId}</if>
<if test="disposalDirection != null and disposalDirection != ''"> and disposal_direction = #{disposalDirection}</if>
<if test="technician != null and technician != ''"> and technician = #{technician}</if>
<if test="handler != null and handler != ''"> and handler = #{handler}</if>
<if test="workGroup != null and workGroup != ''"> and work_group = #{workGroup}</if>
<if test="comment != null and comment != ''"> and comment = #{comment}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
</where>
order by create_time desc
2025-08-06 15:37:17 +08:00
</select>
<select id="selectScSheepDeathById" parameterType="Long" resultMap="ScSheepDeathResult">
<include refid="selectScSheepDeathVo"/>
where id = #{id}
</select>
<!-- 根据管理耳号查询sheep_file视图信息 - 修复删除不存在的status字段 -->
2025-08-06 15:37:17 +08:00
<select id="selectSheepFileByManageTags" parameterType="String" resultType="java.util.Map">
select
id as sheepId,
variety,
name as sheepType,
gender,
day_age as dayAge,
parity,
sheepfold_name as sheepfoldName,
breed as breedStatus,
post_lambing_day as postLambingDay,
lactation_day as lactationDay,
gestation_day as gestationDay
2025-08-06 15:37:17 +08:00
from sheep_file
where bs_manage_tags = #{manageTags} and is_delete = 0
limit 1
2025-08-06 15:37:17 +08:00
</select>
<insert id="insertScSheepDeath" parameterType="ScSheepDeath" useGeneratedKeys="true" keyProperty="id">
insert into sc_sheep_death
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="manageTags != null and manageTags != ''">manage_tags,</if>
<if test="eventType != null">event_type,</if>
<if test="deathDate != null">death_date,</if>
<if test="diseaseTypeId != null">disease_type_id,</if>
<if test="diseaseSubtypeId != null">disease_subtype_id,</if>
<if test="disposalDirection != null">disposal_direction,</if>
<if test="technician != null">technician,</if>
<if test="handler != null">handler,</if>
<if test="workGroup != null">work_group,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="comment != null">comment,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="isDelete != null">is_delete,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="manageTags != null and manageTags != ''">#{manageTags},</if>
<if test="eventType != null">#{eventType},</if>
<if test="deathDate != null">#{deathDate},</if>
<if test="diseaseTypeId != null">#{diseaseTypeId},</if>
<if test="diseaseSubtypeId != null">#{diseaseSubtypeId},</if>
<if test="disposalDirection != null">#{disposalDirection},</if>
<if test="technician != null">#{technician},</if>
<if test="handler != null">#{handler},</if>
<if test="workGroup != null">#{workGroup},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="comment != null">#{comment},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isDelete != null">#{isDelete},</if>
</trim>
</insert>
<update id="updateScSheepDeath" parameterType="ScSheepDeath">
update sc_sheep_death
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="manageTags != null and manageTags != ''">manage_tags = #{manageTags},</if>
<if test="eventType != null">event_type = #{eventType},</if>
<if test="deathDate != null">death_date = #{deathDate},</if>
<if test="diseaseTypeId != null">disease_type_id = #{diseaseTypeId},</if>
<if test="diseaseSubtypeId != null">disease_subtype_id = #{diseaseSubtypeId},</if>
<if test="disposalDirection != null">disposal_direction = #{disposalDirection},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="handler != null">handler = #{handler},</if>
<if test="workGroup != null">work_group = #{workGroup},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScSheepDeathById" parameterType="Long">
delete from sc_sheep_death where id = #{id}
</delete>
<delete id="deleteScSheepDeathByIds" parameterType="String">
delete from sc_sheep_death where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 更新羊只状态 - 根据实际的sheep_file表结构调整字段名 -->
<update id="updateSheepFileStatus">
UPDATE sheep_file
SET breed = #{status},
update_time = NOW()
WHERE id = #{sheepId}
AND is_delete = 0
</update>
2025-08-06 15:37:17 +08:00
</mapper>