From 8630ad3be535683ebf3b398a68fea3fa06907024 Mon Sep 17 00:00:00 2001 From: yz <3614508250@qq.com> Date: Mon, 10 Feb 2025 15:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=20?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=90=8C=E6=AD=A5=E7=BA=A7=E7=BA=BF=E4=B8=8A?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GradeController.java | 25 +++--- .../common/StatisticsController.java | 9 +- .../controller/common/UserController.java | 67 ++++++++------- .../money_management/entity/UserInfo.java | 11 +++ .../entity/UserInfoExample.java | 60 +++++++++++++ .../mapper/UserInfoMapper.java | 3 + .../service/UserInfoService.java | 9 ++ .../service/impl/ScoreRankServiceImpl.java | 86 +++++++++++-------- .../service/impl/TrainingServiceImpl.java | 4 +- .../service/impl/UserInfoServiceImpl.java | 47 ++++++++++ src/main/resources/application-dev.yml | 2 +- src/main/resources/generatorConfig.xml | 10 +-- src/main/resources/mapper/ScoreRankMapper.xml | 2 +- src/main/resources/mapper/UserInfoMapper.xml | 28 ++++-- 14 files changed, 265 insertions(+), 98 deletions(-) create mode 100644 src/main/java/com/sztzjy/money_management/service/UserInfoService.java create mode 100644 src/main/java/com/sztzjy/money_management/service/impl/UserInfoServiceImpl.java diff --git a/src/main/java/com/sztzjy/money_management/controller/GradeController.java b/src/main/java/com/sztzjy/money_management/controller/GradeController.java index bdf7ead..b24ceed 100644 --- a/src/main/java/com/sztzjy/money_management/controller/GradeController.java +++ b/src/main/java/com/sztzjy/money_management/controller/GradeController.java @@ -110,7 +110,7 @@ public class GradeController { studentScoreWeight.setSummaryOfKnowledgeScore(BigDecimal.valueOf(20)); studentScoreWeight.setResourceLearningScore(BigDecimal.valueOf(20)); studentScoreWeight.setLearningAssessmentScore(BigDecimal.valueOf(10)); - studentScoreWeight.setExperimentalTrainingScore(BigDecimal.valueOf(10)); + studentScoreWeight.setExperimentalTrainingScore(BigDecimal.valueOf(1)); //权重 studentScoreWeight.setSummaryOfKnowledgeWeight(BigDecimal.valueOf(0.1)); @@ -377,7 +377,7 @@ public class GradeController { criteria.andNameEqualTo(name); } if (StringUtils.isNotBlank(studentId)) { - criteria.andSchoolIdEqualTo(studentId); + criteria.andStudentIdEqualTo(studentId); } if (StringUtils.isNotBlank(classId)) { criteria.andClassIdEqualTo(classId); @@ -892,7 +892,7 @@ public class GradeController { List planClientList = synthesisPlanClientMapper.selectByExample(synthesisPlanClientExample); for (int i = 0; i < planClientList.size(); i++) { - SynthesisPlanClient client = planClientList.get(0); + SynthesisPlanClient client = planClientList.get(i); String caseid = client.getCaseid(); String userid = client.getUserid(); //根据caseId 查询caseInfo表中的manage_money_matters_type字段 如果等于综合规划 则查询com_case表 获取理财类型TypeList 如果不等于综合规划 则获取caseInfo中的manage_money_matters_type作为理财类型Type @@ -938,6 +938,9 @@ public class GradeController { SynthesisPlanScoreExample scoreExample = new SynthesisPlanScoreExample(); scoreExample.createCriteria().andCaseidEqualTo(caseid).andUseridEqualTo(userid).andManageMoneyMattersTypeEqualTo("财务分析-财务比例分析").andTestCenterEqualTo("客户财务情况分析"); List scoreList = synthesisPlanScoreMapper.selectByExample(scoreExample); + if(scoreList.isEmpty()){ + continue; + } SynthesisPlanScore synthesisPlanScore = scoreList.get(0); synthesisPlanScore.setScore(teacherScore); if(teacherScore.compareTo(BigDecimal.ZERO)>0){ @@ -949,7 +952,7 @@ public class GradeController { } else if ("现金规划".equals(type)) { CaseCashPlanExample example = new CaseCashPlanExample(); example.createCriteria().andCaseidEqualTo(caseid).andUserIdEqualTo(userid); - List list = caseCashPlanMapper.selectByExample(example); + List list = caseCashPlanMapper.selectByExampleWithBLOBs(example); //如果不存在 则跳过 if (list.isEmpty()) { continue; @@ -986,7 +989,7 @@ public class GradeController { } else if ("生涯规划-教育规划".equals(type)) { CaseLifeEducationPlanExample example = new CaseLifeEducationPlanExample(); example.createCriteria().andCaseidEqualTo(caseid).andUserIdEqualTo(userid); - List list = caseLifeEducationPlanMapper.selectByExample(example); + List list = caseLifeEducationPlanMapper.selectByExampleWithBLOBs(example); //如果不存在 则跳过 if (list.isEmpty()) { continue; @@ -1064,7 +1067,7 @@ public class GradeController { } else if ("生涯规划-消费规划".equals(type)) { CaseConsumptionPlanExample example = new CaseConsumptionPlanExample(); example.createCriteria().andCaseIdEqualTo(caseid).andUserIdEqualTo(userid); - List list = caseConsumptionPlanMapper.selectByExample(example); + List list = caseConsumptionPlanMapper.selectByExampleWithBLOBs(example); //如果不存在 则跳过 if (list.isEmpty()) { continue; @@ -1142,7 +1145,7 @@ public class GradeController { } else if ("生涯规划-创业规划".equals(type)) { CaseStartAnUndertakingPlanExample example = new CaseStartAnUndertakingPlanExample(); example.createCriteria().andCaseidEqualTo(caseid).andUserIdEqualTo(userid); - List list = caseStartAnUndertakingPlanMapper.selectByExample(example); + List list = caseStartAnUndertakingPlanMapper.selectByExampleWithBLOBs(example); //如果不存在 则跳过 if (list.isEmpty()) { continue; @@ -1222,7 +1225,7 @@ public class GradeController { } else if ("生涯规划-退休规划".equals(type)) { CaseRetirementPlanExample example = new CaseRetirementPlanExample(); example.createCriteria().andCaseidEqualTo(caseid).andUserIdEqualTo(userid); - List list = caseRetirementPlanMapper.selectByExample(example); + List list = caseRetirementPlanMapper.selectByExampleWithBLOBs(example); //如果不存在 则跳过 if (list.isEmpty()) { continue; @@ -1302,7 +1305,7 @@ public class GradeController { //根据caseid和userId查询case_Financial_Ratios表 CaseInsurancePlanExample example = new CaseInsurancePlanExample(); example.createCriteria().andCaseidEqualTo(caseid).andUserIdEqualTo(userid); - List list = caseInsurancePlanMapper.selectByExample(example); + List list = caseInsurancePlanMapper.selectByExampleWithBLOBs(example); //如果不存在 则跳过 if (list.isEmpty()) { continue; @@ -1343,7 +1346,7 @@ public class GradeController { //根据caseid和userId查询case_Financial_Ratios表 CaseInvestmentPlanExample example = new CaseInvestmentPlanExample(); example.createCriteria().andCaseIdEqualTo(caseid).andUserIdEqualTo(userid); - List list = caseInvestmentPlanMapper.selectByExample(example); + List list = caseInvestmentPlanMapper.selectByExampleWithBLOBs(example); //如果不存在 则跳过 if (list.isEmpty()) { continue; @@ -1381,7 +1384,7 @@ public class GradeController { //根据caseid和userId查询case_Financial_Ratios表 CaseTaxPlanExample example = new CaseTaxPlanExample(); example.createCriteria().andCaseidEqualTo(caseid).andUserIdEqualTo(userid); - List list = caseTaxPlanMapper.selectByExample(example); + List list = caseTaxPlanMapper.selectByExampleWithBLOBs(example); //如果不存在 则跳过 if (list.isEmpty()) { continue; diff --git a/src/main/java/com/sztzjy/money_management/controller/common/StatisticsController.java b/src/main/java/com/sztzjy/money_management/controller/common/StatisticsController.java index 1b55767..bc79f7d 100644 --- a/src/main/java/com/sztzjy/money_management/controller/common/StatisticsController.java +++ b/src/main/java/com/sztzjy/money_management/controller/common/StatisticsController.java @@ -11,6 +11,7 @@ import com.sztzjy.money_management.entity.dto.TeaClassScoreDto; import com.sztzjy.money_management.entity.vo.TeaTrendVo; import com.sztzjy.money_management.mapper.*; import com.sztzjy.money_management.service.ScoreRankService; +import com.sztzjy.money_management.service.UserInfoService; import com.sztzjy.money_management.util.ResultEntity; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -44,6 +45,8 @@ public class StatisticsController { StuTheoryRecordMapper stuTheoryRecordMapper; @Autowired UserInfoMapper userInfoMapper; + @Autowired + UserInfoService userInfoService; //学生端 -我的成绩、有效时长、各模块用时 @AnonymousAccess @@ -140,8 +143,8 @@ public class StatisticsController { @GetMapping("/getTeaTrainingScoreTrend") @ApiOperation("老师端 -班级平均成绩走势") public List getClassAVGScore(String schoolId) { - //先根据schoolId查询所有班级 - List classNameList = userInfoMapper.selectClassNameBySchoolId(schoolId); + //先根据schoolId查询所有班级名 + List classNameList = userInfoService.getClassNameList(schoolId); List returnList = new ArrayList<>(); for (int i = 0; i < classNameList.size(); i++) { //获取第一个班级的平均分和日期 @@ -152,7 +155,7 @@ public class StatisticsController { List voList = scoreRankMapper.selectFiveAvgTotalScoreBySchoolIdAndClassName(scoreRank); List classAverageScoreList = new ArrayList<>(); List startTimeList = new ArrayList<>(); - for (int j = 0; j < voList.size(); j++) { + for (int j = voList.size()-1; j >= 0; j--) { TeaTrendVo teaTrendVo = voList.get(j); classAverageScoreList.add(teaTrendVo.getAvgScore()); startTimeList.add(teaTrendVo.getUpdateDate()); diff --git a/src/main/java/com/sztzjy/money_management/controller/common/UserController.java b/src/main/java/com/sztzjy/money_management/controller/common/UserController.java index 1439f63..2ca244e 100644 --- a/src/main/java/com/sztzjy/money_management/controller/common/UserController.java +++ b/src/main/java/com/sztzjy/money_management/controller/common/UserController.java @@ -10,6 +10,7 @@ import com.sztzjy.money_management.entity.UserInfo; import com.sztzjy.money_management.entity.UserInfoExample; import com.sztzjy.money_management.entity.zy.ZYUserInfo; import com.sztzjy.money_management.mapper.UserInfoMapper; +import com.sztzjy.money_management.service.UserInfoService; import com.sztzjy.money_management.util.ResultEntity; import com.sztzjy.money_management.util.RsaUtil; import com.sztzjy.money_management.util.TzApi; @@ -36,7 +37,8 @@ public class UserController { private AuthenticationManagerBuilder authenticationManagerBuilder; @Autowired UserInfoMapper userInfoMapper; - + @Autowired + UserInfoService userInfoService; @PostMapping("/login") @ApiOperation("登录接口") @@ -72,11 +74,13 @@ public class UserController { UserInfo user = stuUsers.get(0); map.put("name", user.getName()); map.put("username", user.getUsername()); - map.put("roleId", user.getRoleId()); + map.put("roleId", String.valueOf(user.getRoleId())); map.put("schoolId", user.getSchoolId()); map.put("classId", user.getClassId()); map.put("userId", user.getUserid()); map.put("token", token); + user.setLoginTime(new Date()); + userInfoMapper.updateByPrimaryKey(user); return new ResultEntity(HttpStatus.OK, map); }catch (Exception e){ return new ResultEntity(HttpStatus.BAD_REQUEST, "账号不存在"); @@ -95,13 +99,20 @@ public class UserController { Map map = new HashMap<>(); map.put("name", loginResult.getName()); map.put("username", loginResult.getUsername()); - map.put("roleId", loginResult.getRoleId()); + map.put("roleId", String.valueOf(loginResult.getRoleId())); map.put("schoolId", loginResult.getSchoolId()); if (StringUtils.isNotBlank(loginResult.getUserId())) { map.put("classId", loginResult.getClassId()); } - map.put("userId", loginResult.getUserId()); +// map.put("userId", loginResult.getUserId()); map.put("token", token); + UserInfoExample stuUserExample = new UserInfoExample(); + stuUserExample.createCriteria().andStudentIdEqualTo(loginResult.getUsername()); + List stuUsers = userInfoMapper.selectByExample(stuUserExample); + UserInfo userInfo = stuUsers.get(0); + map.put("userId", userInfo.getUserid()); + userInfo.setLoginTime(new Date()); + userInfoMapper.updateByPrimaryKey(userInfo); return new ResultEntity(HttpStatus.OK, map); //todo 从智云登录后将用户添加到本地用户表 } } @@ -114,31 +125,31 @@ public class UserController { List users = new ArrayList<>(); for (int i = 0; i < zyUserInfoList.size(); i++) { ZYUserInfo zyUserInfo = zyUserInfoList.get(i); - Integer zyUserId = zyUserInfo.getUserId(); String username = zyUserInfo.getUsername(); // studentid String name = zyUserInfo.getName(); String password = zyUserInfo.getPassword(); Integer roleId = zyUserInfo.getRoleId(); //3教师 4学生 - UserInfo userInfo = userInfoMapper.selectByPrimaryKey(String.valueOf(zyUserId)); - if (userInfo!=null) { - continue; + UserInfoExample userInfoExample = new UserInfoExample(); + userInfoExample.createCriteria().andUsernameEqualTo(username); + List userInfos = userInfoMapper.selectByExample(userInfoExample); + if(userInfos.isEmpty() || userInfos==null){ + UserInfo stuUser = new UserInfo(); + stuUser.setUserid(IdUtil.randomUUID()); + stuUser.setStudentId(zyUserInfo.getUsername()); + stuUser.setName(name); + stuUser.setUsername(username); + stuUser.setClassId(zyUserInfo.getClassId().toString()); + stuUser.setPassword(password); + stuUser.setPhone(zyUserInfo.getPhone()); + stuUser.setMajor(zyUserInfo.getMajorName()); + stuUser.setRoleId(roleId); + stuUser.setSchoolId(zyUserInfo.getSchoolId().toString()); + stuUser.setSchoolName(zyUserInfo.getSchoolName()); + stuUser.setCreateTime(new Date()); + stuUser.setClassName(zyUserInfo.getClassName()); + users.add(stuUser); } - UserInfo stuUser = new UserInfo(); - stuUser.setUserid(IdUtil.randomUUID()); - stuUser.setStudentId(zyUserInfo.getUsername()); - stuUser.setName(name); - stuUser.setUsername(username); - stuUser.setClassId(zyUserInfo.getClassId().toString()); - stuUser.setPassword(password); - stuUser.setPhone(zyUserInfo.getPhone()); - stuUser.setMajor(zyUserInfo.getMajorName()); - stuUser.setRoleId(roleId); - stuUser.setSchoolId(zyUserInfo.getSchoolId().toString()); - stuUser.setSchoolName(zyUserInfo.getSchoolName()); - stuUser.setCreateTime(new Date()); - stuUser.setClassName(zyUserInfo.getClassName()); - users.add(stuUser); } if (users.isEmpty()) { return "账号已全部存在"; @@ -151,14 +162,6 @@ public class UserController { @ApiOperation("获取班级列表") @AnonymousAccess public Map getClassList(@RequestParam String schoolId){ - Map map=new HashMap<>(); - UserInfoExample userInfoExample = new UserInfoExample(); - userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleIdEqualTo(4); - List userInfos = userInfoMapper.selectByExample(userInfoExample); - for (int i = 0; i < userInfos.size(); i++) { - UserInfo userInfo = userInfos.get(i); - map.put(userInfo.getClassId(),userInfo.getClassName()); - } - return map; + return userInfoService.getClassMap(schoolId); } } diff --git a/src/main/java/com/sztzjy/money_management/entity/UserInfo.java b/src/main/java/com/sztzjy/money_management/entity/UserInfo.java index 5b4bf7c..8df54bc 100644 --- a/src/main/java/com/sztzjy/money_management/entity/UserInfo.java +++ b/src/main/java/com/sztzjy/money_management/entity/UserInfo.java @@ -51,6 +51,9 @@ public class UserInfo { @ApiModelProperty("学校名称") private String schoolName; + @ApiModelProperty("登录时间") + private Date loginTime; + public String getUserid() { return userid; } @@ -162,4 +165,12 @@ public class UserInfo { public void setSchoolName(String schoolName) { this.schoolName = schoolName == null ? null : schoolName.trim(); } + + public Date getLoginTime() { + return loginTime; + } + + public void setLoginTime(Date loginTime) { + this.loginTime = loginTime; + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/money_management/entity/UserInfoExample.java b/src/main/java/com/sztzjy/money_management/entity/UserInfoExample.java index d541252..94d0eca 100644 --- a/src/main/java/com/sztzjy/money_management/entity/UserInfoExample.java +++ b/src/main/java/com/sztzjy/money_management/entity/UserInfoExample.java @@ -1064,6 +1064,66 @@ public class UserInfoExample { addCriterion("school_name not between", value1, value2, "schoolName"); return (Criteria) this; } + + public Criteria andLoginTimeIsNull() { + addCriterion("login_time is null"); + return (Criteria) this; + } + + public Criteria andLoginTimeIsNotNull() { + addCriterion("login_time is not null"); + return (Criteria) this; + } + + public Criteria andLoginTimeEqualTo(Date value) { + addCriterion("login_time =", value, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeNotEqualTo(Date value) { + addCriterion("login_time <>", value, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeGreaterThan(Date value) { + addCriterion("login_time >", value, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeGreaterThanOrEqualTo(Date value) { + addCriterion("login_time >=", value, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeLessThan(Date value) { + addCriterion("login_time <", value, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeLessThanOrEqualTo(Date value) { + addCriterion("login_time <=", value, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeIn(List values) { + addCriterion("login_time in", values, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeNotIn(List values) { + addCriterion("login_time not in", values, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeBetween(Date value1, Date value2) { + addCriterion("login_time between", value1, value2, "loginTime"); + return (Criteria) this; + } + + public Criteria andLoginTimeNotBetween(Date value1, Date value2) { + addCriterion("login_time not between", value1, value2, "loginTime"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/src/main/java/com/sztzjy/money_management/mapper/UserInfoMapper.java b/src/main/java/com/sztzjy/money_management/mapper/UserInfoMapper.java index 5d5ce81..e1b08c2 100644 --- a/src/main/java/com/sztzjy/money_management/mapper/UserInfoMapper.java +++ b/src/main/java/com/sztzjy/money_management/mapper/UserInfoMapper.java @@ -42,4 +42,7 @@ public interface UserInfoMapper { @Select("select DISTINCT class_name from userinfo where school_id=#{schoolId}") List selectClassNameBySchoolId(@Param("schoolId") String schoolId); + + @Select("select DISTINCT class_name from userinfo where school_id=#{schoolId} and login_time is not null and role_id = 4") + List selectClassNameBySchoolIdAndLoginTimeNotNull(String schoolId); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/money_management/service/UserInfoService.java b/src/main/java/com/sztzjy/money_management/service/UserInfoService.java new file mode 100644 index 0000000..6fb52cb --- /dev/null +++ b/src/main/java/com/sztzjy/money_management/service/UserInfoService.java @@ -0,0 +1,9 @@ +package com.sztzjy.money_management.service; + +import java.util.List; +import java.util.Map; + +public interface UserInfoService { + Map getClassMap(String schoolId); + List getClassNameList(String schoolId); +} diff --git a/src/main/java/com/sztzjy/money_management/service/impl/ScoreRankServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/ScoreRankServiceImpl.java index 7f1550e..d7f1a3e 100644 --- a/src/main/java/com/sztzjy/money_management/service/impl/ScoreRankServiceImpl.java +++ b/src/main/java/com/sztzjy/money_management/service/impl/ScoreRankServiceImpl.java @@ -52,7 +52,10 @@ public class ScoreRankServiceImpl implements ScoreRankService { String schoolId = schoolIdList.get(i); //根据学校ID 获取所有学生userId UserInfoExample userInfoExample = new UserInfoExample(); - userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleIdEqualTo(4); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.YEAR, -1); + Date oneYearAgo = calendar.getTime(); + userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleIdEqualTo(4).andLoginTimeBetween(oneYearAgo, new Date()).andLoginTimeIsNotNull(); List userList = userInfoMapper.selectByExample(userInfoExample); //查询学习成绩权重表 Map clientWeight = trainingService.getClientWeight(schoolId); //客户案例权重 @@ -111,32 +114,32 @@ public class ScoreRankServiceImpl implements ScoreRankService { Integer resourceStatus = stuTraining.getResourceLearningCompleteStatus() == null ? 0 : stuTraining.getResourceLearningCompleteStatus(); Integer learningEvalCompleteStatus = stuTraining.getLearningEvalCompleteStatus() == null ? 9999 : stuTraining.getLearningEvalCompleteStatus(); Integer expStatus = stuTraining.getExpTrainingCompleteStatus() == null ? 9999 : stuTraining.getExpTrainingCompleteStatus(); - if(knowledgeStatus>5){ - knowledgeStatus=5; + if (knowledgeStatus > 5) { + knowledgeStatus = 5; } - if(resourceStatus>5){ - resourceStatus=5; + if (resourceStatus > 5) { + resourceStatus = 5; } StudentScoreWeight studentScoreWeight = studentScoreWeightMap.get(stuTraining.getChapterName()); BigDecimal summaryScore = studentScoreWeight.getSummaryOfKnowledgeScore().multiply(BigDecimal.valueOf(knowledgeStatus)).multiply(studentScoreWeight.getSummaryOfKnowledgeWeight()); BigDecimal resourceScore = studentScoreWeight.getResourceLearningScore().multiply(BigDecimal.valueOf(resourceStatus)).multiply(studentScoreWeight.getResourceLearningWeight()); - BigDecimal learningScore= BigDecimal.valueOf(0); - BigDecimal experimentalScore= BigDecimal.valueOf(0); - if(learningEvalCompleteStatus!=9999){ - if(learningEvalCompleteStatus<=10){ + BigDecimal learningScore = BigDecimal.valueOf(0); + BigDecimal experimentalScore = BigDecimal.valueOf(0); + if (learningEvalCompleteStatus != 9999) { + if (learningEvalCompleteStatus <= 10) { learningScore = BigDecimal.valueOf(100).subtract(studentScoreWeight.getLearningAssessmentScore().multiply(BigDecimal.valueOf(learningEvalCompleteStatus))).multiply(studentScoreWeight.getLearningAssessmentWeight()); } } - if(expStatus!=9999){ - if(expStatus<=5){ + if (expStatus != 9999) { + if (expStatus <= 5) { experimentalScore = BigDecimal.valueOf(100).subtract(studentScoreWeight.getExperimentalTrainingScore().multiply(BigDecimal.valueOf(expStatus))).multiply(studentScoreWeight.getExperimentalTrainingWeight()); } //财产分配特殊处理 - if("11".equals(stuTraining.getChapterId())){ - if(stuTraining.getExpTrainingCompleteStatus().compareTo(100)>0){ + if ("11".equals(stuTraining.getChapterId())) { + if (stuTraining.getExpTrainingCompleteStatus().compareTo(100) > 0) { stuTraining.setExpTrainingCompleteStatus(100); } - experimentalScore= BigDecimal.valueOf(stuTraining.getExpTrainingCompleteStatus()).multiply(studentScoreWeight.getExperimentalTrainingWeight()); + experimentalScore = BigDecimal.valueOf(stuTraining.getExpTrainingCompleteStatus()).multiply(studentScoreWeight.getExperimentalTrainingWeight()); } } //计算报告分数 @@ -144,9 +147,11 @@ public class ScoreRankServiceImpl implements ScoreRankService { TrainingReportExample trainingReportExample = new TrainingReportExample(); trainingReportExample.createCriteria().andChapterIdEqualTo(chapterId).andUserIdEqualTo(userId); List trainingReports = trainingReportMapper.selectByExample(trainingReportExample); - BigDecimal reportScore=BigDecimal.ZERO; + BigDecimal reportScore = BigDecimal.ZERO; if (!trainingReports.isEmpty()) { - reportScore=trainingReports.get(0).getTeacherScore().multiply(studentScoreWeight.getReportWeight()); + if (trainingReports.get(0).getTeacherScore() != null) { + reportScore = trainingReports.get(0).getTeacherScore().multiply(studentScoreWeight.getReportWeight()); + } } BigDecimal sum = summaryScore.add(resourceScore).add(learningScore).add(experimentalScore).add(reportScore); if ("风险测评".equals(stuTraining.getChapterName())) { @@ -198,10 +203,10 @@ public class ScoreRankServiceImpl implements ScoreRankService { long countCase = synthesisPlanClientMapper.countByExample(synthesisPlanClientExample); scoreRank.setCountCase((int) countCase); - StuSynthesisPlanScoreAndAvgScoreDto dto = trainingService.selectStuSynthesisPlanScoreList(userId,schoolId); - if(dto==null){ + StuSynthesisPlanScoreAndAvgScoreDto dto = trainingService.selectStuSynthesisPlanScoreList(userId, schoolId); + if (dto == null) { scoreRank.setZhghScore(BigDecimal.ZERO); - }else { + } else { scoreRank.setZhghScore(dto.getAvgScore()); } @@ -335,7 +340,10 @@ public class ScoreRankServiceImpl implements ScoreRankService { List scoreRankList = new ArrayList<>(); //根据学校ID 获取所有学生userId UserInfoExample userInfoExample = new UserInfoExample(); - userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleIdEqualTo(4); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.YEAR, -1); + Date oneYearAgo = calendar.getTime(); + userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleIdEqualTo(4).andLoginTimeBetween(oneYearAgo, new Date()).andLoginTimeIsNotNull(); List userList = userInfoMapper.selectByExample(userInfoExample); //查询学习成绩权重表 Map clientWeight = trainingService.getClientWeight(schoolId); //客户案例权重 @@ -394,32 +402,32 @@ public class ScoreRankServiceImpl implements ScoreRankService { Integer resourceStatus = stuTraining.getResourceLearningCompleteStatus() == null ? 0 : stuTraining.getResourceLearningCompleteStatus(); Integer learningEvalCompleteStatus = stuTraining.getLearningEvalCompleteStatus() == null ? 9999 : stuTraining.getLearningEvalCompleteStatus(); Integer expStatus = stuTraining.getExpTrainingCompleteStatus() == null ? 9999 : stuTraining.getExpTrainingCompleteStatus(); - if(knowledgeStatus>5){ - knowledgeStatus=5; + if (knowledgeStatus > 5) { + knowledgeStatus = 5; } - if(resourceStatus>5){ - resourceStatus=5; + if (resourceStatus > 5) { + resourceStatus = 5; } StudentScoreWeight studentScoreWeight = studentScoreWeightMap.get(stuTraining.getChapterName()); BigDecimal summaryScore = studentScoreWeight.getSummaryOfKnowledgeScore().multiply(BigDecimal.valueOf(knowledgeStatus)).multiply(studentScoreWeight.getSummaryOfKnowledgeWeight()); BigDecimal resourceScore = studentScoreWeight.getResourceLearningScore().multiply(BigDecimal.valueOf(resourceStatus)).multiply(studentScoreWeight.getResourceLearningWeight()); - BigDecimal learningScore= BigDecimal.valueOf(0); - BigDecimal experimentalScore= BigDecimal.valueOf(0); - if(learningEvalCompleteStatus!=9999){ - if(learningEvalCompleteStatus<=10){ + BigDecimal learningScore = BigDecimal.valueOf(0); + BigDecimal experimentalScore = BigDecimal.valueOf(0); + if (learningEvalCompleteStatus != 9999) { + if (learningEvalCompleteStatus <= 10) { learningScore = BigDecimal.valueOf(100).subtract(studentScoreWeight.getLearningAssessmentScore().multiply(BigDecimal.valueOf(learningEvalCompleteStatus))).multiply(studentScoreWeight.getLearningAssessmentWeight()); } } - if(expStatus!=9999){ - if(expStatus<=5){ + if (expStatus != 9999) { + if (expStatus <= 5) { experimentalScore = BigDecimal.valueOf(100).subtract(studentScoreWeight.getExperimentalTrainingScore().multiply(BigDecimal.valueOf(expStatus))).multiply(studentScoreWeight.getExperimentalTrainingWeight()); } //财产分配特殊处理 - if("11".equals(stuTraining.getChapterId())){ - if(stuTraining.getExpTrainingCompleteStatus().compareTo(100)>0){ + if ("11".equals(stuTraining.getChapterId())) { + if (stuTraining.getExpTrainingCompleteStatus().compareTo(100) > 0) { stuTraining.setExpTrainingCompleteStatus(100); } - experimentalScore= BigDecimal.valueOf(stuTraining.getExpTrainingCompleteStatus()).multiply(studentScoreWeight.getExperimentalTrainingWeight()); + experimentalScore = BigDecimal.valueOf(stuTraining.getExpTrainingCompleteStatus()).multiply(studentScoreWeight.getExperimentalTrainingWeight()); } } //计算报告分数 @@ -427,9 +435,11 @@ public class ScoreRankServiceImpl implements ScoreRankService { TrainingReportExample trainingReportExample = new TrainingReportExample(); trainingReportExample.createCriteria().andChapterIdEqualTo(chapterId).andUserIdEqualTo(userId); List trainingReports = trainingReportMapper.selectByExample(trainingReportExample); - BigDecimal reportScore=BigDecimal.ZERO; + BigDecimal reportScore = BigDecimal.ZERO; if (!trainingReports.isEmpty()) { - reportScore=trainingReports.get(0).getTeacherScore().multiply(studentScoreWeight.getReportWeight()); + if (trainingReports.get(0).getTeacherScore() != null) { + reportScore = trainingReports.get(0).getTeacherScore().multiply(studentScoreWeight.getReportWeight()); + } } BigDecimal sum = summaryScore.add(resourceScore).add(learningScore).add(experimentalScore).add(reportScore); @@ -482,10 +492,10 @@ public class ScoreRankServiceImpl implements ScoreRankService { long countCase = synthesisPlanClientMapper.countByExample(synthesisPlanClientExample); scoreRank.setCountCase((int) countCase); - StuSynthesisPlanScoreAndAvgScoreDto dto = trainingService.selectStuSynthesisPlanScoreList(userId,schoolId); - if(dto==null){ + StuSynthesisPlanScoreAndAvgScoreDto dto = trainingService.selectStuSynthesisPlanScoreList(userId, schoolId); + if (dto == null) { scoreRank.setZhghScore(BigDecimal.ZERO); - }else { + } else { scoreRank.setZhghScore(dto.getAvgScore()); } diff --git a/src/main/java/com/sztzjy/money_management/service/impl/TrainingServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/TrainingServiceImpl.java index 669b463..baccf7f 100644 --- a/src/main/java/com/sztzjy/money_management/service/impl/TrainingServiceImpl.java +++ b/src/main/java/com/sztzjy/money_management/service/impl/TrainingServiceImpl.java @@ -76,7 +76,7 @@ public class TrainingServiceImpl implements TrainingService { } } if (expStatus != 9999) { - if (expStatus <= 5) { + if (expStatus <= 100) { experimentalScore = BigDecimal.valueOf(100).subtract(studentScoreWeight.getExperimentalTrainingScore().multiply(BigDecimal.valueOf(expStatus))).multiply(studentScoreWeight.getExperimentalTrainingWeight()); } //财产分配特殊处理 @@ -117,7 +117,7 @@ public class TrainingServiceImpl implements TrainingService { studentScoreWeight.setSummaryOfKnowledgeScore(BigDecimal.valueOf(20)); studentScoreWeight.setResourceLearningScore(BigDecimal.valueOf(20)); studentScoreWeight.setLearningAssessmentScore(BigDecimal.valueOf(10)); - studentScoreWeight.setExperimentalTrainingScore(BigDecimal.valueOf(10)); + studentScoreWeight.setExperimentalTrainingScore(BigDecimal.valueOf(1)); //权重 studentScoreWeight.setSummaryOfKnowledgeWeight(BigDecimal.valueOf(0.1)); diff --git a/src/main/java/com/sztzjy/money_management/service/impl/UserInfoServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/UserInfoServiceImpl.java new file mode 100644 index 0000000..bf4c41b --- /dev/null +++ b/src/main/java/com/sztzjy/money_management/service/impl/UserInfoServiceImpl.java @@ -0,0 +1,47 @@ +package com.sztzjy.money_management.service.impl; + +import com.sztzjy.money_management.entity.UserInfo; +import com.sztzjy.money_management.entity.UserInfoExample; +import com.sztzjy.money_management.mapper.UserInfoMapper; +import com.sztzjy.money_management.service.UserInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class UserInfoServiceImpl implements UserInfoService { + @Autowired + UserInfoMapper userInfoMapper; + + @Override + public Map getClassMap(String schoolId) { + Map map=new HashMap<>(); + UserInfoExample userInfoExample = new UserInfoExample(); + userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleIdEqualTo(4).andLoginTimeIsNotNull(); + List userInfos = userInfoMapper.selectByExample(userInfoExample); + for (int i = 0; i < userInfos.size(); i++) { + UserInfo userInfo = userInfos.get(i); + map.put(userInfo.getClassId(),userInfo.getClassName()); + } + return map; + } + + @Override + public List getClassNameList(String schoolId) { +// List list=new ArrayList(); +// UserInfoExample userInfoExample = new UserInfoExample(); +// userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleIdEqualTo(4).andLoginTimeIsNotNull(); +// userInfoExample.setDistinct(true); +// List userInfos = userInfoMapper.selectByExample(userInfoExample); + List list = userInfoMapper.selectClassNameBySchoolIdAndLoginTimeNotNull(schoolId); +// for (int i = 0; i < userInfos.size(); i++) { +// UserInfo userInfo = userInfos.get(i); +// list.add(userInfo.getClassName()); +// } + return list; + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 0a124bf..d21c30b 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -19,7 +19,7 @@ timer: enable: false swagger: - enable: false + enable: true tokenHeader: Authorization title: 天择外汇模拟交易 • 接口文档 description: 天择外汇模拟交易WebAPI接口文档 diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index bec8b27..5124d70 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -45,13 +45,13 @@ - -
+ + -
+ -
+ @@ -79,7 +79,7 @@ - +
diff --git a/src/main/resources/mapper/ScoreRankMapper.xml b/src/main/resources/mapper/ScoreRankMapper.xml index 17a0b14..c1499ea 100644 --- a/src/main/resources/mapper/ScoreRankMapper.xml +++ b/src/main/resources/mapper/ScoreRankMapper.xml @@ -606,7 +606,7 @@ from score_rank s where school_id = #{schoolId,jdbcType=VARCHAR} and class_name=#{className,jdbcType=VARCHAR} group BY update_date - order by update_date asc + order by update_date desc LIMIT 5 diff --git a/src/main/resources/mapper/UserInfoMapper.xml b/src/main/resources/mapper/UserInfoMapper.xml index 5f633e1..737a017 100644 --- a/src/main/resources/mapper/UserInfoMapper.xml +++ b/src/main/resources/mapper/UserInfoMapper.xml @@ -16,6 +16,7 @@ + @@ -77,7 +78,7 @@ userid, name, student_id, class_id, class_name, username, password, phone, email, - major, role_id, create_time, school_id, school_name + major, role_id, create_time, school_id, school_name, login_time @@ -263,6 +272,9 @@ school_name = #{record.schoolName,jdbcType=VARCHAR}, + + login_time = #{record.loginTime,jdbcType=TIMESTAMP}, + @@ -283,7 +295,8 @@ role_id = #{record.roleId,jdbcType=INTEGER}, create_time = #{record.createTime,jdbcType=TIMESTAMP}, school_id = #{record.schoolId,jdbcType=VARCHAR}, - school_name = #{record.schoolName,jdbcType=VARCHAR} + school_name = #{record.schoolName,jdbcType=VARCHAR}, + login_time = #{record.loginTime,jdbcType=TIMESTAMP} @@ -330,6 +343,9 @@ school_name = #{schoolName,jdbcType=VARCHAR}, + + login_time = #{loginTime,jdbcType=TIMESTAMP}, + where userid = #{userid,jdbcType=VARCHAR} @@ -347,10 +363,12 @@ role_id = #{roleId,jdbcType=INTEGER}, create_time = #{createTime,jdbcType=TIMESTAMP}, school_id = #{schoolId,jdbcType=VARCHAR}, - school_name = #{schoolName,jdbcType=VARCHAR} + school_name = #{schoolName,jdbcType=VARCHAR}, + login_time = #{loginTime,jdbcType=TIMESTAMP} where userid = #{userid,jdbcType=VARCHAR} + INSERT INTO userinfo (userid, name, student_id, class_id,class_name, username, password, phone, email,major,