| | |
| | | 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); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | |
| | | 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); |
| | | |
| | | } |
| | | |
| | | |
| | | } |