From 378669e94558e6d4d7383604f84dabd9d2242e7c Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期五, 06 六月 2025 09:54:12 +0800 Subject: [PATCH] 调整参数 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java | 73 ++++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-) 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 058c274..fb0abf6 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 @@ -15,6 +15,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalTime; +import java.util.List; import java.util.Random; @Service @@ -26,6 +27,7 @@ private final BigDecimal targetLow = new BigDecimal("85"); private final BigDecimal targetHigh = new BigDecimal("87"); + private final int maxIncrement = 10; @@ -108,9 +110,80 @@ public void reset() { BigDecimal currentValue = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP); updateCurrentValue(currentValue); + + refreshValueOne = new BigDecimal("0"); + TSystemConfiguration sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>() + .eq(TSystemConfiguration::getType,4)).get(0); + sysConfigs.setContent("0"); + systemConfigurationMapper.updateById(sysConfigs); + //更新 this.isRunning = true; } + + public static BigDecimal refreshValueOne = new BigDecimal("0"); + /** + *光伏发电和消纳 + */ + @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; + } + // 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)); + 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(3 + (3.5 - 3) * 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); + } + } + + + + } \ No newline at end of file -- Gitblit v1.7.1