新增羊只,转群,修蹄,去势页面品种功能的完善

This commit is contained in:
zyh
2025-07-17 09:58:44 +08:00
parent b9e37fb14a
commit c206f8ad8f
11 changed files with 218 additions and 181 deletions

View File

@@ -4,78 +4,94 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.manage_sheep.add_sheep.mapper.ScAddSheepMapper">
<!-- 1. 结果映射:包含羊舍名称、品种名称 -->
<resultMap type="com.zhyc.module.produce.manage_sheep.add_sheep.domain.ScAddSheep" id="ScAddSheepResult">
<result property="id" column="id"/>
<result property="earNumber" column="ear_number"/>
<result property="sheepfold" column="sheepfold"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="sheepfoldNameExcel" column="sheepfoldName"/>
<result property="father" column="father"/>
<result property="mother" column="mother"/>
<result property="bornWeight" column="born_weight"/>
<result property="birthday" column="birthday"/>
<result property="gender" column="gender"/>
<result property="parity" column="parity"/>
<result property="varietyId" column="variety_id"/>
<result property="joinDate" column="join_date"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="id" column="id"/>
<result property="earNumber" column="ear_number"/>
<result property="sheepfold" column="sheepfold"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="father" column="father"/>
<result property="mother" column="mother"/>
<result property="bornWeight" column="born_weight"/>
<result property="birthday" column="birthday"/>
<result property="gender" column="gender"/>
<result property="parity" column="parity"/>
<result property="varietyId" column="variety_id"/>
<result property="varietyName" column="varietyName"/>
<result property="joinDate" column="join_date"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_add_sheep
(ear_number, sheepfold, father, mother, born_weight, birthday, gender, parity,
variety_id, join_date, comment, technician, create_by, create_time)
VALUES (#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight}, #{birthday},
#{gender}, #{parity}, #{varietyId}, #{joinDate}, #{comment}, #{technician},
#{createBy}, #{createTime})
</insert>
<!-- 2. 查询列表:支持按品种筛选 -->
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
SELECT
sas.*,
sf.sheepfold_name AS sheepfoldName
sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName
FROM sc_add_sheep sas
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
<where>
<if test="earNumber != null and earNumber != ''">
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
</if>
<if test="sheepfold != null">
AND sas.sheepfold = #{sheepfold}
</if>
<if test="varietyId != null">
AND sas.variety_id = #{varietyId}
</if>
</where>
</select>
<!-- 3. 根据耳号精确查询 -->
<select id="selectByEarNumber" parameterType="string" resultMap="ScAddSheepResult">
SELECT * FROM sc_add_sheep WHERE ear_number = #{earNumber}
</select>
<!-- 4. 插入 -->
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_add_sheep
(ear_number, sheepfold, father, mother, born_weight, birthday,
gender, parity, variety_id, join_date, comment, technician,
create_by, create_time)
VALUES
(#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight},
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{joinDate},
#{comment}, #{technician}, #{createBy}, #{createTime})
</insert>
<!-- 5. 更新 -->
<update id="updateScAddSheep" parameterType="ScAddSheep">
UPDATE sc_add_sheep
<set>
ear_number = #{earNumber},
sheepfold = #{sheepfold},
father = #{father},
mother = #{mother},
born_weight = #{bornWeight},
birthday = #{birthday},
gender = #{gender},
parity = #{parity},
variety_id = #{varietyId},
join_date = #{joinDate},
comment = #{comment},
technician = #{technician},
update_by = #{updateBy},
update_time = NOW()
ear_number = #{earNumber},
sheepfold = #{sheepfold},
father = #{father},
mother = #{mother},
born_weight = #{bornWeight},
birthday = #{birthday},
gender = #{gender},
parity = #{parity},
variety_id = #{varietyId},
join_date = #{joinDate},
comment = #{comment},
technician = #{technician},
update_by = #{updateBy},
update_time = NOW()
</set>
WHERE id = #{id}
</update>
<!-- 6. 批量删除 -->
<delete id="deleteScAddSheepByIds">
DELETE FROM sc_add_sheep WHERE id IN
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectByEarNumber" parameterType="string" resultMap="ScAddSheepResult">
SELECT * FROM sc_add_sheep WHERE ear_number = #{earNumber}
</select>
</mapper>

View File

@@ -10,6 +10,8 @@
<result property="foldTo" column="fold_to"/>
<result property="foldFrom" column="fold_from"/>
<result property="reason" column="reason"/>
<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"/>
@@ -23,6 +25,8 @@
tg.fold_to,
tg.fold_from,
tg.reason,
tg.variety_id,
bv.variety AS varietyName,
tg.technician,
tg.status,
tg.comment,
@@ -33,15 +37,17 @@
FROM sc_trans_group tg
LEFT JOIN da_sheepfold sf_from ON tg.fold_from = sf_from.id
LEFT JOIN da_sheepfold sf_to ON tg.fold_to = sf_to.id
LEFT JOIN bas_sheep_variety bv ON tg.variety_id = bv.id
</sql>
<select id="selectScTransGroupList" parameterType="ScTransGroup" resultMap="ScTransGroupResult">
<include refid="selectScTransGroupVo"/>
<where>
<if test="sheepId != null ">and sheep_id = #{sheepId}</if>
<if test="foldTo != null and foldTo != ''">and fold_to = #{foldTo}</if>
<if test="foldFrom != null and foldFrom != ''">and fold_from = #{foldFrom}</if>
<if test="status != null ">and status = #{status}</if>
<if test="sheepId != null">and sheep_id = #{sheepId}</if>
<if test="foldTo != null and foldTo != ''">and fold_to = #{foldTo}</if>
<if test="foldFrom != null and foldFrom != ''">and fold_from = #{foldFrom}</if>
<if test="status != null">and status = #{status}</if>
<if test="varietyId != null">and tg.variety_id = #{varietyId}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
@@ -54,13 +60,15 @@
where tg.id = #{id}
</select>
<insert id="insertScTransGroup" parameterType="ScTransGroup" useGeneratedKeys="true" keyProperty="id">
<insert id="insertScTransGroup" parameterType="ScTransGroup"
useGeneratedKeys="true" keyProperty="id">
insert into sc_trans_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="foldTo != null and foldTo != ''">fold_to,</if>
<if test="foldFrom != null and foldFrom != ''">fold_from,</if>
<if test="reason != null and reason != ''">reason,</if>
<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>
@@ -71,7 +79,8 @@
<if test="sheepId != null">#{sheepId},</if>
<if test="foldTo != null and foldTo != ''">#{foldTo},</if>
<if test="foldFrom != null and foldFrom != ''">#{foldFrom},</if>
<if test="reason != null and reason != ''">#{reason},</if>
<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>
@@ -86,14 +95,15 @@
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="foldTo != null and foldTo != ''">fold_to = #{foldTo},</if>
<if test="foldFrom != null and foldFrom != ''">fold_from = #{foldFrom},</if>
<if test="reason != null and reason != ''">reason = #{reason},</if>
<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>
</trim>
where sc_trans_group.id = #{id}
where id = #{id}
</update>
<delete id="deleteScTransGroupById" parameterType="Integer">