From 8579b568049621bf4b91984c5a147a0e81120c66 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 12 十二月 2024 16:06:18 +0800
Subject: [PATCH] 漏损月统计重新实现

---
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSt/StLossMonthMapper.java              |   30 ++++
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmLossDayMapper.java                |    2 
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayMapper.xml                               |   22 +-
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/StLossMonthMapper.xml                             |  185 ++++++++++++++++++++++++++
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossCtrl.java |   19 ++
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossSv.java   |   62 ++++++++
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSt/VoMonthAmount.java                   |   41 +++--
 7 files changed, 324 insertions(+), 37 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmLossDayMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmLossDayMapper.java
index 835e3e8..02b4e18 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmLossDayMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmLossDayMapper.java
@@ -118,7 +118,7 @@
     List<VoDayLoss> selectIntakes4LossDay(Map<?, ?> params) ;
 
     /**
-     * 鏌ヨ缁熻鍙栨按鍙f棩婕忔崯閲忥紝缁熻鍙栨按鍙f暟閲�
+     * 鏌ヨ缁熻鍙栨按鍙f棩婕忔崯閲�
      * @param params
      * @return
      */
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSt/StLossMonthMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSt/StLossMonthMapper.java
index df3f5ae..fc34ae5 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSt/StLossMonthMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSt/StLossMonthMapper.java
@@ -3,10 +3,12 @@
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.dy.pipIrrGlobal.pojoSt.StLossMonth;
 import com.dy.pipIrrGlobal.voSt.VoIntakeLossStatistics;
+import com.dy.pipIrrGlobal.voSt.VoMonthAmount;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Author: liurunyu
@@ -79,4 +81,32 @@
      */
     List<VoIntakeLossStatistics> statisticsByIntake(Integer year) ;
 
+
+    ////////////////////////////////////////////////
+    // 缁熻鏌ヨ
+    ///////////////////////////////////////////////
+
+    /**
+     * 涓烘煡璇㈢粺璁″彇姘村彛鏃ユ紡鎹熼噺锛岀粺璁″彇姘村彛鏁伴噺
+     * @param intakeN
+     * @return
+     */
+    Long selectIntakeCount4LossMonth(@Param("intakeNum")String intakeN) ;
+
+    /**
+     * 涓烘煡璇㈢粺璁″彇姘村彛鏃ユ紡鎹熼噺锛屾煡璇竴椤靛彇姘村彛ID
+     * @param params
+     * @return
+     */
+    List<VoMonthAmount> selectIntakes4LossMonth(Map<?, ?> params) ;
+
+    /**
+     * 鏌ヨ缁熻鍙栨按鍙f湀婕忔崯閲�
+     * @param params
+     * @return
+     */
+    //涓嬮潰1鍒�12鏈堝垎浜�2涓煡璇紝鍘熷洜鏄湪涓�涓煡璇腑锛岄潪甯告參锛屼笉鐭ラ亾浠�涔堝師鍥狅紝涔熻鏄瓙鏌ヨ澶鐨勫師鍥�
+    List<VoMonthAmount> selectLossAmountOfMonth01_06(Map<?, ?> params);
+    List<VoMonthAmount> selectLossAmountOfMonth07_12(Map<?, ?> params);
+
 }
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSt/VoMonthAmount.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSt/VoMonthAmount.java
index 7006a0e..9ffc36a 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSt/VoMonthAmount.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSt/VoMonthAmount.java
@@ -14,43 +14,52 @@
  */
 
 @Data
-@JsonPropertyOrder({ "intakeId", "intakeNum", "month1" , "month2" , "month3" , "month4" , "month5" , "month6" , "month7" , "month8" , "month9" , "month10" , "month11" , "month12"  })
+@JsonPropertyOrder({ "intakeId", "intakeNum", "intakeLng", "intakeLat", "month1" , "month2" , "month3" , "month4" , "month5" , "month6" , "month7" , "month8" , "month9" , "month10" , "month11" , "month12"  })
 public class VoMonthAmount {
-    private static final long serialVersionUID = 202408081417001L;
+    public static final long serialVersionUID = 202408081417001L;
 
     /**
      * 鍙栨按鍙D
      */
     @JSONField(serializeUsing= ObjectWriterImplToString.class)
-    private Long intakeId;
+    public Long intakeId;
 
     /**
      * 鍙栨按鍙g紪鍙�
      */
-    private String intakeNum;
+    public String intakeNum;
+
+    /**
+     * 缁忓害
+     */
+    public Double intakeLng;
+    /**
+     * 绾害
+     */
+    public Double intakeLat;
 
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month1;
+    public Double month1;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month2;
+    public Double month2;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month3;
+    public Double month3;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month4;
+    public Double month4;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month5;
+    public Double month5;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month6;
+    public Double month6;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month7;
+    public Double month7;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month8;
+    public Double month8;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month9;
+    public Double month9;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month10;
+    public Double month10;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month11;
+    public Double month11;
     @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
-    private Double month12;
+    public Double month12;
 }
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayMapper.xml
index a57afa2..10f472c 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayMapper.xml
@@ -275,10 +275,10 @@
         from rm_loss_day
         <where>
           <if test="startDt != null ">
-            AND dt <![CDATA[>=]]> #{startDt, jdbcType=DATE, jdbcType=DATE}
+            AND dt <![CDATA[>=]]> #{startDt, javaType=DATE, jdbcType=DATE}
           </if>
           <if test="endDt != null ">
-            AND dt <![CDATA[<]]> #{endDt, jdbcType=DATE, jdbcType=DATE}
+            AND dt <![CDATA[<]]> #{endDt, javaType=DATE, jdbcType=DATE}
           </if>
         </where>
         order by intake_id DESC, id ASC
@@ -287,7 +287,6 @@
 
 
   <sql id="selectLossAmountOfDay_with">
-    WITH intakeLossAmountDay AS (
       SELECT intaId.intakeId   AS intakeId,
              rld.dt            AS dt,
              rld.loss_amount   AS lossAmount
@@ -300,18 +299,17 @@
       INNER JOIN rm_loss_day rld ON rld.intake_id = intaId.intakeId
       <where>
         <if test="startDt != null ">
-          AND rld.dt <![CDATA[>=]]> #{startDt, jdbcType=DATE, jdbcType=DATE}
+          AND rld.dt <![CDATA[>=]]> #{startDt, javaType=DATE, jdbcType=DATE}
         </if>
         <if test="endDt != null ">
-          AND rld.dt <![CDATA[<=]]> #{endDt, jdbcType=DATE, jdbcType=DATE}
+          AND rld.dt <![CDATA[<=]]> #{endDt, javaType=DATE, jdbcType=DATE}
         </if>
       </where>
-    )
   </sql>
 
   <!--缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�(1鍙峰埌5鍙�)-->
   <select id="selectLossAmountOfDay01_05" resultType="com.dy.pipIrrGlobal.voSt.VoDayLoss">
-    <include refid="selectLossAmountOfDay_with" />
+    WITH intakeLossAmountDay AS (<include refid="selectLossAmountOfDay_with"/>)
     SELECT inta.intakeId     AS intakeId,
            inta.intakeNum    AS intakeNum,
            inta.intakeLng    AS intakeLng,
@@ -375,7 +373,7 @@
 
   <!--缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�(6鍙峰埌10鍙�)-->
   <select id="selectLossAmountOfDay06_10" resultType="com.dy.pipIrrGlobal.voSt.VoDayLoss">
-    <include refid="selectLossAmountOfDay_with" />
+    WITH intakeLossAmountDay AS (<include refid="selectLossAmountOfDay_with"/>)
     SELECT inta.intakeId     AS intakeId,
            inta.intakeNum    AS intakeNum,
            inta.intakeLng    AS intakeLng,
@@ -438,7 +436,7 @@
 
   <!--缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�(11鍙峰埌15鍙�)-->
   <select id="selectLossAmountOfDay11_15" resultType="com.dy.pipIrrGlobal.voSt.VoDayLoss">
-    <include refid="selectLossAmountOfDay_with" />
+    WITH intakeLossAmountDay AS (<include refid="selectLossAmountOfDay_with"/>)
     SELECT inta.intakeId     AS intakeId,
            inta.intakeNum    AS intakeNum,
            inta.intakeLng    AS intakeLng,
@@ -501,7 +499,7 @@
 
   <!--缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�(20鍙峰埌16鍙�)-->
   <select id="selectLossAmountOfDay16_20" resultType="com.dy.pipIrrGlobal.voSt.VoDayLoss">
-    <include refid="selectLossAmountOfDay_with" />
+    WITH intakeLossAmountDay AS (<include refid="selectLossAmountOfDay_with"/>)
     SELECT inta.intakeId     AS intakeId,
            inta.intakeNum    AS intakeNum,
            inta.intakeLng    AS intakeLng,
@@ -564,7 +562,7 @@
 
   <!--缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�(21鍙峰埌25鍙�)-->
   <select id="selectLossAmountOfDay21_25" resultType="com.dy.pipIrrGlobal.voSt.VoDayLoss">
-    <include refid="selectLossAmountOfDay_with" />
+    WITH intakeLossAmountDay AS (<include refid="selectLossAmountOfDay_with"/>)
     SELECT inta.intakeId     AS intakeId,
            inta.intakeNum    AS intakeNum,
            inta.intakeLng    AS intakeLng,
@@ -627,7 +625,7 @@
 
   <!--缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�(26鍙峰埌31鍙�)-->
   <select id="selectLossAmountOfDay26_31" resultType="com.dy.pipIrrGlobal.voSt.VoDayLoss">
-    <include refid="selectLossAmountOfDay_with" />
+    WITH intakeLossAmountDay AS (<include refid="selectLossAmountOfDay_with"/>)
     SELECT inta.intakeId     AS intakeId,
            inta.intakeNum    AS intakeNum,
            inta.intakeLng    AS intakeLng,
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 09143e9..0b2da89 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StLossMonthMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StLossMonthMapper.xml
@@ -124,4 +124,189 @@
     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
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossCtrl.java
index f3e7f67..f28d0f7 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossCtrl.java
@@ -6,9 +6,6 @@
 import com.dy.common.webUtil.BaseResponseUtils;
 import com.dy.common.webUtil.QueryResultVo;
 import com.dy.pipIrrGlobal.voSt.VoDayLoss;
-import com.dy.pipIrrStatistics.intake.IntakeSv;
-import com.dy.pipIrrStatistics.intake.qo.IntakeAmountQO;
-import com.dy.pipIrrStatistics.result.StatisticlResultCode;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,8 +13,6 @@
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -60,4 +55,18 @@
         return BaseResponseUtils.buildSuccess(this.sv.lossAmountOfDay(qo));
     }
 
+    /**
+     * 鏌ヨ鎸囧畾鏈堜唤鍚勬棩婕忔崯閲�
+     * @param qo
+     * @return
+     */
+    @GetMapping(path = "/lossAmountOfMonth")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<VoDayLoss>>> lossAmountOfMonth(LossQo qo) throws Exception {
+        if(qo.getYear() == null) {
+            return BaseResponseUtils.buildErrorMsg("鏌ヨ鏉′欢骞村害涓嶈兘涓虹┖");
+        }
+        return BaseResponseUtils.buildSuccess(this.sv.lossAmountOfMonth(qo));
+    }
+
 }
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossSv.java
index fcf0413..63db789 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossSv.java
@@ -3,7 +3,9 @@
 import com.alibaba.fastjson2.JSON;
 import com.dy.common.webUtil.QueryResultVo;
 import com.dy.pipIrrGlobal.daoRm.RmLossDayMapper;
+import com.dy.pipIrrGlobal.daoSt.StLossMonthMapper;
 import com.dy.pipIrrGlobal.voSt.VoDayLoss;
+import com.dy.pipIrrGlobal.voSt.VoMonthAmount;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.common.utils.PojoUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,7 +14,6 @@
 import java.text.ParseException;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 
 /**
  * @Author: liurunyu
@@ -26,6 +27,9 @@
 
     @Autowired
     private RmLossDayMapper rmLossDayMapper ;
+
+    @Autowired
+    private StLossMonthMapper stLossMonthMapper ;
 
     /**
      * 缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�
@@ -53,7 +57,7 @@
 
                 List<VoDayLoss> list01_05 = rmLossDayMapper.selectLossAmountOfDay01_05(params);
                 if(list01_05 != null && list01_05.size() > 0){
-                    //涓嬮潰1鍒�31鍙峰垎浜�6涓煡璇紝鍘熷洜鏄叆涓�涓煡璇腑锛岄潪甯告參锛屼笉鐭ラ亾浠�涔堝師鍥狅紝涔熻鏄瓙鏌ヨ澶鐨勫師鍥�
+                    //涓嬮潰1鍒�31鍙峰垎浜�6涓煡璇紝鍘熷洜鏄湪涓�涓煡璇腑锛岄潪甯告參锛屼笉鐭ラ亾浠�涔堝師鍥狅紝涔熻鏄瓙鏌ヨ澶鐨勫師鍥�
                     List<VoDayLoss> list06_10 = rmLossDayMapper.selectLossAmountOfDay06_10(params);
                     List<VoDayLoss> list11_15 = rmLossDayMapper.selectLossAmountOfDay11_15(params);
                     List<VoDayLoss> list16_20 = rmLossDayMapper.selectLossAmountOfDay16_20(params);
@@ -126,7 +130,59 @@
                 }
             }
         }
-
     }
 
+
+    /**
+     * 缁熻鎸囧畾鏈堜唤鍚勬湀婕忔崯閲�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoMonthAmount>> lossAmountOfMonth(LossQo qo) throws ParseException {
+        QueryResultVo<List<VoMonthAmount>> rsVo = new QueryResultVo<>() ;
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = stLossMonthMapper.selectIntakeCount4LossMonth(qo.intakeNum) ;
+
+        if(itemTotal != null && itemTotal > 0){
+            rsVo.pageSize = qo.pageSize ;
+            rsVo.pageCurr = qo.pageCurr ;
+            rsVo.calculateAndSet(itemTotal, params);
+
+            List<VoMonthAmount> list = stLossMonthMapper.selectIntakes4LossMonth(params);
+            if(list == null || list.size() == 0){
+                rsVo.obj = list ;
+            }else{
+                String json = JSON.toJSONString(list) ;
+                params.put("intakesJson", json);
+
+                List<VoMonthAmount> list01_06 = stLossMonthMapper.selectLossAmountOfMonth01_06(params);
+                if(list01_06 != null && list01_06.size() > 0){
+                    //涓嬮潰1鍒�12鏈堝垎浜�2涓煡璇紝鍘熷洜鏄湪涓�涓煡璇腑锛岄潪甯告參锛屼笉鐭ラ亾浠�涔堝師鍥狅紝涔熻鏄瓙鏌ヨ澶鐨勫師鍥�
+                    List<VoMonthAmount> list07_12 = stLossMonthMapper.selectLossAmountOfMonth07_12(params);
+                    this.merge(list01_06, list07_12);
+                }
+                rsVo.obj = list01_06 ;
+            }
+        }
+        return rsVo ;
+    }
+
+    private void merge(List<VoMonthAmount> list01_06,
+                       List<VoMonthAmount> list07_12){
+        for(VoMonthAmount vo01_06 : list01_06){
+            for(VoMonthAmount vo07_12 : list07_12){
+                if(vo01_06.intakeId.longValue() == vo07_12.intakeId.longValue()){
+                    vo01_06.month7 = vo07_12.month7 ;
+                    vo01_06.month8 = vo07_12.month8 ;
+                    vo01_06.month9 = vo07_12.month9 ;
+                    vo01_06.month10 = vo07_12.month10 ;
+                    vo01_06.month11 = vo07_12.month11 ;
+                    vo01_06.month12 = vo07_12.month12 ;
+                    break ;
+                }
+            }
+        }
+    }
 }

--
Gitblit v1.8.0