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/service/impl/TScreenContentServiceImpl.java | 63 ++++++++++--------------------- 1 files changed, 21 insertions(+), 42 deletions(-) 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 3dd359e..caa54aa 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 @@ -15,6 +15,7 @@ import com.ruoyi.other.mapper.TSystemConfigurationMapper; import com.ruoyi.other.service.TScreenContentService; import com.ruoyi.other.service.TSystemConfigurationService; +import com.ruoyi.other.util.KsolarUtils; import com.ruoyi.other.vo.EmissionReductionVO; import com.ruoyi.other.vo.PhotovoltaicPowerGenerationVO; import com.ruoyi.other.vo.ScreenStorageConfigVO; @@ -96,72 +97,48 @@ 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); + + + + + + //计算比率 - vo.setPhotovoltaicRate(calculateRatio(vo.getPhotovoltaic(),vo.getTotal())); - vo.setEnergyStorageRate(calculateRatio(vo.getEnergyStorage(),vo.getTotal())); - vo.setChargeRate(calculateRatio(vo.getCharge(),vo.getTotal())); + vo.setPhotovoltaicRate(calculateRatio(vo.getPhotovoltaic(),vo.getTotal()).multiply(new BigDecimal("100"))); + vo.setEnergyStorageRate(calculateRatio(vo.getEnergyStorage(),vo.getTotal()).multiply(new BigDecimal("100"))); + vo.setChargeRate(calculateRatio(vo.getCharge(),vo.getTotal()).multiply(new BigDecimal("100"))); return vo; } - public static void main(String[] args) { - BigDecimal divide = new BigDecimal("607").multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN); - System.out.println(divide); - } //百分比计算 public static BigDecimal calculateRatio(BigDecimal part, BigDecimal total) { if (total.compareTo(BigDecimal.ZERO) == 0) { throw new ArithmeticException("分母不能为零"); } - - return part.divide(total, 2, RoundingMode.HALF_UP); + return part.divide(total, 4, RoundingMode.HALF_UP); } @Override public PhotovoltaicPowerGenerationVO photovoltaicPowerGeneration(List<Integer> siteIds) { - //需调用接口 - - //假数据 PhotovoltaicPowerGenerationVO vo = new PhotovoltaicPowerGenerationVO(); List<LocalDate> dates = new ArrayList<>(); - List<Integer> values = new ArrayList<>(); + List<Double> values = new ArrayList<>(); LocalDate today = LocalDate.now(); // 生成每天数据 for (int i = 7; i >= 1; i--) {//升序 LocalDate day = today.minusDays(i); //统计 dates.add(day); - int value = new Random().nextInt(151) + 100; // 100-250 - - switch (i){ - case 1: - value = 1780; // 50-100 - break; - case 2: - value = 1810; // 50-100 - break; - case 3: - value = 1765; // 50-100 - break; - case 4: - value = 1793; // 50-100 - break; - case 5: - value = 1833; // 50-100 - break; - case 6: - value = 1815; // 50-100 - break; - case 7: - value =1794; // 50-100 - break; - - } + Double value = KsolarUtils.getTodayEnergy(day.toString()); // 100-250 values.add(value); } vo.setDates(dates); @@ -205,8 +182,11 @@ BigDecimal dailyRate = new BigDecimal("100"); BigDecimal totalCharge = dailyRate.multiply(BigDecimal.valueOf(days)); vo.setStorageCharge(totalCharge); - //获取储能放电量 + 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()); @@ -231,8 +211,7 @@ vo.setStorageDisCharge(storageDisCharge); - vo.setPhotovoltaic(new BigDecimal("9950")); - return vo; + return vo; } @Override -- Gitblit v1.7.1