Explorar el Código

修改科技评估,强制结果取绝对值

anderx hace 1 año
padre
commit
e95d40f4bb

+ 16 - 4
src/main/java/com/goafanti/evaluation/controller/UserEvaluationApiController.java

@@ -325,25 +325,28 @@ public class UserEvaluationApiController extends BaseApiController {
 		result.put("industry", industryCategoryService.list(0).stream().filter(it -> {
 			return it.getId().equals(step1.getIndustry());
 		}).findFirst().get().getName());
-
+		//获得行业分类平均值 -10.43
 		BigDecimal industryAverageRate = getIndustryCategoryValue(step1, subs);
+		//获取用户预测收入
 		List<Long> userForecast = step5.getForecastIncomes().stream().map(fc -> {
 			return fc.getIncome();
 		}).collect(Collectors.toList());
+		//使用行业平均值+预测收入+剩余年份做计算
 		List<Long> sysForecast = calcSysForecast(userForecast, industryAverageRate, timeLeft);
 		calcUserForecast(userForecast, timeLeft);
 		List<Long> measuredForecast = calcMeasuredForecast(userForecast, sysForecast);
 
 		Map<String, Integer> profitScores = getProfitScores(step2, step3);
+		//用户预测+系统预测 >>位移获得值
 		Map<String, Integer> discountRates = getDiscountRates(step7);
-
+		//利润率
 		BigDecimal profitRate = calcProfitRate(profitScores, step1.getIndustry(), result);
 
 		BigDecimal governmentLoanRoR = new BigDecimal(GOVERNMENT_LOAN_ROR,
 				MathContext.DECIMAL32);
 //		BigDecimal governmentLoanRoR = new BigDecimal(0);
 		BigDecimal taxRate = new BigDecimal(step6.getTaxRate());
-
+		//折扣率
 		BigDecimal discountRate = calcDiscountRate(discountRates, taxRate, governmentLoanRoR);
 		result.put("userForecast", userForecast);
 		result.put("sysForecast", sysForecast);
@@ -361,6 +364,14 @@ public class UserEvaluationApiController extends BaseApiController {
 		return value;
 	}
 
+	/**
+	 *
+	 * @param measuredForecast 测量预测
+	 * @param profitRate   利润率
+	 * @param discountRate 折扣率
+	 * @param result
+	 * @return
+	 */
 	private Long calcTotal(List<Long> measuredForecast, BigDecimal profitRate, BigDecimal discountRate,
 			Map<String, Object> result) {
 		List<Long> profitList = new ArrayList<>();
@@ -379,7 +390,7 @@ public class UserEvaluationApiController extends BaseApiController {
 			index++;
 		}
 		result.put("profitList", profitList); // 收入分成额
-		return total.longValue();
+		return Math.abs(total.longValue());
 	}
 
 	private BigDecimal calcDiscountRate(Map<String, Integer> discountRates, BigDecimal taxRate,
@@ -508,6 +519,7 @@ public class UserEvaluationApiController extends BaseApiController {
 		List<Long> sysForecast = new ArrayList<>();
 		BigDecimal lastYear = BigDecimal.ZERO;
 		BigDecimal step = new BigDecimal(0.1, DEFAULT_PRECISION);
+		//
 		industryAverageRate = industryAverageRate.multiply(PERCENTAGE);
 		for (int i = 0; i < timeLeft; i++) {
 			if (i == 0) {