班次奶量
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?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.dairyProducts.mapper.NpMilkInOutStoreMapper">
|
||||
<select id="selectWithColumns" resultType="map">
|
||||
SELECT s.datetime, s.num, s.colost_sheep, s.commercial_intake, s.anti_intake,
|
||||
s.colost_intake, s.intake_total, s.commercial_test, s.colost_test,
|
||||
s.transfer_commercial, s.transfer_anti, s.transfer_colost, s.transfer_total,
|
||||
s.loss, s.stock_commercial, s.stock_anti, s.colost, s.return_fresh, s.return_yogurt
|
||||
<foreach collection="feedSources" item="f" open="," separator="," close="">
|
||||
SUM(CASE WHEN fr.source_id = (SELECT id FROM np_milk_feed WHERE source_name = #{f}) THEN fr.amount ELSE NULL END) AS `${f}`
|
||||
</foreach>
|
||||
<foreach collection="saleDestinations" item="d" open="," separator="," close="">
|
||||
SUM(CASE WHEN sr.destination_id = (SELECT id FROM np_milk_sale WHERE destination_name = #{d}) THEN sr.amount ELSE NULL END) AS `${d}`
|
||||
</foreach>
|
||||
FROM np_milk_in_out_store s
|
||||
LEFT JOIN np_milk_feed_records fr ON fr.store_id = s.id
|
||||
LEFT JOIN np_milk_sale_records sr ON sr.store_id = s.id
|
||||
<where>
|
||||
<if test="start != null"> s.datetime >= #{start}</if>
|
||||
<if test="end != null"> AND s.datetime <= #{end}</if>
|
||||
</where>
|
||||
GROUP BY s.id
|
||||
ORDER BY s.datetime
|
||||
</select>
|
||||
|
||||
<select id="selectFeedSources" resultType="string">SELECT source_name FROM np_milk_feed</select>
|
||||
<select id="selectSaleDestinations" resultType="string">SELECT destination_name FROM np_milk_sale</select>
|
||||
|
||||
<insert id="insertStore" useGeneratedKeys="true" keyProperty="id" parameterType="com.zhyc.module.dairyProducts.domain.NpMilkInOutStore">
|
||||
INSERT INTO np_milk_in_out_store(datetime, num, colost_sheep, commercial_intake, anti_intake,
|
||||
colost_intake, intake_total, commercial_test, colost_test, transfer_commercial,
|
||||
transfer_anti, transfer_colost, transfer_total, loss, stock_commercial,
|
||||
stock_anti, colost, return_fresh, return_yogurt)
|
||||
VALUES (
|
||||
#{datetime}, #{num}, #{colostSheep}, #{commercialIntake}, #{antiIntake},
|
||||
#{colostIntake}, #{intakeTotal}, #{commercialTest}, #{colostTest},
|
||||
#{transferCommercial}, #{transferAnti}, #{transferColost}, #{transferTotal},
|
||||
#{loss}, #{stockCommercial}, #{stockAnti}, #{colost}, #{returnFresh}, #{returnYogurt}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertFeedRecord">
|
||||
INSERT INTO np_milk_feed_records(store_id, source_id, amount)
|
||||
VALUES(#{storeId},
|
||||
(SELECT id FROM np_milk_feed WHERE source_name = #{source}),
|
||||
#{amount})
|
||||
</insert>
|
||||
|
||||
<insert id="insertSaleRecord">
|
||||
INSERT INTO np_milk_sale_records(store_id, destination_id, amount)
|
||||
VALUES(#{storeId},
|
||||
(SELECT id FROM np_milk_sale WHERE destination_name = #{destination}),
|
||||
#{amount})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,152 @@
|
||||
<?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.dairyProducts.mapper.NpSheepMilkAnalysisMapper">
|
||||
|
||||
<resultMap id="NpSheepMilkAnalysisResultMap" type="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||
<id column="id" property="id"/>
|
||||
<result column="manage_ear_tag" property="manageEarTag"/>
|
||||
<result column="variety" property="variety"/>
|
||||
<result column="milking_date" property="milkingDate"/>
|
||||
<result column="dry_date" property="dryDate"/>
|
||||
<result column="milking_days" property="milkingDays"/>
|
||||
<result column="max_parity" property="maxParity"/>
|
||||
<result column="total_milk" property="totalMilk"/>
|
||||
<result column="total_corrected_milk" property="totalCorrectedMilk"/>
|
||||
<result column="avg_daily_corrected_milk" property="avgDailyCorrectedMilk"/>
|
||||
<result column="parity1_total_milk" property="parity1TotalMilk"/>
|
||||
<result column="parity2_total_milk" property="parity2TotalMilk"/>
|
||||
<result column="parity3_total_milk" property="parity3TotalMilk"/>
|
||||
<result column="parity4_total_milk" property="parity4TotalMilk"/>
|
||||
<result column="parity1_avg_milk" property="parity1AvgMilk"/>
|
||||
<result column="parity2_avg_milk" property="parity2AvgMilk"/>
|
||||
<result column="parity3_avg_milk" property="parity3AvgMilk"/>
|
||||
<result column="parity4_avg_milk" property="parity4AvgMilk"/>
|
||||
<result column="lactation_days" property="lactationDays"/>
|
||||
<result column="last_7_avg_milk" property="last7AvgMilk"/>
|
||||
<result column="last_7_corrected_milk" property="last7CorrectedMilk"/>
|
||||
<result column="last_14_avg_milk" property="last14AvgMilk"/>
|
||||
<result column="last_30_avg_milk" property="last30AvgMilk"/>
|
||||
<result column="sheep_type" property="sheepType"/>
|
||||
<result column="birthday" property="birthday"/>
|
||||
<result column="current_parity" property="currentParity"/>
|
||||
<result column="month_age" property="monthAge"/>
|
||||
<result column="current_weight" property="currentWeight"/>
|
||||
<result column="breed_status" property="breedStatus"/>
|
||||
<result column="father_tag" property="fatherTag"/>
|
||||
<result column="mother_tag" property="motherTag"/>
|
||||
<result column="ranch" property="ranch"/>
|
||||
<result column="family" property="family"/>
|
||||
<result column="mother_milking_days" property="motherMilkingDays"/>
|
||||
<result column="mother_total_corrected_milk" property="motherTotalCorrectedMilk"/>
|
||||
<result column="mother_max_parity" property="motherMaxParity"/>
|
||||
<result column="mother_avg_corrected" property="motherAvgCorrected"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, manage_ear_tag, variety, milking_date, dry_date, milking_days,
|
||||
screen_days, max_parity, total_milk, total_corrected_milk,
|
||||
avg_daily_corrected_milk, parity1_total_milk, parity2_total_milk,
|
||||
parity3_total_milk, parity4_total_milk, parity1_avg_milk,
|
||||
parity2_avg_milk, parity3_avg_milk, parity4_avg_milk,
|
||||
lactation_days, last_7_avg_milk, last_7_corrected_milk,
|
||||
last_14_avg_milk, last_30_avg_milk, sheep_type, birthday,
|
||||
current_parity, month_age, current_weight, breed_status,
|
||||
father_tag, mother_tag, ranch, family, mother_milking_days,
|
||||
mother_total_corrected_milk, mother_max_parity,
|
||||
mother_avg_corrected
|
||||
</sql>
|
||||
|
||||
<select id="selectNpSheepMilkAnalysisById" resultMap="NpSheepMilkAnalysisResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM np_sheep_milk_analysis
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectNpSheepMilkAnalysisList" resultMap="NpSheepMilkAnalysisResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM np_sheep_milk_analysis
|
||||
<where>
|
||||
<if test="manageEarTag != null and manageEarTag != ''">
|
||||
AND manage_ear_tag LIKE CONCAT('%', #{manageEarTag}, '%')
|
||||
</if>
|
||||
<!-- 可继续添加其他搜索条件 -->
|
||||
</where>
|
||||
ORDER BY milking_date DESC
|
||||
</select>
|
||||
|
||||
<insert id="insertNpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||
INSERT INTO np_sheep_milk_analysis (
|
||||
<include refid="Base_Column_List"/>
|
||||
) VALUES (
|
||||
#{id}, #{manageEarTag}, #{variety}, #{milkingDate}, #{dryDate},
|
||||
#{milkingDays}, #{screenDays}, #{maxParity}, #{totalMilk},
|
||||
#{totalCorrectedMilk}, #{avgDailyCorrectedMilk}, #{parity1TotalMilk},
|
||||
#{parity2TotalMilk}, #{parity3TotalMilk}, #{parity4TotalMilk},
|
||||
#{parity1AvgMilk}, #{parity2AvgMilk}, #{parity3AvgMilk},
|
||||
#{parity4AvgMilk}, #{lactationDays}, #{last7AvgMilk},
|
||||
#{last7CorrectedMilk}, #{last14AvgMilk}, #{last30AvgMilk},
|
||||
#{sheepType}, #{birthday}, #{currentParity}, #{monthAge},
|
||||
#{currentWeight}, #{breedStatus}, #{fatherTag}, #{motherTag},
|
||||
#{ranch}, #{family}, #{motherMilkingDays},
|
||||
#{motherTotalCorrectedMilk}, #{motherMaxParity},
|
||||
#{motherAvgCorrected}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateNpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||
UPDATE np_sheep_milk_analysis
|
||||
SET manage_ear_tag = #{manageEarTag},
|
||||
variety = #{variety},
|
||||
milking_date = #{milkingDate},
|
||||
dry_date = #{dryDate},
|
||||
milking_days = #{milkingDays},
|
||||
screen_days = #{screenDays},
|
||||
max_parity = #{maxParity},
|
||||
total_milk = #{totalMilk},
|
||||
total_corrected_milk = #{totalCorrectedMilk},
|
||||
avg_daily_corrected_milk = #{avgDailyCorrectedMilk},
|
||||
parity1_total_milk = #{parity1TotalMilk},
|
||||
parity2_total_milk = #{parity2TotalMilk},
|
||||
parity3_total_milk = #{parity3TotalMilk},
|
||||
parity4_total_milk = #{parity4TotalMilk},
|
||||
parity1_avg_milk = #{parity1AvgMilk},
|
||||
parity2_avg_milk = #{parity2AvgMilk},
|
||||
parity3_avg_milk = #{parity3AvgMilk},
|
||||
parity4_avg_milk = #{parity4AvgMilk},
|
||||
lactation_days = #{lactationDays},
|
||||
last_7_avg_milk = #{last7AvgMilk},
|
||||
last_7_corrected_milk = #{last7CorrectedMilk},
|
||||
last_14_avg_milk = #{last14AvgMilk},
|
||||
last_30_avg_milk = #{last30AvgMilk},
|
||||
sheep_type = #{sheepType},
|
||||
birthday = #{birthday},
|
||||
current_parity = #{currentParity},
|
||||
month_age = #{monthAge},
|
||||
current_weight = #{currentWeight},
|
||||
breed_status = #{breedStatus},
|
||||
father_tag = #{fatherTag},
|
||||
mother_tag = #{motherTag},
|
||||
ranch = #{ranch},
|
||||
family = #{family},
|
||||
mother_milking_days = #{motherMilkingDays},
|
||||
mother_total_corrected_milk = #{motherTotalCorrectedMilk},
|
||||
mother_max_parity = #{motherMaxParity},
|
||||
mother_avg_corrected = #{motherAvgCorrected}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteNpSheepMilkAnalysisById" parameterType="Long">
|
||||
DELETE FROM np_sheep_milk_analysis WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteNpSheepMilkAnalysisByIds" parameterType="Long">
|
||||
DELETE FROM np_sheep_milk_analysis WHERE id IN
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user