parent
11d808a0ba
commit
ebffd01048
@ -0,0 +1,36 @@ |
|||||||
|
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(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue