| | |
| | | EmissionReductionVO vo = new EmissionReductionVO(); |
| | | //获取总电量 计算累计充电二氧化碳减排量 |
| | | BigDecimal charge=top.getCarCharge(); |
| | | BigDecimal multiplier = new BigDecimal("0.1404"); |
| | | //计算累计充电二氧化碳减排量 |
| | | if (charge.compareTo(BigDecimal.ZERO) != 0) { |
| | | // 定义乘数和除数 |
| | | BigDecimal multiplier = new BigDecimal("0.1404"); // 0.1404 |
| | | BigDecimal divisor = new BigDecimal("1000"); // 1000 |
| | | // 0.1404 |
| | | // 计算:charge × 0.1404 ÷ 1000 |
| | | charge = charge |
| | | .multiply(multiplier) // 乘以 0.1404 |
| | |
| | | vo.setCharge(charge); |
| | | |
| | | //获取累计储能放电量 |
| | | TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>() |
| | | .eq(TSystemConfiguration::getType,3)); |
| | | //解析 |
| | | ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class); |
| | | LocalDate today = LocalDate.now(); |
| | | // 判断是否等于今天 |
| | | if (configVO.getLastUpdated().equals(today)) { |
| | | 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;//包括今天 |
| | | BigDecimal storageDisCharge = configVO.getStorageDisCharge(); |
| | | // 每天生成一个随机值(不超过100)并累加 |
| | | for (int i = 0; i < count; i++) { |
| | | int dailyCharge = ThreadLocalRandom.current().nextInt(0, 101); // 0-100的随机数 |
| | | storageDisCharge = storageDisCharge.add(new BigDecimal(dailyCharge)); |
| | | } |
| | | String s = KsolarUtils.getElectricity().split("_")[0]; |
| | | vo.setEnergyStorage(new BigDecimal(s).multiply(multiplier) // 乘以 0.1404 |
| | | .divide(new BigDecimal("1000"),2, RoundingMode.HALF_DOWN)); |
| | | |
| | | // 更新回对象 |
| | | configVO.setStorageDisCharge(storageDisCharge); |
| | | configVO.setLastUpdated(today); |
| | | String json = JSON.toJSONString(configVO); |
| | | sysConfig.setContent(json); |
| | | |
| | | 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.setCarDisCharge(carCharge); |
| | | vo.setGreenElectricity(greenElectricity); |
| | | |
| | | //获取系统建设日期和累计储能放电量 |
| | | TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>() |
| | | .eq(TSystemConfiguration::getType,3)); |
| | | //解析 |
| | | ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class); |
| | | //计算储能充电量 |
| | | LocalDate systemCreateTime = configVO.getSystemCreateTime(); |
| | | LocalDate today = LocalDate.now(); |
| | | int days = (int) ChronoUnit.DAYS.between(systemCreateTime, today) +1;//包括今天 |
| | | |
| | | BigDecimal dailyRate = new BigDecimal("100"); |
| | | BigDecimal totalCharge = dailyRate.multiply(BigDecimal.valueOf(days)); |
| | | vo.setStorageCharge(totalCharge); |
| | | String electricity = KsolarUtils.getElectricity(); |
| | | vo.setStorageCharge(new BigDecimal( electricity.split("_")[0])); |
| | | |
| | | 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()); |
| | | return vo; |
| | | } |
| | | //判断离今天还有几天 |
| | | int count = (int) ChronoUnit.DAYS.between(configVO.getLastUpdated(), today) +1;//包括今天 |
| | | BigDecimal storageDisCharge = configVO.getStorageDisCharge(); |
| | | // 每天生成一个随机值(不超过100)并累加 |
| | | for (int i = 0; i < count; i++) { |
| | | int dailyCharge = ThreadLocalRandom.current().nextInt(0, 101); // 0-100的随机数 |
| | | storageDisCharge = storageDisCharge.add(new BigDecimal(dailyCharge)); |
| | | } |
| | | |
| | | // 更新回对象 |
| | | configVO.setStorageDisCharge(storageDisCharge); |
| | | configVO.setLastUpdated(today); |
| | | String json = JSON.toJSONString(configVO); |
| | | sysConfig.setContent(json); |
| | | |
| | | systemConfigurationMapper.updateById(sysConfig); |
| | | vo.setStorageDisCharge(storageDisCharge); |
| | | |
| | | |
| | | vo.setStorageDisCharge(new BigDecimal(electricity.split("_")[1])); |
| | | return vo; |
| | | } |
| | | |