diff --git a/src/main/java/com/sztzjy/fund_investment/controller/UserController.java b/src/main/java/com/sztzjy/fund_investment/controller/UserController.java index 9143ddc..9347fa6 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/UserController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/UserController.java @@ -9,16 +9,22 @@ import com.sztzjy.fund_investment.entity.Flow; import com.sztzjy.fund_investment.entity.PerformanceScore; import com.sztzjy.fund_investment.entity.PerformanceScoreExample; import com.sztzjy.fund_investment.entity.User; +import com.sztzjy.fund_investment.entity.dto.EvaluationLevel; +import com.sztzjy.fund_investment.entity.dto.PerformanceScoreDto; +import com.sztzjy.fund_investment.entity.dto.PerformanceTrainingScoreDto; import com.sztzjy.fund_investment.mapper.FlowMapper; import com.sztzjy.fund_investment.mapper.PerformanceScoreMapper; import com.sztzjy.fund_investment.mapper.UserMapper; import com.sztzjy.fund_investment.service.IIlabService; import com.sztzjy.fund_investment.service.IUserService; +import com.sztzjy.fund_investment.service.PerformanceScoreService; +import com.sztzjy.fund_investment.service.tea.ClassScoreService; import com.sztzjy.fund_investment.util.ResultEntity; import com.sztzjy.fund_investment.util.RsaUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import org.geolatte.geom.M; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -32,6 +38,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.sql.Array; import java.util.*; @Api(tags = "用户管理") @@ -49,7 +58,11 @@ public class UserController { @Autowired private PerformanceScoreMapper performanceScoreMapper; @Autowired + private PerformanceScoreService performanceScoreService; + @Autowired private IIlabService iIlabService; + @Autowired + private ClassScoreService classScoreService; @ApiOperation(value = "用户登录", httpMethod = "POST") @OperateLog(recordParameters = false) @@ -59,7 +72,7 @@ public class UserController { @RequestParam(required = false) String passwordEncode, @RequestParam(required = false) String ticket) { - if (ticket==null) { + if (ticket == null) { String password; try { password = RsaUtil.decryptByPrivateKey(passwordEncode); @@ -97,8 +110,8 @@ public class UserController { //判断用户是否存在 Map accessToken = iIlabService.getAccessToken(ticket); String access_token = accessToken.get("access_token"); - if (access_token==null){ - return new ResultEntity(HttpStatus.BAD_REQUEST,"登录过期,请重试!"); + if (access_token == null) { + return new ResultEntity(HttpStatus.BAD_REQUEST, "登录过期,请重试!"); } String un = accessToken.get("un"); String dis = accessToken.get("dis"); @@ -187,7 +200,139 @@ public class UserController { flow.setFlowId(id); flowMapper.updateByPrimaryKey(flow); - return new ResultEntity(HttpStatus.OK, "已重新实训!",id); + return new ResultEntity(HttpStatus.OK, "已重新实训!", id); + } + + + //恭喜你完成实验,你本次实验总体(非常好,很好,一般,不够好),实验过程充满挑战,能够完成实验已经很棒了,接下来我们看下实验完成情况吧。 + // 实验中你完成的非常好(特别好,非常棒)的步骤有xx,xx和xx步骤,你对这些步骤知识掌提的非常扎实(牢国),相信你一定做了不少努力,这些对你以后参与股权基金投资相关工作非常有帮助。 + // 实验中你完成的一般的步骤有x0x,xx,xx和xx步骤,你初步等握(了解)了这部分内容,相信你通过学习能够(可以)做的更好,这些都是股权基金投资实务业务知识,跟理论还是有一定差距的,努力学习吧! + // 实验中你完成的不够好(较差)的步骤有xx,xx,xax和xx步骡,是不是没有认真实验呢?这是个非常棒(很好)的实验,要认真对待哦,不会的业务知识去搜集资料或者请教下同学和老师吧,争取早日掌握它们! + // 如果你对实验过程有什么疑问,可以通过系统场景右下角的答疑校钮进行提问哦,会有人回复的,如果你对实验有什么意见,也欢迎提出,我们一起改进,让这个实验越来越好帮助更多的人! + @ApiOperation(value = "获取评价等级", httpMethod = "POST") + @PostMapping("getEvaluationLevel") + @AnonymousAccess + public ResultEntity getEvaluationLevel(@RequestParam String flowId) throws IllegalAccessException { + EvaluationLevel evaluationLevel = new EvaluationLevel(); + PerformanceTrainingScoreDto trainingScore = classScoreService.getStuTrainingScore(flowId); + BigDecimal totalScore = trainingScore.getTotalScore(); + BigDecimal five = new BigDecimal(5); + BigDecimal ten = new BigDecimal(10); + BigDecimal fifteen = new BigDecimal(15); + Map maxScoresMap = new HashMap<>(); + maxScoresMap.put("practicalCognitionScore", five); + maxScoresMap.put("knowledgeAssessmentScore", five); + maxScoresMap.put("fundraisingScore", five); + maxScoresMap.put("projectSearchScore", five); + maxScoresMap.put("projectDueDiligenceScore", fifteen); + maxScoresMap.put("projectValuationScore", fifteen); + maxScoresMap.put("investmentSigningScore", ten); + maxScoresMap.put("ipoScore", ten); + maxScoresMap.put("pricingIssuanceScore", ten); + maxScoresMap.put("profitManagementScore", ten); + maxScoresMap.put("profitDistributionScore", five); + maxScoresMap.put("investmentReportScore", five); + String level = ""; + // 计算等级人数 + if (totalScore.compareTo(BigDecimal.valueOf(90)) >= 0 && totalScore.compareTo(BigDecimal.valueOf(100)) <= 0) { + level = "非常好"; + } else if (totalScore.compareTo(BigDecimal.valueOf(80)) >= 0 && totalScore.compareTo(BigDecimal.valueOf(89)) <= 0) { + level = "很好"; + } else if (totalScore.compareTo(BigDecimal.valueOf(60)) >= 0 && totalScore.compareTo(BigDecimal.valueOf(79)) <= 0) { + level = "一般"; + } else if (totalScore.compareTo(BigDecimal.valueOf(0)) >= 0 && totalScore.compareTo(BigDecimal.valueOf(59)) <= 0) { + level = "不够好"; + } + String[] arr1 = {"非常好", "特别好", "非常棒"}; + String[] arr2 = {"扎实", "牢固"}; + String[] arr3 = {"非常棒", "很好"}; + String[] arr4 = {"掌握", "了解"}; + String[] arr5 = {"能够", "可以"}; + String[] arr6 = {"不够好", "较差"}; + Random random = new Random(); + int index1 = random.nextInt(3); + int index2 = random.nextInt(2); + Map> map = evaluatePerformanceLevel(trainingScore, maxScoresMap); + evaluationLevel.setLevelMap(map); + + String[] evaluationLevelArr = {"恭喜你完成实验,你本次实验总体" + level + ",实验过程充满挑战,能够完成实验已经很棒了,接下来我们看下实验完成情况吧。实验中你完成的" + arr1[index1] + "的步骤有" + + String.join(",", map.get("非常好")) + "步骤," + "你对这些步骤知识掌提的非常" + arr2[index2] + ",相信你一定做了不少努力,这些对你以后参与股权基金投资相关工作非常有帮助。实验中你完成的一般的步骤有" + + String.join(",", map.get("一般")) + "步骤,你初步" + arr4[index2] + "了这部分内容,相信你通过学习" + arr5[index2] + "做的更好,这些都是股权基金投资实务业务知识,跟理论还是有一定差距的,努力学习吧! " + + "实验中你完成的" + arr6[index2] + "的步骤有" + String.join(",", map.get("较差")) + "步骤,是不是没有认真实验呢?这是个" + arr3[index2] + "的实验,要认真对待哦,不会的业务知识去搜集资料或者请教下同学和老师吧,争取早日掌握它们! " + + "如果你对实验过程有什么疑问,可以通过系统场景右下角的答疑按钮进行提问哦,会有人回复的,如果你对实验有什么意见,也欢迎提出,我们一起改进,让这个实验越来越好帮助更多的人!"}; + evaluationLevel.setEvaluation(evaluationLevelArr); + return new ResultEntity(evaluationLevel); + } + + //拿到三种评价等级封装成Map + public Map> evaluatePerformanceLevel(Object dto, Map maxScoresMap) throws IllegalAccessException { + Map> levelMap = new HashMap<>(); + List goodList = new ArrayList(); + List generalList = new ArrayList(); + List badList = new ArrayList(); + for (Field field : dto.getClass().getDeclaredFields()) { + if (!field.getName().equals("totalScore")) { // 排除totalScore字段 + field.setAccessible(true); // 允许访问私有字段 + if (field.getType().equals(BigDecimal.class)) { // 如果字段类型是BigDecimal + String name = field.getName(); + BigDecimal value = (BigDecimal) field.get(dto); // 获取字段的值 + BigDecimal maxScore = maxScoresMap.get(name); // 获取该字段的满分分数 + name = getChineseName(name); + if (value.compareTo(maxScore) == 0) { + goodList.add(name); + } else if ((value.compareTo(BigDecimal.ZERO) == 0 || value.compareTo(BigDecimal.ONE) == 0)) { + badList.add(name); + } else { + generalList.add(name); + } + } + } + } + levelMap.put("非常好", goodList); + levelMap.put("一般", generalList); + levelMap.put("较差", badList); + return levelMap; + } + + //拿到中文名称 + private String getChineseName(String name) { + if (name.equals("practicalCognitionScore")) { + name = "实务认知"; + } + if (name.equals("knowledgeAssessmentScore")) { + name = "知识测评"; + } + if (name.equals("fundraisingScore")) { + name = "基金募资"; + } + if (name.equals("projectSearchScore")) { + name = "寻找项目"; + } + if (name.equals("projectDueDiligenceScore")) { + name = "项目尽调"; + } + if (name.equals("projectValuationScore")) { + name = "项目估值"; + } + if (name.equals("investmentSigningScore")) { + name = "签约投资"; + } + if (name.equals("ipoScore")) { + name = "IPO申请"; + } + if (name.equals("pricingIssuanceScore")) { + name = "询价发行"; + } + if (name.equals("profitManagementScore")) { + name = "收益管理"; + } + if (name.equals("profitDistributionScore")) { + name = "收益分配"; + } + if (name.equals("investmentReportScore")) { + name = "投资报告"; + } + return name; } diff --git a/src/main/java/com/sztzjy/fund_investment/controller/tea/ClassScoreController.java b/src/main/java/com/sztzjy/fund_investment/controller/tea/ClassScoreController.java index 1d68cbc..2cb9606 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/tea/ClassScoreController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/tea/ClassScoreController.java @@ -5,10 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.pagehelper.PageInfo; import com.sztzjy.fund_investment.annotation.AnonymousAccess; import com.sztzjy.fund_investment.config.security.TokenProvider; -import com.sztzjy.fund_investment.entity.TeaClassScore; import com.sztzjy.fund_investment.entity.TrainingReport; -import com.sztzjy.fund_investment.entity.User; -import com.sztzjy.fund_investment.entity.UserExample; import com.sztzjy.fund_investment.entity.dto.*; import com.sztzjy.fund_investment.mapper.TrainingReportMapper; import com.sztzjy.fund_investment.mapper.UserMapper; @@ -25,7 +22,6 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; diff --git a/src/main/java/com/sztzjy/fund_investment/entity/dto/EvaluationLevel.java b/src/main/java/com/sztzjy/fund_investment/entity/dto/EvaluationLevel.java new file mode 100644 index 0000000..b88c126 --- /dev/null +++ b/src/main/java/com/sztzjy/fund_investment/entity/dto/EvaluationLevel.java @@ -0,0 +1,16 @@ +package com.sztzjy.fund_investment.entity.dto; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @Author xcj + * @Date 2024/1/25 + */ +@Data +public class EvaluationLevel { + Map> levelMap; + String [] evaluation; +}