作者 wwmin

修正建设期类型问题

@@ -113,7 +113,7 @@ public class Synthesize_no_2_6 implements Serializable { @@ -113,7 +113,7 @@ public class Synthesize_no_2_6 implements Serializable {
113 @TableField("no_60") 113 @TableField("no_60")
114 private Double no60; 114 private Double no60;
115 @TableField("no_61") 115 @TableField("no_61")
116 - private Integer no61; 116 + private Double no61;
117 @TableField("no_62") 117 @TableField("no_62")
118 private Integer no62; 118 private Integer no62;
119 @TableField("no_63") 119 @TableField("no_63")
@@ -2137,7 +2137,7 @@ public class ProjectServiceImpl implements ProjectService { @@ -2137,7 +2137,7 @@ public class ProjectServiceImpl implements ProjectService {
2137 double totalInvestment = synthesize_no_3_6.getNo300(); 2137 double totalInvestment = synthesize_no_3_6.getNo300();
2138 List<NpvData> npvDatas = new ArrayList<>(); 2138 List<NpvData> npvDatas = new ArrayList<>();
2139 NpvData npvData = new NpvData(); 2139 NpvData npvData = new NpvData();
2140 - npvData.setR(synthesize_no_2_6.getNo63()/100); 2140 + npvData.setR(synthesize_no_2_6.getNo63() / 100);
2141 npvData.setYear(synthesize_no_2_6.getNo62()); 2141 npvData.setYear(synthesize_no_2_6.getNo62());
2142 List<Double> list = new ArrayList<>(); 2142 List<Double> list = new ArrayList<>();
2143 int yearLength = npvData.getYear(); 2143 int yearLength = npvData.getYear();
@@ -2150,6 +2150,7 @@ public class ProjectServiceImpl implements ProjectService { @@ -2150,6 +2150,7 @@ public class ProjectServiceImpl implements ProjectService {
2150 currentYearFundData.setAnnualOutcome(0.0); 2150 currentYearFundData.setAnnualOutcome(0.0);
2151 currentYearFundData.setAnnualProfit(0.0); 2151 currentYearFundData.setAnnualProfit(0.0);
2152 double zeroYearDeductionAddedTax = 0.0; 2152 double zeroYearDeductionAddedTax = 0.0;
  2153 + List<Double> ownAddedTasList = new ArrayList<>();
2153 for (int i = 0; i <= yearLength; i++) { 2154 for (int i = 0; i <= yearLength; i++) {
2154 //总 电费+ 燃气水费 + 运维费 2155 //总 电费+ 燃气水费 + 运维费
2155 double annualTotalTransportationCost = annualElectricFee + annualFuelGasAndWaterFee + annualOperationFee; 2156 double annualTotalTransportationCost = annualElectricFee + annualFuelGasAndWaterFee + annualOperationFee;
@@ -2171,6 +2172,7 @@ public class ProjectServiceImpl implements ProjectService { @@ -2171,6 +2172,7 @@ public class ProjectServiceImpl implements ProjectService {
2171 fundDataList.add(currentYearFundData); 2172 fundDataList.add(currentYearFundData);
2172 //所得税 2173 //所得税
2173 double ownAddedTax = 0.0; 2174 double ownAddedTax = 0.0;
  2175 +
2174 //region 2176 //region
2175 if ("1".equals(synthesize_no_2_5.getSale())) { 2177 if ("1".equals(synthesize_no_2_5.getSale())) {
2176 /** 2178 /**
@@ -2241,9 +2243,9 @@ public class ProjectServiceImpl implements ProjectService { @@ -2241,9 +2243,9 @@ public class ProjectServiceImpl implements ProjectService {
2241 //净现金流 2243 //净现金流
2242 double NCF = annualIncome - annualOutcome - ownAddedTax; 2244 double NCF = annualIncome - annualOutcome - ownAddedTax;
2243 if (i == 0) { 2245 if (i == 0) {
2244 -// double r = 1 / Math.pow((1 + synthesize_no_2_6.getNo63()/100), 1);//第0年的折现因子  
2245 NCF = -totalInvestment; 2246 NCF = -totalInvestment;
2246 } 2247 }
  2248 + ownAddedTasList.add(ownAddedTax);
2247 list.add(NCF); 2249 list.add(NCF);
2248 } 2250 }
2249 2251
@@ -2253,18 +2255,20 @@ public class ProjectServiceImpl implements ProjectService { @@ -2253,18 +2255,20 @@ public class ProjectServiceImpl implements ProjectService {
2253 for (int i = 0; i < list.size(); i++) { 2255 for (int i = 0; i < list.size(); i++) {
2254 npvData = new NpvData(); 2256 npvData = new NpvData();
2255 npvData.setYear(yearLength); 2257 npvData.setYear(yearLength);
2256 - npvData.setR(synthesize_no_2_6.getNo63()/100);//使用输入后修改值 (基准收益率) 2258 + npvData.setR(synthesize_no_2_6.getNo63() / 100);//使用输入后修改值 (基准收益率)
2257 npvData.setRmb(list.get(i)); 2259 npvData.setRmb(list.get(i));
2258 - npvData.setY(1 / Math.pow((1 + npvData.getR()), i + 1)); 2260 + npvData.setY(1 / Math.pow((1 + npvData.getR()), i + buildingYear));
2259 npvDatas.add(npvData); 2261 npvDatas.add(npvData);
2260 } 2262 }
2261 /** 2263 /**
2262 * 净现值(NPV) 2264 * 净现值(NPV)
2263 */ 2265 */
2264 double sum = 0; 2266 double sum = 0;
  2267 + List<Double> sumList = new ArrayList<>();
2265 for (NpvData data : npvDatas) { 2268 for (NpvData data : npvDatas) {
2266 double d = formatDouble1(data.getRmb()) * formatDouble1(data.getY()); 2269 double d = formatDouble1(data.getRmb()) * formatDouble1(data.getY());
2267 sum += d; 2270 sum += d;
  2271 + sumList.add(d);
2268 } 2272 }
2269 map.put("num1", df.format(sum)); 2273 map.put("num1", df.format(sum));
2270 /** 2274 /**
@@ -2290,7 +2294,7 @@ public class ProjectServiceImpl implements ProjectService { @@ -2290,7 +2294,7 @@ public class ProjectServiceImpl implements ProjectService {
2290 break; 2294 break;
2291 } 2295 }
2292 } 2296 }
2293 - double spp = year + Math.abs(sum1) / sum2; 2297 + double spp = year + Math.abs(sum1) / sum2 - 1 + buildingYear;
2294 map.put("num3", df.format(spp)); 2298 map.put("num3", df.format(spp));
2295 /** 2299 /**
2296 * 动态投资回收期(DPP) 2300 * 动态投资回收期(DPP)
@@ -2310,7 +2314,7 @@ public class ProjectServiceImpl implements ProjectService { @@ -2310,7 +2314,7 @@ public class ProjectServiceImpl implements ProjectService {
2310 } 2314 }
2311 } 2315 }
2312 //endregion 2316 //endregion
2313 - double dpp = year3 + Math.abs(sum3) / sum4; 2317 + double dpp = year3 + Math.abs(sum3) / sum4 - 1 + buildingYear;
2314 map.put("num4", df.format(dpp)); 2318 map.put("num4", df.format(dpp));
2315 return map; 2319 return map;
2316 } 2320 }
@@ -2352,7 +2356,8 @@ public class ProjectServiceImpl implements ProjectService { @@ -2352,7 +2356,8 @@ public class ProjectServiceImpl implements ProjectService {
2352 return res; 2356 return res;
2353 } 2357 }
2354 2358
2355 - public static double irr(List<Double> values, double guess) { 2359 + //内部收益率 (整年计算)
  2360 + public static double irr(List<Double> ncfList, double guess) {
2356 int maxIterationCount = 1000; 2361 int maxIterationCount = 1000;
2357 double absoluteAccuracy = 1.0E-007D; 2362 double absoluteAccuracy = 1.0E-007D;
2358 2363
@@ -2362,9 +2367,9 @@ public class ProjectServiceImpl implements ProjectService { @@ -2362,9 +2367,9 @@ public class ProjectServiceImpl implements ProjectService {
2362 while (i < maxIterationCount) { 2367 while (i < maxIterationCount) {
2363 double fValue = 0.0D; 2368 double fValue = 0.0D;
2364 double fDerivative = 0.0D; 2369 double fDerivative = 0.0D;
2365 - for (int k = 0; k < values.size(); k++) {  
2366 - fValue += values.get(k) / Math.pow(1.0D + x0, k);  
2367 - fDerivative += -k * values.get(k) / Math.pow(1.0D + x0, k + 1); 2370 + for (int k = 0; k < ncfList.size(); k++) {
  2371 + fValue += ncfList.get(k) / Math.pow(1.0D + x0, k);
  2372 + fDerivative += -k * ncfList.get(k) / Math.pow(1.0D + x0, k + 1);
2368 } 2373 }
2369 double x1 = x0 - fValue / fDerivative; 2374 double x1 = x0 - fValue / fDerivative;
2370 if (Math.abs(x1 - x0) <= absoluteAccuracy) { 2375 if (Math.abs(x1 - x0) <= absoluteAccuracy) {