公羊管理-采精记录和配种记录
This commit is contained in:
@@ -0,0 +1,235 @@
|
||||
<?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.ScBreedRecordMapper">
|
||||
|
||||
<resultMap type="ScBreedRecord" id="ScBreedRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="ramId" column="ram_id" />
|
||||
<result property="eweId" column="ewe_id" />
|
||||
<result property="technician" column="technician" />
|
||||
<result property="breedDrugs" column="breed_drugs" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<!-- 新增显示字段 -->
|
||||
<result property="eweManageTags" column="ewe_manage_tags" />
|
||||
<result property="eweVariety" column="ewe_variety" />
|
||||
<result property="ramManageTags" column="ram_manage_tags" />
|
||||
<result property="ramVariety" column="ram_variety" />
|
||||
<result property="eweParity" column="ewe_parity" />
|
||||
<result property="eweMonthAge" column="ewe_month_age" />
|
||||
<result property="eweSheepfoldName" column="ewe_sheepfold_name" />
|
||||
<result property="eweBreedStatus" column="ewe_breed_status" />
|
||||
<result property="eweControlled" column="ewe_controlled" />
|
||||
<result property="eweComment" column="ewe_comment" />
|
||||
<result property="ranchName" column="ranch_name" />
|
||||
<result property="matingType" column="mating_type" />
|
||||
<result property="sheepType" column="sheep_type" />
|
||||
<result property="matingCount" column="mating_count" />
|
||||
<result property="timeSincePlanning" column="time_since_planning" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectScBreedRecordVo">
|
||||
select
|
||||
br.id,
|
||||
br.sheep_id,
|
||||
br.ram_id,
|
||||
br.ewe_id,
|
||||
br.technician,
|
||||
br.breed_drugs,
|
||||
br.create_by,
|
||||
br.create_time,
|
||||
-- 母羊信息(从视图获取)
|
||||
ewe_view.bs_manage_tags as ewe_manage_tags,
|
||||
ewe_view.variety as ewe_variety,
|
||||
ewe_view.parity as ewe_parity,
|
||||
ewe_view.month_age as ewe_month_age,
|
||||
ewe_view.sheepfold_name as ewe_sheepfold_name,
|
||||
ewe_view.breed as ewe_breed_status,
|
||||
ewe_view.controlled as ewe_controlled,
|
||||
ewe_view.comment as ewe_comment,
|
||||
ewe_view.dr_ranch as ranch_name,
|
||||
ewe_view.name as sheep_type,
|
||||
ewe_view.mating_total as mating_count,
|
||||
-- 公羊信息(从视图获取)
|
||||
ram_view.bs_manage_tags as ram_manage_tags,
|
||||
ram_view.variety as ram_variety,
|
||||
-- 配种方式(如果视图中没有,设为空或从其他地方获取)
|
||||
'' as mating_type,
|
||||
-- 发情后配种时间(小时数)
|
||||
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning
|
||||
from sc_breed_record br
|
||||
left join sheep_file ewe_view on br.ewe_id = ewe_view.id
|
||||
left join sheep_file ram_view on br.ram_id = ram_view.id
|
||||
</sql>
|
||||
|
||||
<select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
<where>
|
||||
<if test="sheepId != null "> and br.sheep_id = #{sheepId}</if>
|
||||
<if test="ramId != null and ramId != ''"> and br.ram_id = #{ramId}</if>
|
||||
<if test="eweId != null and eweId != ''"> and br.ewe_id = #{eweId}</if>
|
||||
<if test="technician != null and technician != ''"> and br.technician like concat('%', #{technician}, '%')</if>
|
||||
<if test="breedDrugs != null and breedDrugs != ''"> and br.breed_drugs like concat('%', #{breedDrugs}, '%')</if>
|
||||
<if test="createBy != null and createBy != ''"> and br.create_by like concat('%', #{createBy}, '%')</if>
|
||||
<if test="createTime != null "> and date_format(br.create_time,'%y-%m-%d') = date_format(#{createTime},'%y-%m-%d')</if>
|
||||
<!-- 新增耳号查询条件 -->
|
||||
<if test="eweManageTags != null and eweManageTags != ''"> and ewe_view.bs_manage_tags like concat('%', #{eweManageTags}, '%')</if>
|
||||
<if test="ramManageTags != null and ramManageTags != ''"> and ram_view.bs_manage_tags like concat('%', #{ramManageTags}, '%')</if>
|
||||
<if test="eweVariety != null and eweVariety != ''"> and ewe_view.variety like concat('%', #{eweVariety}, '%')</if>
|
||||
<if test="ramVariety != null and ramVariety != ''"> and ram_view.variety like concat('%', #{ramVariety}, '%')</if>
|
||||
<if test="ranchId != null"> and ewe_view.ranch_id = #{ranchId}</if>
|
||||
</where>
|
||||
order by br.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectScBreedRecordById" parameterType="Long" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
where br.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据母羊耳号查询羊只ID -->
|
||||
<select id="getSheepIdByManageTags" parameterType="String" resultType="Long">
|
||||
select id from sheep_file where bs_manage_tags = #{manageTags} and is_delete = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据公羊耳号查询羊只ID -->
|
||||
<select id="getRamIdByManageTags" parameterType="String" resultType="Long">
|
||||
select id from sheep_file where bs_manage_tags = #{manageTags} and gender = 2 and is_delete = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据耳号查询羊只详细信息 -->
|
||||
<select id="getSheepInfoByTags" parameterType="String" resultType="map">
|
||||
select
|
||||
id,
|
||||
bs_manage_tags as manage_tags,
|
||||
ranch_id,
|
||||
dr_ranch as ranch_name,
|
||||
sheepfold_id,
|
||||
sheepfold_name,
|
||||
electronic_tags,
|
||||
variety_id,
|
||||
variety,
|
||||
family,
|
||||
name as type_name,
|
||||
gender,
|
||||
birthday,
|
||||
day_age,
|
||||
month_age,
|
||||
parity,
|
||||
birth_weight,
|
||||
weaning_date,
|
||||
status_id,
|
||||
weaning_weight,
|
||||
current_weight,
|
||||
breed_status_id,
|
||||
breed as breed_status,
|
||||
bs_father_id as father_id,
|
||||
father_manage_tags,
|
||||
bs_mother_id as mother_id,
|
||||
mother_manage_tags,
|
||||
receptor_id,
|
||||
receptor_manage_tags,
|
||||
mating_date,
|
||||
mating_type_id,
|
||||
preg_date,
|
||||
lambing_date,
|
||||
lambing_day,
|
||||
mating_day,
|
||||
gestation_day,
|
||||
expected_date,
|
||||
post_lambing_day,
|
||||
lactation_day,
|
||||
anestrous_day,
|
||||
mating_counts,
|
||||
mating_total,
|
||||
miscarriage_counts,
|
||||
comment,
|
||||
controlled,
|
||||
body,
|
||||
breast,
|
||||
source,
|
||||
source_date,
|
||||
source_ranch_id,
|
||||
source_ranch,
|
||||
update_by,
|
||||
update_time,
|
||||
create_by,
|
||||
create_time
|
||||
from sheep_file
|
||||
where bs_manage_tags = #{manageTags} and is_delete = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据母羊耳号获取配种计划信息 -->
|
||||
<select id="getBreedPlanByEweTags" parameterType="String" resultType="map">
|
||||
select
|
||||
bp.id as plan_id,
|
||||
bp.ewe_id,
|
||||
ewe_view.bs_manage_tags as ewe_manage_tags,
|
||||
bp.ram_id,
|
||||
ram_view.bs_manage_tags as ram_manage_tags,
|
||||
bp.plan_date,
|
||||
bp.breed_type,
|
||||
bp.technician,
|
||||
bp.status,
|
||||
bp.create_time as plan_create_time,
|
||||
TIMESTAMPDIFF(HOUR, bp.create_time, NOW()) as hours_since_plan
|
||||
from sc_breed_plan bp
|
||||
left join sheep_file ewe_view on bp.ewe_id = ewe_view.id
|
||||
left join sheep_file ram_view on bp.ram_id = ram_view.id
|
||||
where ewe_view.bs_manage_tags = #{manageTags}
|
||||
and bp.status = '待配种'
|
||||
and bp.is_delete = 0
|
||||
order by bp.create_time desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertScBreedRecord" parameterType="ScBreedRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_breed_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="ramId != null">ram_id,</if>
|
||||
<if test="eweId != null">ewe_id,</if>
|
||||
<if test="technician != null">technician,</if>
|
||||
<if test="breedDrugs != null">breed_drugs,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="ramId != null">#{ramId},</if>
|
||||
<if test="eweId != null">#{eweId},</if>
|
||||
<if test="technician != null">#{technician},</if>
|
||||
<if test="breedDrugs != null">#{breedDrugs},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateScBreedRecord" parameterType="ScBreedRecord">
|
||||
update sc_breed_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
||||
<if test="ramId != null">ram_id = #{ramId},</if>
|
||||
<if test="eweId != null">ewe_id = #{eweId},</if>
|
||||
<if test="technician != null">technician = #{technician},</if>
|
||||
<if test="breedDrugs != null">breed_drugs = #{breedDrugs},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScBreedRecordById" parameterType="Long">
|
||||
delete from sc_breed_record where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteScBreedRecordByIds" parameterType="String">
|
||||
delete from sc_breed_record where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,136 @@
|
||||
<?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.RawSpermRecordMapper">
|
||||
|
||||
<resultMap type="RawSpermRecord" id="RawSpermRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="manageTags" column="bs_manage_tags" />
|
||||
<result property="electronicTags" column="electronic_tags" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
<result property="pickDate" column="pick_date" />
|
||||
<result property="amount" column="amount" />
|
||||
<result property="density" column="density" />
|
||||
<result property="vitallity" column="vitallity" />
|
||||
<result property="controlled" column="controlled" />
|
||||
<result property="sexualStatus" column="sexual_status" />
|
||||
<result property="info" column="info" />
|
||||
<result property="technician" column="technician" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRawSpermRecordVo">
|
||||
select
|
||||
rsr.id,
|
||||
rsr.sheep_id,
|
||||
sf.bs_manage_tags,
|
||||
sf.electronic_tags,
|
||||
sf.month_age,
|
||||
rsr.pick_date,
|
||||
rsr.amount,
|
||||
rsr.density,
|
||||
rsr.vitallity,
|
||||
rsr.controlled,
|
||||
rsr.sexual_status,
|
||||
rsr.info,
|
||||
rsr.technician,
|
||||
rsr.comment,
|
||||
rsr.create_by,
|
||||
rsr.create_time
|
||||
from raw_sperm_record rsr
|
||||
left join sheep_file sf on rsr.sheep_id = sf.id
|
||||
</sql>
|
||||
|
||||
<select id="selectRawSpermRecordList" parameterType="RawSpermRecord" resultMap="RawSpermRecordResult">
|
||||
<include refid="selectRawSpermRecordVo"/>
|
||||
<where>
|
||||
<if test="manageTags != null and manageTags != ''"> and sf.bs_manage_tags like concat('%', #{manageTags}, '%')</if>
|
||||
<if test="pickDate != null "> and rsr.pick_date = #{pickDate}</if>
|
||||
<if test="amount != null "> and rsr.amount = #{amount}</if>
|
||||
<if test="density != null and density != ''"> and rsr.density = #{density}</if>
|
||||
<if test="vitallity != null and vitallity != ''"> and rsr.vitallity = #{vitallity}</if>
|
||||
<if test="controlled != null "> and rsr.controlled = #{controlled}</if>
|
||||
<if test="sexualStatus != null and sexualStatus != ''"> and rsr.sexual_status = #{sexualStatus}</if>
|
||||
<if test="info != null and info != ''"> and rsr.info = #{info}</if>
|
||||
<if test="technician != null and technician != ''"> and rsr.technician = #{technician}</if>
|
||||
<if test="comment != null and comment != ''"> and rsr.comment = #{comment}</if>
|
||||
</where>
|
||||
order by rsr.pick_date desc
|
||||
</select>
|
||||
|
||||
<select id="selectRawSpermRecordById" parameterType="Long" resultMap="RawSpermRecordResult">
|
||||
<include refid="selectRawSpermRecordVo"/>
|
||||
where rsr.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据耳号查询羊只ID -->
|
||||
<select id="selectSheepIdByManageTags" parameterType="String" resultType="Long">
|
||||
select id from sheep_file where bs_manage_tags = #{manageTags}
|
||||
</select>
|
||||
|
||||
<insert id="insertRawSpermRecord" parameterType="RawSpermRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into raw_sperm_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="pickDate != null">pick_date,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
<if test="density != null">density,</if>
|
||||
<if test="vitallity != null">vitallity,</if>
|
||||
<if test="controlled != null">controlled,</if>
|
||||
<if test="sexualStatus != null">sexual_status,</if>
|
||||
<if test="info != null">info,</if>
|
||||
<if test="technician != null">technician,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="pickDate != null">#{pickDate},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
<if test="density != null">#{density},</if>
|
||||
<if test="vitallity != null">#{vitallity},</if>
|
||||
<if test="controlled != null">#{controlled},</if>
|
||||
<if test="sexualStatus != null">#{sexualStatus},</if>
|
||||
<if test="info != null">#{info},</if>
|
||||
<if test="technician != null">#{technician},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateRawSpermRecord" parameterType="RawSpermRecord">
|
||||
update raw_sperm_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
||||
<if test="pickDate != null">pick_date = #{pickDate},</if>
|
||||
<if test="amount != null">amount = #{amount},</if>
|
||||
<if test="density != null">density = #{density},</if>
|
||||
<if test="vitallity != null">vitallity = #{vitallity},</if>
|
||||
<if test="controlled != null">controlled = #{controlled},</if>
|
||||
<if test="sexualStatus != null">sexual_status = #{sexualStatus},</if>
|
||||
<if test="info != null">info = #{info},</if>
|
||||
<if test="technician != null">technician = #{technician},</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="deleteRawSpermRecordById" parameterType="Long">
|
||||
delete from raw_sperm_record where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRawSpermRecordByIds" parameterType="String">
|
||||
delete from raw_sperm_record where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user