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-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/loss/LossSv.java |   62 +++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 3 deletions(-)

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