奶产量分析
This commit is contained in:
@@ -2,151 +2,61 @@
|
||||
<!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
|
||||
<!-- 1) 获取 distinct sheep_id(支持按 sheep_file.bs_manage_tags 模糊搜索) -->
|
||||
<select id="selectDistinctSheepIds" resultType="string" parameterType="map">
|
||||
SELECT DISTINCT a.sheep_id
|
||||
FROM np_milk_prod_classes a
|
||||
LEFT JOIN sheep_file sf ON a.sheep_id = sf.id
|
||||
<where>
|
||||
<if test="manageEarTag != null and manageEarTag != ''">
|
||||
AND manage_ear_tag LIKE CONCAT('%', #{manageEarTag}, '%')
|
||||
AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%')
|
||||
</if>
|
||||
<!-- 可继续添加其他搜索条件 -->
|
||||
</where>
|
||||
ORDER BY milking_date DESC
|
||||
ORDER BY a.sheep_id
|
||||
</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>
|
||||
<!-- 2) 获取某只羊的所有班次记录(按班次日期升序) -->
|
||||
<!-- 假设表中字段:class_date, system_milk, corrected_milk, parity -->
|
||||
<select id="selectMilkRecordsBySheepId" resultType="map" parameterType="string">
|
||||
SELECT
|
||||
datetime AS classDate,
|
||||
milk AS systemMilk,
|
||||
corrected_milk AS correctedMilk,
|
||||
classes AS parity
|
||||
FROM np_milk_prod_classes
|
||||
WHERE sheep_id = #{sheepId}
|
||||
ORDER BY datetime ASC
|
||||
</select>
|
||||
|
||||
<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>
|
||||
<!-- 3) 获取该羊在 sheep_file 视图中的基础信息 -->
|
||||
<!-- 假设字段名称:bs_manage_tags、variety、lactation_day、name、birthday、parity、month_age、current_weight、breed、father_manage_tags、mother_manage_tags、dr_ranch、family -->
|
||||
<select id="selectSheepFileBySheepId" resultType="map" parameterType="string">
|
||||
SELECT
|
||||
id AS sheep_id,
|
||||
bs_manage_tags AS manageEarTag,
|
||||
variety,
|
||||
lactation_day AS lactationDay,
|
||||
name AS sheepType,
|
||||
birthday,
|
||||
parity AS currentParity,
|
||||
month_age AS monthAge,
|
||||
current_weight AS currentWeight,
|
||||
breed AS breedStatus,
|
||||
father_manage_tags AS fatherManageTags,
|
||||
mother_manage_tags AS motherManageTags,
|
||||
dr_ranch AS ranchName,
|
||||
family
|
||||
FROM sheep_file
|
||||
WHERE id = #{sheepId}
|
||||
</select>
|
||||
|
||||
<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>
|
||||
<!-- 4) 兼容旧 list 查询(返回 domain 对象列表),但在我们的实现中 service 会构造最终的 NpSheepMilkAnalysis 列表 -->
|
||||
<select id="selectNpSheepMilkAnalysisList" resultType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||
<!-- 如果你仍需基于某张表的简单映射,可在此实现;当前我们在 ServiceImpl 中组装对象,所以该查询不做复杂实现 -->
|
||||
SELECT 1 FROM dual WHERE 1=0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user