From cf5c7adaf317e29e70aeae84a023271841d3e4d3 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Thu, 27 Jun 2024 18:28:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E5=8A=A1=E8=AE=A4?= =?UTF-8?q?=E7=9F=A5=E5=BE=97=E5=88=86=E5=92=8C=E6=99=BA=E8=83=BD=E8=AF=84?= =?UTF-8?q?=E5=88=86=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/security/WebSecurityConfig.java | 1 - .../service/serviceImpl/TopicServiceImpl.java | 6 +- .../tea/ClassScoreServiceImpl.java | 207 ++++++++++++++++-- .../com/sztzjy/fund_investment/task/Task.java | 2 +- .../sztzjy/fund_investment/util/RsaUtil.java | 1 + src/main/resources/application-pro.yml | 4 +- 6 files changed, 197 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/sztzjy/fund_investment/config/security/WebSecurityConfig.java b/src/main/java/com/sztzjy/fund_investment/config/security/WebSecurityConfig.java index 26cff49..09ba9a0 100644 --- a/src/main/java/com/sztzjy/fund_investment/config/security/WebSecurityConfig.java +++ b/src/main/java/com/sztzjy/fund_investment/config/security/WebSecurityConfig.java @@ -22,7 +22,6 @@ import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import javax.annotation.Resource; import java.util.HashSet; import java.util.Map; import java.util.Objects; diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java index 0f301e3..1378d53 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java @@ -331,12 +331,12 @@ public class TopicServiceImpl implements TopicService { TopicRecordExample example = new TopicRecordExample(); TopicRecordExample.Criteria criteria = example.createCriteria(); criteria.andFlowIdEqualTo(flowId); - if (module.equals("IPO")){ - Listlist =new ArrayList<>(); + if (module.equals("IPO")) { + List list = new ArrayList<>(); list.add(Constant.IPOBK); list.add(Constant.IPOTJ); criteria.andModuleIn(list); - }else { + } else { criteria.andModuleEqualTo(module); } example.setOrderByClause("id"); diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/tea/ClassScoreServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/tea/ClassScoreServiceImpl.java index 1dc1f48..497ac4e 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/tea/ClassScoreServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/tea/ClassScoreServiceImpl.java @@ -9,7 +9,6 @@ import com.sztzjy.fund_investment.entity.dto.*; import com.sztzjy.fund_investment.mapper.*; import com.sztzjy.fund_investment.service.PerformanceScoreService; import com.sztzjy.fund_investment.service.tea.ClassScoreService; -import com.sztzjy.fund_investment.util.PageUtil; import com.sztzjy.fund_investment.util.ResultEntity; import com.sztzjy.fund_investment.util.excel.FilePortUtil; import com.sztzjy.fund_investment.util.file.IFileUtil; @@ -24,8 +23,6 @@ import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; /** * @Author xcj @@ -218,18 +215,13 @@ public class ClassScoreServiceImpl implements ClassScoreService { */ @Override public PageInfo getStudentScoreDetails(Integer index, Integer size, String schoolId, String classId, String studentIdOrName) { - PageHelper.startPage(index,size); + PageHelper.startPage(index, size); List studentScoreDetails = userMapper.getStudentScoreDetails(schoolId, classId, studentIdOrName); - PageInfo pageInfo =new PageInfo(studentScoreDetails); + PageInfo pageInfo = new PageInfo(studentScoreDetails); return pageInfo; } - - - - - /* 成绩详情导出功能 * @author xcj * @Date 2023/11/27 @@ -281,6 +273,156 @@ public class ClassScoreServiceImpl implements ClassScoreService { } } +// /* 智能评分 +// * @author xcj +// * @Date 2023/11/28 +// */ +// @Override +// public ResultEntity autoScore(String schoolId) { +// //根据flowId查出所有页面的结论报告 +// PerformanceScoreExample performanceScoreExample = new PerformanceScoreExample(); +// performanceScoreExample.createCriteria().andSchoolIdEqualTo(schoolId); +// List performanceScores = performanceScoreMapper.selectByExample(performanceScoreExample); +// List list = new ArrayList(); +// +// if (!performanceScores.isEmpty()) { +// for (PerformanceScore performanceScore : performanceScores) { +// String flowId = performanceScore.getFlowId(); +// list.add(flowId); +// FoundProject foundProject = foundProjectMapper.selectByPrimaryKey(flowId); +// if (foundProject == null) { +// continue; +// } +// String serviceDueDiligence = ""; +// String financialDueDiligence = ""; +// String projectValuationRelative = ""; +// String projectValuationAbsolute = ""; +// String foundProjectConclusion = ""; +// if (StringUtils.isBlank(foundProject.getFoundProjectConclusion())) { +// performanceScoreService.updateScore("projectSearchReportScore", 0, flowId); +// } else { +// foundProjectConclusion = foundProject.getFoundProjectConclusion(); // 寻找项目结论 +// } +// if (StringUtils.isBlank(foundProject.getServiceDueDiligence())) { +// performanceScoreService.updateScore("projectDueDiligenceBusinessReportScore", 0, flowId); +// } else { +// serviceDueDiligence = foundProject.getServiceDueDiligence(); // 业务尽调结论 +// } +// if (StringUtils.isBlank(foundProject.getFinancialDueDiligence())) { +// performanceScoreService.updateScore("projectDueDiligenceFinanceReportScore", 0, flowId); +// } else { +// financialDueDiligence = foundProject.getFinancialDueDiligence(); //财务尽调结论 +// } +// if (StringUtils.isBlank(foundProject.getProjectValuationRelative())) { +// performanceScoreService.updateScore("projectValuationRelativeScore", 0, flowId); +// } else { +// projectValuationRelative = foundProject.getProjectValuationRelative();//相对估值结论得分 +// } +// if (StringUtils.isBlank(foundProject.getProjectValuationAbsolute())) { +// performanceScoreService.updateScore("projectValuationAbsoluteScore", 0, flowId); +// } else { +// projectValuationAbsolute = foundProject.getProjectValuationAbsolute();//绝对估值结论得分 +// } +// foundProjectConclusion = foundProjectConclusion.replaceAll("[^\\u4E00-\\u9FA5]", ""); +// serviceDueDiligence = serviceDueDiligence.replaceAll("[^\\u4E00-\\u9FA5]", ""); +// financialDueDiligence = financialDueDiligence.replaceAll("[^\\u4E00-\\u9FA5]", ""); +// projectValuationRelative = projectValuationRelative.replaceAll("[^\\u4E00-\\u9FA5]", ""); +// projectValuationAbsolute = projectValuationAbsolute.replaceAll("[^\\u4E00-\\u9FA5]", ""); +// PerformanceScoreExample performanceScoreExample2 = new PerformanceScoreExample(); +// performanceScoreExample2.createCriteria().andSchoolIdEqualTo(schoolId).andFlowIdEqualTo(flowId); +// +// // 寻找项目结论 +// if (performanceScore.getProjectSearchReportScore() == null) { +// if (foundProjectConclusion.length() >= 30) { +// // 字符串长度超过30 +// performanceScoreService.updateScore("projectSearchReportScore", 2, flowId); +// } else { +// //未超过30,结论报告是必填项,到这里就给1分没有0 +// performanceScoreService.updateScore("projectSearchReportScore", 1, flowId); +// } +// } +// // 业务尽调结论 +// if (performanceScore.getProjectDueDiligenceBusinessReportScore() == null) { +// +// if (serviceDueDiligence.length() >= 30) { +// performanceScoreService.updateScore("projectDueDiligenceBusinessReportScore", 2, flowId); +// } else { +// performanceScoreService.updateScore("projectDueDiligenceBusinessReportScore", 1, flowId); +// } +// } +// //财务尽调结论 +// if (performanceScore.getProjectDueDiligenceFinanceReportScore() == null) { +// +// if (financialDueDiligence.length() >= 30) { +// performanceScoreService.updateScore("projectDueDiligenceFinanceReportScore", 2, flowId); +// } else { +// performanceScoreService.updateScore("projectDueDiligenceFinanceReportScore", 1, flowId); +// } +// } +// //项目相对估值结论 +// if (performanceScore.getProjectValuationRelativeScore() == null) { +// +// if (projectValuationRelative.length() >= 30) { +// performanceScoreService.updateScore("projectValuationRelativeScore", 2, flowId); +// } else { +// performanceScoreService.updateScore("projectValuationRelativeScore", 1, flowId); +// } +// } +// //项目绝对估值结论 +// if (performanceScore.getProjectValuationAbsoluteScore() == null) { +// +// if (projectValuationAbsolute.length() >= 30) { +// performanceScoreService.updateScore("projectValuationAbsoluteScore", 2, flowId); +// } else { +// performanceScoreService.updateScore("projectValuationAbsoluteScore", 1, flowId); +// } +// } +// } +// for (String flowIdByList : list) { +// TrainingReportExample trainingReportExample = new TrainingReportExample(); +// trainingReportExample.createCriteria().andSchoolIdEqualTo(schoolId).andFlowIdEqualTo(flowIdByList).andStepEqualTo("投资报告"); +// PerformanceScore scoreByFlowId = performanceScoreService.getByFlowId(flowIdByList); +// List trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample); +// if (trainingReports.isEmpty()) { +// continue; +// } +// TrainingReport trainingReport = trainingReports.get(0); +// if (scoreByFlowId.getExperienceScore() == null && StringUtils.isBlank(trainingReport.getExperience())) { +// performanceScoreService.updateScore("experienceScore", 0, flowIdByList); +// trainingReport.setExperienceScore(BigDecimal.ZERO); +// } +// //实训心得 +// if (scoreByFlowId.getExperienceScore() == null && StringUtils.isNotBlank(trainingReport.getExperience())) { +// String experience = trainingReport.getExperience(); +// if (experience.length() < 100) { +// performanceScoreService.updateScore("experienceScore", 1, flowIdByList); +// trainingReport.setExperienceScore(BigDecimal.ONE); +// } else if (experience.length() < 300) { +// performanceScoreService.updateScore("experienceScore", 2, flowIdByList); +// trainingReport.setExperienceScore(BigDecimal.valueOf(2)); +// } else { +// performanceScoreService.updateScore("experienceScore", 3, flowIdByList); +// trainingReport.setExperienceScore(BigDecimal.valueOf(3)); +// } +// } +// //实验报告,未上传 0 分 上传得两分 +// if (scoreByFlowId.getInvestmentReportScore() == null) { +// if (trainingReport.getUrl() == null && trainingReport.getReportName() == null) { +// performanceScoreService.updateScore("investmentReportScore", 0, flowIdByList);//todo 需要修改 +// trainingReport.setReportScore(BigDecimal.ZERO); +// } else if (!(trainingReport.getUrl().isEmpty()) && !(trainingReport.getReportName().isEmpty())) { +// performanceScoreService.updateScore("investmentReportScore", 2, flowIdByList);//todo 需要修改 +// trainingReport.setReportScore(BigDecimal.valueOf(2)); +// } +// } +// trainingReportMapper.updateByPrimaryKey(trainingReport); +// } +// return new ResultEntity<>(HttpStatus.OK); +// } +// return new ResultEntity<>(HttpStatus.NOT_FOUND); +// } + + /* 智能评分 * @author xcj * @Date 2023/11/28 @@ -291,12 +433,26 @@ public class ClassScoreServiceImpl implements ClassScoreService { PerformanceScoreExample performanceScoreExample = new PerformanceScoreExample(); performanceScoreExample.createCriteria().andSchoolIdEqualTo(schoolId); List performanceScores = performanceScoreMapper.selectByExample(performanceScoreExample); + List list = new ArrayList(); + for (PerformanceScore performanceScore : performanceScores) { + String flowId = performanceScore.getFlowId(); + list.add(flowId); + } + + FoundProjectExample example = new FoundProjectExample(); + example.createCriteria().andFlowIdIn(list); + List foundProjects = foundProjectMapper.selectByExample(example); + + Map map = new HashMap<>(); + for (FoundProject foundProject : foundProjects) { + map.put(foundProject.getFlowId(), foundProject); + } + if (!performanceScores.isEmpty()) { for (PerformanceScore performanceScore : performanceScores) { String flowId = performanceScore.getFlowId(); - list.add(flowId); - FoundProject foundProject = foundProjectMapper.selectByPrimaryKey(flowId); + FoundProject foundProject = map.get(flowId); if (foundProject == null) { continue; } @@ -385,15 +541,31 @@ public class ClassScoreServiceImpl implements ClassScoreService { } } } + +// 一次性从数据库中查询所有符合条件的 TrainingReport + TrainingReportExample trainingReportExample = new TrainingReportExample(); + trainingReportExample.createCriteria().andSchoolIdEqualTo(schoolId).andFlowIdIn(list).andStepEqualTo("投资报告"); + List allTrainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample); + +// 构建一个以 flowId 为 key 的 TrainingReport 的 Map,方便后续根据 flowId 查找对应的 TrainingReport + Map trainingReportMap = new HashMap<>(); + for (TrainingReport trainingReport : allTrainingReports) { + trainingReportMap.put(trainingReport.getFlowId(), trainingReport); + } + + Map performanceScoreMap = new HashMap<>(); +// 循环外执行一次查询并存储结果 for (String flowIdByList : list) { - TrainingReportExample trainingReportExample = new TrainingReportExample(); - trainingReportExample.createCriteria().andSchoolIdEqualTo(schoolId).andFlowIdEqualTo(flowIdByList).andStepEqualTo("投资报告"); PerformanceScore scoreByFlowId = performanceScoreService.getByFlowId(flowIdByList); - List trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample); - if (trainingReports.isEmpty()) { + performanceScoreMap.put(flowIdByList, scoreByFlowId); + } +// 遍历 list,根据内存中的数据处理流程 + for (String flowIdByList : list) { + TrainingReport trainingReport = trainingReportMap.get(flowIdByList); + if (trainingReport == null) { continue; } - TrainingReport trainingReport = trainingReports.get(0); + PerformanceScore scoreByFlowId = performanceScoreMap.get(flowIdByList); if (scoreByFlowId.getExperienceScore() == null && StringUtils.isBlank(trainingReport.getExperience())) { performanceScoreService.updateScore("experienceScore", 0, flowIdByList); trainingReport.setExperienceScore(BigDecimal.ZERO); @@ -429,6 +601,7 @@ public class ClassScoreServiceImpl implements ClassScoreService { return new ResultEntity<>(HttpStatus.NOT_FOUND); } + public static void main(String[] args) { String projectValuationAbsolute = "12312,./,/@#$好好好好好好好好好好好好好好好好AFGGGS好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好"; projectValuationAbsolute = projectValuationAbsolute.replaceAll("[^\\u4E00-\\u9FA5]", ""); diff --git a/src/main/java/com/sztzjy/fund_investment/task/Task.java b/src/main/java/com/sztzjy/fund_investment/task/Task.java index e44ba58..6f0736d 100644 --- a/src/main/java/com/sztzjy/fund_investment/task/Task.java +++ b/src/main/java/com/sztzjy/fund_investment/task/Task.java @@ -33,7 +33,7 @@ public class Task { * @Date 2023/11/23 */ //todo 重新实训需要把performance_score表的数据删掉,计算班级平均分时只取最新的数据 - @Scheduled(cron = "0 0 0 * * ?") +// @Scheduled(cron = "0 0 0 * * ?") public void getClassScore() { // 查到单个班级下所有的已经在投资报告页面提交过的学生的总成绩 // 算平均值,存表 diff --git a/src/main/java/com/sztzjy/fund_investment/util/RsaUtil.java b/src/main/java/com/sztzjy/fund_investment/util/RsaUtil.java index 8d34229..55b05f5 100644 --- a/src/main/java/com/sztzjy/fund_investment/util/RsaUtil.java +++ b/src/main/java/com/sztzjy/fund_investment/util/RsaUtil.java @@ -72,6 +72,7 @@ public class RsaUtil { return new String(result); } + public static String decryptByPublicKey(String text) throws Exception { X509EncodedKeySpec x509EncodedKeySpec2 = new X509EncodedKeySpec(Base64.decodeBase64(publicKey)); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml index 6d8dff9..97741e7 100644 --- a/src/main/resources/application-pro.yml +++ b/src/main/resources/application-pro.yml @@ -2,9 +2,9 @@ spring: datasource: druid: db-type: mysql - url: jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:fund_investment}?useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true + url: jdbc:mysql://${DB_HOST:211.70.163.178}:${DB_PORT:3306}/${DB_NAME:fund_investment}?useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true username: ${DB_USER:root} - password: ${DB_PWD:Sztzjy506} + password: ${DB_PWD:WxxyDB@2023} driver-class-name: com.mysql.cj.jdbc.Driver