2025-07-12 17:56:28 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
< !DOCTYPE mapper
2025-07-18 11:34:55 +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.manage_sheep.mapper.ScTransitionInfoMapper" >
2025-07-29 21:58:46 +08:00
<resultMap type= "com.zhyc.module.produce.manage_sheep.domain.ScTransitionInfo" id= "ScTransitionInfoResult" >
2025-07-18 11:34:55 +08:00
<result property= "id" column= "id" />
<result property= "sheepId" column= "sheep_id" />
2025-08-19 17:07:16 +08:00
<result property= "eventType" column= "event_type" />
2025-07-18 11:34:55 +08:00
<result property= "varietyId" column= "variety_id" />
<result property= "varietyName" column= "varietyName" />
<result property= "transTo" column= "trans_to" />
<result property= "transFrom" column= "trans_from" />
<result property= "transType" column= "trans_type" />
2025-07-29 21:58:46 +08:00
<result property= "transTypeText" column= "transTypeText" />
2025-08-19 17:07:16 +08:00
<result property= "transitionDate" column= "transition_date" />
2025-07-18 11:34:55 +08:00
<result property= "technician" column= "technician" />
<result property= "status" column= "status" />
<result property= "comment" column= "comment" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
2026-02-09 20:22:51 +08:00
<result property= "userId" column= "user_id" />
<result property= "deptId" column= "dept_id" />
2025-07-12 17:56:28 +08:00
</resultMap>
<sql id= "selectScTransitionInfoVo" >
2025-07-29 21:58:46 +08:00
SELECT t.*,
2025-08-19 17:07:16 +08:00
bv.variety AS varietyName,
bs.manage_tags AS manageTags,
2026-02-09 20:22:51 +08:00
t.user_id,
t.dept_id,
2026-02-03 14:41:28 +08:00
sf.sheepfold_name AS sheepfoldName,
2025-08-19 17:07:16 +08:00
t.event_type AS eventType,
t.transition_date AS transitionDate,
2026-02-03 14:41:28 +08:00
dr.ranch AS currentRanchName,
2025-07-18 11:34:55 +08:00
CASE t.trans_type
2025-07-29 21:58:46 +08:00
WHEN 0 THEN '内部调拨'
WHEN 1 THEN '内部销售'
WHEN 2 THEN '育肥调拨'
2025-07-18 11:34:55 +08:00
ELSE '未知'
2025-08-19 17:07:16 +08:00
END AS transTypeText,
2025-07-29 21:58:46 +08:00
CASE t.status
WHEN 0 THEN '待审批'
WHEN 1 THEN '已通过'
WHEN 2 THEN '已驳回'
ELSE '未知状态'
2025-08-19 17:07:16 +08:00
END AS statusText
2025-07-18 11:34:55 +08:00
FROM sc_transition_info t
2025-07-29 21:58:46 +08:00
LEFT JOIN bas_sheep bs ON t.sheep_id = bs.id
2025-08-14 15:54:50 +08:00
LEFT JOIN bas_sheep_variety bv ON bs.variety_id = bv.id
2026-02-03 14:41:28 +08:00
LEFT JOIN da_sheepfold sf ON t.sheepfold_id = sf.id
LEFT JOIN da_ranch dr ON bs.ranch_id = dr.id
2025-07-12 17:56:28 +08:00
</sql>
2026-01-13 11:17:19 +08:00
<select id= "selectScTransitionInfoList" resultMap= "ScTransitionInfoResult" >
2025-07-12 17:56:28 +08:00
<include refid= "selectScTransitionInfoVo" />
2025-07-18 11:34:55 +08:00
<where >
2026-01-13 11:17:19 +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-29 21:58:46 +08:00
</if>
2026-01-13 11:17:19 +08:00
<if test= "sc.sheepId != null" > and t.sheep_id = #{sc.sheepId}</if>
<if test= "sc.transType != null" > and t.trans_type = #{sc.transType}</if>
<if test= "sc.varietyId != null" > and bs.variety_id = #{sc.varietyId}</if>
<if test= "sc.transTo != null and sc.transTo != ''" > and t.trans_to = #{sc.transTo}</if>
<if test= "sc.transFrom != null and sc.transFrom != ''" > and t.trans_from = #{sc.transFrom}</if>
<if test= "sc.status != null" > and t.status = #{sc.status}</if>
<if test= "sc.params != null and sc.params.beginTransitionDate != null and sc.params.beginTransitionDate != '' and sc.params.endTransitionDate != null and sc.params.endTransitionDate != ''" >
and t.transition_date between #{sc.params.beginTransitionDate} and #{sc.params.endTransitionDate}
2025-08-19 17:07:16 +08:00
</if>
2026-02-03 14:41:28 +08:00
<if test= "sc.technician != null and sc.technician != ''" >
and t.technician like concat('%', #{sc.technician}, '%')
</if>
<if test= "sc.isDelete != null" >
and bs.is_delete = #{sc.isDelete}
</if>
<if test= "sc.sheepTypeId != null" >
and bs.type_id = #{sc.sheepTypeId}
</if>
<if test= "sc.currentRanchId != null" >
and bs.ranch_id = #{sc.currentRanchId}
</if>
2026-02-09 20:22:51 +08:00
${sc.params.dataScope}
2025-07-12 17:56:28 +08:00
</where>
2025-08-22 19:32:56 +08:00
ORDER BY t.create_time DESC
2025-07-12 17:56:28 +08:00
</select>
2025-07-18 11:34:55 +08:00
2025-07-12 17:56:28 +08:00
<select id= "selectScTransitionInfoById" parameterType= "Integer" resultMap= "ScTransitionInfoResult" >
<include refid= "selectScTransitionInfoVo" />
2025-07-18 11:34:55 +08:00
WHERE t.id = #{id}
2025-07-12 17:56:28 +08:00
</select>
<insert id= "insertScTransitionInfo" parameterType= "ScTransitionInfo" useGeneratedKeys= "true" keyProperty= "id" >
insert into sc_transition_info
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "sheepId != null" > sheep_id,</if>
2025-07-18 11:34:55 +08:00
<if test= "varietyId != null" > variety_id,</if>
2025-07-12 17:56:28 +08:00
<if test= "transTo != null and transTo != ''" > trans_to,</if>
<if test= "transFrom != null and transFrom != ''" > trans_from,</if>
2025-08-19 17:07:16 +08:00
<if test= "eventType != null and eventType != ''" > event_type,</if>
2025-07-12 17:56:28 +08:00
<if test= "transType != null" > trans_type,</if>
2025-08-19 17:07:16 +08:00
<if test= "transitionDate != null" > transition_date,</if>
2025-07-12 17:56:28 +08:00
<if test= "technician != null and technician != ''" > technician,</if>
<if test= "status != null" > status,</if>
<if test= "comment != null" > comment,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</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-18 11:34:55 +08:00
</trim>
2025-07-12 17:56:28 +08:00
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "sheepId != null" > #{sheepId},</if>
2025-07-18 11:34:55 +08:00
<if test= "varietyId != null" > #{varietyId},</if>
2025-07-12 17:56:28 +08:00
<if test= "transTo != null and transTo != ''" > #{transTo},</if>
<if test= "transFrom != null and transFrom != ''" > #{transFrom},</if>
2025-08-19 17:07:16 +08:00
<if test= "eventType != null and eventType != ''" > #{eventType},</if>
2025-07-12 17:56:28 +08:00
<if test= "transType != null" > #{transType},</if>
2025-08-19 17:07:16 +08:00
<if test= "transitionDate != null" > #{transitionDate},</if>
2025-07-12 17:56:28 +08:00
<if test= "technician != null and technician != ''" > #{technician},</if>
<if test= "status != null" > #{status},</if>
<if test= "comment != null" > #{comment},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
2026-02-09 20:22:51 +08:00
<if test= "userId != null" > #{userId},</if>
<if test= "deptId != null" > #{deptId},</if>
2025-07-18 11:34:55 +08:00
</trim>
2025-07-12 17:56:28 +08:00
</insert>
2025-07-29 21:58:46 +08:00
<insert id= "insertScTransitionInfoBatch" >
INSERT INTO sc_transition_info (
sheep_id, variety_id, trans_to, trans_from,
2025-08-19 17:07:16 +08:00
event_type,trans_type, transition_date, technician, status, comment,
2025-07-29 21:58:46 +08:00
create_by, create_time
) VALUES
<foreach collection= "list" item= "item" separator= "," >
(
2025-08-19 17:07:16 +08:00
#{item.sheepId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, #{item.eventType},
#{item.transType},#{item.transitionDate}, #{item.technician}, #{item.status}, #{item.comment},
2025-07-29 21:58:46 +08:00
#{item.createBy}, now()
)
</foreach>
</insert>
2025-07-12 17:56:28 +08:00
<update id= "updateScTransitionInfo" parameterType= "ScTransitionInfo" >
update sc_transition_info
<trim prefix= "SET" suffixOverrides= "," >
<if test= "sheepId != null" > sheep_id = #{sheepId},</if>
2025-07-18 11:34:55 +08:00
<if test= "varietyId != null" > variety_id = #{varietyId},</if>
2025-08-19 17:07:16 +08:00
<if test= "sheepfoldId != null" > sheepfold_id = #{sheepfoldId},</if>
2025-07-12 17:56:28 +08:00
<if test= "transTo != null and transTo != ''" > trans_to = #{transTo},</if>
<if test= "transFrom != null and transFrom != ''" > trans_from = #{transFrom},</if>
2025-08-19 17:07:16 +08:00
<if test= "eventType != null and eventType != ''" > event_type = #{eventType},</if>
2025-07-12 17:56:28 +08:00
<if test= "transType != null" > trans_type = #{transType},</if>
2025-08-19 17:07:16 +08:00
<if test= "transitionDate != null" > transition_date = #{transitionDate},</if>
2025-07-12 17:56:28 +08:00
<if test= "technician != null and technician != ''" > technician = #{technician},</if>
<if test= "status != null" > status = #{status},</if>
<if test= "comment != null" > comment = #{comment},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id= "deleteScTransitionInfoById" parameterType= "Integer" >
2025-07-18 11:34:55 +08:00
delete
from sc_transition_info
where id = #{id}
2025-07-12 17:56:28 +08:00
</delete>
<delete id= "deleteScTransitionInfoByIds" parameterType= "String" >
2025-07-18 11:34:55 +08:00
delete from sc_transition_info where id in
2025-07-12 17:56:28 +08:00
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
2026-01-13 11:17:19 +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
2026-02-09 20:22:51 +08:00
ORDER BY bs.manage_tags
2026-01-13 11:17:19 +08:00
</select>
2025-07-12 17:56:28 +08:00
</mapper>