断奶录入问题,断奶查询问题,干奶录入问题,干奶查询问题,死亡录入问题,死亡查询问题

This commit is contained in:
ll
2026-02-01 21:47:56 +08:00
parent 13e0f68289
commit 464126195d
18 changed files with 628 additions and 962 deletions

View File

@@ -14,7 +14,6 @@
<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" />
@@ -33,17 +32,36 @@
<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="manageTagsList != null and manageTagsList.size() > 0">
AND s.bs_manage_tags IN
<foreach collection="manageTagsList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="(manageTagsList == null or manageTagsList.size() == 0) and manageTags != null and manageTags != ''">
AND s.bs_manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''">
AND d.datetime &gt;= #{params.beginTime}
</if>
<if test="params.endTime != null and params.endTime != ''">
AND d.datetime &lt;= #{params.endTime}
</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
order by d.datetime desc
</select>
<select id="selectSheepEarNumberList" resultType="String">
SELECT bs_manage_tags
FROM sheep_file
WHERE bs_manage_tags LIKE concat('%', #{query}, '%')
LIMIT 20
</select>
<select id="selectScDryMilkById" parameterType="Long" resultMap="ScDryMilkResult">
@@ -51,9 +69,8 @@
where d.id = #{id}
</select>
<!-- 根据耳号查询羊只ID -->
<select id="selectSheepIdByManageTags" parameterType="String" resultType="Long">
select id from sheep_file where bs_manage_tags = #{manageTags}
select id from sheep_file where bs_manage_tags = #{manageTags} limit 1
</select>
<insert id="insertScDryMilk" parameterType="ScDryMilk" useGeneratedKeys="true" keyProperty="id">

View File

@@ -22,37 +22,121 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="isDelete" column="is_delete" />
<result property="variety" column="variety" />
<result property="sheepType" column="sheep_type_name" />
<result property="gender" column="gender" />
<result property="dayAge" column="day_age" />
<result property="parity" column="parity" />
<result property="sheepfoldName" column="sheepfold_name" />
<result property="breedStatus" column="breed_status" />
<result property="postLambingDay" column="post_lambing_day" />
<result property="lactationDay" column="lactation_day" />
<result property="gestationDay" column="gestation_day" />
</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 d.id, d.sheep_id, d.manage_tags, d.event_type, d.death_date, d.disease_type_id, d.disease_subtype_id,
d.disposal_direction, d.technician, d.handler, d.work_group, d.create_by, d.create_time, d.comment,
d.update_by, d.update_time, d.is_delete,
s.variety, s.name as sheep_type_name, s.gender, s.day_age, s.parity, s.sheepfold_name,
s.breed as breed_status, s.post_lambing_day, s.lactation_day, s.gestation_day
from sc_sheep_death d
left join sheep_file s on d.manage_tags = s.bs_manage_tags
</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>
<if test="sheepId != null "> and d.sheep_id = #{sheepId}</if>
<if test="manageTagsList != null and manageTagsList.size() > 0">
AND d.manage_tags IN
<foreach collection="manageTagsList" item="tag" open="(" separator="," close=")">
#{tag}
</foreach>
</if>
<if test="(manageTagsList == null or manageTagsList.size() == 0) and manageTags != null and manageTags != ''">
and d.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="params.beginDeathDate != null and params.beginDeathDate != '' and params.endDeathDate != null and params.endDeathDate != ''">
and d.death_date between #{params.beginDeathDate} and #{params.endDeathDate}
</if>
<if test="eventType != null and eventType != ''"> and d.event_type = #{eventType}</if>
<if test="diseaseTypeId != null "> and d.disease_type_id = #{diseaseTypeId}</if>
<if test="diseaseSubtypeId != null "> and d.disease_subtype_id = #{diseaseSubtypeId}</if>
<if test="disposalDirection != null and disposalDirection != ''"> and d.disposal_direction = #{disposalDirection}</if>
<if test="technicianList != null and technicianList.size() > 0">
AND d.technician IN
<foreach collection="technicianList" item="tech" open="(" separator="," close=")">
#{tech}
</foreach>
</if>
<if test="(technicianList == null or technicianList.size() == 0) and technician != null and technician != ''">
and d.technician like concat('%', #{technician}, '%')
</if>
<if test="handlerList != null and handlerList.size() > 0">
AND d.handler IN
<foreach collection="handlerList" item="hand" open="(" separator="," close=")">
#{hand}
</foreach>
</if>
<if test="(handlerList == null or handlerList.size() == 0) and handler != null and handler != ''">
and d.handler like concat('%', #{handler}, '%')
</if>
<if test="workGroupList != null and workGroupList.size() > 0">
AND d.work_group IN
<foreach collection="workGroupList" item="grp" open="(" separator="," close=")">
#{grp}
</foreach>
</if>
<if test="(workGroupList == null or workGroupList.size() == 0) and workGroup != null and workGroup != ''">
and d.work_group = #{workGroup}
</if>
<if test="variety != null and variety != ''"> and s.variety like concat('%', #{variety}, '%')</if>
<if test="sheepTypeList != null and sheepTypeList.size() > 0">
AND s.name IN
<foreach collection="sheepTypeList" item="sType" open="(" separator="," close=")">
#{sType}
</foreach>
</if>
<if test="(sheepTypeList == null or sheepTypeList.size() == 0) and sheepType != null and sheepType != ''">
and s.name like concat('%', #{sheepType}, '%')
</if>
</where>
order by create_time desc
order by d.create_time desc
</select>
<select id="selectDistinctManageTags" resultType="String">
SELECT DISTINCT manage_tags FROM sc_sheep_death
WHERE manage_tags LIKE concat('%', #{query}, '%')
LIMIT 20
</select>
<select id="selectDistinctTechnician" resultType="String">
SELECT DISTINCT technician FROM sc_sheep_death
WHERE technician LIKE concat('%', #{query}, '%') AND technician IS NOT NULL AND technician != ''
LIMIT 20
</select>
<select id="selectDistinctHandler" resultType="String">
SELECT DISTINCT handler FROM sc_sheep_death
WHERE handler LIKE concat('%', #{query}, '%') AND handler IS NOT NULL AND handler != ''
LIMIT 20
</select>
<select id="selectScSheepDeathById" parameterType="Long" resultMap="ScSheepDeathResult">
<include refid="selectScSheepDeathVo"/>
where id = #{id}
where d.id = #{id}
</select>
<!-- 根据管理耳号查询sheep_file视图信息 -->
<select id="selectSheepFileByManageTags" parameterType="String" resultType="java.util.Map">
select
id as sheepId,
@@ -145,7 +229,6 @@
</foreach>
</delete>
<!-- 更新羊只繁育状态 - 更新基础表 bas_sheep使用正确的字段名 -->
<update id="updateSheepFileStatus">
UPDATE bas_sheep
SET breed_status_id = #{status},
@@ -154,7 +237,6 @@
AND is_delete = 0
</update>
<!-- 更新羊只在群状态 - 更新基础表 bas_sheep使用正确的字段名 -->
<update id="updateSheepStatus">
UPDATE bas_sheep
SET status_id = #{status},

View File

@@ -15,7 +15,7 @@
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="electronicTags" column="electronic_tags" />
<!-- 关联查询的字段 -->
<result property="earNumber" column="bs_manage_tags" />
<result property="breed" column="variety" />
<result property="eventType" column="event_type" />
@@ -28,7 +28,6 @@
<result property="breedingStatus" column="breed" />
</resultMap>
<!-- 带关联查询的基础SQL -->
<sql id="selectScWeanRecordVo">
select
wr.id, wr.sheep_id, wr.datetime, wr.weight, wr.status, wr.technician,
@@ -40,13 +39,36 @@
left join sheep_file sf on wr.sheep_id = sf.id
</sql>
<!-- 查询断奶记录列表 -->
<select id="selectScWeanRecordList" parameterType="ScWeanRecord" resultMap="ScWeanRecordResult">
<include refid="selectScWeanRecordVo"/>
<where>
<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>
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND sf.bs_manage_tags IN
<foreach collection="allEarNumbers" item="ear" open="(" separator="," close=")">
#{ear}
</foreach>
</if>
<if test="(allEarNumbers == null or allEarNumbers.size() == 0) and earNumber != null and earNumber != ''">
and sf.bs_manage_tags like concat('%', #{earNumber}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''">
AND date_format(wr.datetime,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''">
AND date_format(wr.datetime,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="isInHerd != null and isInHerd != ''">
AND sf.status = #{isInHerd}
</if>
<if test="sheepCategory != null and sheepCategory != ''">
AND sf.breed = #{sheepCategory}
</if>
<if test="weight != null "> and wr.weight = #{weight}</if>
<if test="status != null "> and wr.status = #{status}</if>
<if test="technician != null and technician != ''"> and wr.technician like concat('%', #{technician}, '%')</if>
@@ -59,23 +81,27 @@
<if test="fatherNumber != null and fatherNumber != ''"> and sf.father_manage_tags like concat('%', #{fatherNumber}, '%')</if>
<if test="motherNumber != null and motherNumber != ''"> and sf.mother_manage_tags like concat('%', #{motherNumber}, '%')</if>
<if test="sheepPen != null and sheepPen != ''"> and sf.sheepfold_name like concat('%', #{sheepPen}, '%')</if>
<if test="breedingStatus != null and breedingStatus != ''"> and sf.breed = #{breedingStatus}</if>
</where>
order by wr.create_time desc
</select>
<!-- 根据ID查询断奶记录 -->
<select id="searchEarNumbers" resultType="String">
SELECT DISTINCT bs_manage_tags
FROM sheep_file
WHERE bs_manage_tags LIKE CONCAT('%', #{query}, '%')
AND is_delete = 0
LIMIT 20
</select>
<select id="selectScWeanRecordById" parameterType="Long" resultMap="ScWeanRecordResult">
<include refid="selectScWeanRecordVo"/>
where wr.id = #{id}
</select>
<!-- 根据耳号查询羊只ID -->
<select id="selectSheepIdByEarNumber" parameterType="String" resultType="Long">
select id from sheep_file where bs_manage_tags = #{earNumber}
</select>
<!-- 插入断奶记录 -->
<insert id="insertScWeanRecord" parameterType="ScWeanRecord" useGeneratedKeys="true" keyProperty="id">
insert into sc_wean_record
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -102,7 +128,6 @@
</trim>
</insert>
<!-- 更新断奶记录 -->
<update id="updateScWeanRecord" parameterType="ScWeanRecord">
update sc_wean_record
<trim prefix="SET" suffixOverrides=",">
@@ -119,23 +144,10 @@
where id = #{id}
</update>
<!-- 根据耳号更新bas_sheep表中的断奶信息 -->
<update id="updateBasSheepWeaningInfo" parameterType="ScWeanRecord">
update bas_sheep
<trim prefix="SET" suffixOverrides=",">
<if test="datetime != null">weaning_date = #{datetime},</if>
<if test="weight != null">weaning_weight = #{weight},</if>
<if test="electronicTags != null and electronicTags != ''">electronic_tags = #{electronicTags},</if>
</trim>
where manage_tags = #{earNumber}
</update>
<!-- 删除断奶记录 -->
<delete id="deleteScWeanRecordById" parameterType="Long">
delete from sc_wean_record where id = #{id}
</delete>
<!-- 批量删除断奶记录 -->
<delete id="deleteScWeanRecordByIds" parameterType="String">
delete from sc_wean_record where id in
<foreach item="id" collection="array" open="(" separator="," close=")">