孕检记录
This commit is contained in:
@@ -1,60 +1,147 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScPregnancyRecordMapper">
|
||||
|
||||
|
||||
<resultMap type="ScPregnancyRecord" id="ScPregnancyRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="manageTags" column="manage_tags" />
|
||||
<result property="datetime" column="datetime" />
|
||||
<result property="result" column="result" />
|
||||
<result property="number" column="number" />
|
||||
<result property="fetusCount" column="fetus_count" />
|
||||
<result property="technician" column="technician" />
|
||||
<result property="way" column="way" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="create_by" />
|
||||
<result property="updateTime" column="create_time" />
|
||||
<!-- 关联羊只信息字段 -->
|
||||
<result property="variety" column="variety" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
<result property="parity" column="parity" />
|
||||
<result property="matingCounts" column="mating_counts" />
|
||||
<result property="sheepfoldName" column="sheepfold_name" />
|
||||
<result property="breedStatus" column="breed" />
|
||||
<result property="fatherManageTags" column="father_manage_tags" />
|
||||
<result property="fatherVariety" column="father_variety" />
|
||||
<result property="matingTypeName" column="mating_type_name" />
|
||||
<result property="matingDate" column="mating_date" />
|
||||
<result property="expectedDate" column="expected_date" />
|
||||
<result property="lastEventDate" column="last_event_date" />
|
||||
<result property="ranchName" column="ranch" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectScPregnancyRecordVo">
|
||||
select id, datetime, result, number, technician, way, create_by, create_time from sc_pregnancy_record
|
||||
select
|
||||
pr.id,
|
||||
pr.sheep_id,
|
||||
pr.datetime,
|
||||
pr.result,
|
||||
pr.fetus_count,
|
||||
pr.technician,
|
||||
pr.way,
|
||||
pr.remark,
|
||||
pr.create_by,
|
||||
pr.create_time,
|
||||
pr.create_by,
|
||||
pr.create_time,
|
||||
sf.bs_manage_tags as manage_tags,
|
||||
sf.variety,
|
||||
sf.month_age,
|
||||
sf.parity,
|
||||
sf.mating_counts,
|
||||
sf.sheepfold_name,
|
||||
sf.breed,
|
||||
sf.father_manage_tags,
|
||||
father_sf.variety as father_variety,
|
||||
mating_type.dict_label as mating_type_name,
|
||||
sf.mating_date,
|
||||
sf.expected_date,
|
||||
sf.lambing_date as last_event_date,
|
||||
r.ranch as ranch
|
||||
from sc_pregnancy_record pr
|
||||
left join sheep_file sf on pr.sheep_id = sf.id
|
||||
left join sys_dict_data mating_type on sf.mating_type_id = mating_type.dict_value and mating_type.dict_type = 'breed_type' and mating_type.status = '0'
|
||||
left join da_ranch r on sf.ranch_id = r.id
|
||||
left join sheep_file father_sf on sf.bs_father_id = father_sf.id
|
||||
</sql>
|
||||
|
||||
<select id="selectScPregnancyRecordList" parameterType="ScPregnancyRecord" resultMap="ScPregnancyRecordResult">
|
||||
<include refid="selectScPregnancyRecordVo"/>
|
||||
<where>
|
||||
<if test="datetime != null "> and datetime = #{datetime}</if>
|
||||
<if test="result != null and result != ''"> and result = #{result}</if>
|
||||
<if test="number != null "> and number = #{number}</if>
|
||||
<if test="technician != null and technician != ''"> and technician = #{technician}</if>
|
||||
<if test="way != null "> and way = #{way}</if>
|
||||
<where>
|
||||
pr.is_delete = 0
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
<choose>
|
||||
<when test="manageTags.contains(',')">
|
||||
and sf.bs_manage_tags in
|
||||
<foreach item="tag" collection="manageTags.split(',')" open="(" separator="," close=")">
|
||||
#{tag}
|
||||
</foreach>
|
||||
</when>
|
||||
<otherwise>
|
||||
and sf.bs_manage_tags like concat('%', #{manageTags}, '%')
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="datetime != null "> and pr.datetime = #{datetime}</if>
|
||||
<if test="result != null and result != ''"> and pr.result = #{result}</if>
|
||||
<if test="technician != null and technician != ''"> and pr.technician like concat('%', #{technician}, '%')</if>
|
||||
<if test="way != null and way != ''"> and pr.way = #{way}</if>
|
||||
</where>
|
||||
order by pr.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectScPregnancyRecordById" parameterType="Long" resultMap="ScPregnancyRecordResult">
|
||||
<include refid="selectScPregnancyRecordVo"/>
|
||||
where id = #{id}
|
||||
where pr.id = #{id} and pr.is_delete = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据耳号查询羊只信息 -->
|
||||
<select id="selectSheepByManageTags" parameterType="String" resultType="map">
|
||||
select
|
||||
id,
|
||||
bs_manage_tags as manageTags,
|
||||
variety,
|
||||
month_age as monthAge,
|
||||
parity,
|
||||
mating_counts as matingCounts,
|
||||
sheepfold_name as sheepfoldName,
|
||||
breed as breedStatus
|
||||
from sheep_file
|
||||
where bs_manage_tags = #{manageTags}
|
||||
and is_delete = 0
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertScPregnancyRecord" parameterType="ScPregnancyRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_pregnancy_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="datetime != null">datetime,</if>
|
||||
<if test="result != null">result,</if>
|
||||
<if test="number != null">number,</if>
|
||||
<if test="fetusCount != null">fetus_count,</if>
|
||||
<if test="technician != null">technician,</if>
|
||||
<if test="way != null">way,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
is_delete
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="datetime != null">#{datetime},</if>
|
||||
<if test="result != null">#{result},</if>
|
||||
<if test="number != null">#{number},</if>
|
||||
<if test="fetusCount != null">#{fetusCount},</if>
|
||||
<if test="technician != null">#{technician},</if>
|
||||
<if test="way != null">#{way},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateScPregnancyRecord" parameterType="ScPregnancyRecord">
|
||||
@@ -62,23 +149,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="datetime != null">datetime = #{datetime},</if>
|
||||
<if test="result != null">result = #{result},</if>
|
||||
<if test="number != null">number = #{number},</if>
|
||||
<if test="fetusCount != null">fetus_count = #{fetusCount},</if>
|
||||
<if test="technician != null">technician = #{technician},</if>
|
||||
<if test="way != null">way = #{way},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null">create_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">create_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScPregnancyRecordById" parameterType="Long">
|
||||
delete from sc_pregnancy_record where id = #{id}
|
||||
</delete>
|
||||
<update id="deleteScPregnancyRecordById" parameterType="Long">
|
||||
update sc_pregnancy_record set is_delete = 1 where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScPregnancyRecordByIds" parameterType="String">
|
||||
delete from sc_pregnancy_record where id in
|
||||
<update id="deleteScPregnancyRecordByIds" parameterType="String">
|
||||
update sc_pregnancy_record set is_delete = 1 where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<!-- 更新羊只基础表中的孕检相关字段 -->
|
||||
<update id="updateSheepPregnancyInfo" parameterType="map">
|
||||
update bas_sheep
|
||||
<set>
|
||||
<if test="pregDate != null">preg_date = #{pregDate},</if>
|
||||
<if test="breedStatusId != null">breed_status_id = #{breedStatusId},</if>
|
||||
<if test="expectedDate != null">expected_date = #{expectedDate},</if>
|
||||
<if test="gestationDay != null">gestation_day = #{gestationDay},</if>
|
||||
create_time = now()
|
||||
</set>
|
||||
where id = #{sheepId}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user