liujie
昨天 378669e94558e6d4d7383604f84dabd9d2242e7c
调整参数
3个文件已修改
91 ■■■■■ 已修改文件
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java
@@ -9,9 +9,11 @@
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.other.api.domain.TNotice;
import com.ruoyi.other.api.domain.TScreenContent;
import com.ruoyi.other.api.domain.TSystemConfiguration;
import com.ruoyi.other.api.dto.NoticeQueryDto;
import com.ruoyi.other.service.TNoticeService;
import com.ruoyi.other.service.TScreenContentService;
import com.ruoyi.other.service.TSystemConfigurationService;
import com.ruoyi.other.util.EnergyRefreshService;
import com.ruoyi.other.vo.*;
import io.swagger.annotations.ApiOperation;
@@ -20,6 +22,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.time.LocalDateTime;
import java.util.HashMap;
@@ -41,6 +44,8 @@
    private TScreenContentService screenContentService;
    @Resource
    private EnergyRefreshService energyRefreshService;
    @Resource
    private TSystemConfigurationService systemConfigurationService;
    /**
     * 顶部-累计电量
@@ -70,7 +75,13 @@
            vo.setGreenElectricityToday(vo.getGreenElectricityToday().add(x.getGreenElectricityToday()));
        });
        vo.setTodayGenerateElectricity(new BigDecimal("1821"));
        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));
        return AjaxResult.success(vo);
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java
@@ -231,7 +231,10 @@
        vo.setStorageDisCharge(storageDisCharge);
        vo.setPhotovoltaic(new BigDecimal("9950"));
        TSystemConfiguration sysConfig1 = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
                .eq(TSystemConfiguration::getType,4));
        vo.setPhotovoltaic(new BigDecimal(sysConfig1.getContent()));
        vo.setGreenElectricity(vo.getPhotovoltaic().multiply(new BigDecimal("0.94")).setScale(2,  RoundingMode.HALF_UP));
        return vo;
    }
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);
        }
    }
}