Merge remote-tracking branch 'origin/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,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.biosafety.mapper.QuarantineItemsMapper">
|
||||
|
||||
<resultMap type="QuarantineItems" id="QuarantineItemsResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectQuarantineItemsVo">
|
||||
select id, name from sw_quarantine_items
|
||||
</sql>
|
||||
|
||||
<select id="selectQuarantineItemsList" parameterType="QuarantineItems" resultMap="QuarantineItemsResult">
|
||||
<include refid="selectQuarantineItemsVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectQuarantineItemsById" parameterType="Long" resultMap="QuarantineItemsResult">
|
||||
<include refid="selectQuarantineItemsVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertQuarantineItems" parameterType="QuarantineItems" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_quarantine_items
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateQuarantineItems" parameterType="QuarantineItems">
|
||||
update sw_quarantine_items
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteQuarantineItemsById" parameterType="Long">
|
||||
delete from sw_quarantine_items where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteQuarantineItemsByIds" parameterType="String">
|
||||
delete from sw_quarantine_items where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,131 @@
|
||||
<?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.biosafety.mapper.QuarantineReportMapper">
|
||||
|
||||
<resultMap type="QuarantineReport" id="QuarantineReportResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="sheepNo" column="sheep_no"/>
|
||||
<result property="sheepType" column="sheep_type"/>
|
||||
<result property="gender" column="gender"/>
|
||||
<result property="monthAge" column="month_age"/>
|
||||
<result property="parity" column="parity"/>
|
||||
<result property="breed" column="breed"/>
|
||||
<result property="datetime" column="datetime" />
|
||||
<result property="quarItem" column="quar_item" />
|
||||
<result property="itemName" column="item_name"/>
|
||||
<result property="sample" column="sample" />
|
||||
<result property="sampleType" column="sample_type" />
|
||||
<result property="sampler" column="sampler" />
|
||||
<result property="quarOfficer" column="quar_officer" />
|
||||
<result property="result" column="result" />
|
||||
<result property="status" column="status" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectQuarantineReportVo">
|
||||
select sqr.id, sheep_type,sheep_id, datetime, quar_item, sample_type, sampler, quar_officer, result, status,
|
||||
sqr.update_by, sqr.update_time, sqr.create_by, sqr.create_time,
|
||||
sqi.name as item_name,
|
||||
sqs.name as sample,
|
||||
sf.bs_manage_tags sheep_no,sf.gender,sf.parity,sf.breed,sf.month_age
|
||||
from sw_quarantine_report sqr
|
||||
left join sw_quarantine_items sqi on sqr.quar_item = sqi.id
|
||||
left join sw_quarantine_sample sqs on sqr.sample_type = sqs.id
|
||||
left join sheep_file sf on sqr.sheep_id = sf.id
|
||||
</sql>
|
||||
|
||||
<select id="selectQuarantineReportList" parameterType="QuarantineReport" resultMap="QuarantineReportResult">
|
||||
<include refid="selectQuarantineReportVo"/>
|
||||
<where>
|
||||
<if test="sheepId != null "> and sheep_id = #{sheepId}</if>
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="quarItem != null "> and quar_item = #{quarItem}</if>
|
||||
<if test="sampleType != null "> and sample_type = #{sampleType}</if>
|
||||
<if test="sampler != null and sampler != ''"> and sampler = #{sampler}</if>
|
||||
<if test="quarOfficer != null and quarOfficer != ''"> and quar_officer = #{quarOfficer}</if>
|
||||
<if test="result != null "> and result = #{result}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectQuarantineReportById" parameterType="Long" resultMap="QuarantineReportResult">
|
||||
select sqr.id, sheep_type,sheep_id, datetime, quar_item, sample_type, sampler, quar_officer, result, status,
|
||||
sqr.update_by, sqr.update_time, sqr.create_by, sqr.create_time,
|
||||
sqi.name as item_name,
|
||||
sqs.name as sample,
|
||||
sf.bs_manage_tags sheep_no
|
||||
from sw_quarantine_report sqr
|
||||
left join sw_quarantine_items sqi on sqr.quar_item = sqi.id
|
||||
left join sw_quarantine_sample sqs on sqr.sample_type = sqs.id
|
||||
left join sheep_file sf on sqr.sheep_id = sf.id
|
||||
where sqr.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertQuarantineReport" parameterType="QuarantineReport" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_quarantine_report
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="datetime != null">datetime,</if>
|
||||
<if test="quarItem != null">quar_item,</if>
|
||||
<if test="sampleType != null">sample_type,</if>
|
||||
<if test="sampler != null">sampler,</if>
|
||||
<if test="quarOfficer != null">quar_officer,</if>
|
||||
<if test="result != null">result,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="datetime != null">#{datetime},</if>
|
||||
<if test="quarItem != null">#{quarItem},</if>
|
||||
<if test="sampleType != null">#{sampleType},</if>
|
||||
<if test="sampler != null">#{sampler},</if>
|
||||
<if test="quarOfficer != null">#{quarOfficer},</if>
|
||||
<if test="result != null">#{result},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateQuarantineReport" parameterType="QuarantineReport">
|
||||
update sw_quarantine_report
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
||||
<if test="datetime != null">datetime = #{datetime},</if>
|
||||
<if test="quarItem != null">quar_item = #{quarItem},</if>
|
||||
<if test="sampleType != null">sample_type = #{sampleType},</if>
|
||||
<if test="sampler != null">sampler = #{sampler},</if>
|
||||
<if test="quarOfficer != null">quar_officer = #{quarOfficer},</if>
|
||||
<if test="result != null">result = #{result},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteQuarantineReportById" parameterType="Long">
|
||||
delete from sw_quarantine_report where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteQuarantineReportByIds" parameterType="String">
|
||||
delete from sw_quarantine_report where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -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.biosafety.mapper.QuarantineSampleMapper">
|
||||
|
||||
<resultMap type="QuarantineSample" id="QuarantineSampleResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectQuarantineSampleVo">
|
||||
select id, name from sw_quarantine_sample
|
||||
</sql>
|
||||
|
||||
<select id="selectQuarantineSampleList" parameterType="QuarantineSample" resultMap="QuarantineSampleResult">
|
||||
<include refid="selectQuarantineSampleVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectQuarantineSampleById" parameterType="Long" resultMap="QuarantineSampleResult">
|
||||
<include refid="selectQuarantineSampleVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertQuarantineSample" parameterType="QuarantineSample" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_quarantine_sample
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateQuarantineSample" parameterType="QuarantineSample">
|
||||
update sw_quarantine_sample
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteQuarantineSampleById" parameterType="Long">
|
||||
delete from sw_quarantine_sample where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteQuarantineSampleByIds" parameterType="String">
|
||||
delete from sw_quarantine_sample 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>
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<?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.group_management.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="status" column="status" />
|
||||
<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 id="selectBasSheepGroupVo">
|
||||
select group_id, parent_id, group_name, ancestors, status, create_by, create_time, update_by, update_time from bas_sheep_group
|
||||
</sql>
|
||||
|
||||
<select id="selectBasSheepGroupList" parameterType="BasSheepGroup" resultMap="BasSheepGroupResult">
|
||||
<include refid="selectBasSheepGroupVo"/>
|
||||
<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>
|
||||
</select>
|
||||
|
||||
<select id="selectBasSheepGroupByGroupId" parameterType="Long" resultMap="BasSheepGroupResult">
|
||||
<include refid="selectBasSheepGroupVo"/>
|
||||
where group_id = #{groupId}
|
||||
</select>
|
||||
|
||||
<insert id="insertBasSheepGroup" parameterType="BasSheepGroup" useGeneratedKeys="true" keyProperty="groupId">
|
||||
insert into bas_sheep_group
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="groupName != null and groupName != ''">group_name,</if>
|
||||
<if test="ancestors != null">ancestors,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="groupName != null and groupName != ''">#{groupName},</if>
|
||||
<if test="ancestors != null">#{ancestors},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateBasSheepGroup" parameterType="BasSheepGroup">
|
||||
update bas_sheep_group
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="groupName != null and groupName != ''">group_name = #{groupName},</if>
|
||||
<if test="ancestors != null">ancestors = #{ancestors},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where group_id = #{groupId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBasSheepGroupByGroupId" parameterType="Long">
|
||||
delete from bas_sheep_group where group_id = #{groupId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBasSheepGroupByGroupIds" parameterType="String">
|
||||
delete from bas_sheep_group where group_id in
|
||||
<foreach item="groupId" collection="array" open="(" separator="," close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -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