From 843d0abd014ec20424844546fc57a9f976f366ba Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 02 九月 2024 10:52:59 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java |   95 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java
index 202d2b0..5ba00a4 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java
@@ -12,6 +12,10 @@
 import com.doumee.dao.business.PlatformWaterGasMapper;
 import com.doumee.dao.business.model.PlatformReason;
 import com.doumee.dao.business.model.PlatformWaterGas;
+import com.doumee.dao.openapi.request.GasByMonthRequest;
+import com.doumee.dao.openapi.request.WaterByMonthRequest;
+import com.doumee.dao.openapi.response.GasByMonthResponse;
+import com.doumee.dao.openapi.response.WaterByMonthResponse;
 import com.doumee.service.business.PlatformWaterGasService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -22,9 +26,13 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.RequestBody;
 
+import java.math.BigDecimal;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 鏈堝彴_鐢ㄦ按鐢ㄦ皵淇℃伅璁板綍琛⊿ervice瀹炵幇
@@ -207,4 +215,91 @@
         QueryWrapper<PlatformWaterGas> wrapper = new QueryWrapper<>(platformWaterGas);
         return platformWaterGasMapper.selectCount(wrapper);
     }
+
+
+    @Override
+    public WaterByMonthResponse waterDataByMonth(WaterByMonthRequest param){
+        Date queryDate = (Objects.nonNull(param)&&Objects.nonNull(param.getTimeInfo()))?param.getTimeInfo():new Date();
+        //鑾峰彇涓婁釜鏈堟棩鏈�
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(queryDate);
+        calendar.add(Calendar.MONTH, -1);
+        Date beforMonth = calendar.getTime();
+        calendar.add(Calendar.MONTH, -11);
+        Date beforYearMonth = calendar.getTime();
+
+        WaterByMonthResponse waterByMonthResponse = new WaterByMonthResponse();
+
+        List<PlatformWaterGas> list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda()
+                .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO)
+                .eq(PlatformWaterGas::getType,Constants.ZERO)
+                .like(PlatformWaterGas::getTimeInfo,DateUtil.getDate(queryDate,"yyyy-MM"))
+        );
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){
+            waterByMonthResponse.setCurrentMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        }
+
+        list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda()
+                .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO)
+                .eq(PlatformWaterGas::getType,Constants.ZERO)
+                .like(PlatformWaterGas::getTimeInfo,beforMonth)
+        );
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){
+            waterByMonthResponse.setLastMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        }
+
+        list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda()
+                .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO)
+                .eq(PlatformWaterGas::getType,Constants.ZERO)
+                .like(PlatformWaterGas::getTimeInfo,beforYearMonth)
+        );
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){
+            waterByMonthResponse.setLastYearMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        }
+        return waterByMonthResponse;
+    }
+
+
+    @Override
+    public GasByMonthResponse gasDataByMonth(GasByMonthRequest param){
+        Date queryDate = (Objects.nonNull(param)&&Objects.nonNull(param.getTimeInfo()))?param.getTimeInfo():new Date();
+        //鑾峰彇涓婁釜鏈堟棩鏈�
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(queryDate);
+        calendar.add(Calendar.MONTH, -1);
+        Date beforMonth = calendar.getTime();
+        calendar.add(Calendar.MONTH, -11);
+        Date beforYearMonth = calendar.getTime();
+
+        GasByMonthResponse response = new GasByMonthResponse();
+
+        List<PlatformWaterGas> list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda()
+                .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO)
+                .eq(PlatformWaterGas::getType,Constants.ONE)
+                .like(PlatformWaterGas::getTimeInfo,DateUtil.getDate(queryDate,"yyyy-MM"))
+        );
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){
+            response.setCurrentMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        }
+
+        list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda()
+                .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO)
+                .eq(PlatformWaterGas::getType,Constants.ONE)
+                .like(PlatformWaterGas::getTimeInfo,beforMonth)
+        );
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){
+            response.setLastMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        }
+
+        list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda()
+                .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO)
+                .eq(PlatformWaterGas::getType,Constants.ONE)
+                .like(PlatformWaterGas::getTimeInfo,beforYearMonth)
+        );
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){
+            response.setLastYearMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        }
+        return response;
+    }
+
 }

--
Gitblit v1.9.3