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-08-19 17:07:16 +08:00
<resultMap type= "com.zhyc.module.produce.other.domain.ScCastrate" id= "ScCastrateResult" >
2025-07-12 17:56:28 +08:00
<result property= "id" column= "id" />
<result property= "sheepId" column= "sheep_id" />
2025-07-29 21:58:46 +08:00
<result property= "manageTags" column= "manageTags" />
2025-08-19 17:07:16 +08:00
<result property= "eventType" column= "event_type" />
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-10-23 16:36:01 +08:00
<result property= "eventDate" column= "eventDate" />
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-08-14 15:54:50 +08:00
bs.manage_tags as manageTags,
2025-08-19 17:07:16 +08:00
'去势' as event_type,
2025-08-14 15:54:50 +08:00
bs.sheepfold_id as sheepfold,
2025-07-12 17:56:28 +08:00
sf.sheepfold_name as sheepfoldName,
2025-08-14 15:54:50 +08:00
bs.variety_id as varietyId,
bv.variety as varietyName,
2025-07-12 17:56:28 +08:00
sc.comment,
sc.technician,
sc.create_by,
2025-10-23 16:36:01 +08:00
sc.create_time,
sc.event_date as eventDate
2025-07-12 17:56:28 +08:00
from sc_castrate sc
2025-07-29 21:58:46 +08:00
left join bas_sheep bs on sc.sheep_id = bs.id
2025-08-14 15:54:50 +08:00
left join da_sheepfold sf on bs.sheepfold_id = sf.id
left join bas_sheep_variety bv on bs.variety_id = bv.id
2025-07-09 14:31:05 +08:00
</sql>
2026-01-16 12:34:24 +08:00
<select id= "selectScCastrateList" resultMap= "ScCastrateResult" >
2025-07-09 14:31:05 +08:00
<include refid= "selectScCastrateVo" />
2025-07-12 17:56:28 +08:00
<where >
2026-01-16 12:34:24 +08:00
<if test= "manageTagsList != null and manageTagsList.size() > 0" >
<foreach collection= "manageTagsList" item= "tag" separator= "or" open= "and (" close= ")" >
bs.manage_tags like concat('%', #{tag}, '%')
</foreach>
2025-07-17 09:58:44 +08:00
</if>
2026-01-16 12:34:24 +08:00
<if test= "sc.sheepfold != null" > and bs.sheepfold_id = #{sc.sheepfold}</if>
<if test= "sc.varietyId != null" > and bs.variety_id = #{sc.varietyId}</if>
2026-02-09 20:22:51 +08:00
<if test= "sc.technician != null and sc.technician != ''" >
and sc.technician like concat('%', #{sc.technician}, '%')
</if>
2026-01-16 12:34:24 +08:00
<if test= "sc.params != null and sc.params.beginCreateTime != null and sc.params.beginCreateTime != '' and sc.params.endCreateTime != null and sc.params.endCreateTime != ''" >
and sc.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime}
2025-07-29 21:58:46 +08:00
</if>
2026-01-16 12:34:24 +08:00
<if test= "sc.params != null and sc.params.beginEventDate != null and sc.params.beginEventDate != '' and sc.params.endEventDate != null and sc.params.endEventDate != ''" >
and sc.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate}
2025-10-23 16:36:01 +08:00
</if>
2026-02-03 14:41:28 +08:00
<if test= "sc.isDelete != null" >
and bs.is_delete = #{sc.isDelete}
</if>
2026-02-09 20:22:51 +08:00
${sc.params.dataScope}
2025-07-09 14:31:05 +08:00
</where>
2025-08-22 19:32:56 +08:00
ORDER BY sc.create_time DESC
2025-07-09 14:31:05 +08:00
</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-10-23 16:36:01 +08:00
<if test= "eventDate != null" > event_date,</if>
2026-02-09 20:22:51 +08:00
<if test= "userId != null" > user_id,</if>
<if test= "deptId != null" > dept_id,</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-10-23 16:36:01 +08:00
<if test= "eventDate != null" > #{eventDate},</if>
2026-02-09 20:22:51 +08:00
<if test= "userId != null" > #{userId},</if>
<if test= "deptId != null" > #{deptId},</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>
2026-01-16 12:34:24 +08:00
<select id= "searchEarNumbers" resultType= "java.lang.String" >
SELECT DISTINCT bs.manage_tags
FROM bas_sheep bs
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
</select>
2025-07-09 14:31:05 +08:00
</mapper>