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/util/EnergyRefreshService.java | 90 ++++++++++++++++++++++++++------------------- 1 files changed, 52 insertions(+), 38 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 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 -- Gitblit v1.7.1