From 988bbb6fe92380ba992a146ed94df2d8973a4edb Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 10 七月 2025 16:48:47 +0800
Subject: [PATCH] 储能对接

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java |   79 +----------
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java    |   20 ++
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java              |  299 +-----------------------------------------
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java                       |   18 +
 4 files changed, 45 insertions(+), 371 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 ba04879..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
@@ -94,12 +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();
-        //今日放能   10:00-11:59 每1分钟随机增值0.5-1,放满90停止;用第一次放能值为基数(85)开始累加,17:00-21:59 每1分钟随机增值0.5-1,放满90停止。
-        vo.setTodayDischarge(energyRefreshService.getTodayDischarge());
-        //今日储能  00:00-次日7:59 每1分钟随机增长0.5-1,储满115停止,12:00-16:59 每1分钟随机增长0.5-1,增加到115减第一次放能剩余值(如放能值为85,则放能剩余值为90-85)结束;
-        vo.setTodayStorage(energyRefreshService.getTodayStorage());
+        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);
     }
 
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 569de12..bee6136 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
@@ -57,11 +57,11 @@
         EmissionReductionVO vo = new EmissionReductionVO();
         //获取总电量 计算累计充电二氧化碳减排量
         BigDecimal charge=top.getCarCharge();
+        BigDecimal multiplier = new BigDecimal("0.1404");
         //计算累计充电二氧化碳减排量
         if (charge.compareTo(BigDecimal.ZERO) != 0) {
             // 定义乘数和除数
-            BigDecimal multiplier = new BigDecimal("0.1404"); // 0.1404
-            BigDecimal divisor = new BigDecimal("1000");    // 1000
+           // 0.1404
             // 计算:charge × 0.1404 ÷ 1000
             charge = charge
                     .multiply(multiplier)      // 乘以 0.1404
@@ -70,42 +70,16 @@
         vo.setCharge(charge);
 
         //获取累计储能放电量
-        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
-                .eq(TSystemConfiguration::getType,3));
-        //解析
-        ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
-        LocalDate today = LocalDate.now();
-        // 判断是否等于今天
-        if (configVO.getLastUpdated().equals(today)) {
-            vo.setEnergyStorage(configVO.getStorageDisCharge().multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN));
-        }else {
-            //判断离今天还有几天
-            int count = (int) ChronoUnit.DAYS.between(configVO.getLastUpdated(), today) +1;//包括今天
-            BigDecimal storageDisCharge = configVO.getStorageDisCharge();
-            // 每天生成一个随机值(不超过100)并累加
-            for (int i = 0; i < count; i++) {
-                int dailyCharge = ThreadLocalRandom.current().nextInt(0, 101); // 0-100的随机数
-                storageDisCharge = storageDisCharge.add(new BigDecimal(dailyCharge));
-            }
+        String s = KsolarUtils.getElectricity().split("_")[0];
+        vo.setEnergyStorage(new BigDecimal(s).multiply(multiplier)      // 乘以 0.1404
+                .divide(new BigDecimal("1000"),2, RoundingMode.HALF_DOWN));
 
-            // 更新回对象
-            configVO.setStorageDisCharge(storageDisCharge);
-            configVO.setLastUpdated(today);
-            String json = JSON.toJSONString(configVO);
-            sysConfig.setContent(json);
-
-            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);
-
-
 
 
 
@@ -173,49 +147,14 @@
         vo.setCarDisCharge(carCharge);
         vo.setGreenElectricity(greenElectricity);
 
-        //获取系统建设日期和累计储能放电量
-        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
-                .eq(TSystemConfiguration::getType,3));
-        //解析
-        ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
         //计算储能充电量
-        LocalDate systemCreateTime = configVO.getSystemCreateTime();
-        LocalDate today = LocalDate.now();
-        int days = (int) ChronoUnit.DAYS.between(systemCreateTime, today) +1;//包括今天
-
-        BigDecimal dailyRate = new BigDecimal("100");
-        BigDecimal totalCharge = dailyRate.multiply(BigDecimal.valueOf(days));
-        vo.setStorageCharge(totalCharge);
+        String electricity = KsolarUtils.getElectricity();
+        vo.setStorageCharge(new BigDecimal( electricity.split("_")[0]));
 
         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());
-            return vo;
-        }
-        //判断离今天还有几天
-        int count = (int) ChronoUnit.DAYS.between(configVO.getLastUpdated(), today) +1;//包括今天
-        BigDecimal storageDisCharge = configVO.getStorageDisCharge();
-        // 每天生成一个随机值(不超过100)并累加
-        for (int i = 0; i < count; i++) {
-            int dailyCharge = ThreadLocalRandom.current().nextInt(0, 101); // 0-100的随机数
-            storageDisCharge = storageDisCharge.add(new BigDecimal(dailyCharge));
-        }
-
-        // 更新回对象
-        configVO.setStorageDisCharge(storageDisCharge);
-        configVO.setLastUpdated(today);
-        String json = JSON.toJSONString(configVO);
-        sysConfig.setContent(json);
-
-        systemConfigurationMapper.updateById(sysConfig);
-        vo.setStorageDisCharge(storageDisCharge);
-
-
-         return vo;
+        vo.setStorageDisCharge(new BigDecimal(electricity.split("_")[1]));
+        return vo;
     }
 
     @Override
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 b5d03b8..d7aa1f6 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
@@ -29,304 +29,21 @@
     @Resource
     private TSystemConfigurationMapper systemConfigurationMapper;
 
-    // 储能相关参数
-    private final BigDecimal storageMax = new BigDecimal("115"); // 储能最大值
-    private final BigDecimal targetDischargeTotal = new BigDecimal("97.75"); // 目标总放电量
-    private final double minChargeIncrement = 0.5; // 充电最小增量
-    private final double maxChargeIncrement = 1.0; // 充电最大增量
-    private final int minDischargeTimes = 3; // 最小放电次数
-    private final int maxDischargeTimes = 4; // 最大放电次数
-    private final BigDecimal minDischargeAmount = new BigDecimal("25"); // 单次最小放电量
-    private final BigDecimal maxDischargeAmount = new BigDecimal("35"); // 单次最大放电量
 
-    // 充电阶段标记
-    private boolean isFirstChargeCompleted = false;
-    private boolean isSecondChargeCompleted = false;
-    // 放电次数计数器
-    private int dischargeCount = 0;
-    // 当前阶段总放电量
-    private BigDecimal currentPhaseDischarge = BigDecimal.ZERO;
-
-    // 定时任务方法 - 能量刷新
-//    @Scheduled(cron = "0 * * * * ?") // 每分钟执行一次
-    public synchronized void refreshValue() {
-        LocalTime now = LocalTime.now();
-
-        // 第一轮充电阶段 (0:00-3:00)
-        if (now.isAfter(LocalTime.of(0, 0)) && now.isBefore(LocalTime.of(3, 0))) {
-            handleChargePhase();
-        }
-        // 第一轮放电阶段 (3:10开始,每10分钟一次)
-        else if (now.isAfter(LocalTime.of(3, 0)) && now.isBefore(LocalTime.of(15, 0))
-                && now.getMinute() % 10 == 0 && now.getSecond() == 0) {
-            handleDischargePhase(false);
-        }
-        // 第二轮充电阶段 (15:00-17:00)
-        else if (now.isAfter(LocalTime.of(15, 0)) && now.isBefore(LocalTime.of(17, 0))) {
-            handleChargePhase();
-        }
-        // 第二轮放电阶段 (17:10开始,每10分钟一次)
-        else if (now.isAfter(LocalTime.of(17, 0)) && now.isBefore(LocalTime.of(23, 59))
-                && now.getMinute() % 10 == 0 && now.getSecond() == 0) {
-            handleDischargePhase(true);
-        }
-    }
-
-    // 充电阶段处理逻辑
-    private void handleChargePhase() {
-        BigDecimal todayStorage = getTodayStorage();
-
-        // 如果已经充满,则不再充电
-        if (todayStorage.compareTo(storageMax) >= 0) {
-            if (!isFirstChargeCompleted && todayStorage.compareTo(storageMax) >= 0) {
-                isFirstChargeCompleted = true;
-                System.out.println("第一轮充电已完成,当前储能: " + todayStorage);
-            } else if (!isSecondChargeCompleted && todayStorage.compareTo(storageMax.multiply(new BigDecimal("2"))) >= 0) {
-                isSecondChargeCompleted = true;
-                System.out.println("第二轮充电已完成,当前储能: " + todayStorage);
-            }
-            return;
-        }
-
-        // 随机增量0.5-1.0
-        BigDecimal increment = randomBigDecimal(minChargeIncrement, maxChargeIncrement);
-        BigDecimal newStorage = todayStorage.add(increment).setScale(2, RoundingMode.HALF_UP);
-
-        // 确保不超过最大值
-        BigDecimal maxAllowed = isFirstChargeCompleted ? storageMax.multiply(new BigDecimal("2")) : storageMax;
-        if (newStorage.compareTo(maxAllowed) > 0) {
-            newStorage = maxAllowed;
-        }
-
-        updateStorageValue(newStorage);
-        System.out.printf("充电阶段:当前时间 %s,今日储能:%.2f%n", LocalTime.now(), newStorage);
-    }
-
-    // 放电阶段处理逻辑
-    private void handleDischargePhase(boolean isSecondPhase) {
-        // 如果是第二轮放电且第一轮未完成,则不执行
-        if (isSecondPhase && !isFirstChargeCompleted) {
-            return;
-        }
-
-        // 如果已经达到目标放电量,则不再放电
-        BigDecimal todayDischarge = getTodayDischarge();
-        BigDecimal target = isSecondPhase ? targetDischargeTotal.multiply(new BigDecimal("2")) : targetDischargeTotal;
-        if (todayDischarge.compareTo(target) >= 0) {
-            return;
-        }
-
-        // 如果是新一轮放电阶段,重置计数器
-        if (currentPhaseDischarge.compareTo(BigDecimal.ZERO) == 0) {
-            dischargeCount = 0;
-        }
-
-        // 计算剩余需要放电的量
-        BigDecimal remainingDischarge = target.subtract(todayDischarge);
-
-        // 随机本次放电量 (25-35)
-        BigDecimal dischargeAmount = randomBigDecimal(minDischargeAmount.doubleValue(), maxDischargeAmount.doubleValue());
-
-        // 如果剩余量不足,则只放剩余量
-        if (dischargeAmount.compareTo(remainingDischarge) > 0) {
-            dischargeAmount = remainingDischarge;
-        }
-
-        // 更新放电量
-        BigDecimal newDischarge = todayDischarge.add(dischargeAmount).setScale(2, RoundingMode.HALF_UP);
-        updateDischargeValue(newDischarge);
-
-        // 更新当前阶段放电总量
-        currentPhaseDischarge = currentPhaseDischarge.add(dischargeAmount);
-        dischargeCount++;
-
-        System.out.printf("放电阶段:当前时间 %s,第%d次放电,本次放电:%.2f,今日总放电:%.2f%n",
-                LocalTime.now(), dischargeCount, dischargeAmount, newDischarge);
-
-        // 如果达到最大放电次数或完成目标放电量,重置当前阶段放电量
-        if (dischargeCount >= maxDischargeTimes || remainingDischarge.subtract(dischargeAmount).compareTo(BigDecimal.ZERO) <= 0) {
-            currentPhaseDischarge = BigDecimal.ZERO;
-        }
-    }
-
-    // 重置任务(每天凌晨0点)
+    // 记录截至昨天的总量(每天凌晨0点)
     @Scheduled(cron = "0 0 0 * * ?")
     public void reset() {
-        // 重置所有状态
-        isFirstChargeCompleted = false;
-        isSecondChargeCompleted = false;
-        dischargeCount = 0;
-        currentPhaseDischarge = BigDecimal.ZERO;
-
-        // 初始化今日储能和放电为0
-        updateStorageValue(BigDecimal.ZERO);
-        updateDischargeValue(BigDecimal.ZERO);
-        System.out.println("每日重置完成:今日储能和放电已清零");
-
-
+        String electricity = KsolarUtils.getElectricity();
 
         TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
-                .eq(TSystemConfiguration::getType,4));
-        sysConfig.setContent("0");
+                .eq(TSystemConfiguration::getType,5));
+        sysConfig.setContent(electricity.split("_")[0]);
         systemConfigurationMapper.updateById(sysConfig);
 
-
-    }
-
-    /**
-     * 生成指定范围内的随机 BigDecimal(两位小数)
-     * @param min 最小值(包含)
-     * @param max 最大值(包含)
-     * @return 随机 BigDecimal
-     */
-    private BigDecimal randomBigDecimal(double min, double max) {
-        // 生成 [0, 1) 随机数
-        double randomValue = random.nextDouble();
-        // 计算范围内的随机值
-        double range = max - min;
-        double value = min + (randomValue * range);
-
-        // 转换为两位小数的 BigDecimal
-        return BigDecimal.valueOf(value).setScale(2, RoundingMode.HALF_UP);
-    }
-
-
-    // 通用配置更新方法
-    private void updateConfigField(String field, BigDecimal value) {
-        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(
-                new LambdaQueryWrapper<TSystemConfiguration>()
-                        .eq(TSystemConfiguration::getType, 3)
-        );
-        if (sysConfig != null) {
-            ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
-            if ("todayStorage".equals(field)) {
-                configVO.setTodayStorage(value);
-            } else {
-                configVO.setTodayDischarge(value);
-            }
-            sysConfig.setContent(JSON.toJSONString(configVO));
-            systemConfigurationMapper.updateById(sysConfig);
-        }
-    }
-    // 时间段判断方法
-    private boolean isInStorageMorning(LocalTime time) {
-        return time.isAfter(LocalTime.of(0, 0)) && time.isBefore(LocalTime.of(8, 0));
-    }
-
-    private boolean isInDischargeMorning(LocalTime time) {
-        return time.isAfter(LocalTime.of(10, 0)) && time.isBefore(LocalTime.of(12, 0));
-    }
-
-    private boolean isInStorageAfternoon(LocalTime time) {
-        return time.isAfter(LocalTime.of(12, 0)) && time.isBefore(LocalTime.of(17, 0));
-    }
-
-    private boolean isInDischargeAfternoon(LocalTime time) {
-        return time.isAfter(LocalTime.of(17, 0)) && time.isBefore(LocalTime.of(22, 0));
-    }
-
-
-    // 更新今日储能值到数据库
-    private void updateStorageValue(BigDecimal value) {
-        updateConfigField("todayStorage", value);
-    }
-
-    // 更新今日放电值到数据库(原逻辑保留)
-    private void updateDischargeValue(BigDecimal value) {
-        updateConfigField("todayDischarge", value);
-    }
-
-    public BigDecimal getTodayStorage() {
-        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(
-                new LambdaQueryWrapper<TSystemConfiguration>()
-                        .eq(TSystemConfiguration::getType, 3)
-        );
-        if (sysConfig != null) {
-            ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
-            return configVO.getTodayStorage();
-        }
-        return BigDecimal.ZERO;
-    }
-
-    public BigDecimal getTodayDischarge() {
-        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(
-                new LambdaQueryWrapper<TSystemConfiguration>()
-                        .eq(TSystemConfiguration::getType, 3)
-        );
-        if (sysConfig != null) {
-            ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
-            return configVO.getTodayDischarge();
-        }
-        return BigDecimal.ZERO;
-    }
-
-
-
-
-    /**
-     *光伏发电和消纳
-     */
-//    @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))) {
-//            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(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( 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(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))) {
-//            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);
+        TSystemConfiguration sysConfig1 = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
+                .eq(TSystemConfiguration::getType,4));
+        sysConfig1.setContent(electricity.split("_")[1]);
+        systemConfigurationMapper.updateById(sysConfig1);
 
     }
 
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
index eb3cf11..06ab4ac 100644
--- 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
@@ -199,6 +199,7 @@
      * @return
      */
     public static String getElectricity(){
+        String valueTotal = "0";
         String value = "0";
         HttpRequest post = HttpRequest.post("https://www.zsdcloud.cn:8443/openApi/equipment/select.action");
         post.form("token", accessToken);
@@ -215,16 +216,23 @@
         }
         String string1 = jsonObject.getString("result");
         JSONObject jsonObject1 = JSONObject.parseObject(string1);
-        String realInfo = jsonObject1.getString("realInfo");
+        String realInfo = jsonObject1.getString("childList");
         JSONArray jsonArray = JSONArray.parseArray(realInfo);
         for (Object o : jsonArray) {
             JSONObject jsonObject2 = JSONObject.parseObject(o.toString());
-            if(jsonObject2.get("Name").toString().equals("累积日充电量")){
-                value=  jsonObject2.get("Value").toString();
-                break;
+            String string2 = jsonObject2.get("valueList").toString();
+            JSONArray jsonArray1 = JSONArray.parseArray(string2);
+            for (Object o1 : jsonArray1) {
+                JSONObject jsonObject3 = JSONObject.parseObject(o1.toString());
+                if(jsonObject3.get("Name").toString().equals("系统累计充电量")){
+                    valueTotal=  jsonObject3.get("Value").toString();
+                }
+                if(jsonObject3.get("Name").toString().equals("系统累计放电量")){
+                    value=  jsonObject3.get("Value").toString();
+                }
             }
         }
-        return value;
+        return valueTotal+"_"+value;
     }
     public static void main(String[] args) throws Exception {
         String electricity = getElectricity();

--
Gitblit v1.7.1