Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -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>
|
||||
@@ -34,8 +34,14 @@
|
||||
<where>
|
||||
<if test="planName != null and planName != ''"> and plan_name like concat('%', #{planName}, '%')</if>
|
||||
<if test="planType != null"> and plan_type = #{planType}</if>
|
||||
<if test="planDate != null"> and plan_date = #{planDate}</if>
|
||||
<if test="planDate != null"> and DATE(plan_date) = DATE(#{planDate})</if>
|
||||
<if test="status != null"> and status = #{status}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
and DATE(plan_date) >= DATE(#{params.beginTime})
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
and DATE(plan_date) <= DATE(#{params.endTime})
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
@@ -48,63 +54,72 @@
|
||||
<!-- 筛选符合条件的母羊 -->
|
||||
<select id="selectEligibleEwe" resultType="Map">
|
||||
select
|
||||
sf.id,
|
||||
sf.bs_manage_tags,
|
||||
sf.variety,
|
||||
sf.name as sheep_type,
|
||||
sf.gender,
|
||||
sf.month_age,
|
||||
sf.current_weight,
|
||||
sf.post_lambing_day,
|
||||
sf.breed
|
||||
from sheep_file sf
|
||||
where sf.gender = 1
|
||||
and sf.is_delete = 0
|
||||
and (sf.status_id = 1 or sf.status_id is null)
|
||||
bs.id,
|
||||
bs.manage_tags as bs_manage_tags,
|
||||
bv.variety as variety,
|
||||
bs.family,
|
||||
bst.name as sheep_type,
|
||||
bs.gender,
|
||||
TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) as month_age,
|
||||
bs.current_weight,
|
||||
bs.post_lambing_day,
|
||||
bbs.breed as breed,
|
||||
bs.parity,
|
||||
dsf.sheepfold_name,
|
||||
bs.comment,
|
||||
CASE WHEN bs.is_core = 1 THEN '是' ELSE '否' END as is_core,
|
||||
CASE WHEN bs.is_breeding = 1 THEN '是' ELSE '否' END as is_breeding,
|
||||
CONCAT('胎次:', IFNULL(bs.parity, 0), ' 配种次数:', IFNULL(bs.mating_counts, 0)) as reproduction_info
|
||||
from bas_sheep bs
|
||||
left join bas_sheep_variety bv on bs.variety_id = bv.id
|
||||
left join bas_sheep_type bst on bs.type_id = bst.id
|
||||
left join bas_breed_status bbs on bs.breed_status_id = bbs.id
|
||||
left join da_sheepfold dsf on bs.sheepfold_id = dsf.id
|
||||
where bs.gender = 1
|
||||
and bs.is_delete = 0
|
||||
and (bs.status_id = 1 or bs.status_id is null)
|
||||
and (
|
||||
-- 青年羊或超龄羊的配种条件
|
||||
(sf.name in ('青年羊', '超龄羊') and (
|
||||
(sf.variety = '湖羊' and sf.month_age >= 7.5 and sf.current_weight >= 33) or
|
||||
(sf.variety = '东佛里生' and sf.month_age >= 9 and sf.current_weight >= 50) or
|
||||
(sf.variety not in ('湖羊', '东佛里生') and sf.month_age >= 9 and sf.current_weight >= 50)
|
||||
(bst.name in ('青年羊', '超龄羊') and (
|
||||
(bv.variety = '湖羊' and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 7.5 and bs.current_weight >= 33) or
|
||||
(bv.variety = '东佛里生' and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 9 and bs.current_weight >= 50) or
|
||||
(bv.variety not in ('湖羊', '东佛里生') and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 9 and bs.current_weight >= 50)
|
||||
))
|
||||
or
|
||||
-- 泌乳羊或种母羊的配种条件
|
||||
(sf.name in ('泌乳羊', '种母羊') and sf.post_lambing_day > 45 and sf.current_weight > 0)
|
||||
(bst.name in ('泌乳羊', '种母羊') and bs.post_lambing_day > 45 and bs.current_weight > 0)
|
||||
)
|
||||
order by sf.variety, sf.month_age desc
|
||||
order by bv.variety, TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) desc
|
||||
</select>
|
||||
|
||||
<!-- 筛选符合条件的公羊 -->
|
||||
<select id="selectEligibleRam" resultType="Map">
|
||||
select
|
||||
sf.id,
|
||||
sf.manage_tags as bs_manage_tags,
|
||||
bs.id,
|
||||
bs.manage_tags as bs_manage_tags,
|
||||
bv.variety as variety,
|
||||
bs.family,
|
||||
bst.name as sheep_type,
|
||||
sf.gender,
|
||||
TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) as month_age,
|
||||
sf.current_weight,
|
||||
bs.gender,
|
||||
bs.birthday,
|
||||
TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) as month_age,
|
||||
bs.current_weight,
|
||||
bbs.breed as breed
|
||||
from bas_sheep sf
|
||||
left join bas_sheep_variety bv on sf.variety_id = bv.id
|
||||
left join bas_sheep_type bst on sf.type_id = bst.id
|
||||
left join bas_breed_status bbs on sf.breed_status_id = bbs.id
|
||||
where sf.gender = 2
|
||||
and sf.is_delete = 0
|
||||
and sf.status_id = 1
|
||||
from bas_sheep bs
|
||||
left join bas_sheep_variety bv on bs.variety_id = bv.id
|
||||
left join bas_sheep_type bst on bs.type_id = bst.id
|
||||
left join bas_breed_status bbs on bs.breed_status_id = bbs.id
|
||||
where bs.gender = 2
|
||||
and bs.is_delete = 0
|
||||
and bs.status_id = 1
|
||||
and (
|
||||
-- 青年羊或超龄羊的参配条件
|
||||
(bst.name in ('青年羊', '超龄羊') and (
|
||||
(bv.variety = '湖羊' and TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) >= 7.5 and sf.current_weight >= 33) or
|
||||
(bv.variety = '东佛里生' and TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) >= 9 and sf.current_weight >= 50) or
|
||||
(bv.variety not in ('湖羊', '东佛里生') and TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) >= 9 and sf.current_weight >= 50)
|
||||
(bv.variety = '湖羊' and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 7.5 and bs.current_weight >= 33) or
|
||||
(bv.variety = '东佛里生' and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 9 and bs.current_weight >= 50) or
|
||||
(bv.variety not in ('湖羊', '东佛里生') and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 9 and bs.current_weight >= 50)
|
||||
))
|
||||
or
|
||||
-- 其他类型公羊
|
||||
bst.name not in ('青年羊', '超龄羊')
|
||||
)
|
||||
order by bv.variety, TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) desc
|
||||
order by bv.variety, TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) desc
|
||||
</select>
|
||||
|
||||
<insert id="insertScBreedPlanGenerate" parameterType="ScBreedPlanGenerate" useGeneratedKeys="true" keyProperty="id">
|
||||
@@ -176,25 +191,110 @@
|
||||
where plan_generate_id = #{planGenerateId}
|
||||
</insert>
|
||||
|
||||
<!-- 获取配种计划详情 -->
|
||||
<!-- 获取配种计划详情 - 显示完整字段信息 -->
|
||||
<select id="selectBreedPlanDetails" parameterType="Long" resultType="Map">
|
||||
select
|
||||
temp.id,
|
||||
temp.ram_id,
|
||||
temp.ewe_id,
|
||||
temp.breed_type,
|
||||
ram.bs_manage_tags as ram_manage_tags,
|
||||
ram.variety as ram_variety,
|
||||
ewe.bs_manage_tags as ewe_manage_tags,
|
||||
ewe.variety as ewe_variety,
|
||||
ewe.current_weight as ewe_weight
|
||||
-- 母羊完整信息
|
||||
ewe.manage_tags as ewe_manage_tags,
|
||||
ewe_variety.variety as ewe_variety,
|
||||
ewe.family as ewe_family,
|
||||
ewe_type.name as ewe_sheep_type,
|
||||
ewe_breed.breed as ewe_breed_status,
|
||||
ewe.parity as ewe_parity,
|
||||
TIMESTAMPDIFF(MONTH, ewe.birthday, NOW()) as ewe_month_age,
|
||||
ewe.current_weight as ewe_current_weight,
|
||||
CASE WHEN ewe.is_core = 1 THEN 1 ELSE 0 END as ewe_is_core,
|
||||
CASE WHEN ewe.is_breeding = 1 THEN 1 ELSE 0 END as ewe_is_breeding,
|
||||
ewe_sheepfold.sheepfold_name as ewe_sheepfold_name,
|
||||
ewe.comment as ewe_comment,
|
||||
CONCAT('胎次:', IFNULL(ewe.parity, 0), ' 配种次数:', IFNULL(ewe.mating_counts, 0)) as ewe_reproduction_info,
|
||||
-- 公羊完整信息 - 直接关联查询耳号
|
||||
ram.manage_tags as ram_manage_tags,
|
||||
ram_variety.variety as ram_variety,
|
||||
ram.family as ram_family,
|
||||
ram_type.name as ram_sheep_type,
|
||||
ram.birthday as ram_birthday,
|
||||
TIMESTAMPDIFF(MONTH, ram.birthday, NOW()) as ram_month_age,
|
||||
ram.current_weight as ram_current_weight
|
||||
from sc_breed_plan_temp temp
|
||||
left join sheep_file ram on temp.ram_id = ram.id
|
||||
left join sheep_file ewe on temp.ewe_id = ewe.id
|
||||
left join bas_sheep ewe on ewe.id = CAST(temp.ewe_id AS UNSIGNED)
|
||||
left join bas_sheep_variety ewe_variety on ewe.variety_id = ewe_variety.id
|
||||
left join bas_sheep_type ewe_type on ewe.type_id = ewe_type.id
|
||||
left join bas_breed_status ewe_breed on ewe.breed_status_id = ewe_breed.id
|
||||
left join da_sheepfold ewe_sheepfold on ewe.sheepfold_id = ewe_sheepfold.id
|
||||
left join bas_sheep ram on ram.id = CAST(temp.ram_id AS UNSIGNED)
|
||||
left join bas_sheep_variety ram_variety on ram.variety_id = ram_variety.id
|
||||
left join bas_sheep_type ram_type on ram.type_id = ram_type.id
|
||||
where temp.plan_generate_id = #{planGenerateId}
|
||||
order by temp.ram_id, temp.ewe_id
|
||||
order by temp.ewe_id, temp.ram_id
|
||||
</select>
|
||||
|
||||
<!-- 获取审批详情 - 包含完整的母羊和公羊信息 -->
|
||||
<select id="selectApproveBreedPlanDetails" parameterType="Long" resultType="Map">
|
||||
select
|
||||
temp.id,
|
||||
temp.ram_id,
|
||||
temp.ewe_id,
|
||||
temp.breed_type,
|
||||
-- 母羊信息
|
||||
ewe.manage_tags as ewe_manage_tags,
|
||||
ewe_variety.variety as ewe_variety,
|
||||
ewe.family as ewe_family,
|
||||
ewe_type.name as ewe_sheep_type,
|
||||
ewe_breed.breed as ewe_breed_status,
|
||||
ewe.parity as ewe_parity,
|
||||
TIMESTAMPDIFF(MONTH, ewe.birthday, NOW()) as ewe_month_age,
|
||||
ewe.current_weight as ewe_current_weight,
|
||||
CASE WHEN ewe.is_core = 1 THEN 1 ELSE 0 END as ewe_is_core,
|
||||
CASE WHEN ewe.is_breeding = 1 THEN 1 ELSE 0 END as ewe_is_breeding,
|
||||
ewe_sheepfold.sheepfold_name as ewe_sheepfold_name,
|
||||
ewe.comment as ewe_comment,
|
||||
CONCAT('胎次:', IFNULL(ewe.parity, 0), ' 配种次数:', IFNULL(ewe.mating_counts, 0)) as ewe_reproduction_info,
|
||||
-- 公羊信息 - 直接关联查询耳号
|
||||
ram.manage_tags as ram_manage_tags,
|
||||
ram_variety.variety as ram_variety,
|
||||
ram.family as ram_family,
|
||||
ram_type.name as ram_sheep_type,
|
||||
ram.birthday as ram_birthday,
|
||||
TIMESTAMPDIFF(MONTH, ram.birthday, NOW()) as ram_month_age,
|
||||
ram.current_weight as ram_current_weight
|
||||
from sc_breed_plan_temp temp
|
||||
left join bas_sheep ewe on ewe.id = CAST(temp.ewe_id AS UNSIGNED)
|
||||
left join bas_sheep_variety ewe_variety on ewe.variety_id = ewe_variety.id
|
||||
left join bas_sheep_type ewe_type on ewe.type_id = ewe_type.id
|
||||
left join bas_breed_status ewe_breed on ewe.breed_status_id = ewe_breed.id
|
||||
left join da_sheepfold ewe_sheepfold on ewe.sheepfold_id = ewe_sheepfold.id
|
||||
left join bas_sheep ram on ram.id = CAST(temp.ram_id AS UNSIGNED)
|
||||
left join bas_sheep_variety ram_variety on ram.variety_id = ram_variety.id
|
||||
left join bas_sheep_type ram_type on ram.type_id = ram_type.id
|
||||
where temp.plan_generate_id = #{planGenerateId}
|
||||
order by temp.ewe_id, temp.ram_id
|
||||
</select>
|
||||
|
||||
<!-- 更新临时配种计划 -->
|
||||
<update id="updateTempBreedPlan">
|
||||
update sc_breed_plan_temp
|
||||
<set>
|
||||
<if test="ramId != null">
|
||||
ram_id = #{ramId},
|
||||
</if>
|
||||
<if test="ramId == null">
|
||||
ram_id = null,
|
||||
</if>
|
||||
<if test="breedType != null">
|
||||
breed_type = #{breedType},
|
||||
</if>
|
||||
<if test="breedType == null">
|
||||
breed_type = null,
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScBreedPlanGenerateById" parameterType="Long">
|
||||
delete from sc_breed_plan_generate where id = #{id}
|
||||
</delete>
|
||||
@@ -205,4 +305,9 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 删除临时配种计划 -->
|
||||
<delete id="deleteTempBreedPlanByPlanId" parameterType="Long">
|
||||
delete from sc_breed_plan_temp where plan_generate_id = #{planGenerateId}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,335 @@
|
||||
<?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="breedType" column="breed_type" />
|
||||
<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" />
|
||||
<!-- 孕检相关字段 -->
|
||||
<result property="pregnancyCheckDate" column="pregnancy_check_date" />
|
||||
<result property="pregnancyResult" column="pregnancy_result" />
|
||||
<result property="pregnancyWay" column="pregnancy_way" />
|
||||
<result property="fetusCount" column="fetus_count" />
|
||||
<result property="pregnancyTechnician" column="pregnancy_technician" />
|
||||
<result property="pregnancyRemark" column="pregnancy_remark" />
|
||||
<result property="pregnancyRecordId" column="pregnancy_record_id" />
|
||||
<result property="daysToPregnancyCheck" column="days_to_pregnancy_check" />
|
||||
<result property="isPregnancyChecked" column="is_pregnancy_checked" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectScBreedRecordVo">
|
||||
select
|
||||
br.id,
|
||||
br.sheep_id,
|
||||
br.ram_id,
|
||||
br.ewe_id,
|
||||
br.technician,
|
||||
br.breed_drugs,
|
||||
br.breed_type,
|
||||
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,
|
||||
-- 配种方式显示
|
||||
CASE br.breed_type
|
||||
WHEN 1 THEN '同期发情'
|
||||
WHEN 2 THEN '本交'
|
||||
ELSE '未知'
|
||||
END as mating_type,
|
||||
-- 发情后配种时间(小时数)
|
||||
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,
|
||||
-- 孕检相关信息
|
||||
pr.datetime as pregnancy_check_date,
|
||||
pr.result as pregnancy_result,
|
||||
pr.way as pregnancy_way,
|
||||
pr.fetus_count,
|
||||
pr.technician as pregnancy_technician,
|
||||
pr.remark as pregnancy_remark,
|
||||
pr.id as pregnancy_record_id,
|
||||
-- 配种到孕检间隔天数
|
||||
CASE
|
||||
WHEN pr.datetime IS NOT NULL THEN DATEDIFF(pr.datetime, br.create_time)
|
||||
ELSE NULL
|
||||
END as days_to_pregnancy_check,
|
||||
-- 是否已孕检
|
||||
CASE
|
||||
WHEN pr.id IS NOT NULL THEN 1
|
||||
ELSE 0
|
||||
END as is_pregnancy_checked
|
||||
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
|
||||
left join sc_pregnancy_record pr on pr.sheep_id = br.ewe_id
|
||||
and pr.is_delete = 0
|
||||
and pr.datetime >= br.create_time
|
||||
and pr.datetime = (
|
||||
select min(pr2.datetime)
|
||||
from sc_pregnancy_record pr2
|
||||
where pr2.sheep_id = br.ewe_id
|
||||
and pr2.is_delete = 0
|
||||
and pr2.datetime >= br.create_time
|
||||
)
|
||||
</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="breedType != null"> and br.breed_type = #{breedType}</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>
|
||||
<!-- 孕检相关查询条件 -->
|
||||
<if test="pregnancyResult != null and pregnancyResult != ''"> and pr.result like concat('%', #{pregnancyResult}, '%')</if>
|
||||
<if test="isPregnancyChecked != null">
|
||||
<if test="isPregnancyChecked == 1"> and pr.id IS NOT NULL</if>
|
||||
<if test="isPregnancyChecked == 0"> and pr.id IS NULL</if>
|
||||
</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.breed_type,
|
||||
CASE bp.breed_type
|
||||
WHEN 1 THEN '同期发情'
|
||||
WHEN 2 THEN '本交'
|
||||
ELSE '未知'
|
||||
END as breed_type_name,
|
||||
TIMESTAMPDIFF(HOUR, NOW(), 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}
|
||||
order by bp.id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 根据母羊耳号获取最新的配种计划信息(从配种计划生成表) -->
|
||||
<select id="getLatestBreedPlanByEweTags" parameterType="String" resultType="map">
|
||||
select
|
||||
bpg.id as plan_generate_id,
|
||||
bpt.ewe_id,
|
||||
ewe_view.bs_manage_tags as ewe_manage_tags,
|
||||
bpt.ram_id,
|
||||
ram_view.bs_manage_tags as ram_manage_tags,
|
||||
bpt.breed_type,
|
||||
CASE bpt.breed_type
|
||||
WHEN 1 THEN '同期发情'
|
||||
WHEN 2 THEN '本交'
|
||||
ELSE '未知'
|
||||
END as breed_type_name,
|
||||
bpg.create_time as plan_create_time
|
||||
from sc_breed_plan_generate bpg
|
||||
inner join sc_breed_plan_temp bpt on bpg.id = bpt.plan_generate_id
|
||||
left join sheep_file ewe_view on bpt.ewe_id = ewe_view.id
|
||||
left join sheep_file ram_view on bpt.ram_id = ram_view.id
|
||||
where ewe_view.bs_manage_tags = #{manageTags}
|
||||
and bpg.status = 1 -- 已审批的计划
|
||||
order by bpg.create_time desc, bpt.id 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="breedType != null">breed_type,</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="breedType != null">#{breedType},</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="breedType != null">breed_type = #{breedType},</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>
|
||||
|
||||
<!-- 根据羊只ID和配种时间查询配种记录 -->
|
||||
<select id="selectBreedRecordByMatingTime" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
<where>
|
||||
<if test="sheepId != null">and br.ewe_id = #{sheepId}</if>
|
||||
<if test="matingDateStart != null and matingDateStart != ''">
|
||||
and br.create_time >= #{matingDateStart}
|
||||
</if>
|
||||
<if test="matingDateEnd != null and matingDateEnd != ''">
|
||||
and br.create_time <= #{matingDateEnd}
|
||||
</if>
|
||||
</where>
|
||||
order by br.create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 更新配种记录的孕检信息 -->
|
||||
<update id="updatePregnancyInfo">
|
||||
update sc_breed_record
|
||||
set pregnancy_record_id = #{pregnancyRecordId}
|
||||
where id = #{breedRecordId}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -15,6 +15,7 @@
|
||||
<result property="score" column="score" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<!-- 修复:数据库字段是create_tme,不是create_time -->
|
||||
<result property="createTime" column="create_tme" />
|
||||
</resultMap>
|
||||
|
||||
@@ -66,42 +67,47 @@
|
||||
lr.id, lr.sheep_id, lr.parity, lr.lambs_born, lr.survival,
|
||||
lr.technician, lr.score, lr.comment, lr.create_by, lr.create_tme,
|
||||
|
||||
-- 从bas_sheep表获取母羊信息
|
||||
mother.manage_tags as female_ear_number,
|
||||
mother.variety_id as female_breed,
|
||||
TIMESTAMPDIFF(MONTH, mother.birthday, NOW()) as month_age,
|
||||
mother.sheepfold_id as current_shed,
|
||||
mother.ranch_id as farm,
|
||||
-- 从sheep_file视图获取母羊信息
|
||||
mother.bs_manage_tags as female_ear_number,
|
||||
mother.variety as female_breed,
|
||||
mother.month_age as month_age,
|
||||
mother.sheepfold_name as current_shed,
|
||||
mother.dr_ranch as farm,
|
||||
|
||||
-- 从sc_breed_record表获取配种信息
|
||||
br.create_time as breeding_date,
|
||||
DATEDIFF(lr.create_tme, br.create_time) as pregnancy_days,
|
||||
DATEDIFF(CURDATE(), br.create_time) as pregnancy_days,
|
||||
|
||||
-- 从bas_sheep表获取公羊信息
|
||||
father.manage_tags as male_ear_number,
|
||||
father.variety_id as male_breed,
|
||||
-- 从sheep_file视图获取公羊信息
|
||||
father.bs_manage_tags as male_ear_number,
|
||||
father.variety as male_breed,
|
||||
|
||||
-- 统计羔羊信息(从bas_sheep表统计,根据母羊ID)
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.is_delete = 0) as male_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.is_delete = 0) as female_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.status_id = 1 AND lamb.is_delete = 0) as retained_male_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.status_id = 1 AND lamb.is_delete = 0) as retained_female_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.status_id != 1 AND lamb.is_delete = 0) as unretained_male_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.status_id != 1 AND lamb.is_delete = 0) as unretained_female_count
|
||||
-- 统计羔羊信息(从sc_lamb_detail表统计)
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1) as male_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0) as female_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1 AND sld.is_retained = 1) as retained_male_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0 AND sld.is_retained = 1) as retained_female_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1 AND sld.is_retained = 0) as unretained_male_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0 AND sld.is_retained = 0) as unretained_female_count
|
||||
|
||||
FROM sc_lambing_record lr
|
||||
LEFT JOIN bas_sheep mother ON lr.sheep_id = mother.id
|
||||
LEFT JOIN sc_breed_record br ON lr.sheep_id = br.ewe_id AND lr.parity = mother.parity
|
||||
LEFT JOIN bas_sheep father ON br.ram_id = father.id
|
||||
LEFT JOIN sheep_file mother ON lr.sheep_id = mother.id
|
||||
LEFT JOIN sc_breed_record br ON lr.sheep_id = br.ewe_id AND br.create_time = (
|
||||
SELECT MAX(br2.create_time)
|
||||
FROM sc_breed_record br2
|
||||
WHERE br2.ewe_id = lr.sheep_id
|
||||
AND br2.create_time <= lr.create_tme
|
||||
)
|
||||
LEFT JOIN sheep_file father ON br.ram_id = father.id
|
||||
</sql>
|
||||
|
||||
<!-- 查询产羔记录列表(包含关联信息) -->
|
||||
<select id="selectScLambingRecordList" parameterType="ScLambingRecord" resultMap="ScLambingRecordDetailResult">
|
||||
<include refid="selectScLambingRecordDetailVo"/>
|
||||
<where>
|
||||
<if test="femaleEarNumber != null and femaleEarNumber != ''"> and mother.manage_tags LIKE CONCAT('%', #{femaleEarNumber}, '%')</if>
|
||||
<if test="femaleBreed != null and femaleBreed != ''"> and mother.variety_id = #{femaleBreed}</if>
|
||||
<if test="farm != null and farm != ''"> and mother.ranch_id = #{farm}</if>
|
||||
<if test="femaleEarNumber != null and femaleEarNumber != ''"> and mother.bs_manage_tags LIKE CONCAT('%', #{femaleEarNumber}, '%')</if>
|
||||
<if test="femaleBreed != null and femaleBreed != ''"> and mother.variety LIKE CONCAT('%', #{femaleBreed}, '%')</if>
|
||||
<if test="farm != null and farm != ''"> and mother.dr_ranch LIKE CONCAT('%', #{farm}, '%')</if>
|
||||
<if test="sheepId != null and sheepId != ''"> and lr.sheep_id = #{sheepId}</if>
|
||||
<if test="parity != null"> and lr.parity = #{parity}</if>
|
||||
<if test="lambsBorn != null"> and lr.lambs_born = #{lambsBorn}</if>
|
||||
@@ -134,23 +140,29 @@
|
||||
where lr.id = #{id} and mother.is_delete = 0
|
||||
</select>
|
||||
|
||||
<!-- 查询羔羊详情(从sc_lamb_detail表查询) -->
|
||||
<select id="selectLambDetailByLambingRecordId" parameterType="Long" resultType="ScLambDetail">
|
||||
<!-- 根据母羊耳号查询最新配种记录 -->
|
||||
<select id="getLatestBreedingByEarNumber" parameterType="String" resultType="java.util.Map">
|
||||
SELECT
|
||||
id,
|
||||
lambing_record_id as lambingRecordId,
|
||||
lamb_ear_number as lambEarNumber,
|
||||
lamb_breed as lambBreed,
|
||||
gender,
|
||||
birth_weight as birthWeight,
|
||||
is_retained as isRetained,
|
||||
lineage,
|
||||
birthday,
|
||||
create_by as createBy,
|
||||
create_time as createTime
|
||||
FROM sc_lamb_detail
|
||||
WHERE lambing_record_id = #{lambingRecordId}
|
||||
ORDER BY create_time ASC
|
||||
sf.id as sheep_id,
|
||||
sf.bs_manage_tags as female_ear_number,
|
||||
sf.variety as female_breed,
|
||||
sf.parity as parity,
|
||||
br.ram_id as ram_id,
|
||||
ram.bs_manage_tags as male_ear_number,
|
||||
ram.variety as male_breed,
|
||||
br.create_time as breeding_date,
|
||||
DATEDIFF(CURDATE(), br.create_time) as pregnancy_days,
|
||||
br.technician as technician
|
||||
FROM sheep_file sf
|
||||
LEFT JOIN sc_breed_record br ON sf.id = br.ewe_id
|
||||
LEFT JOIN sheep_file ram ON br.ram_id = ram.id
|
||||
WHERE sf.bs_manage_tags = #{earNumber}
|
||||
AND sf.is_delete = 0
|
||||
AND br.create_time = (
|
||||
SELECT MAX(br2.create_time)
|
||||
FROM sc_breed_record br2
|
||||
WHERE br2.ewe_id = sf.id
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 新增产羔记录 -->
|
||||
@@ -191,8 +203,8 @@
|
||||
<if test="technician != null">technician = #{technician},</if>
|
||||
<if test="score != null">score = #{score},</if>
|
||||
<if test="comment != null">comment = #{comment},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_tme = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
<?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>
|
||||
</select>
|
||||
|
||||
<select id="selectScSheepDeathById" parameterType="Long" resultMap="ScSheepDeathResult">
|
||||
<include refid="selectScSheepDeathVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据管理耳号查询sheep_file视图信息 -->
|
||||
<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
|
||||
from sheep_file
|
||||
where bs_manage_tags = #{manageTags} and is_delete = 0
|
||||
</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>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user