From e40e5235b571cfb8d3eeca93109d34d0bcdcdf0d Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期四, 05 六月 2025 09:09:54 +0800 Subject: [PATCH] 调整参数 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java | 76 ++++++++++++++++++++++++++++--------- 1 files changed, 57 insertions(+), 19 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 88032be..9fc1fe5 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 @@ -30,10 +30,7 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; +import java.util.*; import java.util.concurrent.ThreadLocalRandom; /** @@ -54,16 +51,11 @@ @Override public EmissionReductionVO emissionReduction(List<Integer> siteIds) { + ScreenTopVO top = top(Arrays.asList(25, 26)); //需调用接口 计算光伏减排 EmissionReductionVO vo = new EmissionReductionVO(); //获取总电量 计算累计充电二氧化碳减排量 - BigDecimal charge=new BigDecimal("0.00"); - if (siteIds!=null && !siteIds.isEmpty()){ - R<BigDecimal> r = chargingOrderClient.getSumDegreeBySiteIds(siteIds); - if (r.getCode()==200){ - charge=r.getData(); - } - } + BigDecimal charge=top.getCarCharge(); //计算累计充电二氧化碳减排量 if (charge.compareTo(BigDecimal.ZERO) != 0) { // 定义乘数和除数 @@ -72,7 +64,7 @@ // 计算:charge × 0.1404 ÷ 1000 charge = charge .multiply(multiplier) // 乘以 0.1404 - .divide(divisor, 2, RoundingMode.HALF_UP); // 除以 1000,保留6位小数,四舍五入 + .divide(new BigDecimal("1000"),2, RoundingMode.HALF_DOWN); // 除以 1000,保留6位小数,四舍五入 } vo.setCharge(charge); @@ -84,7 +76,7 @@ LocalDate today = LocalDate.now(); // 判断是否等于今天 if (configVO.getLastUpdated().equals(today)) { - vo.setEnergyStorage(configVO.getStorageDisCharge()); + vo.setEnergyStorage(configVO.getStorageDisCharge().multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN)); }else { //判断离今天还有几天 int count = (int) ChronoUnit.DAYS.between(configVO.getLastUpdated(), today) +1;//包括今天 @@ -102,18 +94,23 @@ sysConfig.setContent(json); systemConfigurationMapper.updateById(sysConfig); - vo.setEnergyStorage(storageDisCharge); + vo.setEnergyStorage(storageDisCharge.multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN)); } //总数: 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); } //百分比计算 @@ -122,7 +119,7 @@ throw new ArithmeticException("分母不能为零"); } - return part.divide(total, 2, RoundingMode.HALF_UP); + return part.divide(total, 4, RoundingMode.HALF_UP); } @Override @@ -140,6 +137,31 @@ //统计 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; + + } values.add(value); } vo.setDates(dates); @@ -156,7 +178,7 @@ BigDecimal greenElectricity=new BigDecimal("0.00"); if (siteIds!=null && !siteIds.isEmpty()){ //获取充电量 - R<BigDecimal> r = chargingOrderClient.getSumDegreeBySiteIds(siteIds); + R<BigDecimal> r = chargingOrderClient.getSumDegreeBySiteIds(Arrays.asList(25,26)); if (r.getCode()==200){ charge=r.getData(); } @@ -207,6 +229,22 @@ systemConfigurationMapper.updateById(sysConfig); vo.setStorageDisCharge(storageDisCharge); + + + vo.setPhotovoltaic(new BigDecimal("9950")); return vo; } + + @Override + public void carportData(Integer parkingPlace, Integer remainPlace) { + this.baseMapper.carportData(parkingPlace,remainPlace); + } + + @Override + public HashMap<String, Object> getCarportData() { + HashMap<String, Object> carportData = this.baseMapper.getCarportData(); + int count = Integer.valueOf(carportData.get("parkingPlace").toString()) - Integer.valueOf(carportData.get("remainPlace").toString()); + carportData.put("useCarport",count); + return carportData; + } } -- Gitblit v1.7.1