From 023cf94363706f1e0b5c54de5183b2db2e302ac4 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Fri, 16 Aug 2024 17:52:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A3=8E=E9=99=A9=E6=B5=8B?= =?UTF-8?q?=E8=AF=84=20=E8=AE=A1=E7=AE=97=E5=BB=BA=E8=AE=AE=E6=8A=95?= =?UTF-8?q?=E8=B5=84=E4=BA=A7=E5=93=81=E5=88=86=E9=85=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E=E6=A1=88=E4=BE=8B?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CaseController.java | 2 +- ...ingController.java => ExamController.java} | 12 +- .../controller/SynthesisPlanController.java | 19 +- .../service/SynthesisPlanService.java | 12 ++ .../service/impl/CaseServiceImpl.java | 13 -- .../impl/SynthesisPlanServiceImpl.java | 168 ++++++++++++++++++ 6 files changed, 201 insertions(+), 25 deletions(-) rename src/main/java/com/sztzjy/money_management/controller/{TrainingController.java => ExamController.java} (50%) create mode 100644 src/main/java/com/sztzjy/money_management/service/SynthesisPlanService.java create mode 100644 src/main/java/com/sztzjy/money_management/service/impl/SynthesisPlanServiceImpl.java diff --git a/src/main/java/com/sztzjy/money_management/controller/CaseController.java b/src/main/java/com/sztzjy/money_management/controller/CaseController.java index 0019ee6..ec616cc 100644 --- a/src/main/java/com/sztzjy/money_management/controller/CaseController.java +++ b/src/main/java/com/sztzjy/money_management/controller/CaseController.java @@ -39,7 +39,7 @@ public class CaseController { ChapterMapper chapterMapper; @PostMapping("/insertCase") - @ApiOperation("新增案例,老师和管理员新增根据caseInfo中的publish区分") + @ApiOperation("新增案例,老师和管理员新增根据caseInfo中的publish区分,学生端新增传isAnswer为学生答案/题目答案+userId") private ResultEntity insertCase(@ApiParam("左侧caseInfo对象") @RequestParam String caseInfo, //todo 传json字符串 @ApiParam("右侧考核点设置的参数对象") @RequestParam String json) { return caseService.insertCase(caseInfo, json); diff --git a/src/main/java/com/sztzjy/money_management/controller/TrainingController.java b/src/main/java/com/sztzjy/money_management/controller/ExamController.java similarity index 50% rename from src/main/java/com/sztzjy/money_management/controller/TrainingController.java rename to src/main/java/com/sztzjy/money_management/controller/ExamController.java index 0b8dd49..1f7c168 100644 --- a/src/main/java/com/sztzjy/money_management/controller/TrainingController.java +++ b/src/main/java/com/sztzjy/money_management/controller/ExamController.java @@ -1,18 +1,18 @@ package com.sztzjy.money_management.controller; -import com.sztzjy.money_management.mapper.ObjectiveQuestionMapper; import io.swagger.annotations.Api; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @Author xcj - * @Date 2024/8/13 + * @Date 2024/8/19 */ @RestController -@Api(tags = "实训相关接口") -@RequestMapping("api/training") -public class TrainingController { +@Api(tags = "考试中心接口") +@RequestMapping("api/exam") +public class ExamController { + + } diff --git a/src/main/java/com/sztzjy/money_management/controller/SynthesisPlanController.java b/src/main/java/com/sztzjy/money_management/controller/SynthesisPlanController.java index b59b565..39489c1 100644 --- a/src/main/java/com/sztzjy/money_management/controller/SynthesisPlanController.java +++ b/src/main/java/com/sztzjy/money_management/controller/SynthesisPlanController.java @@ -9,6 +9,7 @@ import com.sztzjy.money_management.entity.*; import com.sztzjy.money_management.entity.dto.SynthesisPlanScoreDto; import com.sztzjy.money_management.entity.dto.UserStatisticsDto; import com.sztzjy.money_management.mapper.*; +import com.sztzjy.money_management.service.SynthesisPlanService; import com.sztzjy.money_management.util.ResultEntity; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -19,10 +20,8 @@ import org.springframework.http.HttpStatus; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.math.BigDecimal; +import java.util.*; import java.util.regex.Pattern; //综合规划相关 @@ -44,7 +43,8 @@ public class SynthesisPlanController { UserStatisticsMapper userStatisticsMapper; @Autowired ClientFamilyInfoMapper clientFamilyInfoMapper; - + @Autowired + SynthesisPlanService synthesisPlanService; //目标客户查询 //根据create_time排序 @@ -407,4 +407,13 @@ public class SynthesisPlanController { } return null; } + + @AnonymousAccess + @ApiOperation("风险测评结果/建议投资产品分配") + @PostMapping("/adviseInvestmentProductAllot") + public ResultEntity> adviseInvestmentProductAllot(@ApiParam("风险容忍态度分数") @RequestParam BigDecimal RAIScore, + @ApiParam("风险承受能力分数") @RequestParam BigDecimal RCIScore) { + Map map = synthesisPlanService.adviseInvestmentProductAllot(RAIScore, RCIScore); + return new ResultEntity>(map); + } } diff --git a/src/main/java/com/sztzjy/money_management/service/SynthesisPlanService.java b/src/main/java/com/sztzjy/money_management/service/SynthesisPlanService.java new file mode 100644 index 0000000..ac15cde --- /dev/null +++ b/src/main/java/com/sztzjy/money_management/service/SynthesisPlanService.java @@ -0,0 +1,12 @@ +package com.sztzjy.money_management.service; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * @Author xcj + * @Date 2024/8/16 + */ +public interface SynthesisPlanService { + Map adviseInvestmentProductAllot(BigDecimal raiScore, BigDecimal rciScore); +} diff --git a/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java index e7a2d6b..2505a84 100644 --- a/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java +++ b/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java @@ -163,7 +163,6 @@ public class CaseServiceImpl implements CaseService { CaseRiskIndex caseRiskIndex = gson.fromJson(json, CaseRiskIndex.class); caseRiskIndex.setCaseRiskIndexId(IdUtil.randomUUID()); caseRiskIndex.setCaseid(caseid); - caseRiskIndex.setIsAnswer("题目答案"); caseRiskIndexMapper.insert(caseRiskIndex); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -172,7 +171,6 @@ public class CaseServiceImpl implements CaseService { CaseFinanceLiability caseFinanceLiability = gson.fromJson(json, CaseFinanceLiability.class); caseFinanceLiability.setCaseFinanceLiabilityId(IdUtil.randomUUID()); caseFinanceLiability.setCaseId(caseid); - caseFinanceLiability.setIsAnswer("题目答案"); caseFinanceLiabilityMapper.insert(caseFinanceLiability); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -181,7 +179,6 @@ public class CaseServiceImpl implements CaseService { CaseIncomeAndExpenses caseIncomeAndExpenses = gson.fromJson(json, CaseIncomeAndExpenses.class); caseIncomeAndExpenses.setCaseIncomeAndExpensesId(IdUtil.randomUUID()); caseIncomeAndExpenses.setCaseid(caseid); - caseIncomeAndExpenses.setIsAnswer("题目答案"); caseIncomeAndExpensesMapper.insert(caseIncomeAndExpenses); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -190,7 +187,6 @@ public class CaseServiceImpl implements CaseService { CaseCashFlow caseCashFlow = gson.fromJson(json, CaseCashFlow.class); caseCashFlow.setCaseCashFlowId(IdUtil.randomUUID()); caseCashFlow.setCaseid(caseid); - caseCashFlow.setIsAnswer("题目答案"); caseCashFlowMapper.insert(caseCashFlow); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -199,7 +195,6 @@ public class CaseServiceImpl implements CaseService { CaseFinancialRatiosWithBLOBs caseFinancialRatios = gson.fromJson(json, CaseFinancialRatiosWithBLOBs.class); caseFinancialRatios.setCaseFinancialRatiosId(IdUtil.randomUUID()); caseFinancialRatios.setCaseid(caseid); - caseFinancialRatios.setIsAnswer("题目答案"); caseFinancialRatiosMapper.insert(caseFinancialRatios); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -208,7 +203,6 @@ public class CaseServiceImpl implements CaseService { CaseCashPlan caseCashPlan = gson.fromJson(json, CaseCashPlan.class); caseCashPlan.setCaseCashPlanId(IdUtil.randomUUID()); caseCashPlan.setCaseid(caseid); - caseCashPlan.setIsAnswer("题目答案"); caseCashPlanMapper.insert(caseCashPlan); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -217,7 +211,6 @@ public class CaseServiceImpl implements CaseService { CaseLifeEducationPlan caseLifeEducationPlan = gson.fromJson(json, CaseLifeEducationPlan.class); caseLifeEducationPlan.setCaseLifeEducationPlanId(IdUtil.randomUUID()); caseLifeEducationPlan.setCaseid(caseid); - caseLifeEducationPlan.setIsAnswer("题目答案"); caseLifeEducationPlanMapper.insert(caseLifeEducationPlan); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -234,7 +227,6 @@ public class CaseServiceImpl implements CaseService { CaseStartAnUndertakingPlan caseStartAnUndertakingPlan = gson.fromJson(json, CaseStartAnUndertakingPlan.class); caseStartAnUndertakingPlan.setCaseStartAnUndertakingPlanId(IdUtil.randomUUID()); caseStartAnUndertakingPlan.setCaseid(caseid); - caseStartAnUndertakingPlan.setIsAnswer("题目答案"); caseStartAnUndertakingPlanMapper.insert(caseStartAnUndertakingPlan); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -243,7 +235,6 @@ public class CaseServiceImpl implements CaseService { CaseRetirementPlan caseRetirementPlan = gson.fromJson(json, CaseRetirementPlan.class); caseRetirementPlan.setCaseRetirementPlanId(IdUtil.randomUUID()); caseRetirementPlan.setCaseid(caseid); - caseRetirementPlan.setIsAnswer("题目答案"); caseRetirementPlanMapper.insert(caseRetirementPlan); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -252,7 +243,6 @@ public class CaseServiceImpl implements CaseService { CaseInsurancePlan caseInsurancePlan = gson.fromJson(json, CaseInsurancePlan.class); caseInsurancePlan.setCaseInsurancePlanId(IdUtil.randomUUID()); caseInsurancePlan.setCaseid(caseid); - caseInsurancePlan.setIsAnswer("题目答案"); caseInsurancePlanMapper.insert(caseInsurancePlan); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -266,7 +256,6 @@ public class CaseServiceImpl implements CaseService { CaseTaxPlan caseTaxPlan = gson.fromJson(json, CaseTaxPlan.class); caseTaxPlan.setCaseTaxPlanId(IdUtil.randomUUID()); caseTaxPlan.setCaseid(caseid); - caseTaxPlan.setIsAnswer("题目答案"); caseTaxPlanMapper.insert(caseTaxPlan); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -275,7 +264,6 @@ public class CaseServiceImpl implements CaseService { CaseDistributionOfPropertyWithBLOBs caseDistributionOfPropertyWithBLOBs = gson.fromJson(json, CaseDistributionOfPropertyWithBLOBs.class); caseDistributionOfPropertyWithBLOBs.setCaseDistributionOfPropertyId(IdUtil.randomUUID()); caseDistributionOfPropertyWithBLOBs.setCaseid(caseid); - caseDistributionOfPropertyWithBLOBs.setIsAnswer("题目答案"); caseDistributionOfPropertyMapper.insert(caseDistributionOfPropertyWithBLOBs); return new ResultEntity(HttpStatus.OK, "新增成功!"); } @@ -284,7 +272,6 @@ public class CaseServiceImpl implements CaseService { CaseHeritageWithBLOBs caseHeritageWithBLOBs = gson.fromJson(json, CaseHeritageWithBLOBs.class); caseHeritageWithBLOBs.setCaseHeritageId(IdUtil.randomUUID()); caseHeritageWithBLOBs.setCaseid(caseid); - caseHeritageWithBLOBs.setIsAnswer("题目答案"); caseHeritageMapper.insert(caseHeritageWithBLOBs); return new ResultEntity(HttpStatus.OK, "新增成功!"); } diff --git a/src/main/java/com/sztzjy/money_management/service/impl/SynthesisPlanServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/SynthesisPlanServiceImpl.java new file mode 100644 index 0000000..caa85b7 --- /dev/null +++ b/src/main/java/com/sztzjy/money_management/service/impl/SynthesisPlanServiceImpl.java @@ -0,0 +1,168 @@ +package com.sztzjy.money_management.service.impl; + +import com.sztzjy.money_management.service.SynthesisPlanService; +import io.swagger.annotations.ApiParam; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestParam; + +import java.math.BigDecimal; +import java.util.Map; +import java.util.HashMap; + +/** + * @Author xcj + * @Date 2024/8/16 + */ +@Service +public class SynthesisPlanServiceImpl implements SynthesisPlanService { + + + @Override + public Map adviseInvestmentProductAllot(BigDecimal RAIScore, BigDecimal RCIScore) { + Map allocation = new HashMap<>(); + + int RAIScoreInt = RAIScore.intValue(); //风险容忍态度分数 + int RCIScoreInt = RCIScore.intValue(); //风险承受能力分数 + + if (RAIScoreInt >= 0 && RAIScoreInt <= 19) { + if (RCIScoreInt >= 0 && RCIScoreInt <= 19) { + allocation.put("货币", "70%"); + allocation.put("债券", "20%"); + allocation.put("股票", "10%"); + } + if (RCIScoreInt >= 20 && RCIScoreInt <= 39) { + allocation.put("货币", "50%"); + allocation.put("债券", "40%"); + allocation.put("股票", "10%"); + } + if (RCIScoreInt >= 40 && RCIScoreInt <= 59) { + allocation.put("货币", "40%"); + allocation.put("债券", "40%"); + allocation.put("股票", "20%"); + } + if (RCIScoreInt >= 60 && RCIScoreInt <= 79) { + allocation.put("货币", "20%"); + allocation.put("债券", "50%"); + allocation.put("股票", "30%"); + } + if (RCIScoreInt >= 80 && RCIScoreInt <= 100) { + allocation.put("货币", "0%"); + allocation.put("债券", "50%"); + allocation.put("股票", "50%"); + } + } + + if (RAIScoreInt >= 20 && RAIScoreInt <= 39) { + if (RCIScoreInt >= 0 && RCIScoreInt <= 19) { + allocation.put("货币", "50%"); + allocation.put("债券", "40%"); + allocation.put("股票", "10%"); + } + if (RCIScoreInt >= 20 && RCIScoreInt <= 39) { + allocation.put("货币", "40%"); + allocation.put("债券", "40%"); + allocation.put("股票", "20%"); + } + if (RCIScoreInt >= 40 && RCIScoreInt <= 59) { + allocation.put("货币", "20%"); + allocation.put("债券", "50%"); + allocation.put("股票", "30%"); + } + if (RCIScoreInt >= 60 && RCIScoreInt <= 79) { + allocation.put("货币", "0%"); + allocation.put("债券", "50%"); + allocation.put("股票", "50%"); + } + if (RCIScoreInt >= 80 && RCIScoreInt <= 100) { + allocation.put("货币", "0%"); + allocation.put("债券", "40%"); + allocation.put("股票", "60%"); + } + } + + if (RAIScoreInt >= 40 && RAIScoreInt <= 59) { + if (RCIScoreInt >= 0 && RCIScoreInt <= 19) { + allocation.put("货币", "40%"); + allocation.put("债券", "40%"); + allocation.put("股票", "20%"); + } + if (RCIScoreInt >= 20 && RCIScoreInt <= 39) { + allocation.put("货币", "20%"); + allocation.put("债券", "50%"); + allocation.put("股票", "30%"); + } + if (RCIScoreInt >= 40 && RCIScoreInt <= 59) { + allocation.put("货币", "0%"); + allocation.put("债券", "50%"); + allocation.put("股票", "50%"); + } + if (RCIScoreInt >= 60 && RCIScoreInt <= 79) { + allocation.put("货币", "0%"); + allocation.put("债券", "40%"); + allocation.put("股票", "60%"); + } + if (RCIScoreInt >= 80 && RCIScoreInt <= 100) { + allocation.put("货币", "0%"); + allocation.put("债券", "30%"); + allocation.put("股票", "70%"); + } + } + + if (RAIScoreInt >= 60 && RAIScoreInt <= 79) { + if (RCIScoreInt >= 0 && RCIScoreInt <= 19) { + allocation.put("货币", "20%"); + allocation.put("债券", "30%"); + allocation.put("股票", "50%"); + } + if (RCIScoreInt >= 20 && RCIScoreInt <= 39) { + allocation.put("货币", "0%"); + allocation.put("债券", "50%"); + allocation.put("股票", "50%"); + } + if (RCIScoreInt >= 40 && RCIScoreInt <= 59) { + allocation.put("货币", "0%"); + allocation.put("债券", "40%"); + allocation.put("股票", "60%"); + } + if (RCIScoreInt >= 60 && RCIScoreInt <= 79) { + allocation.put("货币", "0%"); + allocation.put("债券", "30%"); + allocation.put("股票", "70%"); + } + if (RCIScoreInt >= 80 && RCIScoreInt <= 100) { + allocation.put("货币", "0%"); + allocation.put("债券", "20%"); + allocation.put("股票", "80%"); + } + } + + if (RAIScoreInt >= 80 && RAIScoreInt <= 100) { + if (RCIScoreInt >= 0 && RCIScoreInt <= 19) { + allocation.put("货币", "0%"); + allocation.put("债券", "50%"); + allocation.put("股票", "50%"); + } + if (RCIScoreInt >= 20 && RCIScoreInt <= 39) { + allocation.put("货币", "0%"); + allocation.put("债券", "40%"); + allocation.put("股票", "60%"); + } + if (RCIScoreInt >= 40 && RCIScoreInt <= 59) { + allocation.put("货币", "0%"); + allocation.put("债券", "30%"); + allocation.put("股票", "70%"); + } + if (RCIScoreInt >= 60 && RCIScoreInt <= 79) { + allocation.put("货币", "0%"); + allocation.put("债券", "50%"); + allocation.put("股票", "80%"); + } + if (RCIScoreInt >= 80 && RCIScoreInt <= 100) { + allocation.put("货币", "0%"); + allocation.put("债券", "40%"); + allocation.put("股票", "90%"); + } + } + return allocation; + } +}