From 8b0cf2731d2b61999fdd1aeee91567dc47d67e14 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 11 七月 2025 14:26:08 +0800
Subject: [PATCH] Merge branch 'dev' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java
index beb6bee..1dbf64a 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java
@@ -9,10 +9,13 @@
 import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.other.api.domain.TNotice;
 import com.ruoyi.other.api.domain.TScreenContent;
+import com.ruoyi.other.api.domain.TSystemConfiguration;
 import com.ruoyi.other.api.dto.NoticeQueryDto;
 import com.ruoyi.other.service.TNoticeService;
 import com.ruoyi.other.service.TScreenContentService;
+import com.ruoyi.other.service.TSystemConfigurationService;
 import com.ruoyi.other.util.EnergyRefreshService;
+import com.ruoyi.other.util.KsolarUtils;
 import com.ruoyi.other.vo.*;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
@@ -20,6 +23,7 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Arrays;
 import java.time.LocalDateTime;
 import java.util.HashMap;
@@ -41,6 +45,8 @@
     private TScreenContentService screenContentService;
     @Resource
     private EnergyRefreshService energyRefreshService;
+    @Resource
+    private TSystemConfigurationService systemConfigurationService;
 
     /**
      * 顶部-累计电量
@@ -58,19 +64,9 @@
     @GetMapping(value = "/photovoltaicAndConsumption")
     public AjaxResult<PhotovoltaicAndConsumptionVO> photovoltaicAndConsumption() {
         //需调用接口 获取光伏发电量
-        List<Integer> siteIds= Arrays.asList(25,26);
         PhotovoltaicAndConsumptionVO vo = new PhotovoltaicAndConsumptionVO();
-        List<TScreenContent> list = screenContentService.list(new LambdaQueryWrapper<TScreenContent>().in(TScreenContent::getSiteId, siteIds));
-        if(list==null|| list.isEmpty()){
-            return AjaxResult.success(vo);
-        }
-        vo.setGreenElectricityToday(list.get(0).getGreenElectricityToday());
-        list.remove(0);
-        list.forEach(x->{
-            vo.setGreenElectricityToday(vo.getGreenElectricityToday().add(x.getGreenElectricityToday()));
-        });
-
-        vo.setTodayGenerateElectricity(new BigDecimal("1821"));
+        vo.setTodayGenerateElectricity(new BigDecimal(KsolarUtils.getTodayEnergy(LocalDateTime.now().toString())));
+        vo.setGreenElectricityToday(vo.getTodayGenerateElectricity().multiply(new BigDecimal("0.94")).setScale(2, RoundingMode.HALF_UP));
         return AjaxResult.success(vo);
     }
 
@@ -98,9 +94,22 @@
     @ApiOperation(tags = {"储能放电情况"},value = "充电桩数据大屏")
     @GetMapping(value = "/energyStorageDischarge")
     public AjaxResult<EnergyStorageDischargeVO> energyStorageDischarge() {
-        //需调用接口 获取光伏发电量
+        String electricity = KsolarUtils.getElectricity();
+        List<TSystemConfiguration> list = systemConfigurationService.list(new LambdaQueryWrapper<TSystemConfiguration>().in(TSystemConfiguration::getType, 4, 5));
+        // 昨日放能
+        TSystemConfiguration sysConfig = list.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
+        // 昨日储能
+        TSystemConfiguration sysConfig1 = list.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
+        // 总储能
+        String s = electricity.split("_")[0];
+        // 总放能
+        String s1 = electricity.split("_")[1];
+
         EnergyStorageDischargeVO vo = new EnergyStorageDischargeVO();
-        vo.setTodayDischarge(energyRefreshService.getCurrentValue());
+        BigDecimal subtract = new BigDecimal(s1).subtract(new BigDecimal(sysConfig.getContent()));
+                vo.setTodayDischarge(subtract);
+        BigDecimal subtract1 = new BigDecimal(s).subtract(new BigDecimal(sysConfig1.getContent()));
+        vo.setTodayStorage(subtract1);
         return AjaxResult.success(vo);
     }
 

--
Gitblit v1.7.1