From 6ecf7171775a04bbcb52c9943bcafce699c837a7 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 25 六月 2025 11:11:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java |   52 +-----
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicAndConsumptionVO.java        |    2 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java    |   21 --
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicPowerGenerationVO.java       |    2 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/AESUtils.java                          |   95 +++++++++++++
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java              |   90 +++++++-----
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java                       |  146 ++++++++++++++++++++
 7 files changed, 311 insertions(+), 97 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 3e6d890..ba04879 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
@@ -15,6 +15,7 @@
 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;
@@ -63,25 +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()));
-        });
-
-        TSystemConfiguration sysConfig = systemConfigurationService.getOne(new LambdaQueryWrapper<TSystemConfiguration>()
-                .eq(TSystemConfiguration::getType,4));
-        BigDecimal refreshValueOne = new BigDecimal(sysConfig.getContent());
-        vo.setTodayGenerateElectricity(refreshValueOne);
-        vo.setGreenElectricityToday(refreshValueOne.multiply(new BigDecimal("0.94")).setScale(2, RoundingMode.HALF_UP));
-
-
+        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);
     }
 
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java
index 1c016e9..caa54aa 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java
@@ -15,6 +15,7 @@
 import com.ruoyi.other.mapper.TSystemConfigurationMapper;
 import com.ruoyi.other.service.TScreenContentService;
 import com.ruoyi.other.service.TSystemConfigurationService;
+import com.ruoyi.other.util.KsolarUtils;
 import com.ruoyi.other.vo.EmissionReductionVO;
 import com.ruoyi.other.vo.PhotovoltaicPowerGenerationVO;
 import com.ruoyi.other.vo.ScreenStorageConfigVO;
@@ -96,10 +97,19 @@
             systemConfigurationMapper.updateById(sysConfig);
             vo.setEnergyStorage(storageDisCharge.multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN));
         }
+        //获取累计发电
+        vo.setPhotovoltaic(KsolarUtils.getYearAllEnergy());
+
 
         //总数:
         BigDecimal total = vo.getPhotovoltaic().add(vo.getEnergyStorage()).add(vo.getCharge());
         vo.setTotal(total);
+
+
+
+
+
+
         //计算比率
         vo.setPhotovoltaicRate(calculateRatio(vo.getPhotovoltaic(),vo.getTotal()).multiply(new BigDecimal("100")));
         vo.setEnergyStorageRate(calculateRatio(vo.getEnergyStorage(),vo.getTotal()).multiply(new BigDecimal("100")));
@@ -108,60 +118,27 @@
         return vo;
     }
 
-    public static void main(String[] args) {
-        BigDecimal divide = new BigDecimal("607").multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN);
-        System.out.println(divide);
-    }
 
     //百分比计算
     public static BigDecimal calculateRatio(BigDecimal part, BigDecimal total) {
         if (total.compareTo(BigDecimal.ZERO) == 0) {
             throw new ArithmeticException("分母不能为零");
         }
-
         return part.divide(total, 4, RoundingMode.HALF_UP);
     }
 
     @Override
     public PhotovoltaicPowerGenerationVO photovoltaicPowerGeneration(List<Integer> siteIds) {
-        //需调用接口
-
-        //假数据
         PhotovoltaicPowerGenerationVO vo = new PhotovoltaicPowerGenerationVO();
         List<LocalDate> dates = new ArrayList<>();
-        List<Integer> values = new ArrayList<>();
+        List<Double> values = new ArrayList<>();
         LocalDate today = LocalDate.now();
         // 生成每天数据
         for (int i = 7; i >= 1; i--) {//升序
             LocalDate day = today.minusDays(i);
             //统计
             dates.add(day);
-            int value = new Random().nextInt(151) + 100; // 100-250
-
-            switch (i){
-                case 1:
-                    value = 1780; // 50-100
-                    break;
-                case 2:
-                    value = 1810; // 50-100
-                    break;
-                case 3:
-                    value = 1765; // 50-100
-                    break;
-                    case 4:
-                    value = 1793; // 50-100
-                    break;
-                    case 5:
-                    value = 1833; // 50-100
-                    break;
-                    case 6:
-                    value = 1815; // 50-100
-                    break;
-                    case 7:
-                    value =1794; // 50-100
-                    break;
-
-            }
+            Double value = KsolarUtils.getTodayEnergy(day.toString()); // 100-250
             values.add(value);
         }
         vo.setDates(dates);
@@ -206,13 +183,10 @@
         BigDecimal totalCharge = dailyRate.multiply(BigDecimal.valueOf(days));
         vo.setStorageCharge(totalCharge);
 
-        TSystemConfiguration sysConfig1 = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
-                .eq(TSystemConfiguration::getType,5));
-        vo.setPhotovoltaic(new BigDecimal(sysConfig1.getContent()));
+        vo.setPhotovoltaic(new BigDecimal(KsolarUtils.getAllEnergy(LocalDate.now().toString())));
         vo.setGreenElectricity(vo.getPhotovoltaic().multiply(new BigDecimal("0.94")).setScale(2,  RoundingMode.HALF_UP));
 
         //获取储能放电量
-
         // 判断是否等于今天
         if (configVO.getLastUpdated().equals(today)) {
             vo.setStorageDisCharge(configVO.getStorageDisCharge());
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/AESUtils.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/AESUtils.java
new file mode 100644
index 0000000..301cdea
--- /dev/null
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/AESUtils.java
@@ -0,0 +1,95 @@
+package com.ruoyi.other.util;
+
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.Cipher;
+
+import javax.crypto.spec.SecretKeySpec;
+
+
+/**
+ * Created by jhb on 2022-08-03 14:16
+ */
+public class AESUtils {
+    public static final String DEFAULT_SECRET_KEY = "kstar_ase_keysfo";
+    /**
+     * 加密
+     * @param sSrc 需要加密的字符串
+     * @param sKey 此处使用AES-128-ECB加密模式,key需要为16位。
+     * @return
+     * @throws Exception
+     */
+    public static String Encrypt(String sSrc, String sKey) throws Exception {
+        sKey = DEFAULT_SECRET_KEY;
+
+        // 判断Key是否为16位
+        if (sKey.length() != 16) {
+            System.out.print("Key长度不是16位");
+            return null;
+        }
+        byte[] raw = sKey.getBytes("utf-8");
+        SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");//"算法/模式/补码方式"
+        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
+        byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8"));
+
+        return new Base64().encodeToString(encrypted);//此处使用BASE64做转码功能,同时能起到2次加密的作用。
+    }
+
+    /**
+     * 解密
+     * @param sSrc 需要解密的字符串
+     * @param sKey 此处使用AES-128-ECB加密模式,key需要为16位。
+     * @return
+     * @throws Exception
+     */
+    public static String Decrypt(String sSrc, String sKey) throws Exception {
+        sKey = DEFAULT_SECRET_KEY;
+        try {
+            // 判断Key是否正确
+            if (sKey == null) {
+                System.out.print("Key为空null");
+                return null;
+            }
+            // 判断Key是否为16位
+            if (sKey.length() != 16) {
+                System.out.print("Key长度不是16位");
+                return null;
+            }
+            byte[] raw = sKey.getBytes("utf-8");
+            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+            cipher.init(Cipher.DECRYPT_MODE, skeySpec);
+            byte[] encrypted1 = new Base64().decode(sSrc);//先用base64解密
+            try {
+                byte[] original = cipher.doFinal(encrypted1);
+                String originalString = new String(original,"utf-8");
+                return originalString;
+            } catch (Exception e) {
+                System.out.println(e.toString());
+                return null;
+            }
+        } catch (Exception ex) {
+            System.out.println(ex.toString());
+            return null;
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        /*
+         * 此处使用AES-128-ECB加密模式,key需要为16位。
+         */
+        String cKey = "kstar_ase_keysfo";
+        // 需要加密的字串
+        String cSrc = "huandaoguangfu";
+        System.out.println(cSrc);
+        // 加密
+        String enString = AESUtils.Encrypt(cSrc, cKey);
+        System.out.println("加密后的字串是:" + enString);
+
+        // 解密
+        String DeString = AESUtils.Decrypt(enString, cKey);
+        System.out.println("解密后的字串是:" + DeString);
+    }
+
+}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java
index 865b544..3ad10be 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java
@@ -162,6 +162,15 @@
         updateStorageValue(BigDecimal.ZERO);
         updateDischargeValue(BigDecimal.ZERO);
         System.out.println("每日重置完成:今日储能和放电已清零");
+
+
+
+        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
+                .eq(TSystemConfiguration::getType,4));
+        sysConfig.setContent("0");
+        systemConfigurationMapper.updateById(sysConfig);
+
+
     }
 
     /**
@@ -254,67 +263,72 @@
 
 
 
-    public static BigDecimal refreshValueOne = new BigDecimal("0");
     /**
      *光伏发电和消纳
      */
-    @Scheduled(cron = "0 */1 * * * ?")  // 每分钟点执行
+//    @Scheduled(cron = "0 */1 * * * ?")  // 每分钟点执行
     public void refreshValueOne() {
         // 判断时间是否在6:00到8:59
         LocalTime now = LocalTime.now();
-        if (now.isAfter(LocalTime.of(6, 0)) && now.isBefore(LocalTime.of(8, 59))) {
-            refreshValueOne = refreshValueOne.add(new BigDecimal("0.5"));
-            List<TSystemConfiguration> sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>()
-                    .in(TSystemConfiguration::getType,4,5));
-            TSystemConfiguration sysConfig = sysConfigs.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
-            sysConfig.setContent(refreshValueOne.toString());
-            systemConfigurationMapper.updateById(sysConfig);
-
-
-            TSystemConfiguration sysConfig1 = sysConfigs.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
-            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal("0.5")).toString();
-            sysConfig1.setContent(string);
-            systemConfigurationMapper.updateById(sysConfig1);
-            // 在6:00到8:59之间,不执行
-            return;
-        }
+//        if (now.isAfter(LocalTime.of(6, 0)) && now.isBefore(LocalTime.of(8, 59))) {
+//            List<TSystemConfiguration> sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>()
+//                    .in(TSystemConfiguration::getType,4,5));
+//            TSystemConfiguration sysConfig = sysConfigs.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
+//
+//            sysConfig.setContent(new BigDecimal(sysConfig.getContent()).add(new BigDecimal("0.5")).toString());
+//            systemConfigurationMapper.updateById(sysConfig);
+//
+//
+//            TSystemConfiguration sysConfig1 = sysConfigs.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
+//            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal("0.5")).toString();
+//            sysConfig1.setContent(string);
+//            systemConfigurationMapper.updateById(sysConfig1);
+//            // 在6:00到8:59之间,不执行
+//            return;
+//        }
         // 9:00-16:59每分钟增加随机3 到 3.5
-        if (now.isAfter(LocalTime.of(9, 0)) && now.isBefore(LocalTime.of(16, 59))) {
-            refreshValueOne = refreshValueOne.add(new BigDecimal(3 + (3.5 - 3) * random.nextDouble())
-                    .setScale(2, RoundingMode.HALF_UP));
+        if (now.isAfter(LocalTime.of(6, 0)) && now.isBefore(LocalTime.of(12, 0))) {
             List<TSystemConfiguration> sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>()
                     .in(TSystemConfiguration::getType,4,5));
 
             TSystemConfiguration sysConfig = sysConfigs.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
-            sysConfig.setContent(refreshValueOne.toString());
+            sysConfig.setContent( new BigDecimal(sysConfig.getContent()).add(new BigDecimal(0.1 + (1 - 0.1) * random.nextDouble())
+                    .setScale(2, RoundingMode.HALF_UP)).toString());
             systemConfigurationMapper.updateById(sysConfig);
 
 
             TSystemConfiguration sysConfig1 = sysConfigs.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
-            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal(3 + (3.5 - 3) * random.nextDouble())).toString();
+            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal(0.1 + (1 - 0.1) * random.nextDouble())).toString();
             sysConfig1.setContent(string);
             systemConfigurationMapper.updateById(sysConfig1);
             return;
         }
+
         //17:00-18:59 每分钟增加0.5
-        if (now.isAfter(LocalTime.of(17, 0)) && now.isBefore(LocalTime.of(18, 59))) {
-            refreshValueOne = refreshValueOne.add(new BigDecimal("0.5"));
-            List<TSystemConfiguration> sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>()
-                    .in(TSystemConfiguration::getType,4,5));
-
-            TSystemConfiguration sysConfig = sysConfigs.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
-            sysConfig.setContent(refreshValueOne.toString());
-            systemConfigurationMapper.updateById(sysConfig);
-
-
-            TSystemConfiguration sysConfig1 = sysConfigs.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
-            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal("0.5")).toString();
-            sysConfig1.setContent(string);
-            systemConfigurationMapper.updateById(sysConfig1);
-        }
+//        if (now.isAfter(LocalTime.of(17, 0)) && now.isBefore(LocalTime.of(18, 59))) {
+//            List<TSystemConfiguration> sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>()
+//                    .in(TSystemConfiguration::getType,4,5));
+//
+//            TSystemConfiguration sysConfig = sysConfigs.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
+//
+//            sysConfig.setContent(new BigDecimal(sysConfig.getContent()).add(new BigDecimal("0.5")).toString());
+//            systemConfigurationMapper.updateById(sysConfig);
+//
+//
+//            TSystemConfiguration sysConfig1 = sysConfigs.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
+//            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal("0.5")).toString();
+//            sysConfig1.setContent(string);
+//            systemConfigurationMapper.updateById(sysConfig1);
+//        }
     }
 
 
+    public static void main(String[] args) {
+        Random random = new Random();
+        BigDecimal bigDecimal = new BigDecimal(0.1 + (1 - 0.1) * random.nextDouble());
+        System.out.println(bigDecimal);
+
+    }
 
 
 }
\ No newline at end of file
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java
new file mode 100644
index 0000000..1efb97a
--- /dev/null
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java
@@ -0,0 +1,146 @@
+package com.ruoyi.other.util;
+
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ruoyi.other.api.domain.TSystemConfiguration;
+import com.ruoyi.other.mapper.TSystemConfigurationMapper;
+import com.ruoyi.other.vo.ScreenStorageConfigVO;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+
+
+/**
+ * 定时任务:储能放电情况 光伏发电情况
+ */
+@Service
+public class KsolarUtils {
+
+
+    private static String token;
+
+
+    private static List<String> stationIds= Arrays.asList("2025060710462417","2025060711331323","2025060715425437","2025060716010425");
+
+    public static Double getTodayEnergy(String time) {
+        try {
+            HttpRequest get = HttpUtil.createGet("http://111.230.136.62:8092/station/list/earn");
+            get.header("Authorization", "Bearer "+token);
+            get.form("startDate", time);
+            HttpResponse execute = get.execute();
+            String body = execute.body();
+            JSONObject jsonObject = JSONObject.parseObject(body);
+            String code = jsonObject.get("code").toString();
+            if(!"200".equals(code)){
+                token = token();
+                return getTodayEnergy(time);
+            }
+            Object data  = jsonObject.get("data");
+            JSONObject jsonObject1 = JSONObject.parseObject(data.toString());
+            Double earn = jsonObject1.getDouble("dayGeneration");
+            return earn;
+        } catch (Exception e) {
+            e.printStackTrace();
+            token = token();
+            return getTodayEnergy(time);
+        }
+    }
+
+    public static Double getAllEnergy(String time) {
+        try {
+            HttpRequest get = HttpUtil.createGet("http://111.230.136.62:8092/station/list/earn");
+            get.header("Authorization", "Bearer "+token);
+            get.form("startDate", time);
+            HttpResponse execute = get.execute();
+            String body = execute.body();
+            JSONObject jsonObject = JSONObject.parseObject(body);
+            String code = jsonObject.get("code").toString();
+            if(!"200".equals(code)){
+                token = token();
+                return getAllEnergy(time);
+            }
+            Object data  = jsonObject.get("data");
+            JSONObject jsonObject1 = JSONObject.parseObject(data.toString());
+            Double earn = jsonObject1.getDouble("totalGeneration");
+            return earn;
+        } catch (Exception e) {
+            e.printStackTrace();
+            token = token();
+            return getAllEnergy(time);
+        }
+    }
+
+
+    /**
+     * 光伏碳减排
+     * @return
+     */
+    public static BigDecimal getYearAllEnergy() {
+        Double yearAllEnergy = getYearAllEnergy(stationIds.get(0));
+        Double yearAllEnergy1 = getYearAllEnergy(stationIds.get(1));
+        Double yearAllEnergy2 = getYearAllEnergy(stationIds.get(2));
+        Double yearAllEnergy3 = getYearAllEnergy(stationIds.get(3));
+        double v = yearAllEnergy + yearAllEnergy1 + yearAllEnergy2 + yearAllEnergy3;
+        BigDecimal divide = new BigDecimal(v).multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"), 2, RoundingMode.DOWN);
+        return divide;
+    }
+
+    private static Double getYearAllEnergy(String stationId) {
+        try {
+            HttpRequest get = HttpUtil.createGet("http://111.230.136.62:8092/protocol/station/statistic/elec/chart");
+            get.header("Authorization", "Bearer "+token);
+            get.form("stationId", "2025060710462417");
+            get.form("attribId", "202");
+            get.form("stime",LocalDate.now().getYear()+"" );
+            HttpResponse execute = get.execute();
+            String body = execute.body();
+            JSONArray jsonArray = JSONArray.parseArray(body);
+            Object o1 = jsonArray.get(0);
+            JSONObject jsonObject = JSONObject.parseObject(o1.toString());
+            String code = jsonObject.get("attribValue").toString();
+            Double earn = Double.valueOf(code);
+            return earn;
+        } catch (Exception e) {
+            e.printStackTrace();
+            token = token();
+            return getYearAllEnergy(LocalDate.now().getYear()+"");
+        }
+    }
+
+
+
+    public static String token() {
+        HttpRequest post = HttpUtil.createPost("http://111.230.136.62:8092/authentication/form");
+        post.basicAuth("kstar","kstarSecret");
+        post.form("username", "环岛光伏");
+        post.form("password", "cR8GGwIXMI462A8Dfl9eXg==");
+        HttpResponse execute = post.execute();
+        String body = execute.body();
+        JSONObject jsonObject = JSONObject.parseObject(body);
+        String token = jsonObject.getString("token");
+        JSONObject jsonObject1 = JSONObject.parseObject(token);
+        String access_token = jsonObject1.getString("access_token");
+        return  access_token;
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println(getYearAllEnergy("2025",""));
+    }
+
+
+}
\ No newline at end of file
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicAndConsumptionVO.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicAndConsumptionVO.java
index dd9b28f..9ec03b0 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicAndConsumptionVO.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicAndConsumptionVO.java
@@ -14,7 +14,7 @@
     @ApiModelProperty("装机容量")
     private BigDecimal capacity = new BigDecimal("759.52");
     @ApiModelProperty("今日已发电")
-    private BigDecimal todayGenerateElectricity=new BigDecimal("71.29");
+    private BigDecimal todayGenerateElectricity=new BigDecimal("0");
 
     @ApiModelProperty("今日绿电消纳值")
     private BigDecimal greenElectricityToday=new BigDecimal("0.00");
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicPowerGenerationVO.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicPowerGenerationVO.java
index 578eac3..9fd06fa 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicPowerGenerationVO.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicPowerGenerationVO.java
@@ -11,5 +11,5 @@
     @ApiModelProperty("日期")
     private List<LocalDate> dates;
     @ApiModelProperty("数据")
-    private List<Integer> values;
+    private List<Double> values;
 }

--
Gitblit v1.7.1