Merge remote-tracking branch 'origin/main'

This commit is contained in:
2026-01-22 19:59:01 +08:00
27 changed files with 216 additions and 85 deletions

View File

@@ -19,14 +19,13 @@
SELECT
mpc.id,
mpc.datetime,
v.bs_manage_tags, <!-- 取消别名,使用原列名 -->
v.bs_manage_tags,
v.electronic_tags,
v.parity,
v.dr_ranch,
mpc.classes,
mpc.milk,
mpc.corrected_milk AS corrected_milk
<!-- 修改为与 resultMap 对应的列名 -->
FROM np_milk_prod_classes mpc
JOIN sheep_file v ON mpc.sheep_id = v.id
LEFT JOIN xz_wegih_correction wc ON DATE(mpc.datetime) = DATE(wc.datetime) AND v.dr_ranch = wc.factory
@@ -39,19 +38,34 @@
<if test="datetimeEnd != null">
AND mpc.datetime &lt;= #{datetimeEnd}
</if>
<if test="manageEarNo != null and manageEarNo != ''">
AND v.bs_manage_tags LIKE CONCAT('%', #{manageEarNo}, '%')
<if test="npMilkProdClasses.allEarNumbers != null and npMilkProdClasses.allEarNumbers.size() > 0">
AND (
v.bs_manage_tags IN
<foreach collection="npMilkProdClasses.allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<if test="factory != null and factory != ''">
AND v.dr_ranch = #{factory}
<if test="npMilkProdClasses.factory != null and npMilkProdClasses.factory != ''">
AND v.dr_ranch = #{npMilkProdClasses.factory}
</if>
<if test="classes != null">
AND mpc.classes = #{classes}
<if test="npMilkProdClasses.classes != null">
AND mpc.classes = #{npMilkProdClasses.classes}
</if>
</where>
</select>
<!-- 称重矫正系数 -->
<select id="searchEarNumbers" resultType="java.lang.String">
SELECT DISTINCT sf.bs_manage_tags
FROM sheep_file sf
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
AND sf.is_delete = 0
ORDER BY sf.bs_manage_tags
LIMIT 50
</select>
<select id="getWeightCorrection" resultType="java.lang.Double">
SELECT actual / system_milk
FROM xz_wegih_correction
@@ -60,7 +74,6 @@
AND system_milk > 0
</select>
<!-- 胎次矫正系数 -->
<select id="getParityCorrection" resultType="java.lang.Double">
SELECT
CASE
@@ -72,7 +85,6 @@
WHERE parity = #{parity}
</select>
<!-- 干物质矫正系数 -->
<select id="getDryMatterCorrection" resultType="java.lang.Double">
SELECT coefficient
FROM xz_dry_matter_correction
@@ -90,4 +102,4 @@
FROM sheep_file
WHERE bs_manage_tags = #{manageEarNo}
</select>
</mapper>
</mapper>

View File

@@ -4,8 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.dairyProducts.mapper.NpSheepMilkAnalysisMapper">
<!-- 1) 获取distinct sheep_id支持按sheep_file.bs_manage_tags模糊搜索 -->
<select id="selectDistinctSheepIds" resultType="string" parameterType="map">
<select id="selectDistinctSheepIds" resultType="string" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
SELECT DISTINCT a.sheep_id
FROM np_milk_prod_classes a
LEFT JOIN sheep_file sf ON a.sheep_id = sf.id
@@ -13,12 +12,27 @@
<if test="manageEarTag != null and manageEarTag != ''">
AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%')
</if>
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
sf.bs_manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
</where>
ORDER BY a.sheep_id
</select>
<!-- 2) 获取某只羊的所有班次记录(按班次日期升序) -->
<!-- 假设表中字段class_date, system_milk, corrected_milk, parity -->
<select id="searchEarNumbers" resultType="java.lang.String">
SELECT DISTINCT sf.bs_manage_tags
FROM sheep_file sf
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
AND sf.is_delete = 0
ORDER BY sf.bs_manage_tags
LIMIT 50
</select>
<select id="selectMilkRecordsBySheepId" resultType="map" parameterType="string">
SELECT
datetime AS classDate,
@@ -30,8 +44,6 @@
ORDER BY datetime ASC
</select>
<!-- 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,
@@ -52,27 +64,30 @@
WHERE id = #{sheepId}
</select>
<!-- 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>
<!-- 5) 导出奶产量分析记录 -->
<select id="selectNpSheepMilkAnalysisForExport" resultType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
<!-- 这里需要根据实际表结构编写SQL查询 -->
<!-- 示例SQL需要根据实际表结构调整 -->
SELECT
sf.id as sheepId,
sf.bs_manage_tags as manageEarTag,
sf.variety,
<!-- 其他字段 -->
m.datetime as milkingStartTime
FROM sheep_file sf
LEFT JOIN np_milk_prod_classes m ON sf.id = m.sheep_id
<where>
<if test="manageEarTag != null and manageEarTag != ''">
AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%')
</if>
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
sf.bs_manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
</where>
GROUP BY sf.id
</select>

View File

@@ -19,9 +19,9 @@
<select id="selectSgFeedListList" parameterType="SgFeedList" resultMap="SgFeedListResult">
<include refid="selectSgFeedListVo"/>
<where>
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
<if test="formulaBatchId != null and formulaBatchId != ''"> and formula_batch_id = #{formulaBatchId}</if>
<if test="zookeeper != null and zookeeper != ''"> and zookeeper = #{zookeeper}</if>
<if test="formulaId != null and formulaId != ''"> and formula_id LIKE CONCAT('%',#{formulaId},'%')</if>
<if test="formulaBatchId != null and formulaBatchId != ''"> and formula_batch_id LIKE CONCAT('%',#{formulaBatchId},'%')</if>
<if test="zookeeper != null and zookeeper != ''"> and zookeeper LIKE CONCAT('%',#{zookeeper},'%')</if>
<if test="deployDate != null "> and deploy_date = #{deployDate}</if>
</where>
ORDER BY deploy_date ASC, formula_id ASC, formula_batch_id ASC

View File

@@ -36,9 +36,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSgFeedPlanList" parameterType="SgFeedPlan" resultMap="SgFeedPlanResult">
<include refid="selectSgFeedPlanVo"/>
<where>
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
<if test="batchId != null and batchId != ''"> and batch_id = #{batchId}</if>
<if test="sheepHouseId != null "> and sheep_house_id = #{sheepHouseId}</if>
<if test="formulaId != null and formulaId != ''"> and formula_id LIKE CONCAT('%',#{formulaId},'%')</if>
<if test="batchId != null and batchId != ''"> and batch_id LIKE CONCAT('%',#{batchId},'%')</if>
<if test="sheepHouseId != null "> and sheep_house_id LIKE CONCAT('%',#{sheepHouseId},'%')</if>
<if test="planDate != null "> and plan_date = #{planDate}</if>
</where>
ORDER BY plan_date ASC, formula_id ASC , batch_id ASC

View File

@@ -31,8 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSgFeedStatisticList" parameterType="SgFeedStatistic" resultMap="SgFeedStatisticResult">
<include refid="selectSgFeedStatisticVo"/>
<where>
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
<if test="formulaBatchId != null and formulaBatchId != ''"> and formula_batch_id = #{formulaBatchId}</if>
<if test="formulaId != null and formulaId != ''"> and formula_id LIKE CONCAT('%',#{formulaId},'%')</if>
<if test="formulaBatchId != null and formulaBatchId != ''"> and formula_batch_id = LIKE CONCAT('%',#{formulaBatchId},'%')</if>
<if test="silageLossRate != null and silageLossRate != ''"> and silage_loss_rate = #{silageLossRate}</if>
</where>
</select>

View File

@@ -22,9 +22,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSgFormulaListList" parameterType="SgFormulaList" resultMap="SgFormulaListResult">
<include refid="selectSgFormulaListVo"/>
<where>
<if test="materialId != null and materialId != ''">material_id = #{materialId}</if>
<if test="formulaId != null and formulaId != ''">and formula_id = #{formulaId}</if>
<if test="batchId != null and batchId != ''"> and batch_id = #{batchId}</if>
<if test="materialId != null and materialId != ''">material_id LIKE CONCAT('%',#{materialId},'%')</if>
<if test="formulaId != null and formulaId != ''">and formula_id LIKE CONCAT('%',#{formulaId},'%')</if>
<if test="batchId != null and batchId != ''"> and batch_id LIKE CONCAT('%',#{batchId},'%')</if>
</where>
</select>

View File

@@ -21,9 +21,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSgFormulaManagementList" parameterType="SgFormulaManagement" resultMap="SgFormulaManagementResult">
<include refid="selectSgFormulaManagementVo"/>
<where>
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
<if test="feedStage != null and feedStage != ''"> and feed_stage = #{feedStage}</if>
<if test="batchId != null and batchId != ''"> and batch_id = #{batchId}</if>
<if test="formulaId != null and formulaId != ''"> and formula_id LIKE CONCAT('%',#{formulaId},'%')</if>
<if test="feedStage != null and feedStage != ''"> and feed_stage LIKE CONCAT('%',#{feedStage},'%')</if>
<if test="batchId != null and batchId != ''"> and batch_id LIKE CONCAT('%',#{batchId},'%')</if>
</where>
</select>

View File

@@ -17,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSgMaterialList" parameterType="SgMaterial" resultMap="SgMaterialResult">
<include refid="selectSgMaterialVo"/>
<where>
<if test="materialId != null and materialId != ''"> and material_id = #{materialId}</if>
<if test="materialId != null and materialId != ''"> and material_id LIKE CONCAT('%',#{materialId},'%')</if>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="isGranular != null "> and is_granular = #{isGranular}</if>
</where>

View File

@@ -69,6 +69,7 @@
<if test="params.beginOutDate != null and params.endOutDate != null">
and out_date between #{params.beginOutDate} and #{params.endOutDate}
</if>
<if test="status != null and status != ''">and status = #{status}</if>
</where>
</select>

View File

@@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="params.beginOutDt != null and params.endOutDt != null">
and out_dt between #{params.beginOutDt} and #{params.endOutDt}
</if>
<if test="stat != null and stat != ''">and stat = #{stat}</if>
</where>
</select>