Merge remote-tracking branch 'origin/main'
# Conflicts: # zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScDryMilkController.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScSheepDeathController.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScDryMilk.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScSheepDeath.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScWeanRecord.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScDryMilkMapper.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScSheepDeathMapper.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScWeanRecordMapper.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScDryMilkService.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScSheepDeathService.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScWeanRecordService.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScDryMilkServiceImpl.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScSheepDeathServiceImpl.java # zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScWeanRecordServiceImpl.java # zhyc-module/src/main/resources/mapper/produce/breed/ScDryMilkMapper.xml # zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml
This commit is contained in:
@@ -103,6 +103,24 @@
|
||||
<if test="sc.params != null and sc.params.beginCreateTime != null and sc.params.beginCreateTime != '' and sc.params.endCreateTime != null and sc.params.endCreateTime != ''">
|
||||
and sm.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime}
|
||||
</if>
|
||||
<if test="sc.gender != null and sc.gender != ''">
|
||||
and bs.gender = #{sc.gender}
|
||||
</if>
|
||||
<if test="sc.technician != null and sc.technician != ''">
|
||||
and sm.technician like concat('%', #{sc.technician}, '%')
|
||||
</if>
|
||||
<if test="sc.isDelete != null">
|
||||
and bs.is_delete = #{sc.isDelete}
|
||||
</if>
|
||||
<if test="sc.monthAgeStart != null">
|
||||
and <![CDATA[ TIMESTAMPDIFF(MONTH, bs.birthday, CURDATE()) >= #{sc.monthAgeStart} ]]>
|
||||
</if>
|
||||
<if test="sc.monthAgeEnd != null">
|
||||
and <![CDATA[ TIMESTAMPDIFF(MONTH, bs.birthday, CURDATE()) <= #{sc.monthAgeEnd} ]]>
|
||||
</if>
|
||||
<if test="sc.breedStatusName != null and sc.breedStatusName != ''">
|
||||
and bbs.breed = #{sc.breedStatusName}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sm.create_time DESC
|
||||
</select>
|
||||
@@ -196,6 +214,11 @@
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
|
||||
<select id="selectBreedStatusList" resultType="java.util.HashMap">
|
||||
SELECT id, breed as label, breed as value
|
||||
FROM bas_breed_status
|
||||
ORDER BY id
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -59,6 +59,9 @@
|
||||
<if test="sc.params != null and sc.params.beginCreateTime != null and sc.params.beginCreateTime != '' and sc.params.endCreateTime != null and sc.params.endCreateTime != ''">
|
||||
and sbs.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime}
|
||||
</if>
|
||||
<if test="sc.isDelete != null">
|
||||
and bs.is_delete = #{sc.isDelete}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sbs.create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -57,6 +57,9 @@
|
||||
<if test="sc.params != null and sc.params.beginCreateTime != null and sc.params.endCreateTime != null">
|
||||
and sbr.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime}
|
||||
</if>
|
||||
<if test="sc.isDelete != null">
|
||||
and bs.is_delete = #{sc.isDelete}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sbr.create_time DESC
|
||||
</select>
|
||||
@@ -134,7 +137,6 @@
|
||||
FROM bas_sheep bs
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
LIMIT 50
|
||||
ORDER BY bs.manage_tags LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -77,6 +77,9 @@
|
||||
left join da_sheepfold dsf on bs.sheepfold_id = dsf.id
|
||||
where bs.gender = 1
|
||||
and bs.is_delete = 0
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
and (bs.status_id = 1 or bs.status_id is null)
|
||||
and (
|
||||
(bst.name in ('青年羊', '超龄羊') and (
|
||||
@@ -109,6 +112,9 @@
|
||||
left join bas_breed_status bbs on bs.breed_status_id = bbs.id
|
||||
where bs.gender = 2
|
||||
and bs.is_delete = 0
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
and bs.status_id = 1
|
||||
and (
|
||||
(bst.name in ('青年羊', '超龄羊') and (
|
||||
@@ -310,4 +316,13 @@
|
||||
<delete id="deleteTempBreedPlanByPlanId" parameterType="Long">
|
||||
delete from sc_breed_plan_temp where plan_generate_id = #{planGenerateId}
|
||||
</delete>
|
||||
<!-- 模糊查询耳号列表 -->
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT sf.bs_manage_tags
|
||||
FROM sheep_file sf
|
||||
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||
AND sf.is_delete = 0
|
||||
ORDER BY sf.bs_manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -4,6 +4,43 @@
|
||||
"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>-->
|
||||
<resultMap type="ScBreedRecord" id="ScBreedRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
@@ -12,9 +49,15 @@
|
||||
<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="frozenSemenNo" column="frozen_sperm_no" /> <result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<!-- 显示字段 -->
|
||||
<result property="comment" column="comment" />
|
||||
|
||||
<result property="embryoCount" column="embryo_count" />
|
||||
<result property="embryoSubType" column="embryoSubType" />
|
||||
<result property="donorEweNo" column="donor_ewe" />
|
||||
<result property="donorRamNo" column="donor_ram" />
|
||||
|
||||
<result property="eweManageTags" column="ewe_manage_tags" />
|
||||
<result property="eweVariety" column="ewe_variety" />
|
||||
<result property="ramManageTags" column="ram_manage_tags" />
|
||||
@@ -26,90 +69,93 @@
|
||||
<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="daysPostLambing" column="days_post_lambing" />
|
||||
<result property="daysLactation" column="days_lactation" />
|
||||
<result property="daysPostMating" column="days_post_mating" />
|
||||
<result property="lastMatingDate" column="last_mating_date" />
|
||||
|
||||
<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="eweParity" column="eweParity" />
|
||||
|
||||
|
||||
<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,-->
|
||||
<!-- -- 配种方式显示(修改:增加3-冲胚、4-自然发情人工授精)-->
|
||||
<!-- CASE br.breed_type-->
|
||||
<!-- WHEN 1 THEN '同期发情'-->
|
||||
<!-- WHEN 2 THEN '本交'-->
|
||||
<!-- WHEN 3 THEN '冲胚'-->
|
||||
<!-- WHEN 4 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>-->
|
||||
</resultMap>
|
||||
<!-- <sql id="selectScBreedRecordVo">-->
|
||||
<!-- select DISTINCT-->
|
||||
<!-- 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 '本交'-->
|
||||
<!-- WHEN 3 THEN '冲胚'-->
|
||||
<!-- WHEN 4 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.id = (-->
|
||||
<!-- select pr2.id-->
|
||||
<!-- from sc_pregnancy_record pr2-->
|
||||
<!-- where pr2.sheep_id = br.ewe_id-->
|
||||
<!-- and pr2.is_delete = 0-->
|
||||
<!-- and pr2.datetime >= br.create_time-->
|
||||
<!-- order by pr2.datetime asc, pr2.id asc-->
|
||||
<!-- limit 1-->
|
||||
<!-- )-->
|
||||
<!-- </sql>-->
|
||||
<sql id="selectScBreedRecordVo">
|
||||
select DISTINCT
|
||||
br.id,
|
||||
@@ -119,9 +165,20 @@
|
||||
br.technician,
|
||||
br.breed_drugs,
|
||||
br.breed_type,
|
||||
br.frozen_sperm_no, -- 冻精号
|
||||
br.embryoSubType,
|
||||
br.comment,
|
||||
br.create_by,
|
||||
br.create_time,
|
||||
-- 母羊信息(从视图获取)
|
||||
|
||||
-- 胚胎移植相关字段 (如果不存表里,需要join sc_embryo_flush,这里假设存表或已有字段,如需Join请参考下方注释)
|
||||
-- 假设表里已有这些列,或者我们通过Join sheep_file 拿(但sheep_file没有donor信息)
|
||||
-- 这里按照最佳实践,应在插入时将Donor信息固化在breed_record表中
|
||||
br.donor_ewe,
|
||||
br.donor_ram,
|
||||
br.embryo_count,
|
||||
|
||||
-- 母羊信息
|
||||
ewe_view.bs_manage_tags as ewe_manage_tags,
|
||||
ewe_view.variety as ewe_variety,
|
||||
ewe_view.parity as ewe_parity,
|
||||
@@ -133,19 +190,52 @@
|
||||
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 '本交'
|
||||
WHEN 3 THEN '冲胚'
|
||||
WHEN 4 THEN '自然发情人工授精'
|
||||
ELSE '未知'
|
||||
END as mating_type,
|
||||
(SELECT variety FROM sheep_file WHERE bs_manage_tags = br.donor_ewe LIMIT 1) as donorEweVariety,
|
||||
(SELECT variety FROM sheep_file WHERE bs_manage_tags = br.donor_ram LIMIT 1) as donorRamVariety,
|
||||
-- 发情后配种时间(小时数)
|
||||
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,
|
||||
|
||||
-- ================= 计算字段实现 =================
|
||||
|
||||
-- 1. 配种时产后天数 (距离上一次产羔: 找最近一次小于配种时间的产羔日期)
|
||||
DATEDIFF(br.create_time, (
|
||||
SELECT lambing_date
|
||||
FROM sheep_file
|
||||
WHERE id = br.ewe_id
|
||||
)) as days_post_lambing,
|
||||
|
||||
-- 2. 配种时泌乳天数 (距离上一次孕检且怀孕)
|
||||
DATEDIFF(br.create_time, (
|
||||
SELECT MAX(pr_sub.datetime)
|
||||
FROM sc_pregnancy_record pr_sub
|
||||
WHERE pr_sub.sheep_id = br.ewe_id
|
||||
AND pr_sub.result = '怀孕'
|
||||
AND pr_sub.is_delete = 0
|
||||
AND pr_sub.datetime < br.create_time
|
||||
)) as days_lactation,
|
||||
|
||||
-- 3. 配种时配后天数 (距离上一次配种)
|
||||
DATEDIFF(br.create_time, (
|
||||
SELECT MAX(br_sub.create_time)
|
||||
FROM sc_breed_record br_sub
|
||||
WHERE br_sub.ewe_id = br.ewe_id
|
||||
AND br_sub.create_time < br.create_time
|
||||
)) as days_post_mating,
|
||||
|
||||
-- 4. 上次配种日期
|
||||
(
|
||||
SELECT MAX(br_sub.create_time)
|
||||
FROM sc_breed_record br_sub
|
||||
WHERE br_sub.ewe_id = br.ewe_id
|
||||
AND br_sub.create_time < br.create_time
|
||||
) as last_mating_date,
|
||||
|
||||
-- ===============================================
|
||||
|
||||
-- 孕检相关信息
|
||||
pr.datetime as pregnancy_check_date,
|
||||
pr.result as pregnancy_result,
|
||||
@@ -164,10 +254,10 @@
|
||||
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.id = (
|
||||
select pr2.id
|
||||
from sc_pregnancy_record pr2
|
||||
@@ -178,6 +268,32 @@
|
||||
limit 1
|
||||
)
|
||||
</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="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
<where>
|
||||
@@ -185,22 +301,20 @@
|
||||
<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 test="eweManageTags != null and eweManageTags != ''">
|
||||
and (
|
||||
ewe_view.bs_manage_tags like concat('%', #{eweManageTags}, '%')
|
||||
OR br.donor_ewe_no like concat('%', #{eweManageTags}, '%') -- Also search donor
|
||||
)
|
||||
</if>
|
||||
<if test="ramManageTags != null and ramManageTags != ''">
|
||||
and (
|
||||
ram_view.bs_manage_tags like concat('%', #{ramManageTags}, '%')
|
||||
OR br.donor_ram like concat('%', #{ramManageTags}, '%') -- Also search donor
|
||||
)
|
||||
</if>
|
||||
<if test="frozenSemenNo != null and frozenSemenNo != ''"> and br.frozen_sperm_no like concat('%', #{frozenSemenNo}, '%')</if>
|
||||
</where>
|
||||
order by br.create_time desc
|
||||
</select>
|
||||
@@ -210,6 +324,8 @@
|
||||
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
|
||||
@@ -334,6 +450,29 @@
|
||||
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>-->
|
||||
<insert id="insertScBreedRecord" parameterType="ScBreedRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_breed_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -343,8 +482,14 @@
|
||||
<if test="technician != null">technician,</if>
|
||||
<if test="breedDrugs != null">breed_drugs,</if>
|
||||
<if test="breedType != null">breed_type,</if>
|
||||
<if test="frozenSemenNo != null">frozen_sperm_no,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="embryoCount != null">embryo_count,</if>
|
||||
<if test="donorEweNo != null">donor_ewe,</if>
|
||||
<if test="donorRamNo != null">donor_ram,</if>
|
||||
<if test="embryoSubType != null">embryoSubType,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
@@ -353,11 +498,31 @@
|
||||
<if test="technician != null">#{technician},</if>
|
||||
<if test="breedDrugs != null">#{breedDrugs},</if>
|
||||
<if test="breedType != null">#{breedType},</if>
|
||||
<if test="frozenSemenNo != null">#{frozenSemenNo},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="embryoCount != null">#{embryoCount},</if>
|
||||
<if test="donorEweNo != null">#{donorEweNo},</if>
|
||||
<if test="donorRamNo != null">#{donorRamNo},</if>
|
||||
<if test="embryoSubType != null">#{embryoSubType},</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>-->
|
||||
<update id="updateScBreedRecord" parameterType="ScBreedRecord">
|
||||
update sc_breed_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
@@ -367,12 +532,35 @@
|
||||
<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="frozenSemenNo != null">frozen_sperm_no = #{frozenSemenNo},</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="embryoCount != null">embryo_count = #{embryoCount},</if>
|
||||
<if test="donorEweNo != null">donor_ewe = #{donorEweNo},</if>
|
||||
<if test="donorRamNo != null">donor_ram = #{donorRamNo},</if>
|
||||
<if test="embryoSubType != null">embryoSubType = #{embryoSubType},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getFlushRecordByEweNo" parameterType="String" resultType="map">
|
||||
SELECT
|
||||
transferred,
|
||||
donor_female_no,
|
||||
donor_male_no,
|
||||
embryo_type,
|
||||
storage_method
|
||||
FROM sc_embryo_flush
|
||||
WHERE id = (
|
||||
-- Assuming linking via recipient tags is complicated,
|
||||
-- usually this is done by matching a recent flush record
|
||||
-- For now, this mimics the logic in your ServiceImpl
|
||||
SELECT id FROM sc_embryo_flush WHERE donor_female_no LIKE concat('%', #{manageTags}, '%')
|
||||
ORDER BY flush_time DESC LIMIT 1
|
||||
)
|
||||
-- Note: If your sc_embryo_flush structure is different (one row per recipient), adjust accordingly.
|
||||
-- Based on provided file, it has `recipient_cnt`.
|
||||
</select>
|
||||
<delete id="deleteScBreedRecordById" parameterType="Long">
|
||||
delete from sc_breed_record where id = #{id}
|
||||
</delete>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="comment" column="comment" />
|
||||
<!-- 联表查询字段 -->
|
||||
<result property="manageTags" column="bs_manage_tags" />
|
||||
<result property="variety" column="variety" />
|
||||
<result property="sheepfoldName" column="sheepfold_name" />
|
||||
@@ -85,6 +86,8 @@
|
||||
where d.id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 根据耳号查询羊只ID -->
|
||||
<select id="selectSheepIdByManageTags" parameterType="String" resultType="Long">
|
||||
select id from sheep_file where bs_manage_tags = #{manageTags} limit 1
|
||||
</select>
|
||||
@@ -138,4 +141,14 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 当 gender=null 时,不会添加 gender 条件,即查询全部羊 -->
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT sf.bs_manage_tags
|
||||
FROM sheep_file sf
|
||||
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||
AND sf.is_delete = 0
|
||||
ORDER BY sf.bs_manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -203,13 +203,9 @@
|
||||
<!-- ewe_id存的是数字ID,需要先根据耳号找到母羊ID,再查配种记录,再根据公羊ID找到公羊耳号 -->
|
||||
<select id="selectBreedRecordByEwe" resultType="java.util.Map">
|
||||
SELECT
|
||||
ram_sf.bs_manage_tags AS ramId,
|
||||
br.create_time AS matingDate
|
||||
FROM sc_breed_record br
|
||||
INNER JOIN sheep_file ewe_sf ON ewe_sf.id = br.ewe_id
|
||||
INNER JOIN sheep_file ram_sf ON ram_sf.id = br.ram_id
|
||||
WHERE ewe_sf.bs_manage_tags = #{eweManageTag}
|
||||
ORDER BY br.create_time DESC
|
||||
donor_ram AS donorMaleNo, create_time AS matingDate FROM sc_breed_record
|
||||
WHERE donor_ewe = #{eweManageTag} AND (is_delete = 0 OR is_delete IS NULL)
|
||||
ORDER BY create_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
|
||||
@@ -105,7 +105,16 @@
|
||||
<select id="selectScLambingRecordList" parameterType="ScLambingRecord" resultMap="ScLambingRecordDetailResult">
|
||||
<include refid="selectScLambingRecordDetailVo"/>
|
||||
<where>
|
||||
<if test="femaleEarNumber != null and femaleEarNumber != ''"> and mother.bs_manage_tags LIKE CONCAT('%', #{femaleEarNumber}, '%')</if>
|
||||
<!-- 全部羊多耳号查询 -->
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
AND (
|
||||
<!-- 注意:s 代表 sheep_file 表的别名,根据实际 SQL 别名修改 -->
|
||||
mother.bs_manage_tags IN
|
||||
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||
#{earNumber}
|
||||
</foreach>
|
||||
)
|
||||
</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>
|
||||
@@ -229,5 +238,15 @@
|
||||
FROM sc_breed_record br
|
||||
JOIN sc_lambing_record lr ON br.ewe_id = lr.sheep_id
|
||||
WHERE br.ram_id = #{ramManageTags} AND br.is_delete = 0
|
||||
|
||||
</select>
|
||||
<!-- 模糊查询耳号列表 -->
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT sf.bs_manage_tags
|
||||
FROM sheep_file sf
|
||||
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||
AND sf.is_delete = 0
|
||||
ORDER BY sf.bs_manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -29,80 +29,146 @@
|
||||
<result property="matingDate" column="mating_date" />
|
||||
<result property="expectedDate" column="expected_date" />
|
||||
<result property="lastEventDate" column="last_event_date" />
|
||||
<result property="ranchName" column="ranch" />
|
||||
<result property="ranchName" column="sysRanch" />
|
||||
<result property="daysAfterMating" column="days_after_mating" />
|
||||
<result property="reason" column="reason" />
|
||||
<result property="donorEwe" column="donor_ewe" />
|
||||
<result property="donorRam" column="donor_ram" />
|
||||
<result property="embryoCount" column="embryo_count" />
|
||||
<result property="donorEweVariety" column="donor_ewe_variety" />
|
||||
<result property="donorRamVariety" column="donor_ram_variety" />
|
||||
</resultMap>
|
||||
|
||||
<!-- <sql id="selectScPregnancyRecordVo">-->
|
||||
<!-- select-->
|
||||
<!-- pr.id,-->
|
||||
<!-- pr.sheep_id,-->
|
||||
<!-- pr.datetime,-->
|
||||
<!-- pr.result,-->
|
||||
<!-- pr.fetus_count,-->
|
||||
<!-- pr.technician,-->
|
||||
<!-- pr.way,-->
|
||||
<!-- pr.remark,-->
|
||||
<!-- pr.create_by,-->
|
||||
<!-- pr.create_time,-->
|
||||
<!-- sf.bs_manage_tags as manage_tags,-->
|
||||
<!-- sf.variety,-->
|
||||
<!-- sf.month_age,-->
|
||||
<!-- sf.parity,-->
|
||||
<!-- sf.mating_counts,-->
|
||||
<!-- sf.sheepfold_name,-->
|
||||
<!-- sf.breed,-->
|
||||
<!-- sf.expected_date,-->
|
||||
<!-- sf.lambing_date as last_event_date,-->
|
||||
<!-- sf.dr_ranch as sysRanch,-->
|
||||
|
||||
<!-- -- 1. 上次孕检日期逻辑-->
|
||||
<!-- (SELECT MAX(datetime) FROM sc_pregnancy_record-->
|
||||
<!-- WHERE sheep_id = pr.sheep_id AND datetime < pr.datetime AND is_delete = 0) as last_event_date,-->
|
||||
<!-- -- 2. 配种基础信息-->
|
||||
<!-- br.create_time as mating_date,-->
|
||||
<!-- br.embryo_count,-->
|
||||
<!-- br.donor_ewe,-->
|
||||
<!-- br.donor_ram,-->
|
||||
<!-- -- 3. 配种类型映射逻辑-->
|
||||
<!-- CASE br.breed_type-->
|
||||
<!-- WHEN 1 THEN '供体母羊配种'-->
|
||||
<!-- WHEN 2 THEN '同期发情人工授精'-->
|
||||
<!-- WHEN 3 THEN '本交'-->
|
||||
<!-- WHEN 4 THEN '自然发情人工授精'-->
|
||||
<!-- WHEN 5 THEN '胚胎移植'-->
|
||||
<!-- ELSE '' END as mating_type_name,-->
|
||||
<!-- -- 4. 配种公羊品种-->
|
||||
<!-- ram_sf.bs_manage_tags as father_manage_tags,-->
|
||||
<!-- ram_sf.variety as father_variety,-->
|
||||
<!-- -- 5. 供体品种逻辑 (再次关联羊档案)-->
|
||||
<!-- donor_e_sf.variety as donor_ewe_variety,-->
|
||||
<!-- donor_r_sf.variety as donor_ram_variety-->
|
||||
<!-- FROM sc_pregnancy_record pr-->
|
||||
<!-- LEFT JOIN sheep_file sf ON pr.sheep_id = sf.id-->
|
||||
<!-- -- 关联最新的配种记录-->
|
||||
<!-- LEFT JOIN (-->
|
||||
<!-- SELECT t1.* FROM sc_breed_record t1-->
|
||||
<!-- INNER JOIN (SELECT ewe_id, MAX(create_time) as mt FROM sc_breed_record GROUP BY ewe_id) t2-->
|
||||
<!-- ON t1.ewe_id = t2.ewe_id AND t1.create_time = t2.mt-->
|
||||
<!-- ) br ON pr.sheep_id = br.ewe_id-->
|
||||
<!-- -- 关联配种公羊品种-->
|
||||
<!-- LEFT JOIN sheep_file ram_sf ON br.ram_id = ram_sf.id-->
|
||||
<!-- -- 关联供体母羊品种 (基于耳号)-->
|
||||
<!-- LEFT JOIN sheep_file donor_e_sf ON br.donor_ewe = donor_e_sf.bs_manage_tags-->
|
||||
<!-- -- 关联供体公羊品种 (基于耳号)-->
|
||||
<!-- LEFT JOIN sheep_file donor_r_sf ON br.donor_ram = donor_r_sf.bs_manage_tags-->
|
||||
<!-- -- 关联配种信息-->
|
||||
<!-- ram_sf.bs_manage_tags as father_manage_tags,-->
|
||||
<!-- ram_sf.variety as father_variety,-->
|
||||
<!-- mating_type.dict_label as mating_type_name,-->
|
||||
<!-- COALESCE(br.create_time, sf.mating_date) as mating_date,-->
|
||||
<!-- -- 计算配后天数:孕检日期 - 配种日期-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN COALESCE(br.create_time, sf.mating_date) IS NOT NULL-->
|
||||
<!-- THEN DATEDIFF(pr.datetime, COALESCE(br.create_time, sf.mating_date))-->
|
||||
<!-- ELSE NULL-->
|
||||
<!-- END as days_after_mating-->
|
||||
<!-- from sc_pregnancy_record pr-->
|
||||
<!-- INNER JOIN sheep_file sf on pr.sheep_id = sf.id-->
|
||||
<!-- -- 关联配种记录表,获取最新的配种记录-->
|
||||
<!-- left join (-->
|
||||
<!-- select br1.*-->
|
||||
<!-- from sc_breed_record br1-->
|
||||
<!-- inner join (-->
|
||||
<!-- select ewe_id, max(create_time) as max_time-->
|
||||
<!-- from sc_breed_record-->
|
||||
<!-- group by ewe_id-->
|
||||
<!-- ) br2 on br1.ewe_id = br2.ewe_id and br1.create_time = br2.max_time-->
|
||||
<!-- ) br on sf.id = br.ewe_id-->
|
||||
<!-- -- 关联公羊信息-->
|
||||
<!-- left join sheep_file ram_sf on br.ram_id = ram_sf.id-->
|
||||
<!-- -- 关联配种类型字典-->
|
||||
<!-- left join sys_dict_data mating_type on sf.mating_type_id = mating_type.dict_value-->
|
||||
<!-- and mating_type.dict_type = 'breed_type' and mating_type.status = '0'-->
|
||||
<!-- </sql>-->
|
||||
|
||||
|
||||
<sql id="selectScPregnancyRecordVo">
|
||||
select
|
||||
pr.id,
|
||||
pr.sheep_id,
|
||||
pr.datetime,
|
||||
pr.result,
|
||||
pr.fetus_count,
|
||||
pr.technician,
|
||||
pr.way,
|
||||
pr.remark,
|
||||
pr.create_by,
|
||||
pr.create_time,
|
||||
sf.bs_manage_tags as manage_tags,
|
||||
sf.variety,
|
||||
sf.month_age,
|
||||
sf.parity,
|
||||
sf.mating_counts,
|
||||
sf.sheepfold_name,
|
||||
sf.breed,
|
||||
sf.expected_date,
|
||||
sf.lambing_date as last_event_date,
|
||||
sf.dr_ranch as ranch,
|
||||
-- 关联配种信息
|
||||
pr.id, pr.sheep_id, pr.datetime, pr.result, pr.fetus_count, pr.technician, pr.way, pr.remark, pr.create_by, pr.create_time,pr.reason,
|
||||
sf.bs_manage_tags as manage_tags, sf.variety, sf.month_age, sf.parity, sf.mating_counts, sf.sheepfold_name, sf.breed, sf.expected_date, sf.dr_ranch as sysRanch,
|
||||
(SELECT MAX(datetime) FROM sc_pregnancy_record WHERE sheep_id = pr.sheep_id AND datetime < pr.datetime AND is_delete = 0) as last_event_date,
|
||||
br.create_time as mating_date,
|
||||
br.embryo_count, br.donor_ewe, br.donor_ram,
|
||||
mating_type.dict_label as mating_type_name,
|
||||
ram_sf.bs_manage_tags as father_manage_tags,
|
||||
ram_sf.variety as father_variety,
|
||||
mating_type.dict_label as mating_type_name,
|
||||
COALESCE(br.create_time, sf.mating_date) as mating_date,
|
||||
-- 计算配后天数:孕检日期 - 配种日期
|
||||
CASE
|
||||
WHEN COALESCE(br.create_time, sf.mating_date) IS NOT NULL
|
||||
THEN DATEDIFF(pr.datetime, COALESCE(br.create_time, sf.mating_date))
|
||||
ELSE NULL
|
||||
END as days_after_mating
|
||||
donor_e_sf.variety as donor_ewe_variety,
|
||||
donor_r_sf.variety as donor_ram_variety,
|
||||
DATEDIFF(pr.datetime, br.create_time) as days_after_mating
|
||||
from sc_pregnancy_record pr
|
||||
INNER JOIN sheep_file sf on pr.sheep_id = sf.id
|
||||
-- 关联配种记录表,获取最新的配种记录
|
||||
left join (
|
||||
select br1.*
|
||||
from sc_breed_record br1
|
||||
inner join (
|
||||
select ewe_id, max(create_time) as max_time
|
||||
from sc_breed_record
|
||||
group by ewe_id
|
||||
) br2 on br1.ewe_id = br2.ewe_id and br1.create_time = br2.max_time
|
||||
) br on sf.id = br.ewe_id
|
||||
-- 关联公羊信息
|
||||
left join sheep_file ram_sf on br.ram_id = ram_sf.id
|
||||
-- 关联配种类型字典
|
||||
left join sys_dict_data mating_type on sf.mating_type_id = mating_type.dict_value
|
||||
LEFT JOIN sheep_file sf on pr.sheep_id = sf.id
|
||||
LEFT JOIN (
|
||||
select t1.* from sc_breed_record t1
|
||||
inner join (select ewe_id, max(create_time) as mt from sc_breed_record group by ewe_id) t2
|
||||
on t1.ewe_id = t2.ewe_id and t1.create_time = t2.mt
|
||||
) br on pr.sheep_id = br.ewe_id
|
||||
LEFT JOIN sheep_file ram_sf on br.ram_id = ram_sf.id
|
||||
LEFT JOIN sys_dict_data mating_type on CAST(br.breed_type AS CHAR) = mating_type.dict_value
|
||||
and mating_type.dict_type = 'breed_type' and mating_type.status = '0'
|
||||
LEFT JOIN sheep_file donor_e_sf on br.donor_ewe = donor_e_sf.bs_manage_tags
|
||||
LEFT JOIN sheep_file donor_r_sf on br.donor_ram = donor_r_sf.bs_manage_tags
|
||||
</sql>
|
||||
|
||||
<!-- 重写的查询列表方法 -->
|
||||
<select id="selectScPregnancyRecordList" parameterType="ScPregnancyRecord" resultMap="ScPregnancyRecordResult">
|
||||
<include refid="selectScPregnancyRecordVo"/>
|
||||
|
||||
<where>
|
||||
pr.is_delete = 0
|
||||
|
||||
<!-- 耳号搜索 - 支持多种匹配方式 -->
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
<bind name="searchTag" value="manageTags.trim()" />
|
||||
AND (
|
||||
<!-- 精确匹配 -->
|
||||
sf.bs_manage_tags = #{searchTag}
|
||||
<!-- 模糊匹配 -->
|
||||
OR sf.bs_manage_tags LIKE CONCAT('%', #{searchTag}, '%')
|
||||
<!-- 处理逗号分隔的多个耳号 -->
|
||||
OR FIND_IN_SET(sf.bs_manage_tags, REPLACE(#{searchTag}, ' ', '')) > 0
|
||||
<!-- 反向匹配:输入包含数据库中的耳号 -->
|
||||
OR #{searchTag} LIKE CONCAT('%', sf.bs_manage_tags, '%')
|
||||
<!-- 正确:sf.bs_manage_tags,sf是sheep_file的别名 -->
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
AND (sf.bs_manage_tags IN
|
||||
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||
#{earNumber}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
|
||||
@@ -148,22 +214,33 @@
|
||||
<select id="selectBreedInfoByManageTags" parameterType="String" resultType="map">
|
||||
SELECT
|
||||
sf.bs_manage_tags as manageTags,
|
||||
-- 从配种记录表获取公羊耳号
|
||||
ram_sf.bs_manage_tags as fatherManageTags,
|
||||
ram_sf.variety as fatherVariety,
|
||||
br.donor_ewe as donorEwe,
|
||||
br.donor_ram as donorRam,
|
||||
donor_e_sf.variety as donorEweVariety,
|
||||
donor_r_sf.variety as donorRamVariety,
|
||||
-- 核心修改:如果是胚胎移植(5),显示供体公羊;否则显示普通配种公羊
|
||||
CASE
|
||||
WHEN br.breed_type = 5 THEN br.donor_ram
|
||||
ELSE ram_sf.bs_manage_tags
|
||||
END as fatherManageTags,
|
||||
-- 品种也需要同步切换
|
||||
CASE
|
||||
WHEN br.breed_type = 5 THEN donor_r_sf.variety
|
||||
ELSE ram_sf.variety
|
||||
END as fatherVariety,
|
||||
br.create_time as matingDate,
|
||||
mating_type.dict_label as matingTypeName,
|
||||
br.technician as breedTechnician,
|
||||
br.create_time as breedCreateTime
|
||||
br.technician as breedTechnician
|
||||
FROM sheep_file sf
|
||||
LEFT JOIN sc_breed_record br ON sf.id = br.ewe_id
|
||||
LEFT JOIN sheep_file ram_sf ON br.ram_id = ram_sf.id
|
||||
LEFT JOIN sys_dict_data mating_type ON sf.mating_type_id = mating_type.dict_value
|
||||
-- 新增关联:通过耳号获取供体公羊的品种信息
|
||||
LEFT JOIN sheep_file donor_r_sf ON br.donor_ram = donor_r_sf.bs_manage_tags
|
||||
LEFT JOIN sheep_file donor_e_sf ON br.donor_ewe = donor_e_sf.bs_manage_tags
|
||||
LEFT JOIN sys_dict_data mating_type ON CAST(br.breed_type AS CHAR) = mating_type.dict_value
|
||||
AND mating_type.dict_type = 'breed_type' AND mating_type.status = '0'
|
||||
WHERE sf.bs_manage_tags = #{manageTags}
|
||||
AND sf.is_delete = 0
|
||||
ORDER BY br.create_time DESC
|
||||
LIMIT 1
|
||||
WHERE sf.bs_manage_tags = #{manageTags} AND sf.is_delete = 0
|
||||
ORDER BY br.create_time DESC LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insertScPregnancyRecord" parameterType="ScPregnancyRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
@@ -178,6 +255,7 @@
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
is_delete
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
@@ -190,6 +268,7 @@
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
@@ -203,6 +282,7 @@
|
||||
<if test="technician != null">technician = #{technician},</if>
|
||||
<if test="way != null">way = #{way},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="reason != null">reason = #{reason},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -242,4 +322,14 @@
|
||||
AND br.breed_type = #{breedType}
|
||||
AND pr.result IN ('有胎', '阳性', '怀孕')
|
||||
</select>
|
||||
|
||||
<!-- 模糊查询耳号列表 -->
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT sf.bs_manage_tags
|
||||
FROM sheep_file sf
|
||||
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||
AND sf.is_delete = 0
|
||||
ORDER BY sf.bs_manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -137,6 +137,7 @@
|
||||
where d.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据管理耳号查询sheep_file视图信息 -->
|
||||
<select id="selectSheepFileByManageTags" parameterType="String" resultType="java.util.Map">
|
||||
select
|
||||
id as sheepId,
|
||||
@@ -229,6 +230,7 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 更新羊只繁育状态 - 更新基础表 bas_sheep,使用正确的字段名 -->
|
||||
<update id="updateSheepFileStatus">
|
||||
UPDATE bas_sheep
|
||||
SET breed_status_id = #{status},
|
||||
@@ -237,6 +239,7 @@
|
||||
AND is_delete = 0
|
||||
</update>
|
||||
|
||||
<!-- 更新羊只在群状态 - 更新基础表 bas_sheep,使用正确的字段名 -->
|
||||
<update id="updateSheepStatus">
|
||||
UPDATE bas_sheep
|
||||
SET status_id = #{status},
|
||||
@@ -245,4 +248,13 @@
|
||||
AND is_delete = 0
|
||||
</update>
|
||||
|
||||
<!-- 模糊查询耳号列表 -->
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT sf.bs_manage_tags
|
||||
FROM sheep_file sf
|
||||
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||
AND sf.is_delete = 0
|
||||
ORDER BY sf.bs_manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -42,6 +42,15 @@
|
||||
<select id="selectScWeanRecordList" parameterType="ScWeanRecord" resultMap="ScWeanRecordResult">
|
||||
<include refid="selectScWeanRecordVo"/>
|
||||
<where>
|
||||
<!-- 全部羊多耳号查询 -->
|
||||
<!-- 正确:sf.bs_manage_tags,sf是sheep_file的别名 -->
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
AND (sf.bs_manage_tags IN
|
||||
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||
#{earNumber}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="sheepId != null "> and wr.sheep_id = #{sheepId}</if>
|
||||
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
@@ -154,4 +163,14 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 模糊查询耳号列表 -->
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT sf.bs_manage_tags
|
||||
FROM sheep_file sf
|
||||
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||
AND sf.is_delete = 0
|
||||
ORDER BY sf.bs_manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -43,8 +43,11 @@
|
||||
bs.manage_tags like concat('%', #{tag}, '%')
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="sc.sheepfoldId != null">
|
||||
and bs.sheepfold_id = #{sc.sheepfoldId}
|
||||
<!-- <if test="sc.sheepfoldId != null">-->
|
||||
<!-- and bs.sheepfold_id = #{sc.sheepfoldId}-->
|
||||
<!-- </if>-->
|
||||
<if test="sc.technician != null and sc.technician != ''">
|
||||
and scc.technician like concat('%', #{sc.technician}, '%')
|
||||
</if>
|
||||
<if test="sc.newComment != null and sc.newComment != ''">
|
||||
and scc.new_comment like concat('%', #{sc.newComment}, '%')
|
||||
@@ -60,6 +63,9 @@
|
||||
and sc.params.endEventDate != null and sc.params.endEventDate != ''">
|
||||
and scc.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate}
|
||||
</if>
|
||||
<if test="sc.isDelete != null">
|
||||
and bs.is_delete = #{sc.isDelete}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY scc.create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
sce.sheep_id,
|
||||
bs.manage_tags as manage_tags,
|
||||
sf.sheepfold_name as sheepfold_name,
|
||||
bv.variety as varietyName,
|
||||
case
|
||||
when sce.ear_type = 0 then '改电子耳号'
|
||||
when sce.ear_type = 1 then '改管理耳号'
|
||||
@@ -41,6 +42,7 @@
|
||||
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
|
||||
LEFT JOIN bas_sheep_variety bv on bs.variety_id = bv.id
|
||||
</sql>
|
||||
|
||||
<select id="selectScChangeEarList" resultMap="ScChangeEarResult">
|
||||
@@ -53,7 +55,7 @@
|
||||
or bs.electronic_tags like concat('%', #{tag}, '%'))
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="sc.sheepfoldId != null">and bs.sheepfold_id = #{sc.sheepfoldId}</if>
|
||||
<if test="sc.technician != null and sc.technician != ''">and sce.technician like concat('%', #{sc.technician}, '%')</if>
|
||||
<if test="sc.earType != null">and sce.ear_type = #{sc.earType}</if>
|
||||
<if test="sc.newTag != null and sc.newTag != ''">and sce.newTag like concat('%', #{sc.newTag}, '%')</if>
|
||||
<if test="sc.oldTag != null and sc.oldTag != ''">and sce.oldTag like concat('%', #{sc.oldTag}, '%')</if>
|
||||
@@ -65,6 +67,12 @@
|
||||
and sc.params.endEventDate != null and sc.params.endEventDate != ''">
|
||||
and sce.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate}
|
||||
</if>
|
||||
<if test="sc.inGroup != null">
|
||||
<choose>
|
||||
<when test="sc.inGroup == 1">and bs.is_delete = 0</when>
|
||||
<when test="sc.inGroup == 2">and bs.is_delete = 1</when>
|
||||
</choose>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sce.create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -46,15 +46,25 @@
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="sc.sheepId != null">and scv.sheep_id = #{sc.sheepId}</if>
|
||||
<if test="sc.sheepfoldId != null">and bs.sheepfold_id = #{sc.sheepfoldId}</if>
|
||||
<if test="sc.varietyOld != null and sc.varietyOld != ''">and scv.variety_old like concat('%', #{sc.varietyOld}, '%')</if>
|
||||
<if test="sc.varietyNew != null and sc.varietyNew != ''">and scv.variety_new like concat('%', #{sc.varietyNew}, '%')</if>
|
||||
<!-- <if test="sc.sheepfoldId != null">and bs.sheepfold_id = #{sc.sheepfoldId}</if>-->
|
||||
<if test="sc.technician != null and sc.technician != ''">and scv.technician like concat('%',
|
||||
#{sc.technician}, '%')
|
||||
</if>
|
||||
<if test="sc.varietyOld != null and sc.varietyOld != ''">and scv.variety_old like concat('%',
|
||||
#{sc.varietyOld}, '%')
|
||||
</if>
|
||||
<if test="sc.varietyNew != null and sc.varietyNew != ''">and scv.variety_new like concat('%',
|
||||
#{sc.varietyNew}, '%')
|
||||
</if>
|
||||
<if test="sc.params != null and sc.params.beginCreateTime != null and sc.params.beginCreateTime != '' and sc.params.endCreateTime != null and sc.params.endCreateTime != ''">
|
||||
and scv.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime}
|
||||
</if>
|
||||
<if test="sc.params != null and sc.params.beginEventDate != null and sc.params.beginEventDate != '' and sc.params.endEventDate != null and sc.params.endEventDate != ''">
|
||||
and scv.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate}
|
||||
</if>
|
||||
<if test="sc.isDelete != null">
|
||||
and bs.is_delete = #{sc.isDelete}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY scv.create_time DESC
|
||||
</select>
|
||||
@@ -119,7 +129,6 @@
|
||||
FROM bas_sheep bs
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
LIMIT 50
|
||||
ORDER BY bs.manage_tags LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -15,7 +15,6 @@
|
||||
<result property="varietyId" column="variety_id"/>
|
||||
<result property="varietyName" column="varietyName"/>
|
||||
<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"/>
|
||||
@@ -25,8 +24,8 @@
|
||||
SELECT tg.id,
|
||||
tg.sheep_id,
|
||||
s.manage_tags AS manageTags,
|
||||
tg.event_type AS eventType,
|
||||
tg.trans_date AS transDate,
|
||||
tg.event_type AS eventType,
|
||||
tg.trans_date AS transDate,
|
||||
tg.fold_to,
|
||||
tg.fold_from,
|
||||
tg.reason,
|
||||
@@ -34,7 +33,6 @@
|
||||
bv.variety AS varietyName,
|
||||
st.id AS sheepTypeId,
|
||||
st.name AS sheepTypeName,
|
||||
tg.status,
|
||||
tg.comment,
|
||||
tg.create_by,
|
||||
tg.create_time,
|
||||
@@ -54,20 +52,28 @@
|
||||
<select id="selectScTransGroupList" resultMap="ScTransGroupResult">
|
||||
<include refid="selectScTransGroupVo"/>
|
||||
<where>
|
||||
<if test="manageTagsList != null and manageTagsList.size() > 0">
|
||||
<foreach collection="manageTagsList" item="tag" separator="or" open="and (" close=")">
|
||||
s.manage_tags like concat('%', #{tag}, '%')
|
||||
<if test="sc.manageTagsList != null and sc.manageTagsList.size() > 0">
|
||||
<foreach collection="sc.manageTagsList" item="tag" separator="or" open="and (" close=")">
|
||||
s.manage_tags LIKE CONCAT('%', #{tag}, '%')
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="sc.sheepId != null">and tg.sheep_id = #{sc.sheepId}</if>
|
||||
<if test="sc.foldTo != null and sc.foldTo != ''">and tg.fold_to = #{sc.foldTo}</if>
|
||||
<if test="sc.foldFrom != null and sc.foldFrom != ''">and tg.fold_from = #{sc.foldFrom}</if>
|
||||
<if test="sc.status != null">and tg.status = #{sc.status}</if>
|
||||
<if test="sc.varietyId != null">and tg.variety_id = #{sc.varietyId}</if>
|
||||
<if test="sc.sheepTypeId != null">and st.id = #{sc.sheepTypeId}</if>
|
||||
<if test="sc.params != null and sc.params.beginTransDate != null and sc.params.beginTransDate != '' and sc.params.endTransDate != null and sc.params.endTransDate != ''">
|
||||
and tg.trans_date between #{sc.params.beginTransDate} and #{sc.params.endTransDate}
|
||||
</if>
|
||||
<if test="sc.eventType != null and sc.eventType != ''">
|
||||
and tg.event_type like concat('%', #{sc.eventType}, '%')
|
||||
</if>
|
||||
<if test="sc.technician != null and sc.technician != ''">
|
||||
and tg.technician like concat('%', #{sc.technician}, '%')
|
||||
</if>
|
||||
<if test="sc.isDelete != null">
|
||||
and s.is_delete = #{sc.isDelete}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY tg.create_time DESC
|
||||
</select>
|
||||
@@ -90,7 +96,6 @@
|
||||
<if test="varietyId != null">variety_id,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
<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>
|
||||
@@ -104,7 +109,6 @@
|
||||
<if test="varietyId != null">#{varietyId},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
<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>
|
||||
@@ -122,7 +126,6 @@
|
||||
<if test="varietyId != null">variety_id = #{varietyId},</if>
|
||||
<if test="reason != null">reason = #{reason},</if>
|
||||
<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>
|
||||
@@ -149,6 +152,5 @@
|
||||
WHERE s.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND s.is_delete = 0
|
||||
ORDER BY s.manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -25,8 +25,10 @@
|
||||
SELECT t.*,
|
||||
bv.variety AS varietyName,
|
||||
bs.manage_tags AS manageTags,
|
||||
sf.sheepfold_name AS sheepfoldName,
|
||||
t.event_type AS eventType,
|
||||
t.transition_date AS transitionDate,
|
||||
dr.ranch AS currentRanchName,
|
||||
CASE t.trans_type
|
||||
WHEN 0 THEN '内部调拨'
|
||||
WHEN 1 THEN '内部销售'
|
||||
@@ -42,6 +44,8 @@
|
||||
FROM sc_transition_info t
|
||||
LEFT JOIN bas_sheep bs ON t.sheep_id = bs.id
|
||||
LEFT JOIN bas_sheep_variety bv ON bs.variety_id = bv.id
|
||||
LEFT JOIN da_sheepfold sf ON t.sheepfold_id = sf.id
|
||||
LEFT JOIN da_ranch dr ON bs.ranch_id = dr.id
|
||||
</sql>
|
||||
|
||||
<select id="selectScTransitionInfoList" resultMap="ScTransitionInfoResult">
|
||||
@@ -61,6 +65,18 @@
|
||||
<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}
|
||||
</if>
|
||||
<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>
|
||||
</where>
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
@@ -155,7 +171,6 @@
|
||||
FROM bas_sheep bs
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
LIMIT 50
|
||||
ORDER BY bs.manage_tags LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -57,6 +57,9 @@
|
||||
<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}
|
||||
</if>
|
||||
<if test="sc.isDelete != null">
|
||||
and bs.is_delete = #{sc.isDelete}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sc.create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<sql id="selectScFixHoofVo">
|
||||
select fh.id,
|
||||
bs.manage_tags as manageTags,
|
||||
'修蹄' as event_type,
|
||||
'修蹄' as event_type,
|
||||
bs.sheepfold_id as sheepfold,
|
||||
sf.sheepfold_name as sheepfoldName,
|
||||
bs.variety_id as varietyId,
|
||||
@@ -47,13 +47,18 @@
|
||||
</if>
|
||||
<if test="sc.sheepfold != null">and bs.sheepfold_id = #{sc.sheepfold}</if>
|
||||
<if test="sc.varietyId != null">and bs.variety_id = #{sc.varietyId}</if>
|
||||
<if test="sc.technician != null and sc.technician != ''">and fh.technician like concat('%', #{sc.technician}, '%')</if>
|
||||
<if test="sc.technician != null and sc.technician != ''">and fh.technician like concat('%',
|
||||
#{sc.technician}, '%')
|
||||
</if>
|
||||
<if test="sc.params != null and sc.params.beginCreateTime != null and sc.params.beginCreateTime != '' and sc.params.endCreateTime != null and sc.params.endCreateTime != ''">
|
||||
and fh.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime}
|
||||
</if>
|
||||
<if test="sc.params != null and sc.params.beginEventDate != null and sc.params.beginEventDate != '' and sc.params.endEventDate != null and sc.params.endEventDate != ''">
|
||||
and fh.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate}
|
||||
</if>
|
||||
<if test="sc.isDelete != null">
|
||||
and bs.is_delete = #{sc.isDelete}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY fh.create_time DESC
|
||||
</select>
|
||||
@@ -118,6 +123,5 @@
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user