select sce.id as sce_id, sce.sheep_id, bs.manage_tags as manage_tags, sf.sheepfold_name as sheepfold_name, case when sce.ear_type = 0 then '改电子耳号' when sce.ear_type = 1 then '改管理耳号' else '' end as event_type, sce.ear_type, sce.newTag, sce.oldTag as oldTag, sce.comment, sce.create_by, sce.create_time from sc_change_ear sce LEFT JOIN bas_sheep bs ON sce.sheep_id = bs.id LEFT JOIN da_sheepfold sf ON bs.sheepfold_id = sf.id insert into sc_change_ear sheep_id, ear_type, newTag, oldTag, comment, create_by, create_time, #{sheepId}, #{earType}, #{newTag}, #{oldTag}, #{comment}, #{createBy}, #{createTime}, update sc_change_ear sheep_id = #{sheepId}, ear_type = #{earType}, newTag = #{newTag}, oldTag = #{oldTag}, comment = #{comment}, create_by = #{createBy}, create_time = #{createTime}, where id = #{id} delete from sc_change_ear where id = #{id} delete from sc_change_ear where id in #{id}