繁育多个页面的多耳号输入

This commit is contained in:
zyk
2026-01-27 15:19:38 +08:00
parent 2722fb985e
commit ced5b0b09a
37 changed files with 474 additions and 57 deletions

View File

@@ -33,24 +33,41 @@
<select id="selectScDryMilkList" parameterType="ScDryMilk" resultMap="ScDryMilkResult">
<include refid="selectScDryMilkVo"/>
<where>
<if test="sheepId != null and sheepId != ''"> and d.sheep_id = #{sheepId}</if>
<if test="manageTags != null and manageTags != ''"> and s.bs_manage_tags like concat('%', #{manageTags}, '%')</if>
<if test="datetime != null "> and d.datetime = #{datetime}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="sheepfold != null "> and d.sheepfold = #{sheepfold}</if>
<if test="tecahnician != null and tecahnician != ''"> and d.tecahnician like concat('%', #{tecahnician}, '%')</if>
<if test="createBy != null and createBy != ''"> and d.create_by = #{createBy}</if>
<if test="createTime != null "> and d.create_time = #{createTime}</if>
<if test="variety != null and variety != ''"> and s.variety like concat('%', #{variety}, '%')</if>
<!-- 多耳号精确匹配查询 -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND s.bs_manage_tags IN
<foreach item="earNumber" collection="allEarNumbers" open="(" separator="," close=")">
#{earNumber}
</foreach>
</if>
<!-- 保留原单耳号模糊查询(仅当allEarNumbers为空时生效) -->
<if test="(allEarNumbers == null or allEarNumbers.size() == 0) and manageTags != null and manageTags != ''">
AND s.bs_manage_tags LIKE CONCAT('%', #{manageTags}, '%')
</if>
<if test="sheepId != null">AND d.sheep_id = #{sheepId}</if>
<if test="datetime != null">AND d.datetime = #{datetime}</if>
<if test="status != null">AND d.status = #{status}</if>
<if test="sheepfold != null">AND d.sheepfold = #{sheepfold}</if>
<if test="tecahnician != null and tecahnician != ''">
AND d.tecahnician LIKE CONCAT('%', #{tecahnician}, '%')
</if>
<if test="createBy != null and createBy != ''">AND d.create_by = #{createBy}</if>
<if test="createTime != null">AND d.create_time = #{createTime}</if>
<if test="variety != null and variety != ''">
AND s.variety LIKE CONCAT('%', #{variety}, '%')
</if>
</where>
order by d.create_time desc
</select>
<select id="selectScDryMilkById" parameterType="Long" resultMap="ScDryMilkResult">
<include refid="selectScDryMilkVo"/>
where d.id = #{id}
</select>
<!-- 根据耳号查询羊只ID -->
<select id="selectSheepIdByManageTags" parameterType="String" resultType="Long">
select id from sheep_file where bs_manage_tags = #{manageTags}
@@ -105,4 +122,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>

View File

@@ -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>

View File

@@ -91,18 +91,12 @@
<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_tagssf是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>
@@ -242,4 +236,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>

View File

@@ -25,12 +25,23 @@
</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
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 d
left join sheep_file s on d.sheep_id = s.id
</sql>
<select id="selectScSheepDeathList" parameterType="ScSheepDeath" resultMap="ScSheepDeathResult">
<include refid="selectScSheepDeathVo"/>
<where>
<!-- 全部羊多耳号查询 -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
<!-- 注意s 代表 sheep_file 表的别名,根据实际 SQL 别名修改 -->
s.bs_manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<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>
@@ -163,4 +174,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>

View File

@@ -44,6 +44,15 @@
<select id="selectScWeanRecordList" parameterType="ScWeanRecord" resultMap="ScWeanRecordResult">
<include refid="selectScWeanRecordVo"/>
<where>
<!-- 全部羊多耳号查询 -->
<!-- 正确sf.bs_manage_tagssf是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="earNumber != null and earNumber != ''"> and sf.bs_manage_tags like concat('%', #{earNumber}, '%')</if>
<if test="datetime != null "> and wr.datetime = #{datetime}</if>
@@ -142,4 +151,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>