From 742b6bbac1b4609386817a6e6fb489ec098a5490 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期二, 21 一月 2025 18:29:44 +0800
Subject: [PATCH] 重构获取分水房详情接口
---
pipIrr-platform/pipIrr-global/src/main/resources/mapper/StLossMonthMapper.xml | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 203 insertions(+), 1 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StLossMonthMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StLossMonthMapper.xml
index 4783b47..d11c76f 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StLossMonthMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StLossMonthMapper.xml
@@ -21,6 +21,22 @@
from st_loss_month
where id = #{id,jdbcType=BIGINT}
</select>
+ <select id="selectByIntakeIdAndYearAndMonth" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List" />
+ from st_loss_month
+ <where>
+ <if test="intakeId != null">
+ and `intake_id` = #{intakeId,jdbcType=BIGINT}
+ </if>
+ <if test="year != null">
+ and `year` = #{year,jdbcType=INTEGER}
+ </if>
+ <if test="month != null">
+ and `month` = #{month,jdbcType=INTEGER}
+ </if>
+ </where>
+ </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated-->
delete from st_loss_month
@@ -102,10 +118,196 @@
<select id="statisticsByIntake" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeLossStatistics">
- select intake_id, sum(amount) as amount
+ select intake_id as intakeId,
+ sum(amount) as amount
from st_loss_month
where `year` = #{year,jdbcType=INTEGER}
group by intake_id
</select>
+
+ <!-- 涓烘煡璇㈢粺璁″彇姘村彛鏃ユ紡鎹熼噺锛岀粺璁″彇姘村彛鏁伴噺 -->
+ <select id="selectIntakeCount4LossMonth" resultType="java.lang.Long">
+ SELECT COUNT(*)
+ FROM pr_intake tb
+ <where>
+ AND tb.deleted != 1
+ <if test="intakeNum != null and intakeNum != ''">
+ AND tb.name = #{intakeNum}
+ </if>
+ </where>
+ </select>
+
+ <!-- 涓烘煡璇㈢粺璁″彇姘村彛鏃ユ紡鎹熼噺锛屾煡璇竴椤靛彇姘村彛ID -->
+ <select id="selectIntakes4LossMonth" resultType="com.dy.pipIrrGlobal.voSt.VoMonthAmount">
+ SELECT id as intakeId,
+ name as intakeNum,
+ lat as intakeLat,
+ lng as intakeLng
+ FROM pr_intake
+ <where>
+ AND deleted != 1
+ <if test="intakeNum != null and intakeNum != ''">
+ AND name = #{intakeNum}
+ </if>
+ </where>
+ order by id DESC
+ <trim prefix="limit " >
+ <if test="start != null and count != null">
+ #{start, javaType=Integer, jdbcType=INTEGER}, #{count, javaType=Integer, jdbcType=INTEGER}
+ </if>
+ </trim>
+ </select>
+
+ <sql id="selectLossAmountOfMonth_with">
+ SELECT intaId.intakeId AS intakeId,
+ sld.year AS `year`,
+ sld.month AS `month`,
+ sld.amount AS amount
+ FROM JSON_TABLE(
+ #{intakesJson},
+ '$[*]' COLUMNS (
+ intakeId BIGINT PATH '$.intakeId'
+ )
+ ) intaId
+ INNER JOIN st_loss_month sld ON sld.intake_id = intaId.intakeId
+ <where>
+ <if test="year != null ">
+ AND sld.year = #{year, javaType=Integer, jdbcType=INTEGER}
+ </if>
+ </where>
+ </sql>
+
+ <!--缁熻鎸囧畾鏈堜唤鍚勬湀婕忔崯閲�(1鍙峰埌6鏈�)-->
+ <select id="selectLossAmountOfMonth01_06" resultType="com.dy.pipIrrGlobal.voSt.VoMonthAmount">
+ WITH intakeLossAmountMonth AS (<include refid="selectLossAmountOfMonth_with" />)
+ SELECT inta.intakeId AS intakeId,
+ inta.intakeNum AS intakeNum,
+ inta.intakeLng AS intakeLng,
+ inta.intakeLat AS intakeLat,
+ tb01.amount AS month1,
+ tb02.amount AS month2,
+ tb03.amount AS month3,
+ tb04.amount AS month4,
+ tb05.amount AS month5,
+ tb06.amount AS month6
+ FROM JSON_TABLE(
+ #{intakesJson},
+ '$[*]' COLUMNS (
+ intakeId BIGINT PATH '$.intakeId',
+ intakeNum VARCHAR(100) PATH '$.intakeNum',
+ intakeLng DOUBLE PATH '$.intakeLng',
+ intakeLat DOUBLE PATH '$.intakeLat'
+ )
+ ) inta
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 1
+ ) as tb01 on tb01.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 2
+ ) as tb02 on tb02.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 3
+ ) as tb03 on tb03.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 4
+ ) as tb04 on tb04.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 5
+ ) as tb05 on tb05.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 6
+ ) as tb06 on tb06.intakeId = inta.intakeId
+ </select>
+
+ <!--缁熻鎸囧畾鏈堜唤鍚勬湀婕忔崯閲�(7鍙峰埌12鏈�)-->
+ <select id="selectLossAmountOfMonth07_12" resultType="com.dy.pipIrrGlobal.voSt.VoMonthAmount">
+ WITH intakeLossAmountMonth AS (<include refid="selectLossAmountOfMonth_with" />)
+ SELECT inta.intakeId AS intakeId,
+ inta.intakeNum AS intakeNum,
+ inta.intakeLng AS intakeLng,
+ inta.intakeLat AS intakeLat,
+ tb07.amount AS month7,
+ tb08.amount AS month8,
+ tb09.amount AS month9,
+ tb010.amount AS month10,
+ tb011.amount AS month11,
+ tb012.amount AS month12
+ FROM JSON_TABLE(
+ #{intakesJson},
+ '$[*]' COLUMNS (
+ intakeId BIGINT PATH '$.intakeId',
+ intakeNum VARCHAR(100) PATH '$.intakeNum',
+ intakeLng DOUBLE PATH '$.intakeLng',
+ intakeLat DOUBLE PATH '$.intakeLat'
+ )
+ ) inta
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 7
+ ) as tb07 on tb07.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 8
+ ) as tb08 on tb08.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 9
+ ) as tb09 on tb09.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 10
+ ) as tb010 on tb010.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 11
+ ) as tb011 on tb011.intakeId = inta.intakeId
+ LEFT JOIN (
+ SELECT tb.intakeId AS intakeId,
+ tb.amount AS amount
+ FROM intakeLossAmountMonth AS tb
+ WHERE tb.year = #{year}
+ AND tb.month = 12
+ ) as tb012 on tb012.intakeId = inta.intakeId
+ </select>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.8.0