From ff476f919202a3ddbe0f9ebe1a324c95a9447ee0 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Mon, 9 Dec 2024 17:56:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=89=E4=B8=AA=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=E8=83=BD,=E5=92=8C=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E8=80=83=E6=A0=B8=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tea/TeaGradeManageController.java | 28 +- .../mapper/StuTheoryRecordMapper.java | 5 + .../service/tea/ITeaGradeManageService.java | 2 +- .../tea/impl/TeaGradeManageServiceImpl.java | 45 +- .../mapper/StuTheoryRecordMapper.xml | 668 +++++++++--------- 5 files changed, 392 insertions(+), 356 deletions(-) diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java index 82e1be3..d9633e4 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java @@ -93,25 +93,32 @@ public class TeaGradeManageController { return null; } List teaExamManageCountDtos = new ArrayList<>(); - Map userMap = new HashMap<>(); + Map userMap = new HashMap<>(); - List userIds = new ArrayList<>(); + List userIds = new ArrayList<>(); for (TeaExamManage teaExamManage : teaExamManages) { - Integer zyUserId = Integer.parseInt(teaExamManage.getUserId()); //这里是智云 zyUserId - userIds.add(zyUserId); + userIds.add(teaExamManage.getUserId()); } //存储用户信息 StuUserExample example = new StuUserExample(); - example.createCriteria().andSystemOnwerEqualTo(systemOwner).andZyUseridIn(userIds); + example.createCriteria().andSystemOnwerEqualTo(systemOwner).andUseridIn(userIds); List stuUsers = userMapper.selectByExample(example); for (StuUser stuUser : stuUsers) { - userMap.put(stuUser.getZyUserid(), stuUser); + userMap.put(stuUser.getUserid(), stuUser); } for (TeaExamManage teaExamManage : teaExamManages) { TeaExamManageCountDto copyexamManageWithBLOBs = new TeaExamManageCountDto(); + String userId = teaExamManage.getUserId(); + StuUser stuUser = userMap.get(userId); + if (stuUser==null){ + continue; + } + copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人 + teaExamManageCountDtos.add(copyexamManageWithBLOBs); + //获取班级和考试人数 TeaAndStudentExam teaAndStudentExam = teaAndStudentExamMapper.selectByExamMangeId(teaExamManage.getExamManageId()); @@ -139,10 +146,6 @@ public class TeaGradeManageController { String concatenatedTimeString = startTime + " -- " + endTime; copyexamManageWithBLOBs.setExamTime(concatenatedTimeString); //考试时间 - String userId = teaExamManage.getUserId(); - StuUser stuUser = userMap.get(Integer.parseInt(userId)); - copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人 - teaExamManageCountDtos.add(copyexamManageWithBLOBs); } PageInfo pageInfo = PageUtil.pageHelper(teaExamManageCountDtos, index, size); return new ResultEntity<>(pageInfo); @@ -644,8 +647,9 @@ public class TeaGradeManageController { @ApiOperation("理论考试--导出理论考试信息") public void exportTheoryExamInfo(HttpServletResponse response, @ApiParam("不选择班级就是学习全部导出") @RequestParam(required = false) String classId, - @RequestParam String schoolId) { - iTeaGradeManageService.exportTheoryExamInfo(response, classId, schoolId); + @RequestParam String schoolId, + @RequestParam String systemOwner) { + iTeaGradeManageService.exportTheoryExamInfo(response, classId, schoolId,systemOwner); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuTheoryRecordMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuTheoryRecordMapper.java index 88a0b04..fa049e4 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuTheoryRecordMapper.java +++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuTheoryRecordMapper.java @@ -33,4 +33,9 @@ public interface StuTheoryRecordMapper { int updateByPrimaryKey(StuTheoryRecord record); StuTheoryIndexInfoDto selectTheoryInfo(@Param("userId") String userId); + + List selectConditions(@Param("schoolId") String schoolId, + @Param("classId") String classId, + @Param("keyWord") String keyWord, + @Param("systemOwner") String systemOwner); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaGradeManageService.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaGradeManageService.java index 3813b6f..c172e7f 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaGradeManageService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaGradeManageService.java @@ -31,7 +31,7 @@ public interface ITeaGradeManageService { PageInfo getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord, String systemOwner); - void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId); + void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId,String systemOwner); SysWeight getSysWeightResultEntity(String courseId, String schoolId, String systemOwner); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java index 7e27bc7..52ac944 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java @@ -272,37 +272,38 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { @Override public PageInfo getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord, String systemOwner) { PageHelper.startPage(index, size); - List list = getStuTheoryRecordPageInfo(schoolId, classId, keyWord, systemOwner); +// List list = getStuTheoryRecordPageInfo(schoolId, classId, keyWord, systemOwner); + List list = stuTheoryRecordMapper.selectConditions(schoolId, classId, keyWord, systemOwner); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } - //查询方法 - private List getStuTheoryRecordPageInfo(String schoolId, String classId, String keyWord, String systemOwner) { - StuTheoryRecordExample s = new StuTheoryRecordExample(); - StuTheoryRecordExample.Criteria criteria = s.createCriteria(); - StuTheoryRecordExample.Criteria orCriteria = s.createCriteria(); - criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); - orCriteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); - if (StringUtils.isNotBlank(classId)) { - criteria.andClassIdEqualTo(classId); - orCriteria.andClassIdEqualTo(classId); - } - if (StringUtils.isNotBlank(keyWord)) { - criteria.andStudentIdEqualTo(keyWord); - orCriteria.andNameEqualTo(keyWord); - } - s.or(orCriteria); - s.setOrderByClause("average_score ASC"); - return stuTheoryRecordMapper.selectByExample(s); - } +// //查询方法 +// private List getStuTheoryRecordPageInfo(String schoolId, String classId, String keyWord, String systemOwner) { +// StuTheoryRecordExample s = new StuTheoryRecordExample(); +// StuTheoryRecordExample.Criteria criteria = s.createCriteria(); +// StuTheoryRecordExample.Criteria orCriteria = s.createCriteria(); +// criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); +// orCriteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); +// if (StringUtils.isNotBlank(classId)) { +// criteria.andClassIdEqualTo(classId); +// orCriteria.andClassIdEqualTo(classId); +// } +// if (StringUtils.isNotBlank(keyWord)) { +// criteria.andStudentIdEqualTo(keyWord); +// orCriteria.andNameEqualTo(keyWord); +// } +// s.or(orCriteria); +// s.setOrderByClause("average_score ASC"); +// return stuTheoryRecordMapper.selectByExample(s); +// } @Override - public void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId) { + public void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId, String systemOwner) { StuTheoryRecordExample s = new StuTheoryRecordExample(); StuTheoryRecordExample.Criteria criteria = s.createCriteria(); - criteria.andSchoolIdEqualTo(schoolId); + criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); if (StringUtils.isNotBlank(classId)) { criteria.andClassIdEqualTo(classId); } diff --git a/src/main/resources/mapper/StuTheoryRecordMapper.xml b/src/main/resources/mapper/StuTheoryRecordMapper.xml index 5cfe0bb..e3279bf 100644 --- a/src/main/resources/mapper/StuTheoryRecordMapper.xml +++ b/src/main/resources/mapper/StuTheoryRecordMapper.xml @@ -1,340 +1,366 @@ - - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + - - - - - - - user_id, school_id, class_id, name, student_id, exam_count, highest_score, lowest_score, + + + + user_id + , school_id, class_id, name, student_id, exam_count, highest_score, lowest_score, total_duration, average_score, system_owner - - - - - delete from stu_theory_record - where user_id = #{userId,jdbcType=VARCHAR} - - - delete from stu_theory_record - - - - - - insert into stu_theory_record (user_id, school_id, class_id, - name, student_id, exam_count, - highest_score, lowest_score, total_duration, - average_score, system_owner) - values (#{userId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR}, - #{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{examCount,jdbcType=INTEGER}, - #{highestScore,jdbcType=DECIMAL}, #{lowestScore,jdbcType=DECIMAL}, #{totalDuration,jdbcType=INTEGER}, - #{averageScore,jdbcType=DECIMAL}, #{systemOwner,jdbcType=VARCHAR}) - - - insert into stu_theory_record - - - user_id, - - - school_id, - - - class_id, - - - name, - - - student_id, - - - exam_count, - - - highest_score, - - - lowest_score, - - - total_duration, - - - average_score, - - - system_owner, - - - - - #{userId,jdbcType=VARCHAR}, - - - #{schoolId,jdbcType=VARCHAR}, - - - #{classId,jdbcType=VARCHAR}, - - - #{name,jdbcType=VARCHAR}, - - - #{studentId,jdbcType=VARCHAR}, - - - #{examCount,jdbcType=INTEGER}, - - - #{highestScore,jdbcType=DECIMAL}, - - - #{lowestScore,jdbcType=DECIMAL}, - - - #{totalDuration,jdbcType=INTEGER}, - - - #{averageScore,jdbcType=DECIMAL}, - - - #{systemOwner,jdbcType=VARCHAR}, - - - - - - update stu_theory_record - - - user_id = #{record.userId,jdbcType=VARCHAR}, - - + + + + + delete + from stu_theory_record + where user_id = #{userId,jdbcType=VARCHAR} + + + delete from stu_theory_record + + + + + + insert into stu_theory_record (user_id, school_id, class_id, + name, student_id, exam_count, + highest_score, lowest_score, total_duration, + average_score, system_owner) + values (#{userId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR}, + #{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{examCount,jdbcType=INTEGER}, + #{highestScore,jdbcType=DECIMAL}, #{lowestScore,jdbcType=DECIMAL}, #{totalDuration,jdbcType=INTEGER}, + #{averageScore,jdbcType=DECIMAL}, #{systemOwner,jdbcType=VARCHAR}) + + + insert into stu_theory_record + + + user_id, + + + school_id, + + + class_id, + + + name, + + + student_id, + + + exam_count, + + + highest_score, + + + lowest_score, + + + total_duration, + + + average_score, + + + system_owner, + + + + + #{userId,jdbcType=VARCHAR}, + + + #{schoolId,jdbcType=VARCHAR}, + + + #{classId,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{studentId,jdbcType=VARCHAR}, + + + #{examCount,jdbcType=INTEGER}, + + + #{highestScore,jdbcType=DECIMAL}, + + + #{lowestScore,jdbcType=DECIMAL}, + + + #{totalDuration,jdbcType=INTEGER}, + + + #{averageScore,jdbcType=DECIMAL}, + + + #{systemOwner,jdbcType=VARCHAR}, + + + + + + update stu_theory_record + + + user_id = #{record.userId,jdbcType=VARCHAR}, + + + school_id = #{record.schoolId,jdbcType=VARCHAR}, + + + class_id = #{record.classId,jdbcType=VARCHAR}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + student_id = #{record.studentId,jdbcType=VARCHAR}, + + + exam_count = #{record.examCount,jdbcType=INTEGER}, + + + highest_score = #{record.highestScore,jdbcType=DECIMAL}, + + + lowest_score = #{record.lowestScore,jdbcType=DECIMAL}, + + + total_duration = #{record.totalDuration,jdbcType=INTEGER}, + + + average_score = #{record.averageScore,jdbcType=DECIMAL}, + + + system_owner = #{record.systemOwner,jdbcType=VARCHAR}, + + + + + + + + update stu_theory_record + set user_id = #{record.userId,jdbcType=VARCHAR}, school_id = #{record.schoolId,jdbcType=VARCHAR}, - - class_id = #{record.classId,jdbcType=VARCHAR}, - - name = #{record.name,jdbcType=VARCHAR}, - - student_id = #{record.studentId,jdbcType=VARCHAR}, - - exam_count = #{record.examCount,jdbcType=INTEGER}, - - highest_score = #{record.highestScore,jdbcType=DECIMAL}, - - lowest_score = #{record.lowestScore,jdbcType=DECIMAL}, - - total_duration = #{record.totalDuration,jdbcType=INTEGER}, - - average_score = #{record.averageScore,jdbcType=DECIMAL}, - - - system_owner = #{record.systemOwner,jdbcType=VARCHAR}, - - - - - - - - update stu_theory_record - set user_id = #{record.userId,jdbcType=VARCHAR}, - school_id = #{record.schoolId,jdbcType=VARCHAR}, - class_id = #{record.classId,jdbcType=VARCHAR}, - name = #{record.name,jdbcType=VARCHAR}, - student_id = #{record.studentId,jdbcType=VARCHAR}, - exam_count = #{record.examCount,jdbcType=INTEGER}, - highest_score = #{record.highestScore,jdbcType=DECIMAL}, - lowest_score = #{record.lowestScore,jdbcType=DECIMAL}, - total_duration = #{record.totalDuration,jdbcType=INTEGER}, - average_score = #{record.averageScore,jdbcType=DECIMAL}, - system_owner = #{record.systemOwner,jdbcType=VARCHAR} - - - - - - update stu_theory_record - - - school_id = #{schoolId,jdbcType=VARCHAR}, - - - class_id = #{classId,jdbcType=VARCHAR}, - - - name = #{name,jdbcType=VARCHAR}, - - - student_id = #{studentId,jdbcType=VARCHAR}, - - - exam_count = #{examCount,jdbcType=INTEGER}, - - - highest_score = #{highestScore,jdbcType=DECIMAL}, - - - lowest_score = #{lowestScore,jdbcType=DECIMAL}, - - - total_duration = #{totalDuration,jdbcType=INTEGER}, - - - average_score = #{averageScore,jdbcType=DECIMAL}, - - - system_owner = #{systemOwner,jdbcType=VARCHAR}, - - - where user_id = #{userId,jdbcType=VARCHAR} - - - update stu_theory_record - set school_id = #{schoolId,jdbcType=VARCHAR}, - class_id = #{classId,jdbcType=VARCHAR}, - name = #{name,jdbcType=VARCHAR}, - student_id = #{studentId,jdbcType=VARCHAR}, - exam_count = #{examCount,jdbcType=INTEGER}, - highest_score = #{highestScore,jdbcType=DECIMAL}, - lowest_score = #{lowestScore,jdbcType=DECIMAL}, - total_duration = #{totalDuration,jdbcType=INTEGER}, - average_score = #{averageScore,jdbcType=DECIMAL}, - system_owner = #{systemOwner,jdbcType=VARCHAR} - where user_id = #{userId,jdbcType=VARCHAR} - + system_owner = #{record.systemOwner,jdbcType=VARCHAR} + + + + + + update stu_theory_record + + + school_id = #{schoolId,jdbcType=VARCHAR}, + + + class_id = #{classId,jdbcType=VARCHAR}, + + + name = #{name,jdbcType=VARCHAR}, + + + student_id = #{studentId,jdbcType=VARCHAR}, + + + exam_count = #{examCount,jdbcType=INTEGER}, + + + highest_score = #{highestScore,jdbcType=DECIMAL}, + + + lowest_score = #{lowestScore,jdbcType=DECIMAL}, + + + total_duration = #{totalDuration,jdbcType=INTEGER}, + + + average_score = #{averageScore,jdbcType=DECIMAL}, + + + system_owner = #{systemOwner,jdbcType=VARCHAR}, + + + where user_id = #{userId,jdbcType=VARCHAR} + + + update stu_theory_record + set school_id = #{schoolId,jdbcType=VARCHAR}, + class_id = #{classId,jdbcType=VARCHAR}, + name = #{name,jdbcType=VARCHAR}, + student_id = #{studentId,jdbcType=VARCHAR}, + exam_count = #{examCount,jdbcType=INTEGER}, + highest_score = #{highestScore,jdbcType=DECIMAL}, + lowest_score = #{lowestScore,jdbcType=DECIMAL}, + total_duration = #{totalDuration,jdbcType=INTEGER}, + average_score = #{averageScore,jdbcType=DECIMAL}, + system_owner = #{systemOwner,jdbcType=VARCHAR} + where user_id = #{userId,jdbcType=VARCHAR} + - - - - - - + + + + + + - + SELECT ste.score, + str.total_duration, + str.exam_count, + ( + SELECT COUNT(*) AS `rank` + FROM stu_theory_exam + WHERE accuracy >= ( + SELECT accuracy + FROM stu_theory_exam + WHERE user_id = 4 + ORDER BY exam_time DESC + LIMIT 1 ) ) AS `rank` - FROM stu_theory_exam ste - JOIN stu_theory_record str ON ste.user_id = str.user_id - WHERE ste.user_id = 4 - AND ste.answered = 1 - AND ste.accuracy >= ( - SELECT accuracy - FROM stu_theory_exam - WHERE user_id = 4 - ORDER BY exam_time DESC - LIMIT 1 - ) - ORDER BY ste.exam_time DESC - LIMIT 1; - + FROM stu_theory_exam ste + JOIN stu_theory_record str + ON ste.user_id = str.user_id + WHERE ste.user_id = 4 + AND ste.answered = 1 + AND ste.accuracy >= ( + SELECT accuracy + FROM stu_theory_exam + WHERE user_id = 4 + ORDER BY exam_time DESC + LIMIT 1 + ) + ORDER BY ste.exam_time DESC + LIMIT 1; + + + + \ No newline at end of file