Merge remote-tracking branch 'main/main'
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.produce.wean.mapper.ScWeanRecordMapper">
|
||||
|
||||
<resultMap type="ScWeanRecord" id="ScWeanRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="datetime" column="datetime" />
|
||||
<result property="weight" column="weight" />
|
||||
<result property="status" column="status" />
|
||||
<result property="technician" column="technician" />
|
||||
<result property="comment" column="comment" />
|
||||
<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" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="fatherNumber" column="father_manage_tags" />
|
||||
<result property="motherNumber" column="mother_manage_tags" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
<result property="birthWeight" column="birth_weight" />
|
||||
<result property="sheepPen" column="sheepfold_name" />
|
||||
<result property="breedingStatus" column="breed" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 带关联查询的基础SQL -->
|
||||
<sql id="selectScWeanRecordVo">
|
||||
select
|
||||
wr.id, wr.sheep_id, wr.datetime, wr.weight, wr.status, wr.technician,
|
||||
wr.comment, wr.create_by, wr.create_time, wr.electronic_tags,
|
||||
sf.bs_manage_tags, sf.variety, sf.gender, sf.father_manage_tags, sf.mother_manage_tags,
|
||||
sf.birth_weight, sf.sheepfold_name, sf.breed, sf.month_age,
|
||||
'断奶' as event_type
|
||||
from sc_wean_record wr
|
||||
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="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>
|
||||
<if test="comment != null and comment != ''"> and wr.comment like concat('%', #{comment}, '%')</if>
|
||||
<if test="createBy != null and createBy != ''"> and wr.create_by like concat('%', #{createBy}, '%')</if>
|
||||
<if test="createTime != null "> and wr.create_time = #{createTime}</if>
|
||||
<if test="electronicTags != null and electronicTags != ''"> and wr.electronic_tags like concat('%', #{electronicTags}, '%')</if>
|
||||
<if test="breed != null and breed != ''"> and sf.variety like concat('%', #{breed}, '%')</if>
|
||||
<if test="gender != null and gender != ''"> and sf.gender = #{gender}</if>
|
||||
<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="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=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="datetime != null">datetime,</if>
|
||||
<if test="weight != null">weight,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="technician != null">technician,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="electronicTags != null">electronic_tags,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="datetime != null">#{datetime},</if>
|
||||
<if test="weight != null">#{weight},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="technician != null">#{technician},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="electronicTags != null">#{electronicTags},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新断奶记录 -->
|
||||
<update id="updateScWeanRecord" parameterType="ScWeanRecord">
|
||||
update sc_wean_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
||||
<if test="datetime != null">datetime = #{datetime},</if>
|
||||
<if test="weight != null">weight = #{weight},</if>
|
||||
<if test="status != null">status = #{status},</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="electronicTags != null">electronic_tags = #{electronicTags},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</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=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,256 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScLambDetailMapper">
|
||||
|
||||
<!-- 羔羊详情结果映射 -->
|
||||
<resultMap type="ScLambDetail" id="ScLambDetailResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="lambingRecordId" column="lambing_record_id" />
|
||||
<result property="lambEarNumber" column="lamb_ear_number" />
|
||||
<result property="lambBreed" column="lamb_breed" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="birthWeight" column="birth_weight" />
|
||||
<result property="isRetained" column="is_retained" />
|
||||
<result property="lineage" column="lineage" />
|
||||
<result property="birthday" column="birthday" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础查询SQL -->
|
||||
<sql id="selectScLambDetailVo">
|
||||
select id, lambing_record_id, lamb_ear_number, lamb_breed, gender, birth_weight,
|
||||
is_retained, lineage, birthday, create_by, create_time, update_by, update_time
|
||||
from sc_lamb_detail
|
||||
</sql>
|
||||
|
||||
<!-- 查询羔羊详情列表 -->
|
||||
<select id="selectScLambDetailList" parameterType="ScLambDetail" resultMap="ScLambDetailResult">
|
||||
<include refid="selectScLambDetailVo"/>
|
||||
<where>
|
||||
<if test="lambingRecordId != null"> and lambing_record_id = #{lambingRecordId}</if>
|
||||
<if test="lambEarNumber != null and lambEarNumber != ''"> and lamb_ear_number like concat('%', #{lambEarNumber}, '%')</if>
|
||||
<if test="lambBreed != null"> and lamb_breed = #{lambBreed}</if>
|
||||
<if test="gender != null"> and gender = #{gender}</if>
|
||||
<if test="isRetained != null"> and is_retained = #{isRetained}</if>
|
||||
<if test="lineage != null and lineage != ''"> and lineage like concat('%', #{lineage}, '%')</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 查询羔羊详情 -->
|
||||
<select id="selectScLambDetailById" parameterType="Long" resultMap="ScLambDetailResult">
|
||||
<include refid="selectScLambDetailVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据产羔记录ID查询羔羊详情列表 -->
|
||||
<select id="selectScLambDetailByLambingRecordId" parameterType="Long" resultMap="ScLambDetailResult">
|
||||
<include refid="selectScLambDetailVo"/>
|
||||
where lambing_record_id = #{lambingRecordId}
|
||||
order by create_time asc
|
||||
</select>
|
||||
|
||||
<!-- 检查羔羊耳号是否已存在 -->
|
||||
<select id="checkLambEarNumberExists" resultType="int">
|
||||
select count(*) from sc_lamb_detail
|
||||
where lamb_ear_number = #{lambEarNumber}
|
||||
<if test="excludeId != null">
|
||||
and id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 新增羔羊详情(同步录入到bas_sheep表) -->
|
||||
<insert id="insertScLambDetail" parameterType="ScLambDetail" useGeneratedKeys="true" keyProperty="id">
|
||||
<!-- 插入到sc_lamb_detail表 -->
|
||||
insert into sc_lamb_detail
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="lambingRecordId != null">lambing_record_id,</if>
|
||||
<if test="lambEarNumber != null and lambEarNumber != ''">lamb_ear_number,</if>
|
||||
<if test="lambBreed != null">lamb_breed,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="birthWeight != null">birth_weight,</if>
|
||||
<if test="isRetained != null">is_retained,</if>
|
||||
<if test="lineage != null">lineage,</if>
|
||||
<if test="birthday != null">birthday,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="lambingRecordId != null">#{lambingRecordId},</if>
|
||||
<if test="lambEarNumber != null and lambEarNumber != ''">#{lambEarNumber},</if>
|
||||
<if test="lambBreed != null">#{lambBreed},</if>
|
||||
<if test="gender != null ">#{gender},</if>
|
||||
<if test="birthWeight != null">#{birthWeight},</if>
|
||||
<if test="isRetained != null">#{isRetained},</if>
|
||||
<if test="lineage != null">#{lineage},</if>
|
||||
<if test="birthday != null">#{birthday},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 同步插入到bas_sheep表 -->
|
||||
<insert id="insertBasSheep" parameterType="ScLambDetail">
|
||||
insert into bas_sheep
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="lambEarNumber != null and lambEarNumber != ''">manage_tags,</if>
|
||||
<if test="lambBreed != null">variety_id,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="birthday != null">birthday,</if>
|
||||
<if test="birthWeight != null">birth_weight,</if>
|
||||
<if test="lineage != null">family,</if>
|
||||
<if test="motherId != null">mother_id,</if>
|
||||
<if test="fatherId != null">father_id,</if>
|
||||
<if test="ranchId != null">ranch_id,</if>
|
||||
<if test="sheepfoldId != null">sheepfold_id,</if>
|
||||
<if test="parity != null">parity,</if>
|
||||
<if test="isRetained != null">status_id,</if>
|
||||
type_id,
|
||||
breed_status_id,
|
||||
is_delete,
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="lambEarNumber != null and lambEarNumber != ''">#{lambEarNumber},</if>
|
||||
<if test="lambBreed != null">#{lambBreed},</if>
|
||||
<if test="gender != null">#{gender},</if>
|
||||
<if test="birthday != null">#{birthday},</if>
|
||||
<if test="birthWeight != null">#{birthWeight},</if>
|
||||
<if test="lineage != null">#{lineage},</if>
|
||||
<if test="motherId != null">#{motherId},</if>
|
||||
<if test="fatherId != null">#{fatherId},</if>
|
||||
<if test="ranchId != null">#{ranchId},</if>
|
||||
<if test="sheepfoldId != null">#{sheepfoldId},</if>
|
||||
<if test="parity != null">#{parity},</if>
|
||||
<if test="isRetained != null">#{isRetained},</if>
|
||||
3, <!-- type_id: 3表示羔羊 -->
|
||||
1, <!-- breed_status_id: 1表示初始繁育状态 -->
|
||||
0, <!-- is_delete: 0表示未删除 -->
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 批量新增羔羊详情(同步录入到bas_sheep表) -->
|
||||
<insert id="insertScLambDetailBatch" parameterType="java.util.List">
|
||||
<!-- 批量插入到sc_lamb_detail表 -->
|
||||
insert into sc_lamb_detail (lambing_record_id, lamb_ear_number, lamb_breed, gender, birth_weight,
|
||||
is_retained, lineage, birthday, create_by, create_time)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.lambingRecordId}, #{item.lambEarNumber}, #{item.lambBreed}, #{item.gender},
|
||||
#{item.birthWeight}, #{item.isRetained}, #{item.lineage}, #{item.birthday},
|
||||
#{item.createBy}, #{item.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量同步插入到bas_sheep表 -->
|
||||
<insert id="insertBasSheepBatch" parameterType="java.util.List">
|
||||
insert into bas_sheep (manage_tags, variety_id, gender, birthday, birth_weight, family,
|
||||
mother_id, father_id, ranch_id, sheepfold_id, parity, status_id, type_id, breed_status_id, is_delete, create_by, create_time)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.lambEarNumber}, #{item.lambBreed}, #{item.gender}, #{item.birthday},
|
||||
#{item.birthWeight}, #{item.lineage}, #{item.motherId}, #{item.fatherId},
|
||||
#{item.ranchId}, #{item.sheepfoldId}, #{item.parity}, #{item.isRetained},
|
||||
3, 1, 0, #{item.createBy}, #{item.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 修改羔羊详情(同步更新bas_sheep表) -->
|
||||
<update id="updateScLambDetail" parameterType="ScLambDetail">
|
||||
update sc_lamb_detail
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="lambingRecordId != null">lambing_record_id = #{lambingRecordId},</if>
|
||||
<if test="lambEarNumber != null and lambEarNumber != ''">lamb_ear_number = #{lambEarNumber},</if>
|
||||
<if test="lambBreed != null">lamb_breed = #{lambBreed},</if>
|
||||
<if test="gender != null">gender = #{gender},</if>
|
||||
<if test="birthWeight != null">birth_weight = #{birthWeight},</if>
|
||||
<if test="isRetained != null">is_retained = #{isRetained},</if>
|
||||
<if test="lineage != null">lineage = #{lineage},</if>
|
||||
<if test="birthday != null">birthday = #{birthday},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 同步更新bas_sheep表 -->
|
||||
<update id="updateBasSheep" parameterType="ScLambDetail">
|
||||
update bas_sheep
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="lambEarNumber != null and lambEarNumber != ''">manage_tags = #{lambEarNumber},</if>
|
||||
<if test="lambBreed != null">variety_id = #{lambBreed},</if>
|
||||
<if test="gender != null ">gender = #{gender},</if>
|
||||
<if test="birthday != null">birthday = #{birthday},</if>
|
||||
<if test="birthWeight != null">birth_weight = #{birthWeight},</if>
|
||||
<if test="lineage != null">family = #{lineage},</if>
|
||||
<if test="isRetained != null">status_id = #{isRetained},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where manage_tags = #{lambEarNumber} and is_delete = 0
|
||||
</update>
|
||||
|
||||
<!-- 删除羔羊详情(同步删除bas_sheep表) -->
|
||||
<delete id="deleteScLambDetailById" parameterType="Long">
|
||||
delete from sc_lamb_detail where id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 同步删除bas_sheep表中的羔羊记录 -->
|
||||
<update id="deleteBasSheepByEarNumber" parameterType="String">
|
||||
update bas_sheep set is_delete = 1 where manage_tags = #{lambEarNumber}
|
||||
</update>
|
||||
|
||||
<!-- 批量删除羔羊详情(同步删除bas_sheep表) -->
|
||||
<delete id="deleteScLambDetailByIds" parameterType="String">
|
||||
delete from sc_lamb_detail where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 批量同步删除bas_sheep表中的羔羊记录 -->
|
||||
<update id="deleteBasSheepByEarNumbers" parameterType="String">
|
||||
update bas_sheep set is_delete = 1 where manage_tags in
|
||||
<foreach item="earNumber" collection="array" open="(" separator="," close=")">
|
||||
#{earNumber}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 根据产羔记录ID删除羔羊详情(同步删除bas_sheep表) -->
|
||||
<delete id="deleteScLambDetailByLambingRecordId" parameterType="Long">
|
||||
delete from sc_lamb_detail where lambing_record_id = #{lambingRecordId}
|
||||
</delete>
|
||||
|
||||
<!-- 同步删除bas_sheep表中对应产羔记录的羔羊 -->
|
||||
<update id="deleteBasSheepByLambingRecordId" parameterType="Long">
|
||||
update bas_sheep set is_delete = 1
|
||||
where manage_tags in (
|
||||
select lamb_ear_number from sc_lamb_detail
|
||||
where lambing_record_id = #{lambingRecordId}
|
||||
)
|
||||
</update>
|
||||
|
||||
<!-- 根据产羔记录获取母羊和父羊信息 -->
|
||||
<select id="getParentInfoByLambingRecordId" parameterType="Long" resultType="java.util.Map">
|
||||
SELECT
|
||||
lr.sheep_id as motherId,
|
||||
mother.ranch_id as ranchId,
|
||||
mother.sheepfold_id as sheepfoldId,
|
||||
mother.parity as parity,
|
||||
father.id as fatherId
|
||||
FROM sc_lambing_record lr
|
||||
LEFT JOIN bas_sheep mother ON lr.sheep_id = mother.id
|
||||
LEFT JOIN sc_breed_record br ON lr.sheep_id = br.ewe_id AND lr.parity = mother.parity
|
||||
LEFT JOIN bas_sheep father ON br.ram_id = father.id
|
||||
WHERE lr.id = #{lambingRecordId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -15,7 +15,7 @@
|
||||
<result property="score" column="score" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTme" column="create_tme" />
|
||||
<result property="createTime" column="create_tme" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 详细结果映射(包含关联信息) -->
|
||||
@@ -29,7 +29,7 @@
|
||||
<result property="score" column="score" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTme" column="create_tme" />
|
||||
<result property="createTime" column="create_tme" />
|
||||
|
||||
<!-- 母羊信息 -->
|
||||
<result property="femaleEarNumber" column="female_ear_number" />
|
||||
@@ -110,7 +110,7 @@
|
||||
<if test="score != null"> and lr.score = #{score}</if>
|
||||
<if test="comment != null and comment != ''"> and lr.comment LIKE CONCAT('%', #{comment}, '%')</if>
|
||||
<if test="createBy != null and createBy != ''"> and lr.create_by = #{createBy}</if>
|
||||
<if test="createTme != null"> and DATE(lr.create_tme) = #{createTme}</if>
|
||||
<if test="createTime != null"> and DATE(lr.create_tme) = #{createTime}</if>
|
||||
<if test="params.beginBreedingDate != null and params.beginBreedingDate != ''"><!-- 配种日期开始 -->
|
||||
and DATE(br.create_time) >= #{params.beginBreedingDate}
|
||||
</if>
|
||||
@@ -134,27 +134,23 @@
|
||||
where lr.id = #{id} and mother.is_delete = 0
|
||||
</select>
|
||||
|
||||
<!-- 查询羔羊详情(从bas_sheep表查询) -->
|
||||
<select id="selectLambDetailByLambingRecordId" parameterType="Long" resultType="map">
|
||||
<!-- 查询羔羊详情(从sc_lamb_detail表查询) -->
|
||||
<select id="selectLambDetailByLambingRecordId" parameterType="Long" resultType="ScLambDetail">
|
||||
SELECT
|
||||
sheep.manage_tags as lambEarNumber,
|
||||
sheep.variety_id as lambBreed,
|
||||
CASE sheep.gender
|
||||
WHEN 1 THEN 'male'
|
||||
WHEN 0 THEN 'female'
|
||||
ELSE 'unknown'
|
||||
END as gender,
|
||||
sheep.birth_weight as birthWeight,
|
||||
CASE sheep.status_id
|
||||
WHEN 1 THEN true
|
||||
ELSE false
|
||||
END as isRetained,
|
||||
sheep.family as lineage,
|
||||
sheep.birthday
|
||||
FROM bas_sheep sheep
|
||||
WHERE sheep.mother_id = (SELECT sheep_id FROM sc_lambing_record WHERE id = #{lambingRecordId})
|
||||
AND sheep.is_delete = 0
|
||||
ORDER BY sheep.birthday ASC
|
||||
id,
|
||||
lambing_record_id as lambingRecordId,
|
||||
lamb_ear_number as lambEarNumber,
|
||||
lamb_breed as lambBreed,
|
||||
gender,
|
||||
birth_weight as birthWeight,
|
||||
is_retained as isRetained,
|
||||
lineage,
|
||||
birthday,
|
||||
create_by as createBy,
|
||||
create_time as createTime
|
||||
FROM sc_lamb_detail
|
||||
WHERE lambing_record_id = #{lambingRecordId}
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 新增产羔记录 -->
|
||||
@@ -169,7 +165,7 @@
|
||||
<if test="score != null">score,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTme != null">create_tme,</if>
|
||||
<if test="createTime != null">create_tme,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
@@ -180,7 +176,7 @@
|
||||
<if test="score != null">#{score},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTme != null">#{createTme},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -196,7 +192,7 @@
|
||||
<if test="score != null">score = #{score},</if>
|
||||
<if test="comment != null">comment = #{comment},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTme != null">create_tme = #{createTme},</if>
|
||||
<if test="createTime != null">create_tme = #{createTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.dryMatterCorrection.mapper.XzDryMatterCorrectionMapper">
|
||||
<mapper namespace="com.zhyc.module.dairyProducts.dryMatterCorrection.mapper.XzDryMatterCorrectionMapper">
|
||||
|
||||
<resultMap type="XzDryMatterCorrection" id="XzDryMatterCorrectionResult">
|
||||
<result property="id" column="id"/>
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.parityCorrection.mapper.XzParityCorrectionMapper">
|
||||
<mapper namespace="com.zhyc.module.dairyProducts.parityCorrection.mapper.XzParityCorrectionMapper">
|
||||
|
||||
<resultMap type="XzParityCorrection" id="XzParityCorrectionResult">
|
||||
<result property="id" column="id" />
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.weightCorrection.mapper.XzWegihCorrectionMapper">
|
||||
<mapper namespace="com.zhyc.module.dairyProducts.weightCorrection.mapper.XzWegihCorrectionMapper">
|
||||
|
||||
<resultMap type="XzWegihCorrection" id="XzWegihCorrectionResult">
|
||||
<result property="id" column="id" />
|
||||
@@ -2,13 +2,15 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.group_management.mapper.BasSheepGroupMapper">
|
||||
<mapper namespace="com.zhyc.module.fileManagement.mapper.BasSheepGroupMapper">
|
||||
|
||||
<resultMap type="BasSheepGroup" id="BasSheepGroupResult">
|
||||
<result property="groupId" column="group_id" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="groupName" column="group_name" />
|
||||
<result property="ancestors" column="ancestors" />
|
||||
<result property="ancestorNames" column="ancestor_names"/>
|
||||
<result property="isLeaf" column="is_leaf"/>
|
||||
<result property="status" column="status" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
@@ -16,16 +18,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<!-- <sql id="selectBasSheepGroupVo">-->
|
||||
<!-- select group_id, parent_id, group_name, ancestors, status, create_by, create_time, update_by, update_time from bas_sheep_group-->
|
||||
<!-- </sql>-->
|
||||
<!-- 修改基础查询语句 -->
|
||||
<sql id="selectBasSheepGroupVo">
|
||||
select group_id, parent_id, group_name, ancestors, status, create_by, create_time, update_by, update_time from bas_sheep_group
|
||||
SELECT
|
||||
g.group_id,
|
||||
g.parent_id,
|
||||
g.group_name,
|
||||
g.ancestors,
|
||||
g.status,
|
||||
g.create_by,
|
||||
g.create_time,
|
||||
g.update_by,
|
||||
g.update_time,
|
||||
<!-- 新增祖先名称查询 -->
|
||||
(SELECT GROUP_CONCAT(parent.group_name ORDER BY FIND_IN_SET(parent.group_id, g.ancestors))
|
||||
FROM bas_sheep_group parent
|
||||
WHERE FIND_IN_SET(parent.group_id, g.ancestors) > 0
|
||||
) AS ancestor_names,
|
||||
(CASE WHEN (SELECT COUNT(1) FROM bas_sheep_group child WHERE child.parent_id = g.group_id) > 0 THEN 0 ELSE 1 END) AS is_leaf
|
||||
FROM bas_sheep_group g
|
||||
</sql>
|
||||
|
||||
<select id="selectBasSheepGroupList" parameterType="BasSheepGroup" resultMap="BasSheepGroupResult">
|
||||
<include refid="selectBasSheepGroupVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</where>
|
||||
</where>ORDER BY g.group_id <!-- 确保正确排序 -->
|
||||
</select>
|
||||
|
||||
<select id="selectBasSheepGroupByGroupId" parameterType="Long" resultMap="BasSheepGroupResult">
|
||||
@@ -77,9 +99,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBasSheepGroupByGroupIds" parameterType="String">
|
||||
delete from bas_sheep_group where group_id in
|
||||
delete from bas_sheep_group where group_id in
|
||||
<foreach item="groupId" collection="array" open="(" separator="," close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.sheepfold_management.mapper.DaSheepfoldMapper">
|
||||
<mapper namespace="com.zhyc.module.fileManagement.mapper.DaSheepfoldMapper">
|
||||
|
||||
<resultMap type="DaSheepfold" id="DaSheepfoldResult">
|
||||
<result property="id" column="id" />
|
||||
@@ -78,4 +78,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectCount" parameterType="DaSheepfold" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
FROM da_sheepfold
|
||||
WHERE ranch_id = #{ranchId}
|
||||
AND sheepfold_type_id = #{sheepfoldTypeId}
|
||||
AND sheepfold_no = #{sheepfoldNo}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.sheep_file.mapper.SheepFileMapper">
|
||||
<mapper namespace="com.zhyc.module.fileManagement.mapper.SheepFileMapper">
|
||||
|
||||
<resultMap type="SheepFile" id="SheepFileResult">
|
||||
<result property="id" column="id" />
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.base.variety.mapper.BasSheepVarietyMapper">
|
||||
|
||||
<resultMap type="BasSheepVariety" id="BasSheepVarietyResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="variety" column="variety" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBasSheepVarietyVo">
|
||||
select id, variety from bas_sheep_variety
|
||||
</sql>
|
||||
|
||||
<select id="selectBasSheepVarietyList" parameterType="BasSheepVariety" resultMap="BasSheepVarietyResult">
|
||||
<include refid="selectBasSheepVarietyVo"/>
|
||||
<where>
|
||||
<if test="variety != null and variety != ''"> and variety = #{variety}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectBasSheepVarietyById" parameterType="Long" resultMap="BasSheepVarietyResult">
|
||||
<include refid="selectBasSheepVarietyVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertBasSheepVariety" parameterType="BasSheepVariety" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into bas_sheep_variety
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="variety != null">variety,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="variety != null">#{variety},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateBasSheepVariety" parameterType="BasSheepVariety">
|
||||
update bas_sheep_variety
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="variety != null">variety = #{variety},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBasSheepVarietyById" parameterType="Long">
|
||||
delete from bas_sheep_variety where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBasSheepVarietyByIds" parameterType="String">
|
||||
delete from bas_sheep_variety where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user