Commit 811b18e9 by baochunxin

#G:公众号选课后端接口上传

parent 8db017d6
...@@ -88,20 +88,20 @@ spring: ...@@ -88,20 +88,20 @@ spring:
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
host: localhost # host: localhost
# host: 43.143.63.140 host: 43.143.63.140
# host: 47.105.176.202 # host: 47.105.176.202
# host: 127.0.0.1 # host: 127.0.0.1
# 端口,默认为6379 # 端口,默认为6379
# port: 8134 # port: 8134
port: 6379 # port: 6379
# port: 16379 port: 16379
# port: 9121 # port: 9121
# 数据库索引 # 数据库索引
database: 11 database: 11
# 密码 # 密码
password: # password:
# password: lbt18062367596 password: lbt18062367596
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
lettuce: lettuce:
......
package yangtz.cs.liu.campus.service.curricula; package yangtz.cs.liu.campus.service.curricula;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import yangtz.cs.liu.campus.domain.curricula.CurriculaStudent;
import yangtz.cs.liu.campus.domain.student.SchoolStudentScore; import yangtz.cs.liu.campus.domain.student.SchoolStudentScore;
import yangtz.cs.liu.campus.vo.student.SchoolStudentScoreVo; import yangtz.cs.liu.campus.vo.student.SchoolStudentScoreVo;
...@@ -15,6 +16,9 @@ public interface IStudentScoreService extends IService<SchoolStudentScore> { ...@@ -15,6 +16,9 @@ public interface IStudentScoreService extends IService<SchoolStudentScore> {
*/ */
List<SchoolStudentScoreVo> selectStudentScoreList(SchoolStudentScoreVo schoolStudentScoreVo); List<SchoolStudentScoreVo> selectStudentScoreList(SchoolStudentScoreVo schoolStudentScoreVo);
//根据学生ID查询成绩
List<SchoolStudentScoreVo> selectStudentScoreList(Long studentId);
/** /**
* 查询学生成绩详细信息 * 查询学生成绩详细信息
* @param id * @param id
...@@ -62,4 +66,9 @@ public interface IStudentScoreService extends IService<SchoolStudentScore> { ...@@ -62,4 +66,9 @@ public interface IStudentScoreService extends IService<SchoolStudentScore> {
* @return * @return
*/ */
int deleteStudentScore(Long[] ids); int deleteStudentScore(Long[] ids);
/**
* 根据类型查询三类成绩
*/
List<SchoolStudentScoreVo> getStudentTypeViwe(CurriculaStudent curriculaStudent);
} }
...@@ -7,10 +7,16 @@ import com.ruoyi.common.exception.base.BaseException; ...@@ -7,10 +7,16 @@ import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.reflect.ReflectUtils;
import com.ruoyi.system.service.impl.SysDictDataServiceImpl;
import java.util.HashMap;
import java.util.Iterator;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import yangtz.cs.liu.campus.domain.curricula.CurriculaStudent;
import yangtz.cs.liu.campus.domain.schoolAuthority.SchoolAuthority;
import yangtz.cs.liu.campus.domain.schoolClass.SchoolClass; import yangtz.cs.liu.campus.domain.schoolClass.SchoolClass;
import yangtz.cs.liu.campus.domain.student.SchoolStudent; import yangtz.cs.liu.campus.domain.student.SchoolStudent;
import yangtz.cs.liu.campus.domain.student.SchoolStudentScore; import yangtz.cs.liu.campus.domain.student.SchoolStudentScore;
...@@ -25,6 +31,7 @@ import java.util.Comparator; ...@@ -25,6 +31,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import yangtz.cs.liu.campus.vo.student.SchoolStudentVO;
@Service @Service
public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, SchoolStudentScore> implements IStudentScoreService { public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, SchoolStudentScore> implements IStudentScoreService {
...@@ -35,6 +42,8 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, Sch ...@@ -35,6 +42,8 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, Sch
private SchoolStudentMapper schoolStudentMapper; private SchoolStudentMapper schoolStudentMapper;
@Autowired @Autowired
private SchoolClassMapper schoolClassMapper; private SchoolClassMapper schoolClassMapper;
@Autowired
private SysDictDataServiceImpl dictDataService;
/** /**
* 查询学生成绩列表 * 查询学生成绩列表
...@@ -45,280 +54,7 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, Sch ...@@ -45,280 +54,7 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, Sch
public List<SchoolStudentScoreVo> selectStudentScoreList(SchoolStudentScoreVo schoolStudentScoreVo) { public List<SchoolStudentScoreVo> selectStudentScoreList(SchoolStudentScoreVo schoolStudentScoreVo) {
List<SchoolStudentScoreVo> list = studentScoreMapper.selectStudentScoreList(schoolStudentScoreVo); List<SchoolStudentScoreVo> list = studentScoreMapper.selectStudentScoreList(schoolStudentScoreVo);
list.forEach(studentScoreVo -> { list.forEach(studentScoreVo -> {
//计算考试成绩年级排名/班级排名 this.handleAchievement(studentScoreVo);
//按年级查询
SchoolStudentScoreVo schoolStudentScoreVo1 = new SchoolStudentScoreVo();
schoolStudentScoreVo1.setCurriculaId(studentScoreVo.getCurriculaId());
schoolStudentScoreVo1.setExamType(studentScoreVo.getExamType());
List<SchoolStudentScoreVo> list1 = studentScoreMapper.selectStudentScoreList(schoolStudentScoreVo1);
//按班级查询
SchoolStudentScoreVo schoolStudentScoreVo2 = new SchoolStudentScoreVo();
schoolStudentScoreVo2.setCurriculaId(studentScoreVo.getCurriculaId());
schoolStudentScoreVo2.setClassId(studentScoreVo.getClassId());
schoolStudentScoreVo2.setExamType(studentScoreVo.getExamType());
List<SchoolStudentScoreVo> list2 = studentScoreMapper.selectStudentScoreList(schoolStudentScoreVo2);
//总成绩年级排名
//按总成绩降序排序
List<SchoolStudentScoreVo> collect = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getTotalScore).reversed()).collect(Collectors.toList());
//排名
int index = 1;
double totalScore = studentScoreVo.getTotalScore();
for (int i = 0; i < collect.size(); i++) {
SchoolStudentScoreVo studentScoreVo1 = collect.get(i);
if (Double.compare(totalScore,studentScoreVo1.getTotalScore()) != 0 && Double.compare(totalScore,studentScoreVo1.getTotalScore()) == -1){
index ++;
}
}
studentScoreVo.setRanking(index);
//总成绩班级排名
//按总成绩降序排序
List<SchoolStudentScoreVo> collect1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getTotalScore).reversed()).collect(Collectors.toList());
//排名
int index1 = 1;
for (int i = 0; i < collect1.size(); i++) {
SchoolStudentScoreVo studentScoreVo2 = collect1.get(i);
if (Double.compare(totalScore,studentScoreVo2.getTotalScore()) != 0 && Double.compare(totalScore,studentScoreVo2.getTotalScore()) == -1){
index1 ++;
}
}
studentScoreVo.setClassRanking(index1);
//语文成绩年级排名
//按语文成绩降序排序
List<SchoolStudentScoreVo> collect2 = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getLanguage).reversed()).collect(Collectors.toList());
//排名
int index3 = 1;
double language = studentScoreVo.getLanguage();
for (int i = 0; i < collect2.size(); i++) {
SchoolStudentScoreVo studentScoreVo1 = collect2.get(i);
if (Double.compare(language,studentScoreVo1.getLanguage()) != 0 && Double.compare(language,studentScoreVo1.getLanguage()) == -1){
index3 ++;
}
}
studentScoreVo.setYwRanking(index3);
//语文成绩班级排名
//按语文成绩降序排序
List<SchoolStudentScoreVo> collect4 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getLanguage).reversed()).collect(Collectors.toList());
//排名
int index4 = 1;
for (int i = 0; i < collect4.size(); i++) {
SchoolStudentScoreVo studentScoreVo2 = collect4.get(i);
if (Double.compare(language,studentScoreVo2.getLanguage()) != 0 && Double.compare(language,studentScoreVo2.getLanguage()) == -1){
index4 ++;
}
}
studentScoreVo.setYwClassRanking(index4);
//数学成绩年级排名
//按数学成绩降序排序
List<SchoolStudentScoreVo> collect3 = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getMath).reversed()).collect(Collectors.toList());
//排名
int index5 = 1;
double math = studentScoreVo.getMath();
for (int i = 0; i < collect3.size(); i++) {
SchoolStudentScoreVo studentScoreVo1 = collect3.get(i);
if (Double.compare(math,studentScoreVo1.getMath()) != 0 && Double.compare(math,studentScoreVo1.getMath()) == -1){
index5 ++;
}
}
studentScoreVo.setSxRanking(index5);
//数学成绩班级排名
//按数学成绩降序排序
List<SchoolStudentScoreVo> collect6 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getMath).reversed()).collect(Collectors.toList());
//排名
int index6 = 1;
for (int i = 0; i < collect6.size(); i++) {
SchoolStudentScoreVo studentScoreVo2 = collect6.get(i);
if (Double.compare(math,studentScoreVo2.getMath()) != 0 && Double.compare(math,studentScoreVo2.getMath()) == -1) {
index6++;
}
}
studentScoreVo.setSxClassRanking(index6);
//英语成绩年级排名
//按英语成绩降序排序
List<SchoolStudentScoreVo> collectYy = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getEnglish).reversed()).collect(Collectors.toList());
//排名
int indexYy = 1;
double english = studentScoreVo.getEnglish();
for (int i = 0; i < collectYy.size(); i++) {
SchoolStudentScoreVo studentScoreVoYy = collectYy.get(i);
if (Double.compare(english,studentScoreVoYy.getEnglish()) != 0 && Double.compare(english,studentScoreVoYy.getEnglish()) == -1){
indexYy ++;
}
}
studentScoreVo.setYyRanking(indexYy);
//英语成绩班级排名
//按英语成绩降序排序
List<SchoolStudentScoreVo> collectYy1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getEnglish).reversed()).collect(Collectors.toList());
//排名
int indexYy1 = 1;
for (int i = 0; i < collectYy1.size(); i++) {
SchoolStudentScoreVo studentScoreVoYy1 = collectYy1.get(i);
if (Double.compare(english,studentScoreVoYy1.getEnglish()) != 0 && Double.compare(english,studentScoreVoYy1.getEnglish()) == -1){
indexYy1 ++;
}
}
studentScoreVo.setYyClassRanking(indexYy1);
//政治成绩年级排名
//按政治成绩降序排序
List<SchoolStudentScoreVo> collectZz = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getPolitics).reversed()).collect(Collectors.toList());
//排名
int indexZz = 1;
double politics = studentScoreVo.getPolitics();
for (int i = 0; i < collectZz.size(); i++) {
SchoolStudentScoreVo studentScoreVoZz = collectZz.get(i);
if (Double.compare(politics,studentScoreVoZz.getPolitics()) != 0 && Double.compare(politics,studentScoreVoZz.getPolitics()) == -1){
indexZz ++;
}
}
studentScoreVo.setZzRanking(indexZz);
//政治成绩班级排名
//按政治成绩降序排序
List<SchoolStudentScoreVo> collectZz1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getPolitics).reversed()).collect(Collectors.toList());
//排名
int indexZz1 = 1;
for (int i = 0; i < collectZz1.size(); i++) {
SchoolStudentScoreVo studentScoreVoZz1 = collectZz1.get(i);
if (Double.compare(politics,studentScoreVoZz1.getPolitics()) != 0 && Double.compare(politics,studentScoreVoZz1.getPolitics()) == -1){
indexZz1 ++;
}
}
studentScoreVo.setZzClassRanking(indexZz1);
//地理成绩年级排名
//按地理成绩降序排序
List<SchoolStudentScoreVo> collectDl = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getGeography).reversed()).collect(Collectors.toList());
//排名
int indexDl = 1;
double geography = studentScoreVo.getGeography();
for (int i = 0; i < collectDl.size(); i++) {
SchoolStudentScoreVo studentScoreVoDl = collectDl.get(i);
if (Double.compare(geography,studentScoreVoDl.getGeography()) != 0 && Double.compare(geography,studentScoreVoDl.getGeography()) == -1){
indexDl ++;
}
}
studentScoreVo.setDlRanking(indexDl);
//地理成绩班级排名
//按地理成绩降序排序
List<SchoolStudentScoreVo> collectDl1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getGeography).reversed()).collect(Collectors.toList());
//排名
int indexDl1 = 1;
for (int i = 0; i < collectDl1.size(); i++) {
SchoolStudentScoreVo studentScoreVoDl1 = collectDl1.get(i);
if (Double.compare(geography,studentScoreVoDl1.getGeography()) != 0 && Double.compare(geography,studentScoreVoDl1.getGeography()) == -1){
indexDl1 ++;
}
}
studentScoreVo.setDlClassRanking(indexDl1);
//历史成绩年级排名
//按历史成绩降序排序
List<SchoolStudentScoreVo> collectLs = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getHistory).reversed()).collect(Collectors.toList());
//排名
int indexLs = 1;
double history = studentScoreVo.getHistory();
for (int i = 0; i < collectLs.size(); i++) {
SchoolStudentScoreVo studentScoreVoLs = collectLs.get(i);
if (Double.compare(history,studentScoreVoLs.getHistory()) != 0 && Double.compare(history,studentScoreVoLs.getHistory()) == -1){
indexLs ++;
}
}
studentScoreVo.setLsRanking(indexLs);
//历史成绩班级排名
//按历史成绩降序排序
List<SchoolStudentScoreVo> collectLs1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getHistory).reversed()).collect(Collectors.toList());
//排名
int indexLs1 = 1;
for (int i = 0; i < collectLs1.size(); i++) {
SchoolStudentScoreVo studentScoreVoLs1 = collectLs1.get(i);
if (Double.compare(history,studentScoreVoLs1.getHistory()) != 0 && Double.compare(history,studentScoreVoLs1.getHistory()) == -1){
indexLs1 ++;
}
}
studentScoreVo.setLsClassRanking(indexLs1);
//物理成绩年级排名
//按物理成绩降序排序
List<SchoolStudentScoreVo> collectWl = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getPhysics).reversed()).collect(Collectors.toList());
//排名
int indexWl = 1;
double physics = studentScoreVo.getPhysics();
for (int i = 0; i < collectWl.size(); i++) {
SchoolStudentScoreVo studentScoreVoWl = collectWl.get(i);
if (Double.compare(physics,studentScoreVoWl.getPhysics()) != 0 && Double.compare(physics,studentScoreVoWl.getPhysics()) == -1){
indexWl ++;
}
}
studentScoreVo.setWlRanking(indexWl);
//物理成绩班级排名
//按物理成绩降序排序
List<SchoolStudentScoreVo> collectWl1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getPhysics).reversed()).collect(Collectors.toList());
//排名
int indexWl1 = 1;
for (int i = 0; i < collectWl1.size(); i++) {
SchoolStudentScoreVo studentScoreVoWl1 = collectWl1.get(i);
if (Double.compare(physics,studentScoreVoWl1.getPhysics()) != 0 && Double.compare(physics,studentScoreVoWl1.getPhysics()) == -1){
indexWl1 ++;
}
}
studentScoreVo.setWlClassRanking(indexWl1);
//化学成绩年级排名
//按化学成绩降序排序
List<SchoolStudentScoreVo> collectHx = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getChemistry).reversed()).collect(Collectors.toList());
//排名
int indexHx = 1;
double chemistry = studentScoreVo.getChemistry();
for (int i = 0; i < collectHx.size(); i++) {
SchoolStudentScoreVo studentScoreVoHx = collectHx.get(i);
if (Double.compare(chemistry,studentScoreVoHx.getChemistry()) != 0 && Double.compare(chemistry,studentScoreVoHx.getChemistry()) == -1){
indexHx ++;
}
}
studentScoreVo.setHxRanking(indexHx);
//化学成绩班级排名
//按化学成绩降序排序
List<SchoolStudentScoreVo> collectHx1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getChemistry).reversed()).collect(Collectors.toList());
//排名
int indexHx1 = 1;
for (int i = 0; i < collectHx1.size(); i++) {
SchoolStudentScoreVo studentScoreVoHx1 = collectHx1.get(i);
if (Double.compare(chemistry,studentScoreVoHx1.getChemistry()) != 0 && Double.compare(chemistry,studentScoreVoHx1.getChemistry()) == -1){
indexHx1 ++;
}
}
studentScoreVo.setHxClassRanking(indexHx1);
//生物成绩年级排名
//按生物成绩降序排序
List<SchoolStudentScoreVo> collectSw = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getBiology).reversed()).collect(Collectors.toList());
//排名
int indexSw = 1;
double biology = studentScoreVo.getBiology();
for (int i = 0; i < collectSw.size(); i++) {
SchoolStudentScoreVo studentScoreVoSw = collectSw.get(i);
if (Double.compare(biology,studentScoreVoSw.getBiology()) != 0 && Double.compare(biology,studentScoreVoSw.getBiology()) == -1){
indexSw ++;
}
}
studentScoreVo.setSwRanking(indexSw);
//生物成绩班级排名
//按生物成绩降序排序
List<SchoolStudentScoreVo> collectSw1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getBiology).reversed()).collect(Collectors.toList());
//排名
int indexSw1 = 1;
for (int i = 0; i < collectSw1.size(); i++) {
SchoolStudentScoreVo studentScoreVoSw1 = collectSw1.get(i);
if (Double.compare(biology,studentScoreVoSw1.getBiology()) != 0 && Double.compare(biology,studentScoreVoSw1.getBiology()) == -1){
indexSw1 ++;
}
}
studentScoreVo.setSwClassRanking(indexSw1);
}); });
return list; return list;
} }
...@@ -508,5 +244,421 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, Sch ...@@ -508,5 +244,421 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, Sch
return studentScoreMapper.deleteStudentScore(ids); return studentScoreMapper.deleteStudentScore(ids);
} }
private Map<String,String> typeMap = new HashMap<String,String>(){{
this.put("语文","language");
this.put("数学","math");
this.put("英语","english");
this.put("政治","politics");
this.put("地理","geography");
this.put("历史","history");
this.put("物理","physics");
this.put("化学","chemistry");
this.put("生物","biology");
}};
//排名
private Map<String,String> ranKingMap = new HashMap<String,String>(){{
this.put("语文","ywRanking");
this.put("数学","sxRanking");
this.put("英语","yyRanking");
this.put("政治","zzRanking");
this.put("地理","dlRanking");
this.put("历史","lsRanking");
this.put("物理","wlRanking");
this.put("化学","hxRanking");
this.put("生物","swRanking");
}};
/**
* 查询学生三类行成绩
* @param curriculaStudent
* @return
*/
@Override
public List<SchoolStudentScoreVo> getStudentTypeViwe(CurriculaStudent curriculaStudent) {
//获取学生id
Long studentId = curriculaStudent.getStudentId();
//获取课程信息
String selectedCourse = curriculaStudent.getSelectedCourse();
//学生信息查询年级信息
SchoolStudentVO info = schoolStudentMapper.getInfo(studentId);
//获取年级
SchoolClass schoolClass = schoolClassMapper.selectById(info.getClassId());
//对比课程中文名
String section_type = dictDataService.selectDictLabel("section_type" , selectedCourse);
String[] split = section_type.split("\\+");
//获取班级成绩
List<SchoolStudentScoreVo> schoolStudentScoreVos = this.selectStudentScoreList(studentId);
for (SchoolStudentScoreVo data : schoolStudentScoreVos) {
//重新计算年级总排名,值给根据选择专业去判断
//个人3课总成绩
Double toleType = (Double)ReflectUtils.invokeGetter(data,typeMap.get(split[0])) + (Double)ReflectUtils.invokeGetter(data,typeMap.get(split[1])) +(Double)ReflectUtils.invokeGetter(data,typeMap.get(split[2]));
data.setTotalScore(toleType);
//获取其他学生三门总成绩 做对比
SchoolStudentScoreVo schoolStudentScoreVo1 = new SchoolStudentScoreVo();
//查询本年级所有成绩列表
schoolStudentScoreVo1.setGradeValue(schoolClass.getGradeValue());
schoolStudentScoreVo1.setExamType(data.getExamType());
List<SchoolStudentScoreVo> list1 = studentScoreMapper.selectStudentScoreList(schoolStudentScoreVo1);
//重写总成绩
list1.forEach(voDate->{
voDate.setTotalScore((Double)ReflectUtils.invokeGetter(voDate,typeMap.get(split[0])) + (Double)ReflectUtils.invokeGetter(voDate,typeMap.get(split[1])) +(Double)ReflectUtils.invokeGetter(voDate,typeMap.get(split[2])));
});
//按总成绩降序排序
List<SchoolStudentScoreVo> collect = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getTotalScore).reversed()).collect(Collectors.toList());
//排名
int index = 1;
double totalScore = data.getTotalScore();
for (int i = 0; i < collect.size(); i++) {
SchoolStudentScoreVo studentScoreVo1 = collect.get(i);
if (Double.compare(totalScore,studentScoreVo1.getTotalScore()) != 0 && Double.compare(totalScore,studentScoreVo1.getTotalScore()) == -1){
index ++;
}
}
data.setRanking(index);
}
//重新封装返回值去除无效值
List<SchoolStudentScoreVo> listVo = new ArrayList<>();
schoolStudentScoreVos.forEach(data->{
SchoolStudentScoreVo scoreVo = new SchoolStudentScoreVo();
scoreVo.setStudentId(data.getStudentId());
scoreVo.setClassId(data.getClassId());
scoreVo.setStudentName(data.getStudentName());
scoreVo.setStudentNumber(data.getStudentNumber());
scoreVo.setIdCard(data.getIdCard());
scoreVo.setClassName(data.getClassName());
scoreVo.setExamType(data.getExamType());
scoreVo.setTotalScore(data.getTotalScore());
scoreVo.setRanking(data.getRanking());
ReflectUtils.invokeSetter(scoreVo,typeMap.get(split[0]), (Double)ReflectUtils.invokeGetter(data,typeMap.get(split[0])));
ReflectUtils.invokeSetter(scoreVo,typeMap.get(split[1]), (Double)ReflectUtils.invokeGetter(data,typeMap.get(split[1])));
ReflectUtils.invokeSetter(scoreVo,typeMap.get(split[2]), (Double)ReflectUtils.invokeGetter(data,typeMap.get(split[2])));
ReflectUtils.invokeSetter(scoreVo,ranKingMap.get(split[0]), ReflectUtils.invokeGetter(data,ranKingMap.get(split[0])));
ReflectUtils.invokeSetter(scoreVo,ranKingMap.get(split[1]), ReflectUtils.invokeGetter(data,ranKingMap.get(split[1])));
ReflectUtils.invokeSetter(scoreVo,ranKingMap.get(split[2]), ReflectUtils.invokeGetter(data,ranKingMap.get(split[2])));
listVo.add(scoreVo);
});
return listVo;
}
/**
* 根据学生ID查询所有成绩
* @param studentId
* @return
*/
@Override
public List<SchoolStudentScoreVo> selectStudentScoreList(Long studentId) {
SchoolStudentScoreVo schoolStudentScoreVo = new SchoolStudentScoreVo();
schoolStudentScoreVo.setStudentId(studentId);
List<SchoolStudentScoreVo> schoolStudentScoreVos = studentScoreMapper
.selectStudentScoreList(schoolStudentScoreVo);
//学生信息查询年级信息
SchoolStudentVO info = schoolStudentMapper.getInfo(studentId);
//获取年级
SchoolClass schoolClass = schoolClassMapper.selectById(info.getClassId());
for (SchoolStudentScoreVo data : schoolStudentScoreVos) {
//之查看学生本年级的成绩
data.setGradeValue(schoolClass.getGradeValue());
this.handleAchievement(data);
}
Iterator<SchoolStudentScoreVo> iterator = schoolStudentScoreVos.iterator();
while (iterator.hasNext()){
SchoolStudentScoreVo next = iterator.next();
if (StringUtils.equals("4",next.getExamType())){
iterator.remove();
}
}
return schoolStudentScoreVos;
}
private SchoolStudentScoreVo handleAchievement(SchoolStudentScoreVo studentScoreVo){
//计算考试成绩年级排名/班级排名
//按年级查询
SchoolStudentScoreVo schoolStudentScoreVo1 = new SchoolStudentScoreVo();
schoolStudentScoreVo1.setCurriculaId(studentScoreVo.getCurriculaId());
schoolStudentScoreVo1.setExamType(studentScoreVo.getExamType());
if (studentScoreVo.getGradeValue()!=null){
schoolStudentScoreVo1.setGradeValue(studentScoreVo.getGradeValue());
}
List<SchoolStudentScoreVo> list1 = studentScoreMapper.selectStudentScoreList(schoolStudentScoreVo1);
//按班级查询
SchoolStudentScoreVo schoolStudentScoreVo2 = new SchoolStudentScoreVo();
schoolStudentScoreVo2.setCurriculaId(studentScoreVo.getCurriculaId());
schoolStudentScoreVo2.setClassId(studentScoreVo.getClassId());
schoolStudentScoreVo2.setExamType(studentScoreVo.getExamType());
if (studentScoreVo.getGradeValue()!=null){
schoolStudentScoreVo2.setGradeValue(studentScoreVo.getGradeValue());
}
List<SchoolStudentScoreVo> list2 = studentScoreMapper.selectStudentScoreList(schoolStudentScoreVo2);
//总成绩年级排名
//按总成绩降序排序
List<SchoolStudentScoreVo> collect = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getTotalScore).reversed()).collect(Collectors.toList());
//排名
int index = 1;
double totalScore = studentScoreVo.getTotalScore();
for (int i = 0; i < collect.size(); i++) {
SchoolStudentScoreVo studentScoreVo1 = collect.get(i);
if (Double.compare(totalScore,studentScoreVo1.getTotalScore()) != 0 && Double.compare(totalScore,studentScoreVo1.getTotalScore()) == -1){
index ++;
}
}
studentScoreVo.setRanking(index);
//总成绩班级排名
//按总成绩降序排序
List<SchoolStudentScoreVo> collect1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getTotalScore).reversed()).collect(Collectors.toList());
//排名
int index1 = 1;
for (int i = 0; i < collect1.size(); i++) {
SchoolStudentScoreVo studentScoreVo2 = collect1.get(i);
if (Double.compare(totalScore,studentScoreVo2.getTotalScore()) != 0 && Double.compare(totalScore,studentScoreVo2.getTotalScore()) == -1){
index1 ++;
}
}
studentScoreVo.setClassRanking(index1);
//语文成绩年级排名
//按语文成绩降序排序
List<SchoolStudentScoreVo> collect2 = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getLanguage).reversed()).collect(Collectors.toList());
//排名
int index3 = 1;
double language = studentScoreVo.getLanguage();
for (int i = 0; i < collect2.size(); i++) {
SchoolStudentScoreVo studentScoreVo1 = collect2.get(i);
if (Double.compare(language,studentScoreVo1.getLanguage()) != 0 && Double.compare(language,studentScoreVo1.getLanguage()) == -1){
index3 ++;
}
}
studentScoreVo.setYwRanking(index3);
//语文成绩班级排名
//按语文成绩降序排序
List<SchoolStudentScoreVo> collect4 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getLanguage).reversed()).collect(Collectors.toList());
//排名
int index4 = 1;
for (int i = 0; i < collect4.size(); i++) {
SchoolStudentScoreVo studentScoreVo2 = collect4.get(i);
if (Double.compare(language,studentScoreVo2.getLanguage()) != 0 && Double.compare(language,studentScoreVo2.getLanguage()) == -1){
index4 ++;
}
}
studentScoreVo.setYwClassRanking(index4);
//数学成绩年级排名
//按数学成绩降序排序
List<SchoolStudentScoreVo> collect3 = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getMath).reversed()).collect(Collectors.toList());
//排名
int index5 = 1;
double math = studentScoreVo.getMath();
for (int i = 0; i < collect3.size(); i++) {
SchoolStudentScoreVo studentScoreVo1 = collect3.get(i);
if (Double.compare(math,studentScoreVo1.getMath()) != 0 && Double.compare(math,studentScoreVo1.getMath()) == -1){
index5 ++;
}
}
studentScoreVo.setSxRanking(index5);
//数学成绩班级排名
//按数学成绩降序排序
List<SchoolStudentScoreVo> collect6 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getMath).reversed()).collect(Collectors.toList());
//排名
int index6 = 1;
for (int i = 0; i < collect6.size(); i++) {
SchoolStudentScoreVo studentScoreVo2 = collect6.get(i);
if (Double.compare(math,studentScoreVo2.getMath()) != 0 && Double.compare(math,studentScoreVo2.getMath()) == -1) {
index6++;
}
}
studentScoreVo.setSxClassRanking(index6);
//英语成绩年级排名
//按英语成绩降序排序
List<SchoolStudentScoreVo> collectYy = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getEnglish).reversed()).collect(Collectors.toList());
//排名
int indexYy = 1;
double english = studentScoreVo.getEnglish();
for (int i = 0; i < collectYy.size(); i++) {
SchoolStudentScoreVo studentScoreVoYy = collectYy.get(i);
if (Double.compare(english,studentScoreVoYy.getEnglish()) != 0 && Double.compare(english,studentScoreVoYy.getEnglish()) == -1){
indexYy ++;
}
}
studentScoreVo.setYyRanking(indexYy);
//英语成绩班级排名
//按英语成绩降序排序
List<SchoolStudentScoreVo> collectYy1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getEnglish).reversed()).collect(Collectors.toList());
//排名
int indexYy1 = 1;
for (int i = 0; i < collectYy1.size(); i++) {
SchoolStudentScoreVo studentScoreVoYy1 = collectYy1.get(i);
if (Double.compare(english,studentScoreVoYy1.getEnglish()) != 0 && Double.compare(english,studentScoreVoYy1.getEnglish()) == -1){
indexYy1 ++;
}
}
studentScoreVo.setYyClassRanking(indexYy1);
//政治成绩年级排名
//按政治成绩降序排序
List<SchoolStudentScoreVo> collectZz = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getPolitics).reversed()).collect(Collectors.toList());
//排名
int indexZz = 1;
double politics = studentScoreVo.getPolitics();
for (int i = 0; i < collectZz.size(); i++) {
SchoolStudentScoreVo studentScoreVoZz = collectZz.get(i);
if (Double.compare(politics,studentScoreVoZz.getPolitics()) != 0 && Double.compare(politics,studentScoreVoZz.getPolitics()) == -1){
indexZz ++;
}
}
studentScoreVo.setZzRanking(indexZz);
//政治成绩班级排名
//按政治成绩降序排序
List<SchoolStudentScoreVo> collectZz1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getPolitics).reversed()).collect(Collectors.toList());
//排名
int indexZz1 = 1;
for (int i = 0; i < collectZz1.size(); i++) {
SchoolStudentScoreVo studentScoreVoZz1 = collectZz1.get(i);
if (Double.compare(politics,studentScoreVoZz1.getPolitics()) != 0 && Double.compare(politics,studentScoreVoZz1.getPolitics()) == -1){
indexZz1 ++;
}
}
studentScoreVo.setZzClassRanking(indexZz1);
//地理成绩年级排名
//按地理成绩降序排序
List<SchoolStudentScoreVo> collectDl = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getGeography).reversed()).collect(Collectors.toList());
//排名
int indexDl = 1;
double geography = studentScoreVo.getGeography();
for (int i = 0; i < collectDl.size(); i++) {
SchoolStudentScoreVo studentScoreVoDl = collectDl.get(i);
if (Double.compare(geography,studentScoreVoDl.getGeography()) != 0 && Double.compare(geography,studentScoreVoDl.getGeography()) == -1){
indexDl ++;
}
}
studentScoreVo.setDlRanking(indexDl);
//地理成绩班级排名
//按地理成绩降序排序
List<SchoolStudentScoreVo> collectDl1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getGeography).reversed()).collect(Collectors.toList());
//排名
int indexDl1 = 1;
for (int i = 0; i < collectDl1.size(); i++) {
SchoolStudentScoreVo studentScoreVoDl1 = collectDl1.get(i);
if (Double.compare(geography,studentScoreVoDl1.getGeography()) != 0 && Double.compare(geography,studentScoreVoDl1.getGeography()) == -1){
indexDl1 ++;
}
}
studentScoreVo.setDlClassRanking(indexDl1);
//历史成绩年级排名
//按历史成绩降序排序
List<SchoolStudentScoreVo> collectLs = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getHistory).reversed()).collect(Collectors.toList());
//排名
int indexLs = 1;
double history = studentScoreVo.getHistory();
for (int i = 0; i < collectLs.size(); i++) {
SchoolStudentScoreVo studentScoreVoLs = collectLs.get(i);
if (Double.compare(history,studentScoreVoLs.getHistory()) != 0 && Double.compare(history,studentScoreVoLs.getHistory()) == -1){
indexLs ++;
}
}
studentScoreVo.setLsRanking(indexLs);
//历史成绩班级排名
//按历史成绩降序排序
List<SchoolStudentScoreVo> collectLs1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getHistory).reversed()).collect(Collectors.toList());
//排名
int indexLs1 = 1;
for (int i = 0; i < collectLs1.size(); i++) {
SchoolStudentScoreVo studentScoreVoLs1 = collectLs1.get(i);
if (Double.compare(history,studentScoreVoLs1.getHistory()) != 0 && Double.compare(history,studentScoreVoLs1.getHistory()) == -1){
indexLs1 ++;
}
}
studentScoreVo.setLsClassRanking(indexLs1);
//物理成绩年级排名
//按物理成绩降序排序
List<SchoolStudentScoreVo> collectWl = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getPhysics).reversed()).collect(Collectors.toList());
//排名
int indexWl = 1;
double physics = studentScoreVo.getPhysics();
for (int i = 0; i < collectWl.size(); i++) {
SchoolStudentScoreVo studentScoreVoWl = collectWl.get(i);
if (Double.compare(physics,studentScoreVoWl.getPhysics()) != 0 && Double.compare(physics,studentScoreVoWl.getPhysics()) == -1){
indexWl ++;
}
}
studentScoreVo.setWlRanking(indexWl);
//物理成绩班级排名
//按物理成绩降序排序
List<SchoolStudentScoreVo> collectWl1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getPhysics).reversed()).collect(Collectors.toList());
//排名
int indexWl1 = 1;
for (int i = 0; i < collectWl1.size(); i++) {
SchoolStudentScoreVo studentScoreVoWl1 = collectWl1.get(i);
if (Double.compare(physics,studentScoreVoWl1.getPhysics()) != 0 && Double.compare(physics,studentScoreVoWl1.getPhysics()) == -1){
indexWl1 ++;
}
}
studentScoreVo.setWlClassRanking(indexWl1);
//化学成绩年级排名
//按化学成绩降序排序
List<SchoolStudentScoreVo> collectHx = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getChemistry).reversed()).collect(Collectors.toList());
//排名
int indexHx = 1;
double chemistry = studentScoreVo.getChemistry();
for (int i = 0; i < collectHx.size(); i++) {
SchoolStudentScoreVo studentScoreVoHx = collectHx.get(i);
if (Double.compare(chemistry,studentScoreVoHx.getChemistry()) != 0 && Double.compare(chemistry,studentScoreVoHx.getChemistry()) == -1){
indexHx ++;
}
}
studentScoreVo.setHxRanking(indexHx);
//化学成绩班级排名
//按化学成绩降序排序
List<SchoolStudentScoreVo> collectHx1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getChemistry).reversed()).collect(Collectors.toList());
//排名
int indexHx1 = 1;
for (int i = 0; i < collectHx1.size(); i++) {
SchoolStudentScoreVo studentScoreVoHx1 = collectHx1.get(i);
if (Double.compare(chemistry,studentScoreVoHx1.getChemistry()) != 0 && Double.compare(chemistry,studentScoreVoHx1.getChemistry()) == -1){
indexHx1 ++;
}
}
studentScoreVo.setHxClassRanking(indexHx1);
//生物成绩年级排名
//按生物成绩降序排序
List<SchoolStudentScoreVo> collectSw = list1.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getBiology).reversed()).collect(Collectors.toList());
//排名
int indexSw = 1;
double biology = studentScoreVo.getBiology();
for (int i = 0; i < collectSw.size(); i++) {
SchoolStudentScoreVo studentScoreVoSw = collectSw.get(i);
if (Double.compare(biology,studentScoreVoSw.getBiology()) != 0 && Double.compare(biology,studentScoreVoSw.getBiology()) == -1){
indexSw ++;
}
}
studentScoreVo.setSwRanking(indexSw);
//生物成绩班级排名
//按生物成绩降序排序
List<SchoolStudentScoreVo> collectSw1 = list2.stream().sorted(Comparator.comparing(SchoolStudentScoreVo::getBiology).reversed()).collect(Collectors.toList());
//排名
int indexSw1 = 1;
for (int i = 0; i < collectSw1.size(); i++) {
SchoolStudentScoreVo studentScoreVoSw1 = collectSw1.get(i);
if (Double.compare(biology,studentScoreVoSw1.getBiology()) != 0 && Double.compare(biology,studentScoreVoSw1.getBiology()) == -1){
indexSw1 ++;
}
}
studentScoreVo.setSwClassRanking(indexSw1);
return studentScoreVo;
}
} }
...@@ -30,12 +30,14 @@ public class SchoolStudentScoreVo extends OurBaseEntity { ...@@ -30,12 +30,14 @@ public class SchoolStudentScoreVo extends OurBaseEntity {
/** 班级 */ /** 班级 */
@Excel(name = "班级") @Excel(name = "班级")
private String className; private String className;
/**年级值*/
private Integer gradeValue;
/** 考试类型 */ /** 考试类型 */
@Excel(name = "考试类型",combo = {"一次","二次","三次","期末"},readConverterExp = "1=一次,2=二次,3=三次,4=期末") @Excel(name = "考试类型",combo = {"一次","二次","三次","期末"},readConverterExp = "1=一次,2=二次,3=三次,4=期末")
private String examType; private String examType;
/** 总成绩 */ /** 总成绩 */
private double totalScore; private double totalScore;
/** 年级排名 */ /** 总成绩年级排名 */
private Integer ranking; private Integer ranking;
/** 班级排名 */ /** 班级排名 */
private Integer classRanking; private Integer classRanking;
......
package yangtz.cs.liu.wechat.controller.courseSelection;
import com.ruoyi.common.core.domain.AjaxResult;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yangtz.cs.liu.campus.domain.curricula.CurriculaStudent;
import yangtz.cs.liu.campus.service.curricula.ICurriculaStudentService;
import yangtz.cs.liu.campus.service.curricula.IStudentScoreService;
import yangtz.cs.liu.campus.vo.student.SchoolStudentScoreVo;
/**
* 公众号,选课
*/
@RestController
@RequestMapping("/wx/course")
public class WxCouresSelection {
@Autowired
IStudentScoreService iStudentScoreService;
@Autowired
ICurriculaStudentService iCurriculaStudentService;
/**
* 学生成绩查询
*/
@GetMapping("/achievement/{studentId}")
private AjaxResult getStudentAchievements(@PathVariable("studentId") Long studentId){
List<SchoolStudentScoreVo> schoolStudentScoreVos = iStudentScoreService
.selectStudentScoreList(studentId);
return AjaxResult.success(schoolStudentScoreVos);
}
/**
* 据物理化类型查看
*/
@GetMapping("/studenttypeview")
private AjaxResult getStudentTypeview( CurriculaStudent curriculaStudent){
List<SchoolStudentScoreVo> studentTypeViwe = iStudentScoreService
.getStudentTypeViwe(curriculaStudent);
return AjaxResult.success(studentTypeViwe);
}
/**
* 保存选课信息
*/
@PostMapping("/savestudentcourse")
private AjaxResult saveStudentcourse(@RequestBody CurriculaStudent curriculaStudent){
//保存专业信息
try {
iCurriculaStudentService.save(curriculaStudent);
return AjaxResult.success("选课成功");
}catch (Exception e){
return AjaxResult.error("选课失败");
}
}
}
...@@ -59,8 +59,10 @@ ...@@ -59,8 +59,10 @@
LEFT JOIN school_student xs ON cj.student_id = xs.id LEFT JOIN school_student xs ON cj.student_id = xs.id
LEFT JOIN school_class bj ON cj.class_id = bj.id LEFT JOIN school_class bj ON cj.class_id = bj.id
WHERE WHERE
cj.curricula_id = #{curriculaId} cj.del_flag = '0'
AND cj.del_flag = '0' <if test="curriculaId != null and curriculaId != ''">and cj.curricula_id = #{curriculaId} </if>
<if test="gradeValue != null and gradeValue != ''">and bj.grade_value = #{gradeValue} </if>
<if test="studentId != null and studentId != ''">and cj.student_id = #{studentId} </if>
<if test="examType != null and examType != ''">and cj.exam_type = #{examType}</if> <if test="examType != null and examType != ''">and cj.exam_type = #{examType}</if>
<if test="studentName != null and studentName != ''">and xs.student_name like concat('%', #{studentName}, '%')</if> <if test="studentName != null and studentName != ''">and xs.student_name like concat('%', #{studentName}, '%')</if>
<if test="classId != null">and cj.class_id = #{classId}</if> <if test="classId != null">and cj.class_id = #{classId}</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment