From 3a9d852d83dd380d4a8d3dd07883a44ab1783953 Mon Sep 17 00:00:00 2001 From: yz <3614508250@qq.com> Date: Tue, 12 Nov 2024 17:50:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=80=81=E5=B8=88=E6=88=90?= =?UTF-8?q?=E7=BB=A9=E6=96=B9=E9=9D=A2=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A5=BC=E7=8A=B6=E5=9B=BE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ChapterController.java | 5 + .../controller/GradeController.java | 2 +- .../common/StatisticsController.java | 173 +++++++++++------- .../mapper/SynthesisPlanScoreMapper.java | 3 + .../impl/ResourceCenterServiceImpl.java | 5 +- .../service/impl/ScoreRankServiceImpl.java | 20 +- 6 files changed, 139 insertions(+), 69 deletions(-) diff --git a/src/main/java/com/sztzjy/money_management/controller/ChapterController.java b/src/main/java/com/sztzjy/money_management/controller/ChapterController.java index 0aeeb66..3c4b3a7 100644 --- a/src/main/java/com/sztzjy/money_management/controller/ChapterController.java +++ b/src/main/java/com/sztzjy/money_management/controller/ChapterController.java @@ -56,6 +56,11 @@ public class ChapterController { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "schoolId不能为空"); } List list=chapterService.chapterSelect(schoolId,familes); + for (int i = 0; i < list.size(); i++) { + if(list.get(i).getChapterName().equals("财务分析")){ + list.get(i).setChapterName("家庭财务报表的编制与分析"); + } + } return new ResultEntity<>(HttpStatus.OK, "章节查询成功",list); } 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 8955c19..e143fb0 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(2)); studentScoreWeight.setLearningAssessmentScore(BigDecimal.valueOf(10)); - studentScoreWeight.setExperimentalTrainingScore(BigDecimal.valueOf(20)); + studentScoreWeight.setExperimentalTrainingScore(BigDecimal.valueOf(10)); //权重 studentScoreWeight.setSummaryOfKnowledgeWeight(BigDecimal.valueOf(0.2)); 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 0464092..cd0fe24 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 @@ -23,9 +23,10 @@ import org.springframework.web.bind.annotation.RestController; import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.logging.Handler; @RestController @RequestMapping("/api/statisticsController") @@ -43,11 +44,12 @@ public class StatisticsController { StuTheoryRecordMapper stuTheoryRecordMapper; @Autowired UserInfoMapper userInfoMapper; + //学生端 -我的成绩、有效时长、各模块用时 @AnonymousAccess @GetMapping("/selectStuStatistics") @ApiOperation("学生端 -我的成绩、有效时长、各模块用时") - public ResultEntity selectStuStatistics(@RequestParam String userId){ + public ResultEntity selectStuStatistics(@RequestParam String userId) { ScoreRankExample scoreRankExample = new ScoreRankExample(); scoreRankExample.createCriteria().andUseridEqualTo(userId).andUpdateDateEqualTo(scoreRankService.getNowDate()); List scoreRankList = scoreRankMapper.selectByExample(scoreRankExample); @@ -59,43 +61,43 @@ public class StatisticsController { stuStatisticsDto.setZhghTime(0); stuStatisticsDto.setKszxTime(BigDecimal.valueOf(0)); stuStatisticsDto.setZyzxTime(0); - if(!scoreRankList.isEmpty()){ + if (!scoreRankList.isEmpty()) { ScoreRank scoreRank = scoreRankList.get(0); stuStatisticsDto.setRank(scoreRank.getTotalRank()); stuStatisticsDto.setScore(scoreRank.getTotalScore()); //获取客户案例时长 - Integer khanTime=stuTrainingMapper.selectTotalTrainingTimeByUserId(userId); - if (khanTime==null){ + Integer khanTime = stuTrainingMapper.selectTotalTrainingTimeByUserId(userId); + if (khanTime == null) { khanTime = 0; } stuStatisticsDto.setKhalTime(khanTime); //获取综合规划时间 - Integer zhghTime=synthesisPlanClientMapper.getTotalUseTime(userId); - if (zhghTime==null){ + Integer zhghTime = synthesisPlanClientMapper.getTotalUseTime(userId); + if (zhghTime == null) { zhghTime = 0; } stuStatisticsDto.setZhghTime(zhghTime); //获取考试中心时间 StuTheoryRecord stuTheoryRecord = stuTheoryRecordMapper.selectByPrimaryKey(userId); - if(stuTheoryRecord!=null){ + if (stuTheoryRecord != null) { stuStatisticsDto.setKszxTime(stuTheoryRecord.getTotalDuration()); } - stuStatisticsDto.setTotalTime(BigDecimal.valueOf(khanTime+zhghTime).add(stuTheoryRecord==null?BigDecimal.ZERO:stuTheoryRecord.getTotalDuration())); + stuStatisticsDto.setTotalTime(BigDecimal.valueOf(khanTime + zhghTime).add(stuTheoryRecord == null ? BigDecimal.ZERO : stuTheoryRecord.getTotalDuration())); } - return new ResultEntity<>(HttpStatus.OK, "我的成绩、有效时长、各模块用时返回成功!",stuStatisticsDto); + return new ResultEntity<>(HttpStatus.OK, "我的成绩、有效时长、各模块用时返回成功!", stuStatisticsDto); } //学生端 -成绩走势 @AnonymousAccess @GetMapping("/getStuTrainingScoreTrend") @ApiOperation("学生端 -成绩走势") - public ResultEntity> getStuTrainingScoreTrend(@RequestParam String userId,@RequestParam String classId,@RequestParam String schoolId){ + public ResultEntity> getStuTrainingScoreTrend(@RequestParam String userId, @RequestParam String classId, @RequestParam String schoolId) { //根据schoolID 查询score_rank表第一名和最后一名 并根据userId 查询本学生的成绩 ScoreRankExample scoreRankExample = new ScoreRankExample(); scoreRankExample.createCriteria().andClassIdEqualTo(classId).andUpdateDateEqualTo(scoreRankService.getNowDate().trim()); scoreRankExample.setOrderByClause("khal_score desc"); List scoreRankList = scoreRankMapper.selectByExample(scoreRankExample); - if(scoreRankList.isEmpty()){ //代表成绩还没更新 + if (scoreRankList.isEmpty()) { //代表成绩还没更新 scoreRankService.doRankOne(schoolId); scoreRankList = scoreRankMapper.selectByExample(scoreRankExample); } @@ -103,7 +105,7 @@ public class StatisticsController { String endUserId = scoreRankList.get(scoreRankList.size() - 1).getUserid();//最后一名UserId //根据传递的userId 查询最近的五条成绩 - List returnDtoList=new ArrayList<>(); + List returnDtoList = new ArrayList<>(); //获取自己的成绩 StuTrainingScoreTrendDto selfDto = getTrendDto(userId, "我"); //获取第一名成绩 @@ -113,16 +115,16 @@ public class StatisticsController { returnDtoList.add(selfDto); returnDtoList.add(firstDto); returnDtoList.add(endDto); - return new ResultEntity<>(HttpStatus.OK, "学生端 -成绩走势返回成功!",returnDtoList); + return new ResultEntity<>(HttpStatus.OK, "学生端 -成绩走势返回成功!", returnDtoList); } //获取成绩走势dto - private StuTrainingScoreTrendDto getTrendDto(String userId,String title){ - List scoreList=scoreRankMapper.selectFiveScoreByUserId(userId); + private StuTrainingScoreTrendDto getTrendDto(String userId, String title) { + List scoreList = scoreRankMapper.selectFiveScoreByUserId(userId); StuTrainingScoreTrendDto trendDto = new StuTrainingScoreTrendDto(); trendDto.setTitle(title); - List scores=new ArrayList<>(); - List dateList=new ArrayList<>(); + List scores = new ArrayList<>(); + List dateList = new ArrayList<>(); for (int i = 0; i < scoreList.size(); i++) { ScoreRank scoreRank = scoreList.get(i); scores.add(scoreRank.getKhalScore()); @@ -148,8 +150,8 @@ public class StatisticsController { scoreRank.setClassName(className); scoreRank.setSchoolId(schoolId); List voList = scoreRankMapper.selectFiveAvgTotalScoreBySchoolIdAndClassName(scoreRank); - List classAverageScoreList=new ArrayList<>(); - List startTimeList=new ArrayList<>(); + List classAverageScoreList = new ArrayList<>(); + List startTimeList = new ArrayList<>(); for (int j = 0; j < voList.size(); j++) { TeaTrendVo teaTrendVo = voList.get(j); classAverageScoreList.add(teaTrendVo.getAvgScore()); @@ -182,52 +184,91 @@ public class StatisticsController { formattedDate = sdf.format(time); criteria.andClassIdEqualTo(classId).andUpdateDateEqualTo(formattedDate); } - List scoreRankList = scoreRankMapper.selectByExample(scoreExample); - int excellentCount = 0; - int goodCount = 0; - int generalCount = 0; - int failCount = 0; - BigDecimal maxScore = BigDecimal.ZERO; - BigDecimal minScore = BigDecimal.valueOf(1000); - BigDecimal avgScore = BigDecimal.ZERO; - for (int i = 0; i < scoreRankList.size(); i++) { - ScoreRank scoreRank = scoreRankList.get(i); - BigDecimal khalScore = scoreRank.getKhalScore(); - if(khalScore==null){ - khalScore=BigDecimal.ZERO; - } - if(khalScore.compareTo(maxScore)>0){ //设置最高分 - maxScore=khalScore; - } - if(khalScore.compareTo(minScore)<0){ //设置最低分 - minScore=khalScore; - } - avgScore=avgScore.add(khalScore); - if(khalScore.compareTo(BigDecimal.valueOf(90))>=0){ //设置优秀、良好、一般、不及格人数 - excellentCount = excellentCount+1; - }else if(khalScore.compareTo(BigDecimal.valueOf(90))<0 && khalScore.compareTo(BigDecimal.valueOf(80))>=0){ - goodCount= goodCount+1; - }else if(khalScore.compareTo(BigDecimal.valueOf(80))<0 && khalScore.compareTo(BigDecimal.valueOf(60))>=0){ - generalCount=generalCount+1; - }else { - failCount = failCount +1; - } + List scoreRankList = scoreRankMapper.selectByExample(scoreExample); + int excellentCount = 0; + int goodCount = 0; + int generalCount = 0; + int failCount = 0; + BigDecimal maxScore = BigDecimal.ZERO; + BigDecimal minScore = BigDecimal.valueOf(1000); + BigDecimal avgScore = BigDecimal.ZERO; + for (int i = 0; i < scoreRankList.size(); i++) { + ScoreRank scoreRank = scoreRankList.get(i); + BigDecimal khalScore = scoreRank.getKhalScore(); + if (khalScore == null) { + khalScore = BigDecimal.ZERO; + } + if (khalScore.compareTo(maxScore) > 0) { //设置最高分 + maxScore = khalScore; + } + if (khalScore.compareTo(minScore) < 0) { //设置最低分 + minScore = khalScore; + } + avgScore = avgScore.add(khalScore); + if (khalScore.compareTo(BigDecimal.valueOf(90)) >= 0) { //设置优秀、良好、一般、不及格人数 + excellentCount = excellentCount + 1; + } else if (khalScore.compareTo(BigDecimal.valueOf(90)) < 0 && khalScore.compareTo(BigDecimal.valueOf(80)) >= 0) { + goodCount = goodCount + 1; + } else if (khalScore.compareTo(BigDecimal.valueOf(80)) < 0 && khalScore.compareTo(BigDecimal.valueOf(60)) >= 0) { + generalCount = generalCount + 1; + } else { + failCount = failCount + 1; } - if(!scoreRankList.isEmpty()){ - avgScore = avgScore.divide(BigDecimal.valueOf(scoreRankList.size()), 2, BigDecimal.ROUND_HALF_UP); + } + if (!scoreRankList.isEmpty()) { + avgScore = avgScore.divide(BigDecimal.valueOf(scoreRankList.size()), 2, BigDecimal.ROUND_HALF_UP); + } + if (minScore.compareTo(BigDecimal.valueOf(1000)) == 0) { + minScore = BigDecimal.ZERO; + } + TeaClassScoreDto teaClassScoreDto = new TeaClassScoreDto(); + teaClassScoreDto.setExcellentCount(excellentCount); + teaClassScoreDto.setGoodCount(goodCount); + teaClassScoreDto.setGeneralCount(generalCount); + teaClassScoreDto.setFailCount(failCount); + teaClassScoreDto.setMaxScore(maxScore); + teaClassScoreDto.setMinScore(minScore); + teaClassScoreDto.setAverageScore(avgScore); + teaClassScoreDto.setStartTime(formattedDate); + return teaClassScoreDto; + } + + @AnonymousAccess + @GetMapping("/getStuPieChart") + @ApiOperation("学生端 -我的成绩饼状图") + public Map getStuPieChart(String schoolId) { + //根据schoolId查询当日scoreRank.totalScore 进行分类 + Map map=new HashMap<>(); + map.put("great",0); + map.put("good",0); + map.put("poor",0); + ScoreRankExample scoreRankExample = new ScoreRankExample(); + scoreRankExample.createCriteria().andSchoolIdEqualTo(schoolId).andUpdateDateEqualTo(getNowDate()); + List scoreRankList = scoreRankMapper.selectByExample(scoreRankExample); + for (int i = 0; i < scoreRankList.size(); i++) { + if(scoreRankList.get(i).getTotalScore().compareTo(BigDecimal.valueOf(80))>=0){ + Integer great = map.get("great"); + map.put("great",great+1); + continue; } - if(minScore.compareTo(BigDecimal.valueOf(1000))==0){ - minScore=BigDecimal.ZERO; + if(scoreRankList.get(i).getTotalScore().compareTo(BigDecimal.valueOf(60))<0){ + Integer poor = map.get("poor"); + map.put("poor",poor+1); + continue; + }else { + Integer good = map.get("good"); + map.put("good",good+1); + continue; } - TeaClassScoreDto teaClassScoreDto = new TeaClassScoreDto(); - teaClassScoreDto.setExcellentCount(excellentCount); - teaClassScoreDto.setGoodCount(goodCount); - teaClassScoreDto.setGeneralCount(generalCount); - teaClassScoreDto.setFailCount(failCount); - teaClassScoreDto.setMaxScore(maxScore); - teaClassScoreDto.setMinScore(minScore); - teaClassScoreDto.setAverageScore(avgScore); - teaClassScoreDto.setStartTime(formattedDate); - return teaClassScoreDto; } + return map; + } + + + public String getNowDate() { + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String nowDate = now.format(formatter); + return nowDate; + } } diff --git a/src/main/java/com/sztzjy/money_management/mapper/SynthesisPlanScoreMapper.java b/src/main/java/com/sztzjy/money_management/mapper/SynthesisPlanScoreMapper.java index 875fb3e..5422708 100644 --- a/src/main/java/com/sztzjy/money_management/mapper/SynthesisPlanScoreMapper.java +++ b/src/main/java/com/sztzjy/money_management/mapper/SynthesisPlanScoreMapper.java @@ -52,4 +52,7 @@ public interface SynthesisPlanScoreMapper { BigDecimal selectTotalScoreByUserId(@Param("userId")String userId); int batchInsert(@Param("list") List synthesisPlanScore); + + @Select("SELECT count(userid) from synthesis_plan_score where userid=#{userId}") + Integer CountScoreSizeByUserId(String userId); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/money_management/service/impl/ResourceCenterServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/ResourceCenterServiceImpl.java index 223f3f4..c30181d 100644 --- a/src/main/java/com/sztzjy/money_management/service/impl/ResourceCenterServiceImpl.java +++ b/src/main/java/com/sztzjy/money_management/service/impl/ResourceCenterServiceImpl.java @@ -12,6 +12,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.UUID; @@ -31,6 +32,7 @@ public class ResourceCenterServiceImpl implements ResourceCenterService { resourceCenter.setResourceUrl(uploadUrl); resourceCenter.setChapterId(chapterId); resourceCenter.setSource(schoolId); + resourceCenter.setAddTime(new Date()); resourceCenter.setType(type); int insert = resourceCenterMapper.insert(resourceCenter); return insert==1; @@ -49,7 +51,8 @@ public class ResourceCenterServiceImpl implements ResourceCenterService { criteria.andSourceIn(schoolIds); } criteria.andChapterIdEqualTo(chapterId); - List resourceCenterList = resourceCenterMapper.selectByExample(example); + example.setOrderByClause("add_time asc"); + List resourceCenterList = resourceCenterMapper.selectByExampleWithBLOBs(example); return resourceCenterList; } 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 f6fea93..1c70ef5 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 @@ -174,6 +174,15 @@ public class ScoreRankServiceImpl implements ScoreRankService { scoreRank.setCountCase((int) countCase); BigDecimal zhghScore = synthesisPlanScoreMapper.selectTotalScoreByUserId(userId); + if (zhghScore==null){ + scoreRank.setZhghScore(BigDecimal.ZERO); + }else { + //查询zhgh考核点数量 + Integer zhghSize=synthesisPlanScoreMapper.CountScoreSizeByUserId(userId); + //考核点所有分数 + BigDecimal zhghTotalScore=BigDecimal.valueOf(zhghSize).multiply(BigDecimal.valueOf(2)); + scoreRank.setZhghScore(zhghScore.divide(zhghTotalScore,2,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(countCase),2,BigDecimal.ROUND_HALF_UP)); + } scoreRank.setZhghScore(zhghScore); //设置理论考核平均分成绩 @@ -431,7 +440,16 @@ public class ScoreRankServiceImpl implements ScoreRankService { scoreRank.setCountCase((int) countCase); BigDecimal zhghScore = synthesisPlanScoreMapper.selectTotalScoreByUserId(userId); - scoreRank.setZhghScore(zhghScore); + if (zhghScore==null){ + scoreRank.setZhghScore(BigDecimal.ZERO); + }else { + //查询zhgh考核点数量 + Integer zhghSize=synthesisPlanScoreMapper.CountScoreSizeByUserId(userId); + //考核点所有分数 + BigDecimal zhghTotalScore=BigDecimal.valueOf(zhghSize).multiply(BigDecimal.valueOf(2)); + scoreRank.setZhghScore(zhghScore.divide(zhghTotalScore,2,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(countCase),2,BigDecimal.ROUND_HALF_UP)); + } + //设置理论考核平均分成绩 StuTheoryRecord stuTheoryRecord = theoryRecordMapper.selectByPrimaryKey(userId);