albertshaw лет назад: 8
Родитель
Сommit
c68f6c83a3
1 измененных файлов с 11 добавлено и 5 удалено
  1. 11 5
      src/main/java/com/goafanti/evaluation/controller/EvaluationController.java

+ 11 - 5
src/main/java/com/goafanti/evaluation/controller/EvaluationController.java

@@ -52,6 +52,7 @@ import com.goafanti.evaluation.service.ValueEvaluationService;
 @RequestMapping(value = "/api/user/evaluate")
 @RequestMapping(value = "/api/user/evaluate")
 public class EvaluationController extends BaseApiController {
 public class EvaluationController extends BaseApiController {
 
 
+	private static final String			GOVERNMENT_LOAN_ROR	= "government_loan_ror";
 	private static final Logger			logger				= LoggerFactory.getLogger(EvaluationController.class);
 	private static final Logger			logger				= LoggerFactory.getLogger(EvaluationController.class);
 	private static final MathContext	DEFAULT_PRECISION	= new MathContext(4, RoundingMode.HALF_UP);
 	private static final MathContext	DEFAULT_PRECISION	= new MathContext(4, RoundingMode.HALF_UP);
 
 
@@ -260,14 +261,18 @@ public class EvaluationController extends BaseApiController {
 	}
 	}
 
 
 	@RequestMapping(value = "/report/{id}", method = RequestMethod.GET)
 	@RequestMapping(value = "/report/{id}", method = RequestMethod.GET)
-	public Result report(@PathVariable String id) {
+	public Result report(@PathVariable String id, String noCache) {
 		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
 		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
 		Result res = new Result();
 		Result res = new Result();
 		ValueEvaluation ve = valueEvaluationService.getMyEvaluation(Long.valueOf(id));
 		ValueEvaluation ve = valueEvaluationService.getMyEvaluation(Long.valueOf(id));
 		if (ve == null || ve.getStep() < 7) {
 		if (ve == null || ve.getStep() < 7) {
 			res.error(buildError(ErrorConstants.EVALUATE_ID));
 			res.error(buildError(ErrorConstants.EVALUATE_ID));
 		} else {
 		} else {
+			if (noCache != null) {
+				sysDictService.clear(GOVERNMENT_LOAN_ROR);
+			}
 			Map<String, Object> map = new HashMap<>();
 			Map<String, Object> map = new HashMap<>();
+			map.put("customer", TokenManager.getUserToken().getNickname());
 			calcValue(ve, map);
 			calcValue(ve, map);
 			res.data(map);
 			res.data(map);
 		}
 		}
@@ -311,9 +316,9 @@ public class EvaluationController extends BaseApiController {
 		Map<String, Integer> profitScores = getProfitScores(step2, step3);
 		Map<String, Integer> profitScores = getProfitScores(step2, step3);
 		Map<String, Integer> discountRates = getDiscountRates(step7);
 		Map<String, Integer> discountRates = getDiscountRates(step7);
 
 
-		BigDecimal profitRate = calcProfitRate(profitScores, step1.getIndustry());
+		BigDecimal profitRate = calcProfitRate(profitScores, step1.getIndustry(), result);
 
 
-		BigDecimal governmentLoanRoR = new BigDecimal(sysDictService.getValue("government_loan_ror"),
+		BigDecimal governmentLoanRoR = new BigDecimal(sysDictService.getValue(GOVERNMENT_LOAN_ROR),
 				MathContext.DECIMAL32);
 				MathContext.DECIMAL32);
 		BigDecimal taxRate = new BigDecimal(step6.getTaxRate());
 		BigDecimal taxRate = new BigDecimal(step6.getTaxRate());
 
 
@@ -378,7 +383,7 @@ public class EvaluationController extends BaseApiController {
 		return profitScores;
 		return profitScores;
 	}
 	}
 
 
-	private BigDecimal calcProfitRate(Map<String, Integer> profitScores, Integer industry) {
+	private BigDecimal calcProfitRate(Map<String, Integer> profitScores, Integer industry, Map<String, Object> map) {
 		BigDecimal legalFactor = new BigDecimal(0.2, DEFAULT_PRECISION);
 		BigDecimal legalFactor = new BigDecimal(0.2, DEFAULT_PRECISION);
 		BigDecimal techFactor = new BigDecimal(0.6, DEFAULT_PRECISION);
 		BigDecimal techFactor = new BigDecimal(0.6, DEFAULT_PRECISION);
 		BigDecimal fundFactor = legalFactor;
 		BigDecimal fundFactor = legalFactor;
@@ -415,7 +420,8 @@ public class EvaluationController extends BaseApiController {
 			minRate = new BigDecimal(pr.getMinRate());
 			minRate = new BigDecimal(pr.getMinRate());
 			maxRate = new BigDecimal(pr.getMaxRate());
 			maxRate = new BigDecimal(pr.getMaxRate());
 		}
 		}
-
+		map.put("minRate", minRate);
+		map.put("maxRate", maxRate);
 		profitRate = maxRate.subtract(minRate).multiply(profitRate.multiply(PERCENTAGE)).add(minRate)
 		profitRate = maxRate.subtract(minRate).multiply(profitRate.multiply(PERCENTAGE)).add(minRate)
 				.multiply(PERCENTAGE).setScale(4, RoundingMode.FLOOR);
 				.multiply(PERCENTAGE).setScale(4, RoundingMode.FLOOR);