Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?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.common.mapper.UserPostMapper">
|
||||
|
||||
<resultMap type="UserPost" id="UserPostResult">
|
||||
|
||||
<result property="nickName" column="nick_name" />
|
||||
<result property="postName" column="post_name"/>
|
||||
<result property="postCode" column="post_code" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getUserPostListByCode" resultMap="UserPostResult">
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?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.feed.mapper.SgFeedDetailsMapper">
|
||||
|
||||
<resultMap type="SgFeedDetails" id="SgFeedDetailsResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="fodder" column="fodder" />
|
||||
<result property="number" column="number" />
|
||||
<result property="nuit" column="nuit" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSgFeedDetailsVo">
|
||||
select id, fodder, number, nuit from sg_feed_details
|
||||
</sql>
|
||||
|
||||
<select id="selectSgFeedDetailsList" parameterType="SgFeedDetails" resultMap="SgFeedDetailsResult">
|
||||
<include refid="selectSgFeedDetailsVo"/>
|
||||
<where>
|
||||
<if test="fodder != null and fodder != ''"> and fodder = #{fodder}</if>
|
||||
<if test="number != null "> and number = #{number}</if>
|
||||
<if test="nuit != null and nuit != ''"> and nuit = #{nuit}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedDetailsById" parameterType="Long" resultMap="SgFeedDetailsResult">
|
||||
<include refid="selectSgFeedDetailsVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSgFeedDetails" parameterType="SgFeedDetails" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sg_feed_details
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="fodder != null">fodder,</if>
|
||||
<if test="number != null">number,</if>
|
||||
<if test="nuit != null">nuit,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="fodder != null">#{fodder},</if>
|
||||
<if test="number != null">#{number},</if>
|
||||
<if test="nuit != null">#{nuit},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSgFeedDetails" parameterType="SgFeedDetails">
|
||||
update sg_feed_details
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="fodder != null">fodder = #{fodder},</if>
|
||||
<if test="number != null">number = #{number},</if>
|
||||
<if test="nuit != null">nuit = #{nuit},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSgFeedDetailsById" parameterType="Long">
|
||||
delete from sg_feed_details where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSgFeedDetailsByIds" parameterType="String">
|
||||
delete from sg_feed_details where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -1,129 +0,0 @@
|
||||
<?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.feed.mapper.SgFeedInfoMapper">
|
||||
|
||||
<resultMap type="SgFeedInfo" id="SgFeedInfoResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="formulaId" column="formula_id" />
|
||||
<result property="sheepfoldId" column="sheepfold_id" />
|
||||
<result property="average" column="average" />
|
||||
<result property="planMonring" column="plan_monring" />
|
||||
<result property="actualMonring" column="actual_monring" />
|
||||
<result property="planNoon" column="plan_noon" />
|
||||
<result property="actualNoon" column="actual_noon" />
|
||||
<result property="planEvenig" column="plan_evenig" />
|
||||
<result property="actualEvening" column="actual_evening" />
|
||||
<result property="particle" column="particle" />
|
||||
<result property="other" column="other" />
|
||||
<result property="replenish" column="replenish" />
|
||||
<result property="planDate" column="plan_date" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSgFeedInfoVo">
|
||||
select id, formula_id, sheepfold_id, average, plan_monring, actual_monring, plan_noon, actual_noon, plan_evenig, actual_evening, particle, other, replenish, plan_date, comment, create_by, create_time from sg_feed_info
|
||||
</sql>
|
||||
|
||||
<select id="selectSgFeedInfoList" parameterType="SgFeedInfo" resultMap="SgFeedInfoResult">
|
||||
<include refid="selectSgFeedInfoVo"/>
|
||||
<where>
|
||||
<if test="formulaId != null "> and formula_id = #{formulaId}</if>
|
||||
<if test="sheepfoldId != null and sheepfoldId != ''"> and sheepfold_id = #{sheepfoldId}</if>
|
||||
<if test="average != null "> and average = #{average}</if>
|
||||
<if test="planMonring != null "> and plan_monring = #{planMonring}</if>
|
||||
<if test="actualMonring != null "> and actual_monring = #{actualMonring}</if>
|
||||
<if test="planNoon != null "> and plan_noon = #{planNoon}</if>
|
||||
<if test="actualNoon != null "> and actual_noon = #{actualNoon}</if>
|
||||
<if test="planEvenig != null "> and plan_evenig = #{planEvenig}</if>
|
||||
<if test="actualEvening != null "> and actual_evening = #{actualEvening}</if>
|
||||
<if test="particle != null "> and particle = #{particle}</if>
|
||||
<if test="other != null "> and other = #{other}</if>
|
||||
<if test="replenish != null "> and replenish = #{replenish}</if>
|
||||
<if test="planDate != null "> and plan_date = #{planDate}</if>
|
||||
<if test="comment != null and comment != ''"> and comment = #{comment}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedInfoById" parameterType="Long" resultMap="SgFeedInfoResult">
|
||||
<include refid="selectSgFeedInfoVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSgFeedInfo" parameterType="SgFeedInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sg_feed_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="formulaId != null">formula_id,</if>
|
||||
<if test="sheepfoldId != null">sheepfold_id,</if>
|
||||
<if test="average != null">average,</if>
|
||||
<if test="planMonring != null">plan_monring,</if>
|
||||
<if test="actualMonring != null">actual_monring,</if>
|
||||
<if test="planNoon != null">plan_noon,</if>
|
||||
<if test="actualNoon != null">actual_noon,</if>
|
||||
<if test="planEvenig != null">plan_evenig,</if>
|
||||
<if test="actualEvening != null">actual_evening,</if>
|
||||
<if test="particle != null">particle,</if>
|
||||
<if test="other != null">other,</if>
|
||||
<if test="replenish != null">replenish,</if>
|
||||
<if test="planDate != null">plan_date,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="formulaId != null">#{formulaId},</if>
|
||||
<if test="sheepfoldId != null">#{sheepfoldId},</if>
|
||||
<if test="average != null">#{average},</if>
|
||||
<if test="planMonring != null">#{planMonring},</if>
|
||||
<if test="actualMonring != null">#{actualMonring},</if>
|
||||
<if test="planNoon != null">#{planNoon},</if>
|
||||
<if test="actualNoon != null">#{actualNoon},</if>
|
||||
<if test="planEvenig != null">#{planEvenig},</if>
|
||||
<if test="actualEvening != null">#{actualEvening},</if>
|
||||
<if test="particle != null">#{particle},</if>
|
||||
<if test="other != null">#{other},</if>
|
||||
<if test="replenish != null">#{replenish},</if>
|
||||
<if test="planDate != null">#{planDate},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSgFeedInfo" parameterType="SgFeedInfo">
|
||||
update sg_feed_info
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="formulaId != null">formula_id = #{formulaId},</if>
|
||||
<if test="sheepfoldId != null">sheepfold_id = #{sheepfoldId},</if>
|
||||
<if test="average != null">average = #{average},</if>
|
||||
<if test="planMonring != null">plan_monring = #{planMonring},</if>
|
||||
<if test="actualMonring != null">actual_monring = #{actualMonring},</if>
|
||||
<if test="planNoon != null">plan_noon = #{planNoon},</if>
|
||||
<if test="actualNoon != null">actual_noon = #{actualNoon},</if>
|
||||
<if test="planEvenig != null">plan_evenig = #{planEvenig},</if>
|
||||
<if test="actualEvening != null">actual_evening = #{actualEvening},</if>
|
||||
<if test="particle != null">particle = #{particle},</if>
|
||||
<if test="other != null">other = #{other},</if>
|
||||
<if test="replenish != null">replenish = #{replenish},</if>
|
||||
<if test="planDate != null">plan_date = #{planDate},</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 id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSgFeedInfoById" parameterType="Long">
|
||||
delete from sg_feed_info where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSgFeedInfoByIds" parameterType="String">
|
||||
delete from sg_feed_info where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -7,21 +7,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="SgFeedPlan" id="SgFeedPlanResult">
|
||||
<result property="createDate" column="create_date" />
|
||||
<result property="formulaId" column="formula_id" />
|
||||
<result property="batchId" column="batch_id" />
|
||||
<result property="sheepHouseId" column="sheep_house_id" />
|
||||
<result property="sheepCount" column="sheep_count" />
|
||||
<result property="planDailySize" column="plan_daily_size" />
|
||||
<result property="ratioMorning" column="ratio_morning" />
|
||||
<result property="ratioNoon" column="ratio_noon" />
|
||||
<result property="ratioAfternoon" column="ratio_afternoon" />
|
||||
<result property="planMorningSize" column="plan_morning_size" />
|
||||
<result property="planMorningTotal" column="plan_morning_total" />
|
||||
<result property="ratioMorning" column="ratio_morning" />
|
||||
<result property="actualMorningSize" column="actual_morning_size" />
|
||||
<result property="planNoonSize" column="plan_noon_size" />
|
||||
<result property="planNoonTotal" column="plan_noon_total" />
|
||||
<result property="actualNoonSize" column="actual_noon_size" />
|
||||
<result property="ratioNoon" column="ratio_noon" />
|
||||
<result property="planAfternoonSize" column="plan_afternoon_size" />
|
||||
<result property="planAfternoonTotal" column="plan_afternoon_total" />
|
||||
<result property="actualAfternoonSize" column="actual_afternoon_size" />
|
||||
<result property="ratioAfternoon" column="ratio_afternoon" />
|
||||
<result property="planFeedTotal" column="plan_feed_total" />
|
||||
<result property="zookeeper" column="zookeeper" />
|
||||
<result property="planDate" column="plan_date" />
|
||||
@@ -29,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSgFeedPlanVo">
|
||||
select create_date, formula_id, sheep_house_id, sheep_count, plan_daily_size, plan_morning_size, plan_morning_total, ratio_morning, actual_morning_size, plan_noon_size, plan_noon_total, actual_noon_size, ratio_noon, plan_afternoon_size, plan_afternoon_total, actual_afternoon_size, ratio_afternoon, plan_feed_total, zookeeper, plan_date, remark from sg_feed_plan
|
||||
select create_date, formula_id, batch_id, sheep_house_id, sheep_count, plan_daily_size, ratio_morning, ratio_noon, ratio_afternoon, plan_morning_size, plan_morning_total, actual_morning_size, plan_noon_size, plan_noon_total, actual_noon_size, plan_afternoon_size, plan_afternoon_total, actual_afternoon_size, plan_feed_total, zookeeper, plan_date, remark from sg_feed_plan
|
||||
</sql>
|
||||
|
||||
<select id="selectSgFeedPlanList" parameterType="SgFeedPlan" resultMap="SgFeedPlanResult">
|
||||
@@ -37,9 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
|
||||
<if test="sheepHouseId != null "> and sheep_house_id = #{sheepHouseId}</if>
|
||||
<if test="zookeeper != null and zookeeper != ''"> and zookeeper = #{zookeeper}</if>
|
||||
<if test="planDate != null "> and plan_date = #{planDate}</if>
|
||||
</where>
|
||||
ORDER BY formula_id ASC, plan_date ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedPlanByCreateDate" parameterType="Date" resultMap="SgFeedPlanResult">
|
||||
@@ -52,21 +52,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="createDate != null">create_date,</if>
|
||||
<if test="formulaId != null and formulaId != ''">formula_id,</if>
|
||||
<if test="batchId != null and batchId != ''">batch_id,</if>
|
||||
<if test="sheepHouseId != null">sheep_house_id,</if>
|
||||
<if test="sheepCount != null">sheep_count,</if>
|
||||
<if test="planDailySize != null">plan_daily_size,</if>
|
||||
<if test="ratioMorning != null">ratio_morning,</if>
|
||||
<if test="ratioNoon != null">ratio_noon,</if>
|
||||
<if test="ratioAfternoon != null">ratio_afternoon,</if>
|
||||
<if test="planMorningSize != null">plan_morning_size,</if>
|
||||
<if test="planMorningTotal != null">plan_morning_total,</if>
|
||||
<if test="ratioMorning != null">ratio_morning,</if>
|
||||
<if test="actualMorningSize != null">actual_morning_size,</if>
|
||||
<if test="planNoonSize != null">plan_noon_size,</if>
|
||||
<if test="planNoonTotal != null">plan_noon_total,</if>
|
||||
<if test="actualNoonSize != null">actual_noon_size,</if>
|
||||
<if test="ratioNoon != null">ratio_noon,</if>
|
||||
<if test="planAfternoonSize != null">plan_afternoon_size,</if>
|
||||
<if test="planAfternoonTotal != null">plan_afternoon_total,</if>
|
||||
<if test="actualAfternoonSize != null">actual_afternoon_size,</if>
|
||||
<if test="ratioAfternoon != null">ratio_afternoon,</if>
|
||||
<if test="planFeedTotal != null">plan_feed_total,</if>
|
||||
<if test="zookeeper != null">zookeeper,</if>
|
||||
<if test="planDate != null">plan_date,</if>
|
||||
@@ -75,21 +76,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="createDate != null">#{createDate},</if>
|
||||
<if test="formulaId != null and formulaId != ''">#{formulaId},</if>
|
||||
<if test="batchId != null and batchId != ''">#{batchId},</if>
|
||||
<if test="sheepHouseId != null">#{sheepHouseId},</if>
|
||||
<if test="sheepCount != null">#{sheepCount},</if>
|
||||
<if test="planDailySize != null">#{planDailySize},</if>
|
||||
<if test="ratioMorning != null">#{ratioMorning},</if>
|
||||
<if test="ratioNoon != null">#{ratioNoon},</if>
|
||||
<if test="ratioAfternoon != null">#{ratioAfternoon},</if>
|
||||
<if test="planMorningSize != null">#{planMorningSize},</if>
|
||||
<if test="planMorningTotal != null">#{planMorningTotal},</if>
|
||||
<if test="ratioMorning != null">#{ratioMorning},</if>
|
||||
<if test="actualMorningSize != null">#{actualMorningSize},</if>
|
||||
<if test="planNoonSize != null">#{planNoonSize},</if>
|
||||
<if test="planNoonTotal != null">#{planNoonTotal},</if>
|
||||
<if test="actualNoonSize != null">#{actualNoonSize},</if>
|
||||
<if test="ratioNoon != null">#{ratioNoon},</if>
|
||||
<if test="planAfternoonSize != null">#{planAfternoonSize},</if>
|
||||
<if test="planAfternoonTotal != null">#{planAfternoonTotal},</if>
|
||||
<if test="actualAfternoonSize != null">#{actualAfternoonSize},</if>
|
||||
<if test="ratioAfternoon != null">#{ratioAfternoon},</if>
|
||||
<if test="planFeedTotal != null">#{planFeedTotal},</if>
|
||||
<if test="zookeeper != null">#{zookeeper},</if>
|
||||
<if test="planDate != null">#{planDate},</if>
|
||||
@@ -101,21 +103,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update sg_feed_plan
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="formulaId != null and formulaId != ''">formula_id = #{formulaId},</if>
|
||||
<if test="batchId != null and batchId != ''">batch_id = #{batchId},</if>
|
||||
<if test="sheepHouseId != null">sheep_house_id = #{sheepHouseId},</if>
|
||||
<if test="sheepCount != null">sheep_count = #{sheepCount},</if>
|
||||
<if test="planDailySize != null">plan_daily_size = #{planDailySize},</if>
|
||||
<if test="ratioMorning != null">ratio_morning = #{ratioMorning},</if>
|
||||
<if test="ratioNoon != null">ratio_noon = #{ratioNoon},</if>
|
||||
<if test="ratioAfternoon != null">ratio_afternoon = #{ratioAfternoon},</if>
|
||||
<if test="planMorningSize != null">plan_morning_size = #{planMorningSize},</if>
|
||||
<if test="planMorningTotal != null">plan_morning_total = #{planMorningTotal},</if>
|
||||
<if test="ratioMorning != null">ratio_morning = #{ratioMorning},</if>
|
||||
<if test="actualMorningSize != null">actual_morning_size = #{actualMorningSize},</if>
|
||||
<if test="planNoonSize != null">plan_noon_size = #{planNoonSize},</if>
|
||||
<if test="planNoonTotal != null">plan_noon_total = #{planNoonTotal},</if>
|
||||
<if test="actualNoonSize != null">actual_noon_size = #{actualNoonSize},</if>
|
||||
<if test="ratioNoon != null">ratio_noon = #{ratioNoon},</if>
|
||||
<if test="planAfternoonSize != null">plan_afternoon_size = #{planAfternoonSize},</if>
|
||||
<if test="planAfternoonTotal != null">plan_afternoon_total = #{planAfternoonTotal},</if>
|
||||
<if test="actualAfternoonSize != null">actual_afternoon_size = #{actualAfternoonSize},</if>
|
||||
<if test="ratioAfternoon != null">ratio_afternoon = #{ratioAfternoon},</if>
|
||||
<if test="planFeedTotal != null">plan_feed_total = #{planFeedTotal},</if>
|
||||
<if test="zookeeper != null">zookeeper = #{zookeeper},</if>
|
||||
<if test="planDate != null">plan_date = #{planDate},</if>
|
||||
@@ -134,4 +137,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{createDate}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectSheepCountByFoldId" parameterType="Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM bas_sheep
|
||||
WHERE sheepfold_id = #{foldId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?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.feed.mapper.SgFeedRatioMapper">
|
||||
|
||||
<resultMap type="SgFeedRatio" id="SgFeedRatioResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="morning" column="morning" />
|
||||
<result property="noon" column="noon" />
|
||||
<result property="evening" column="evening" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSgFeedRatioVo">
|
||||
select id, morning, noon, evening from sg_feed_ratio
|
||||
</sql>
|
||||
|
||||
<select id="selectSgFeedRatioList" parameterType="SgFeedRatio" resultMap="SgFeedRatioResult">
|
||||
<include refid="selectSgFeedRatioVo"/>
|
||||
<where>
|
||||
<if test="morning != null and morning != ''"> and morning = #{morning}</if>
|
||||
<if test="noon != null and noon != ''"> and noon = #{noon}</if>
|
||||
<if test="evening != null and evening != ''"> and evening = #{evening}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedRatioById" parameterType="Long" resultMap="SgFeedRatioResult">
|
||||
<include refid="selectSgFeedRatioVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSgFeedRatio" parameterType="SgFeedRatio" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sg_feed_ratio
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="morning != null">morning,</if>
|
||||
<if test="noon != null">noon,</if>
|
||||
<if test="evening != null">evening,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="morning != null">#{morning},</if>
|
||||
<if test="noon != null">#{noon},</if>
|
||||
<if test="evening != null">#{evening},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSgFeedRatio" parameterType="SgFeedRatio">
|
||||
update sg_feed_ratio
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="morning != null">morning = #{morning},</if>
|
||||
<if test="noon != null">noon = #{noon},</if>
|
||||
<if test="evening != null">evening = #{evening},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSgFeedRatioById" parameterType="Long">
|
||||
delete from sg_feed_ratio where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSgFeedRatioByIds" parameterType="String">
|
||||
delete from sg_feed_ratio where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -1,61 +0,0 @@
|
||||
<?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.feed.mapper.SgFodderMapper">
|
||||
|
||||
<resultMap type="SgFodder" id="SgFodderResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="fodderType" column="fodder_type" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSgFodderVo">
|
||||
select id, name, fodder_type from sg_fodder
|
||||
</sql>
|
||||
|
||||
<select id="selectSgFodderList" parameterType="SgFodder" resultMap="SgFodderResult">
|
||||
<include refid="selectSgFodderVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="fodderType != null "> and fodder_type = #{fodderType}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSgFodderById" parameterType="Long" resultMap="SgFodderResult">
|
||||
<include refid="selectSgFodderVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSgFodder" parameterType="SgFodder" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sg_fodder
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
<if test="fodderType != null">fodder_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="fodderType != null">#{fodderType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSgFodder" parameterType="SgFodder">
|
||||
update sg_fodder
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="fodderType != null">fodder_type = #{fodderType},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSgFodderById" parameterType="Long">
|
||||
delete from sg_fodder where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSgFodderByIds" parameterType="String">
|
||||
delete from sg_fodder where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -34,8 +34,14 @@
|
||||
<where>
|
||||
<if test="planName != null and planName != ''"> and plan_name like concat('%', #{planName}, '%')</if>
|
||||
<if test="planType != null"> and plan_type = #{planType}</if>
|
||||
<if test="planDate != null"> and plan_date = #{planDate}</if>
|
||||
<if test="planDate != null"> and DATE(plan_date) = DATE(#{planDate})</if>
|
||||
<if test="status != null"> and status = #{status}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
and DATE(plan_date) >= DATE(#{params.beginTime})
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
and DATE(plan_date) <= DATE(#{params.endTime})
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
@@ -48,63 +54,72 @@
|
||||
<!-- 筛选符合条件的母羊 -->
|
||||
<select id="selectEligibleEwe" resultType="Map">
|
||||
select
|
||||
sf.id,
|
||||
sf.bs_manage_tags,
|
||||
sf.variety,
|
||||
sf.name as sheep_type,
|
||||
sf.gender,
|
||||
sf.month_age,
|
||||
sf.current_weight,
|
||||
sf.post_lambing_day,
|
||||
sf.breed
|
||||
from sheep_file sf
|
||||
where sf.gender = 1
|
||||
and sf.is_delete = 0
|
||||
and (sf.status_id = 1 or sf.status_id is null)
|
||||
bs.id,
|
||||
bs.manage_tags as bs_manage_tags,
|
||||
bv.variety as variety,
|
||||
bs.family,
|
||||
bst.name as sheep_type,
|
||||
bs.gender,
|
||||
TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) as month_age,
|
||||
bs.current_weight,
|
||||
bs.post_lambing_day,
|
||||
bbs.breed as breed,
|
||||
bs.parity,
|
||||
dsf.sheepfold_name,
|
||||
bs.comment,
|
||||
CASE WHEN bs.is_core = 1 THEN '是' ELSE '否' END as is_core,
|
||||
CASE WHEN bs.is_breeding = 1 THEN '是' ELSE '否' END as is_breeding,
|
||||
CONCAT('胎次:', IFNULL(bs.parity, 0), ' 配种次数:', IFNULL(bs.mating_counts, 0)) as reproduction_info
|
||||
from bas_sheep bs
|
||||
left join bas_sheep_variety bv on bs.variety_id = bv.id
|
||||
left join bas_sheep_type bst on bs.type_id = bst.id
|
||||
left join bas_breed_status bbs on bs.breed_status_id = bbs.id
|
||||
left join da_sheepfold dsf on bs.sheepfold_id = dsf.id
|
||||
where bs.gender = 1
|
||||
and bs.is_delete = 0
|
||||
and (bs.status_id = 1 or bs.status_id is null)
|
||||
and (
|
||||
-- 青年羊或超龄羊的配种条件
|
||||
(sf.name in ('青年羊', '超龄羊') and (
|
||||
(sf.variety = '湖羊' and sf.month_age >= 7.5 and sf.current_weight >= 33) or
|
||||
(sf.variety = '东佛里生' and sf.month_age >= 9 and sf.current_weight >= 50) or
|
||||
(sf.variety not in ('湖羊', '东佛里生') and sf.month_age >= 9 and sf.current_weight >= 50)
|
||||
(bst.name in ('青年羊', '超龄羊') and (
|
||||
(bv.variety = '湖羊' and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 7.5 and bs.current_weight >= 33) or
|
||||
(bv.variety = '东佛里生' and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 9 and bs.current_weight >= 50) or
|
||||
(bv.variety not in ('湖羊', '东佛里生') and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 9 and bs.current_weight >= 50)
|
||||
))
|
||||
or
|
||||
-- 泌乳羊或种母羊的配种条件
|
||||
(sf.name in ('泌乳羊', '种母羊') and sf.post_lambing_day > 45 and sf.current_weight > 0)
|
||||
(bst.name in ('泌乳羊', '种母羊') and bs.post_lambing_day > 45 and bs.current_weight > 0)
|
||||
)
|
||||
order by sf.variety, sf.month_age desc
|
||||
order by bv.variety, TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) desc
|
||||
</select>
|
||||
|
||||
<!-- 筛选符合条件的公羊 -->
|
||||
<select id="selectEligibleRam" resultType="Map">
|
||||
select
|
||||
sf.id,
|
||||
sf.manage_tags as bs_manage_tags,
|
||||
bs.id,
|
||||
bs.manage_tags as bs_manage_tags,
|
||||
bv.variety as variety,
|
||||
bs.family,
|
||||
bst.name as sheep_type,
|
||||
sf.gender,
|
||||
TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) as month_age,
|
||||
sf.current_weight,
|
||||
bs.gender,
|
||||
bs.birthday,
|
||||
TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) as month_age,
|
||||
bs.current_weight,
|
||||
bbs.breed as breed
|
||||
from bas_sheep sf
|
||||
left join bas_sheep_variety bv on sf.variety_id = bv.id
|
||||
left join bas_sheep_type bst on sf.type_id = bst.id
|
||||
left join bas_breed_status bbs on sf.breed_status_id = bbs.id
|
||||
where sf.gender = 2
|
||||
and sf.is_delete = 0
|
||||
and sf.status_id = 1
|
||||
from bas_sheep bs
|
||||
left join bas_sheep_variety bv on bs.variety_id = bv.id
|
||||
left join bas_sheep_type bst on bs.type_id = bst.id
|
||||
left join bas_breed_status bbs on bs.breed_status_id = bbs.id
|
||||
where bs.gender = 2
|
||||
and bs.is_delete = 0
|
||||
and bs.status_id = 1
|
||||
and (
|
||||
-- 青年羊或超龄羊的参配条件
|
||||
(bst.name in ('青年羊', '超龄羊') and (
|
||||
(bv.variety = '湖羊' and TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) >= 7.5 and sf.current_weight >= 33) or
|
||||
(bv.variety = '东佛里生' and TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) >= 9 and sf.current_weight >= 50) or
|
||||
(bv.variety not in ('湖羊', '东佛里生') and TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) >= 9 and sf.current_weight >= 50)
|
||||
(bv.variety = '湖羊' and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 7.5 and bs.current_weight >= 33) or
|
||||
(bv.variety = '东佛里生' and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 9 and bs.current_weight >= 50) or
|
||||
(bv.variety not in ('湖羊', '东佛里生') and TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) >= 9 and bs.current_weight >= 50)
|
||||
))
|
||||
or
|
||||
-- 其他类型公羊
|
||||
bst.name not in ('青年羊', '超龄羊')
|
||||
)
|
||||
order by bv.variety, TIMESTAMPDIFF(MONTH, sf.birthday, NOW()) desc
|
||||
order by bv.variety, TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) desc
|
||||
</select>
|
||||
|
||||
<insert id="insertScBreedPlanGenerate" parameterType="ScBreedPlanGenerate" useGeneratedKeys="true" keyProperty="id">
|
||||
@@ -176,25 +191,110 @@
|
||||
where plan_generate_id = #{planGenerateId}
|
||||
</insert>
|
||||
|
||||
<!-- 获取配种计划详情 -->
|
||||
<!-- 获取配种计划详情 - 显示完整字段信息 -->
|
||||
<select id="selectBreedPlanDetails" parameterType="Long" resultType="Map">
|
||||
select
|
||||
temp.id,
|
||||
temp.ram_id,
|
||||
temp.ewe_id,
|
||||
temp.breed_type,
|
||||
ram.bs_manage_tags as ram_manage_tags,
|
||||
ram.variety as ram_variety,
|
||||
ewe.bs_manage_tags as ewe_manage_tags,
|
||||
ewe.variety as ewe_variety,
|
||||
ewe.current_weight as ewe_weight
|
||||
-- 母羊完整信息
|
||||
ewe.manage_tags as ewe_manage_tags,
|
||||
ewe_variety.variety as ewe_variety,
|
||||
ewe.family as ewe_family,
|
||||
ewe_type.name as ewe_sheep_type,
|
||||
ewe_breed.breed as ewe_breed_status,
|
||||
ewe.parity as ewe_parity,
|
||||
TIMESTAMPDIFF(MONTH, ewe.birthday, NOW()) as ewe_month_age,
|
||||
ewe.current_weight as ewe_current_weight,
|
||||
CASE WHEN ewe.is_core = 1 THEN 1 ELSE 0 END as ewe_is_core,
|
||||
CASE WHEN ewe.is_breeding = 1 THEN 1 ELSE 0 END as ewe_is_breeding,
|
||||
ewe_sheepfold.sheepfold_name as ewe_sheepfold_name,
|
||||
ewe.comment as ewe_comment,
|
||||
CONCAT('胎次:', IFNULL(ewe.parity, 0), ' 配种次数:', IFNULL(ewe.mating_counts, 0)) as ewe_reproduction_info,
|
||||
-- 公羊完整信息 - 直接关联查询耳号
|
||||
ram.manage_tags as ram_manage_tags,
|
||||
ram_variety.variety as ram_variety,
|
||||
ram.family as ram_family,
|
||||
ram_type.name as ram_sheep_type,
|
||||
ram.birthday as ram_birthday,
|
||||
TIMESTAMPDIFF(MONTH, ram.birthday, NOW()) as ram_month_age,
|
||||
ram.current_weight as ram_current_weight
|
||||
from sc_breed_plan_temp temp
|
||||
left join sheep_file ram on temp.ram_id = ram.id
|
||||
left join sheep_file ewe on temp.ewe_id = ewe.id
|
||||
left join bas_sheep ewe on ewe.id = CAST(temp.ewe_id AS UNSIGNED)
|
||||
left join bas_sheep_variety ewe_variety on ewe.variety_id = ewe_variety.id
|
||||
left join bas_sheep_type ewe_type on ewe.type_id = ewe_type.id
|
||||
left join bas_breed_status ewe_breed on ewe.breed_status_id = ewe_breed.id
|
||||
left join da_sheepfold ewe_sheepfold on ewe.sheepfold_id = ewe_sheepfold.id
|
||||
left join bas_sheep ram on ram.id = CAST(temp.ram_id AS UNSIGNED)
|
||||
left join bas_sheep_variety ram_variety on ram.variety_id = ram_variety.id
|
||||
left join bas_sheep_type ram_type on ram.type_id = ram_type.id
|
||||
where temp.plan_generate_id = #{planGenerateId}
|
||||
order by temp.ram_id, temp.ewe_id
|
||||
order by temp.ewe_id, temp.ram_id
|
||||
</select>
|
||||
|
||||
<!-- 获取审批详情 - 包含完整的母羊和公羊信息 -->
|
||||
<select id="selectApproveBreedPlanDetails" parameterType="Long" resultType="Map">
|
||||
select
|
||||
temp.id,
|
||||
temp.ram_id,
|
||||
temp.ewe_id,
|
||||
temp.breed_type,
|
||||
-- 母羊信息
|
||||
ewe.manage_tags as ewe_manage_tags,
|
||||
ewe_variety.variety as ewe_variety,
|
||||
ewe.family as ewe_family,
|
||||
ewe_type.name as ewe_sheep_type,
|
||||
ewe_breed.breed as ewe_breed_status,
|
||||
ewe.parity as ewe_parity,
|
||||
TIMESTAMPDIFF(MONTH, ewe.birthday, NOW()) as ewe_month_age,
|
||||
ewe.current_weight as ewe_current_weight,
|
||||
CASE WHEN ewe.is_core = 1 THEN 1 ELSE 0 END as ewe_is_core,
|
||||
CASE WHEN ewe.is_breeding = 1 THEN 1 ELSE 0 END as ewe_is_breeding,
|
||||
ewe_sheepfold.sheepfold_name as ewe_sheepfold_name,
|
||||
ewe.comment as ewe_comment,
|
||||
CONCAT('胎次:', IFNULL(ewe.parity, 0), ' 配种次数:', IFNULL(ewe.mating_counts, 0)) as ewe_reproduction_info,
|
||||
-- 公羊信息 - 直接关联查询耳号
|
||||
ram.manage_tags as ram_manage_tags,
|
||||
ram_variety.variety as ram_variety,
|
||||
ram.family as ram_family,
|
||||
ram_type.name as ram_sheep_type,
|
||||
ram.birthday as ram_birthday,
|
||||
TIMESTAMPDIFF(MONTH, ram.birthday, NOW()) as ram_month_age,
|
||||
ram.current_weight as ram_current_weight
|
||||
from sc_breed_plan_temp temp
|
||||
left join bas_sheep ewe on ewe.id = CAST(temp.ewe_id AS UNSIGNED)
|
||||
left join bas_sheep_variety ewe_variety on ewe.variety_id = ewe_variety.id
|
||||
left join bas_sheep_type ewe_type on ewe.type_id = ewe_type.id
|
||||
left join bas_breed_status ewe_breed on ewe.breed_status_id = ewe_breed.id
|
||||
left join da_sheepfold ewe_sheepfold on ewe.sheepfold_id = ewe_sheepfold.id
|
||||
left join bas_sheep ram on ram.id = CAST(temp.ram_id AS UNSIGNED)
|
||||
left join bas_sheep_variety ram_variety on ram.variety_id = ram_variety.id
|
||||
left join bas_sheep_type ram_type on ram.type_id = ram_type.id
|
||||
where temp.plan_generate_id = #{planGenerateId}
|
||||
order by temp.ewe_id, temp.ram_id
|
||||
</select>
|
||||
|
||||
<!-- 更新临时配种计划 -->
|
||||
<update id="updateTempBreedPlan">
|
||||
update sc_breed_plan_temp
|
||||
<set>
|
||||
<if test="ramId != null">
|
||||
ram_id = #{ramId},
|
||||
</if>
|
||||
<if test="ramId == null">
|
||||
ram_id = null,
|
||||
</if>
|
||||
<if test="breedType != null">
|
||||
breed_type = #{breedType},
|
||||
</if>
|
||||
<if test="breedType == null">
|
||||
breed_type = null,
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScBreedPlanGenerateById" parameterType="Long">
|
||||
delete from sc_breed_plan_generate where id = #{id}
|
||||
</delete>
|
||||
@@ -205,4 +305,9 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 删除临时配种计划 -->
|
||||
<delete id="deleteTempBreedPlanByPlanId" parameterType="Long">
|
||||
delete from sc_breed_plan_temp where plan_generate_id = #{planGenerateId}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -11,9 +11,10 @@
|
||||
<result property="eweId" column="ewe_id" />
|
||||
<result property="technician" column="technician" />
|
||||
<result property="breedDrugs" column="breed_drugs" />
|
||||
<result property="breedType" column="breed_type" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<!-- 新增显示字段 -->
|
||||
<!-- 显示字段 -->
|
||||
<result property="eweManageTags" column="ewe_manage_tags" />
|
||||
<result property="eweVariety" column="ewe_variety" />
|
||||
<result property="ramManageTags" column="ram_manage_tags" />
|
||||
@@ -29,6 +30,16 @@
|
||||
<result property="sheepType" column="sheep_type" />
|
||||
<result property="matingCount" column="mating_count" />
|
||||
<result property="timeSincePlanning" column="time_since_planning" />
|
||||
<!-- 孕检相关字段 -->
|
||||
<result property="pregnancyCheckDate" column="pregnancy_check_date" />
|
||||
<result property="pregnancyResult" column="pregnancy_result" />
|
||||
<result property="pregnancyWay" column="pregnancy_way" />
|
||||
<result property="fetusCount" column="fetus_count" />
|
||||
<result property="pregnancyTechnician" column="pregnancy_technician" />
|
||||
<result property="pregnancyRemark" column="pregnancy_remark" />
|
||||
<result property="pregnancyRecordId" column="pregnancy_record_id" />
|
||||
<result property="daysToPregnancyCheck" column="days_to_pregnancy_check" />
|
||||
<result property="isPregnancyChecked" column="is_pregnancy_checked" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectScBreedRecordVo">
|
||||
@@ -39,6 +50,7 @@
|
||||
br.ewe_id,
|
||||
br.technician,
|
||||
br.breed_drugs,
|
||||
br.breed_type,
|
||||
br.create_by,
|
||||
br.create_time,
|
||||
-- 母羊信息(从视图获取)
|
||||
@@ -56,13 +68,45 @@
|
||||
-- 公羊信息(从视图获取)
|
||||
ram_view.bs_manage_tags as ram_manage_tags,
|
||||
ram_view.variety as ram_variety,
|
||||
-- 配种方式(如果视图中没有,设为空或从其他地方获取)
|
||||
'' as mating_type,
|
||||
-- 配种方式显示
|
||||
CASE br.breed_type
|
||||
WHEN 1 THEN '同期发情'
|
||||
WHEN 2 THEN '本交'
|
||||
ELSE '未知'
|
||||
END as mating_type,
|
||||
-- 发情后配种时间(小时数)
|
||||
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning
|
||||
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,
|
||||
-- 孕检相关信息
|
||||
pr.datetime as pregnancy_check_date,
|
||||
pr.result as pregnancy_result,
|
||||
pr.way as pregnancy_way,
|
||||
pr.fetus_count,
|
||||
pr.technician as pregnancy_technician,
|
||||
pr.remark as pregnancy_remark,
|
||||
pr.id as pregnancy_record_id,
|
||||
-- 配种到孕检间隔天数
|
||||
CASE
|
||||
WHEN pr.datetime IS NOT NULL THEN DATEDIFF(pr.datetime, br.create_time)
|
||||
ELSE NULL
|
||||
END as days_to_pregnancy_check,
|
||||
-- 是否已孕检
|
||||
CASE
|
||||
WHEN pr.id IS NOT NULL THEN 1
|
||||
ELSE 0
|
||||
END as is_pregnancy_checked
|
||||
from sc_breed_record br
|
||||
left join sheep_file ewe_view on br.ewe_id = ewe_view.id
|
||||
left join sheep_file ram_view on br.ram_id = ram_view.id
|
||||
left join sc_pregnancy_record pr on pr.sheep_id = br.ewe_id
|
||||
and pr.is_delete = 0
|
||||
and pr.datetime >= br.create_time
|
||||
and pr.datetime = (
|
||||
select min(pr2.datetime)
|
||||
from sc_pregnancy_record pr2
|
||||
where pr2.sheep_id = br.ewe_id
|
||||
and pr2.is_delete = 0
|
||||
and pr2.datetime >= br.create_time
|
||||
)
|
||||
</sql>
|
||||
|
||||
<select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">
|
||||
@@ -71,6 +115,7 @@
|
||||
<if test="sheepId != null "> and br.sheep_id = #{sheepId}</if>
|
||||
<if test="ramId != null and ramId != ''"> and br.ram_id = #{ramId}</if>
|
||||
<if test="eweId != null and eweId != ''"> and br.ewe_id = #{eweId}</if>
|
||||
<if test="breedType != null"> and br.breed_type = #{breedType}</if>
|
||||
<if test="technician != null and technician != ''"> and br.technician like concat('%', #{technician}, '%')</if>
|
||||
<if test="breedDrugs != null and breedDrugs != ''"> and br.breed_drugs like concat('%', #{breedDrugs}, '%')</if>
|
||||
<if test="createBy != null and createBy != ''"> and br.create_by like concat('%', #{createBy}, '%')</if>
|
||||
@@ -81,6 +126,12 @@
|
||||
<if test="eweVariety != null and eweVariety != ''"> and ewe_view.variety like concat('%', #{eweVariety}, '%')</if>
|
||||
<if test="ramVariety != null and ramVariety != ''"> and ram_view.variety like concat('%', #{ramVariety}, '%')</if>
|
||||
<if test="ranchId != null"> and ewe_view.ranch_id = #{ranchId}</if>
|
||||
<!-- 孕检相关查询条件 -->
|
||||
<if test="pregnancyResult != null and pregnancyResult != ''"> and pr.result like concat('%', #{pregnancyResult}, '%')</if>
|
||||
<if test="isPregnancyChecked != null">
|
||||
<if test="isPregnancyChecked == 1"> and pr.id IS NOT NULL</if>
|
||||
<if test="isPregnancyChecked == 0"> and pr.id IS NULL</if>
|
||||
</if>
|
||||
</where>
|
||||
order by br.create_time desc
|
||||
</select>
|
||||
@@ -170,19 +221,43 @@
|
||||
ewe_view.bs_manage_tags as ewe_manage_tags,
|
||||
bp.ram_id,
|
||||
ram_view.bs_manage_tags as ram_manage_tags,
|
||||
bp.plan_date,
|
||||
bp.breed_type,
|
||||
bp.technician,
|
||||
bp.status,
|
||||
bp.create_time as plan_create_time,
|
||||
TIMESTAMPDIFF(HOUR, bp.create_time, NOW()) as hours_since_plan
|
||||
CASE bp.breed_type
|
||||
WHEN 1 THEN '同期发情'
|
||||
WHEN 2 THEN '本交'
|
||||
ELSE '未知'
|
||||
END as breed_type_name,
|
||||
TIMESTAMPDIFF(HOUR, NOW(), NOW()) as hours_since_plan
|
||||
from sc_breed_plan bp
|
||||
left join sheep_file ewe_view on bp.ewe_id = ewe_view.id
|
||||
left join sheep_file ram_view on bp.ram_id = ram_view.id
|
||||
where ewe_view.bs_manage_tags = #{manageTags}
|
||||
and bp.status = '待配种'
|
||||
and bp.is_delete = 0
|
||||
order by bp.create_time desc
|
||||
order by bp.id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 根据母羊耳号获取最新的配种计划信息(从配种计划生成表) -->
|
||||
<select id="getLatestBreedPlanByEweTags" parameterType="String" resultType="map">
|
||||
select
|
||||
bpg.id as plan_generate_id,
|
||||
bpt.ewe_id,
|
||||
ewe_view.bs_manage_tags as ewe_manage_tags,
|
||||
bpt.ram_id,
|
||||
ram_view.bs_manage_tags as ram_manage_tags,
|
||||
bpt.breed_type,
|
||||
CASE bpt.breed_type
|
||||
WHEN 1 THEN '同期发情'
|
||||
WHEN 2 THEN '本交'
|
||||
ELSE '未知'
|
||||
END as breed_type_name,
|
||||
bpg.create_time as plan_create_time
|
||||
from sc_breed_plan_generate bpg
|
||||
inner join sc_breed_plan_temp bpt on bpg.id = bpt.plan_generate_id
|
||||
left join sheep_file ewe_view on bpt.ewe_id = ewe_view.id
|
||||
left join sheep_file ram_view on bpt.ram_id = ram_view.id
|
||||
where ewe_view.bs_manage_tags = #{manageTags}
|
||||
and bpg.status = 1 -- 已审批的计划
|
||||
order by bpg.create_time desc, bpt.id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
@@ -194,6 +269,7 @@
|
||||
<if test="eweId != null">ewe_id,</if>
|
||||
<if test="technician != null">technician,</if>
|
||||
<if test="breedDrugs != null">breed_drugs,</if>
|
||||
<if test="breedType != null">breed_type,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
@@ -203,6 +279,7 @@
|
||||
<if test="eweId != null">#{eweId},</if>
|
||||
<if test="technician != null">#{technician},</if>
|
||||
<if test="breedDrugs != null">#{breedDrugs},</if>
|
||||
<if test="breedType != null">#{breedType},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
@@ -216,6 +293,7 @@
|
||||
<if test="eweId != null">ewe_id = #{eweId},</if>
|
||||
<if test="technician != null">technician = #{technician},</if>
|
||||
<if test="breedDrugs != null">breed_drugs = #{breedDrugs},</if>
|
||||
<if test="breedType != null">breed_type = #{breedType},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
@@ -232,4 +310,26 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 根据羊只ID和配种时间查询配种记录 -->
|
||||
<select id="selectBreedRecordByMatingTime" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
<where>
|
||||
<if test="sheepId != null">and br.ewe_id = #{sheepId}</if>
|
||||
<if test="matingDateStart != null and matingDateStart != ''">
|
||||
and br.create_time >= #{matingDateStart}
|
||||
</if>
|
||||
<if test="matingDateEnd != null and matingDateEnd != ''">
|
||||
and br.create_time <= #{matingDateEnd}
|
||||
</if>
|
||||
</where>
|
||||
order by br.create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 更新配种记录的孕检信息 -->
|
||||
<update id="updatePregnancyInfo">
|
||||
update sc_breed_record
|
||||
set pregnancy_record_id = #{pregnancyRecordId}
|
||||
where id = #{breedRecordId}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -15,6 +15,7 @@
|
||||
<result property="score" column="score" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<!-- 修复:数据库字段是create_tme,不是create_time -->
|
||||
<result property="createTime" column="create_tme" />
|
||||
</resultMap>
|
||||
|
||||
@@ -66,42 +67,47 @@
|
||||
lr.id, lr.sheep_id, lr.parity, lr.lambs_born, lr.survival,
|
||||
lr.technician, lr.score, lr.comment, lr.create_by, lr.create_tme,
|
||||
|
||||
-- 从bas_sheep表获取母羊信息
|
||||
mother.manage_tags as female_ear_number,
|
||||
mother.variety_id as female_breed,
|
||||
TIMESTAMPDIFF(MONTH, mother.birthday, NOW()) as month_age,
|
||||
mother.sheepfold_id as current_shed,
|
||||
mother.ranch_id as farm,
|
||||
-- 从sheep_file视图获取母羊信息
|
||||
mother.bs_manage_tags as female_ear_number,
|
||||
mother.variety as female_breed,
|
||||
mother.month_age as month_age,
|
||||
mother.sheepfold_name as current_shed,
|
||||
mother.dr_ranch as farm,
|
||||
|
||||
-- 从sc_breed_record表获取配种信息
|
||||
br.create_time as breeding_date,
|
||||
DATEDIFF(lr.create_tme, br.create_time) as pregnancy_days,
|
||||
DATEDIFF(CURDATE(), br.create_time) as pregnancy_days,
|
||||
|
||||
-- 从bas_sheep表获取公羊信息
|
||||
father.manage_tags as male_ear_number,
|
||||
father.variety_id as male_breed,
|
||||
-- 从sheep_file视图获取公羊信息
|
||||
father.bs_manage_tags as male_ear_number,
|
||||
father.variety as male_breed,
|
||||
|
||||
-- 统计羔羊信息(从bas_sheep表统计,根据母羊ID)
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.is_delete = 0) as male_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.is_delete = 0) as female_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.status_id = 1 AND lamb.is_delete = 0) as retained_male_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.status_id = 1 AND lamb.is_delete = 0) as retained_female_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.status_id != 1 AND lamb.is_delete = 0) as unretained_male_count,
|
||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.status_id != 1 AND lamb.is_delete = 0) as unretained_female_count
|
||||
-- 统计羔羊信息(从sc_lamb_detail表统计)
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1) as male_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0) as female_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1 AND sld.is_retained = 1) as retained_male_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0 AND sld.is_retained = 1) as retained_female_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1 AND sld.is_retained = 0) as unretained_male_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0 AND sld.is_retained = 0) as unretained_female_count
|
||||
|
||||
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
|
||||
LEFT JOIN sheep_file mother ON lr.sheep_id = mother.id
|
||||
LEFT JOIN sc_breed_record br ON lr.sheep_id = br.ewe_id AND br.create_time = (
|
||||
SELECT MAX(br2.create_time)
|
||||
FROM sc_breed_record br2
|
||||
WHERE br2.ewe_id = lr.sheep_id
|
||||
AND br2.create_time <= lr.create_tme
|
||||
)
|
||||
LEFT JOIN sheep_file father ON br.ram_id = father.id
|
||||
</sql>
|
||||
|
||||
<!-- 查询产羔记录列表(包含关联信息) -->
|
||||
<select id="selectScLambingRecordList" parameterType="ScLambingRecord" resultMap="ScLambingRecordDetailResult">
|
||||
<include refid="selectScLambingRecordDetailVo"/>
|
||||
<where>
|
||||
<if test="femaleEarNumber != null and femaleEarNumber != ''"> and mother.manage_tags LIKE CONCAT('%', #{femaleEarNumber}, '%')</if>
|
||||
<if test="femaleBreed != null and femaleBreed != ''"> and mother.variety_id = #{femaleBreed}</if>
|
||||
<if test="farm != null and farm != ''"> and mother.ranch_id = #{farm}</if>
|
||||
<if test="femaleEarNumber != null and femaleEarNumber != ''"> and mother.bs_manage_tags LIKE CONCAT('%', #{femaleEarNumber}, '%')</if>
|
||||
<if test="femaleBreed != null and femaleBreed != ''"> and mother.variety LIKE CONCAT('%', #{femaleBreed}, '%')</if>
|
||||
<if test="farm != null and farm != ''"> and mother.dr_ranch LIKE CONCAT('%', #{farm}, '%')</if>
|
||||
<if test="sheepId != null and sheepId != ''"> and lr.sheep_id = #{sheepId}</if>
|
||||
<if test="parity != null"> and lr.parity = #{parity}</if>
|
||||
<if test="lambsBorn != null"> and lr.lambs_born = #{lambsBorn}</if>
|
||||
@@ -134,23 +140,29 @@
|
||||
where lr.id = #{id} and mother.is_delete = 0
|
||||
</select>
|
||||
|
||||
<!-- 查询羔羊详情(从sc_lamb_detail表查询) -->
|
||||
<select id="selectLambDetailByLambingRecordId" parameterType="Long" resultType="ScLambDetail">
|
||||
<!-- 根据母羊耳号查询最新配种记录 -->
|
||||
<select id="getLatestBreedingByEarNumber" parameterType="String" resultType="java.util.Map">
|
||||
SELECT
|
||||
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
|
||||
sf.id as sheep_id,
|
||||
sf.bs_manage_tags as female_ear_number,
|
||||
sf.variety as female_breed,
|
||||
sf.parity as parity,
|
||||
br.ram_id as ram_id,
|
||||
ram.bs_manage_tags as male_ear_number,
|
||||
ram.variety as male_breed,
|
||||
br.create_time as breeding_date,
|
||||
DATEDIFF(CURDATE(), br.create_time) as pregnancy_days,
|
||||
br.technician as technician
|
||||
FROM sheep_file sf
|
||||
LEFT JOIN sc_breed_record br ON sf.id = br.ewe_id
|
||||
LEFT JOIN sheep_file ram ON br.ram_id = ram.id
|
||||
WHERE sf.bs_manage_tags = #{earNumber}
|
||||
AND sf.is_delete = 0
|
||||
AND br.create_time = (
|
||||
SELECT MAX(br2.create_time)
|
||||
FROM sc_breed_record br2
|
||||
WHERE br2.ewe_id = sf.id
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 新增产羔记录 -->
|
||||
@@ -191,8 +203,8 @@
|
||||
<if test="technician != null">technician = #{technician},</if>
|
||||
<if test="score != null">score = #{score},</if>
|
||||
<if test="comment != null">comment = #{comment},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_tme = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
Reference in New Issue
Block a user