Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -126,5 +126,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectByParentIdAndGroupName" resultMap="BasSheepGroupResult">
|
||||
SELECT * FROM bas_sheep_group
|
||||
WHERE parent_id = #{parentId} AND group_name = #{groupName}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -54,7 +54,7 @@
|
||||
END as mating_type_name,
|
||||
sf.mating_date,
|
||||
sf.parity,
|
||||
sf.variety as ram_variety, -- 这里需要根据实际配种公羊信息调整
|
||||
sf.variety as ram_variety,
|
||||
sf.month_age,
|
||||
CASE
|
||||
WHEN sf.mating_date IS NOT NULL AND smr.datetime IS NOT NULL
|
||||
@@ -145,9 +145,15 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 根据耳号查询羊只信息 -->
|
||||
<select id="selectSheepByManageTags" parameterType="String" resultType="map">
|
||||
select bs_manage_tags, variety, parity, month_age, sheepfold_name, dr_ranch
|
||||
select
|
||||
bs_manage_tags,
|
||||
variety,
|
||||
parity,
|
||||
month_age,
|
||||
sheepfold_name,
|
||||
dr_ranch,
|
||||
gender
|
||||
from sheep_file
|
||||
where bs_manage_tags = #{manageTags}
|
||||
</select>
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.produce.breed.mapper.RawSpermRecordMapper">
|
||||
|
||||
<resultMap type="RawSpermRecord" id="RawSpermRecordResult">
|
||||
<resultMap type="com.zhyc.module.produce.breed.domain.RawSpermRecord" id="RawSpermRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="manageTags" column="bs_manage_tags" />
|
||||
<result property="manageTags" column="manage_tags" />
|
||||
<result property="electronicTags" column="electronic_tags" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
<result property="pickDate" column="pick_date" />
|
||||
@@ -19,95 +19,95 @@
|
||||
<result property="info" column="info" />
|
||||
<result property="technician" column="technician" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="scrotumCircumference" column="scrotum_circumference" />
|
||||
<result property="semenQuality" column="semen_quality" />
|
||||
<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
|
||||
select id, sheep_id, manage_tags, electronic_tags, month_age, pick_date, amount,
|
||||
density, vitallity, controlled, sexual_status, info, technician, comment,
|
||||
scrotum_circumference, semen_quality, create_by, create_time
|
||||
from raw_sperm_record
|
||||
</sql>
|
||||
|
||||
<select id="selectRawSpermRecordList" parameterType="RawSpermRecord" resultMap="RawSpermRecordResult">
|
||||
<select id="selectRawSpermRecordList" parameterType="com.zhyc.module.produce.breed.domain.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>
|
||||
<if test="sheepId != null "> and sheep_id = #{sheepId}</if>
|
||||
<if test="manageTags != null and manageTags != ''"> and manage_tags like concat('%', #{manageTags}, '%')</if>
|
||||
<if test="electronicTags != null and electronicTags != ''"> and electronic_tags like concat('%', #{electronicTags}, '%')</if>
|
||||
<if test="monthAge != null "> and month_age = #{monthAge}</if>
|
||||
<if test="pickDate != null "> and DATE(pick_date) = DATE(#{pickDate})</if>
|
||||
<if test="amount != null "> and amount = #{amount}</if>
|
||||
<if test="density != null and density != ''"> and density like concat('%', #{density}, '%')</if>
|
||||
<if test="vitallity != null and vitallity != ''"> and vitallity like concat('%', #{vitallity}, '%')</if>
|
||||
<if test="controlled != null "> and controlled = #{controlled}</if>
|
||||
<if test="sexualStatus != null and sexualStatus != ''"> and sexual_status like concat('%', #{sexualStatus}, '%')</if>
|
||||
<if test="info != null and info != ''"> and info like concat('%', #{info}, '%')</if>
|
||||
<if test="technician != null and technician != ''"> and technician like concat('%', #{technician}, '%')</if>
|
||||
<if test="comment != null and comment != ''"> and comment like concat('%', #{comment}, '%')</if>
|
||||
<if test="scrotumCircumference != null "> and scrotum_circumference = #{scrotumCircumference}</if>
|
||||
<if test="semenQuality != null and semenQuality != ''"> and semen_quality = #{semenQuality}</if>
|
||||
</where>
|
||||
order by rsr.pick_date desc
|
||||
order by pick_date desc, id desc
|
||||
</select>
|
||||
|
||||
<select id="selectRawSpermRecordById" parameterType="Long" resultMap="RawSpermRecordResult">
|
||||
<include refid="selectRawSpermRecordVo"/>
|
||||
where rsr.id = #{id}
|
||||
where 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 id="insertRawSpermRecord" parameterType="com.zhyc.module.produce.breed.domain.RawSpermRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into raw_sperm_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="manageTags != null and manageTags != ''">manage_tags,</if>
|
||||
<if test="electronicTags != null and electronicTags != ''">electronic_tags,</if>
|
||||
<if test="monthAge != null">month_age,</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="density != null and density != ''">density,</if>
|
||||
<if test="vitallity != null and vitallity != ''">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="sexualStatus != null and sexualStatus != ''">sexual_status,</if>
|
||||
<if test="info != null and info != ''">info,</if>
|
||||
<if test="technician != null and technician != ''">technician,</if>
|
||||
<if test="comment != null and comment != ''">comment,</if>
|
||||
<if test="scrotumCircumference != null">scrotum_circumference,</if>
|
||||
<if test="semenQuality != null and semenQuality != ''">semen_quality,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="manageTags != null and manageTags != ''">#{manageTags},</if>
|
||||
<if test="electronicTags != null and electronicTags != ''">#{electronicTags},</if>
|
||||
<if test="monthAge != null">#{monthAge},</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="density != null and density != ''">#{density},</if>
|
||||
<if test="vitallity != null and vitallity != ''">#{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="sexualStatus != null and sexualStatus != ''">#{sexualStatus},</if>
|
||||
<if test="info != null and info != ''">#{info},</if>
|
||||
<if test="technician != null and technician != ''">#{technician},</if>
|
||||
<if test="comment != null and comment != ''">#{comment},</if>
|
||||
<if test="scrotumCircumference != null">#{scrotumCircumference},</if>
|
||||
<if test="semenQuality != null and semenQuality != ''">#{semenQuality},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateRawSpermRecord" parameterType="RawSpermRecord">
|
||||
<update id="updateRawSpermRecord" parameterType="com.zhyc.module.produce.breed.domain.RawSpermRecord">
|
||||
update raw_sperm_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
||||
<if test="manageTags != null">manage_tags = #{manageTags},</if>
|
||||
<if test="electronicTags != null">electronic_tags = #{electronicTags},</if>
|
||||
<if test="monthAge != null">month_age = #{monthAge},</if>
|
||||
<if test="pickDate != null">pick_date = #{pickDate},</if>
|
||||
<if test="amount != null">amount = #{amount},</if>
|
||||
<if test="density != null">density = #{density},</if>
|
||||
@@ -117,8 +117,8 @@
|
||||
<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>
|
||||
<if test="scrotumCircumference != null">scrotum_circumference = #{scrotumCircumference},</if>
|
||||
<if test="semenQuality != null">semen_quality = #{semenQuality},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -133,4 +133,19 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 根据耳号查询羊只ID -->
|
||||
<select id="selectSheepIdByManageTags" parameterType="String" resultType="Integer">
|
||||
select id from sheep_file where bs_manage_tags = #{manageTags} and is_delete = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据耳号查询羊只完整信息(包含ID和性别) -->
|
||||
<select id="selectSheepInfoByManageTags" parameterType="String" resultType="java.util.Map">
|
||||
select id, gender, bs_manage_tags as manageTags, electronic_tags as electronicTags,
|
||||
name, variety, month_age as monthAge
|
||||
from sheep_file
|
||||
where bs_manage_tags = #{manageTags} and is_delete = 0
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -67,7 +67,7 @@
|
||||
ELSE NULL
|
||||
END as days_after_mating
|
||||
from sc_pregnancy_record pr
|
||||
left join sheep_file sf on pr.sheep_id = sf.id
|
||||
INNER JOIN sheep_file sf on pr.sheep_id = sf.id
|
||||
-- 关联配种记录表,获取最新的配种记录
|
||||
left join (
|
||||
select br1.*
|
||||
@@ -85,27 +85,39 @@
|
||||
and mating_type.dict_type = 'breed_type' and mating_type.status = '0'
|
||||
</sql>
|
||||
|
||||
<!-- 重写的查询列表方法 -->
|
||||
<select id="selectScPregnancyRecordList" parameterType="ScPregnancyRecord" resultMap="ScPregnancyRecordResult">
|
||||
<include refid="selectScPregnancyRecordVo"/>
|
||||
<where>
|
||||
pr.is_delete = 0
|
||||
|
||||
<!-- 耳号搜索 - 支持多种匹配方式 -->
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
<choose>
|
||||
<when test="manageTags.contains(',')">
|
||||
and sf.bs_manage_tags in
|
||||
<foreach item="tag" collection="manageTags.split(',')" open="(" separator="," close=")">
|
||||
#{tag}
|
||||
</foreach>
|
||||
</when>
|
||||
<otherwise>
|
||||
and sf.bs_manage_tags like concat('%', #{manageTags}, '%')
|
||||
</otherwise>
|
||||
</choose>
|
||||
<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, '%')
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="datetime != null">
|
||||
AND DATE(pr.datetime) = DATE(#{datetime})
|
||||
</if>
|
||||
<if test="result != null and result != ''">
|
||||
AND pr.result = #{result}
|
||||
</if>
|
||||
<if test="technician != null and technician != ''">
|
||||
AND pr.technician like concat('%', #{technician}, '%')
|
||||
</if>
|
||||
<if test="way != null and way != ''">
|
||||
AND pr.way = #{way}
|
||||
</if>
|
||||
<if test="datetime != null "> and DATE(pr.datetime) = DATE(#{datetime})</if>
|
||||
<if test="result != null and result != ''"> and pr.result = #{result}</if>
|
||||
<if test="technician != null and technician != ''"> and pr.technician like concat('%', #{technician}, '%')</if>
|
||||
<if test="way != null and way != ''"> and pr.way = #{way}</if>
|
||||
</where>
|
||||
order by pr.create_time desc
|
||||
</select>
|
||||
|
||||
@@ -145,19 +145,19 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 更新羊只繁育状态 - 保留原有功能 -->
|
||||
<!-- 更新羊只繁育状态 - 更新基础表 bas_sheep,使用正确的字段名 -->
|
||||
<update id="updateSheepFileStatus">
|
||||
UPDATE sheep_file
|
||||
SET breed = #{status},
|
||||
UPDATE bas_sheep
|
||||
SET breed_status_id = #{status},
|
||||
update_time = NOW()
|
||||
WHERE id = #{sheepId}
|
||||
AND is_delete = 0
|
||||
</update>
|
||||
|
||||
<!-- 新增:更新羊只在群状态 -->
|
||||
<!-- 更新羊只在群状态 - 更新基础表 bas_sheep,使用正确的字段名 -->
|
||||
<update id="updateSheepStatus">
|
||||
UPDATE sheep_file
|
||||
SET status = #{status},
|
||||
UPDATE bas_sheep
|
||||
SET status_id = #{status},
|
||||
update_time = NOW()
|
||||
WHERE id = #{sheepId}
|
||||
AND is_delete = 0
|
||||
|
||||
Reference in New Issue
Block a user