作者 wwmin

修正建设期类型问题

... ... @@ -113,7 +113,7 @@ public class Synthesize_no_2_6 implements Serializable {
@TableField("no_60")
private Double no60;
@TableField("no_61")
private Integer no61;
private Double no61;
@TableField("no_62")
private Integer no62;
@TableField("no_63")
... ...
... ... @@ -2137,7 +2137,7 @@ public class ProjectServiceImpl implements ProjectService {
double totalInvestment = synthesize_no_3_6.getNo300();
List<NpvData> npvDatas = new ArrayList<>();
NpvData npvData = new NpvData();
npvData.setR(synthesize_no_2_6.getNo63()/100);
npvData.setR(synthesize_no_2_6.getNo63() / 100);
npvData.setYear(synthesize_no_2_6.getNo62());
List<Double> list = new ArrayList<>();
int yearLength = npvData.getYear();
... ... @@ -2150,6 +2150,7 @@ public class ProjectServiceImpl implements ProjectService {
currentYearFundData.setAnnualOutcome(0.0);
currentYearFundData.setAnnualProfit(0.0);
double zeroYearDeductionAddedTax = 0.0;
List<Double> ownAddedTasList = new ArrayList<>();
for (int i = 0; i <= yearLength; i++) {
//总 电费+ 燃气水费 + 运维费
double annualTotalTransportationCost = annualElectricFee + annualFuelGasAndWaterFee + annualOperationFee;
... ... @@ -2171,6 +2172,7 @@ public class ProjectServiceImpl implements ProjectService {
fundDataList.add(currentYearFundData);
//所得税
double ownAddedTax = 0.0;
//region
if ("1".equals(synthesize_no_2_5.getSale())) {
/**
... ... @@ -2241,9 +2243,9 @@ public class ProjectServiceImpl implements ProjectService {
//净现金流
double NCF = annualIncome - annualOutcome - ownAddedTax;
if (i == 0) {
// double r = 1 / Math.pow((1 + synthesize_no_2_6.getNo63()/100), 1);//第0年的折现因子
NCF = -totalInvestment;
}
ownAddedTasList.add(ownAddedTax);
list.add(NCF);
}
... ... @@ -2253,18 +2255,20 @@ public class ProjectServiceImpl implements ProjectService {
for (int i = 0; i < list.size(); i++) {
npvData = new NpvData();
npvData.setYear(yearLength);
npvData.setR(synthesize_no_2_6.getNo63()/100);//使用输入后修改值 (基准收益率)
npvData.setR(synthesize_no_2_6.getNo63() / 100);//使用输入后修改值 (基准收益率)
npvData.setRmb(list.get(i));
npvData.setY(1 / Math.pow((1 + npvData.getR()), i + 1));
npvData.setY(1 / Math.pow((1 + npvData.getR()), i + buildingYear));
npvDatas.add(npvData);
}
/**
* 净现值(NPV)
*/
double sum = 0;
List<Double> sumList = new ArrayList<>();
for (NpvData data : npvDatas) {
double d = formatDouble1(data.getRmb()) * formatDouble1(data.getY());
sum += d;
sumList.add(d);
}
map.put("num1", df.format(sum));
/**
... ... @@ -2290,7 +2294,7 @@ public class ProjectServiceImpl implements ProjectService {
break;
}
}
double spp = year + Math.abs(sum1) / sum2;
double spp = year + Math.abs(sum1) / sum2 - 1 + buildingYear;
map.put("num3", df.format(spp));
/**
* 动态投资回收期(DPP)
... ... @@ -2310,7 +2314,7 @@ public class ProjectServiceImpl implements ProjectService {
}
}
//endregion
double dpp = year3 + Math.abs(sum3) / sum4;
double dpp = year3 + Math.abs(sum3) / sum4 - 1 + buildingYear;
map.put("num4", df.format(dpp));
return map;
}
... ... @@ -2352,7 +2356,8 @@ public class ProjectServiceImpl implements ProjectService {
return res;
}
public static double irr(List<Double> values, double guess) {
//内部收益率 (整年计算)
public static double irr(List<Double> ncfList, double guess) {
int maxIterationCount = 1000;
double absoluteAccuracy = 1.0E-007D;
... ... @@ -2362,9 +2367,9 @@ public class ProjectServiceImpl implements ProjectService {
while (i < maxIterationCount) {
double fValue = 0.0D;
double fDerivative = 0.0D;
for (int k = 0; k < values.size(); k++) {
fValue += values.get(k) / Math.pow(1.0D + x0, k);
fDerivative += -k * values.get(k) / Math.pow(1.0D + x0, k + 1);
for (int k = 0; k < ncfList.size(); k++) {
fValue += ncfList.get(k) / Math.pow(1.0D + x0, k);
fDerivative += -k * ncfList.get(k) / Math.pow(1.0D + x0, k + 1);
}
double x1 = x0 - fValue / fDerivative;
if (Math.abs(x1 - x0) <= absoluteAccuracy) {
... ...