You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
1 year ago
|
package com.dky.utils;
|
||
|
|
||
|
import com.dky.utils.enums.EnergyEmissions;
|
||
|
import com.dky.utils.enums.EnergyPriceType;
|
||
|
|
||
|
import java.util.EnumSet;
|
||
|
import java.util.concurrent.atomic.AtomicReference;
|
||
|
|
||
|
public class GetThisEnergyEmissions {
|
||
|
|
||
|
public static Double getThisEnergyEmission(Integer code) {
|
||
|
// 二氧化碳排放系数
|
||
|
AtomicReference<Double> co2EmissionFactor = new AtomicReference<>(0.0);
|
||
|
EnumSet<EnergyEmissions> daysSet = EnumSet.allOf(EnergyEmissions.class);
|
||
|
daysSet.forEach(day -> {
|
||
|
if (code.equals(day.getCode())){
|
||
|
co2EmissionFactor.set(day.getCo2EmissionFactor());
|
||
|
}
|
||
|
});
|
||
|
return co2EmissionFactor.get();
|
||
|
}
|
||
|
|
||
|
public static Double getThisEnergyPrice(Integer code) {
|
||
|
// 二氧化碳排放系数
|
||
|
AtomicReference<Double> price = new AtomicReference<>(0.0);
|
||
|
EnumSet<EnergyPriceType> daysSet = EnumSet.allOf(EnergyPriceType.class);
|
||
|
daysSet.forEach(day -> {
|
||
|
if (code.equals(day.getCode())){
|
||
|
price.set(day.getPrice());
|
||
|
}
|
||
|
});
|
||
|
return price.get();
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|