|
|
@@ -1,11 +1,11 @@
|
|
|
package com.usoftchina.smartschool.school.wxschool.basic.service.impl;
|
|
|
|
|
|
-import com.usoftchina.smartschool.school.wxschool.mapper.WxClazzMapper;
|
|
|
-import com.usoftchina.smartschool.school.wxschool.mapper.WxStuScoreMapper;
|
|
|
-import com.usoftchina.smartschool.school.wxschool.mapper.WxStudentMapper;
|
|
|
import com.usoftchina.smartschool.school.po.StuScoreDO;
|
|
|
import com.usoftchina.smartschool.school.po.StudentDO;
|
|
|
import com.usoftchina.smartschool.school.wxschool.basic.service.WxStuScoreService;
|
|
|
+import com.usoftchina.smartschool.school.wxschool.mapper.WxClazzMapper;
|
|
|
+import com.usoftchina.smartschool.school.wxschool.mapper.WxStuScoreMapper;
|
|
|
+import com.usoftchina.smartschool.school.wxschool.mapper.WxStudentMapper;
|
|
|
import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -43,57 +43,95 @@ public class WxStuScoreServiceImpl implements WxStuScoreService {
|
|
|
if (ObjectUtils.isNotEmpty(stuScoreDOS)){
|
|
|
List<Map> maps = new ArrayList<>();
|
|
|
List<Long> longs = new ArrayList<>();
|
|
|
- List<StudentDO> studentDOS = studentMapper.listByClazzId(studentMapper.get(stuId).getClazzId());
|
|
|
- if (ObjectUtils.isNotEmpty(studentDOS)){
|
|
|
- for (StudentDO st:studentDOS) {
|
|
|
- longs.add(st.getStuId());
|
|
|
- }
|
|
|
- }
|
|
|
+ StudentDO studentDO = studentMapper.get(stuId);
|
|
|
+ if (ObjectUtils.isNotEmpty(studentDO)){
|
|
|
+ Long clazzId = studentDO.getClazzId();
|
|
|
+ if (ObjectUtils.isNotEmpty(clazzId)){
|
|
|
+ List<StudentDO> studentDOS = studentMapper.listByClazzId(clazzId);
|
|
|
+ if (ObjectUtils.isNotEmpty(studentDOS)){
|
|
|
+ for (StudentDO st:studentDOS) {
|
|
|
+ longs.add(st.getStuId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
for (StuScoreDO ss:stuScoreDOS) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- List<StuScoreDO> stuScoreDOS1 = stuScoreMapper.selectScoreListByStuId(longs, ss.getScoreType(), ss.getSubjectId());
|
|
|
- if (ObjectUtils.isNotEmpty(stuScoreDOS1)) {
|
|
|
- Double m = 0.0;
|
|
|
- for (int j = 0; j < stuScoreDOS1.size(); j++) {
|
|
|
- StuScoreDO score = stuScoreDOS1.get(j);
|
|
|
- Long stuId1 = score.getStuId();
|
|
|
- if (stuId.compareTo(stuId1) == 0) {
|
|
|
- score.setStuName(studentMapper.get(stuId1).getStuName());
|
|
|
- map.put("scoreBasic", score);
|
|
|
- map.put("classRank", j + 1);
|
|
|
- map.put("title", clazzMapper.get(studentMapper.get(stuId).getClazzId()).getClazzName() + score.getScoreName() + score.getScoreType());
|
|
|
- }
|
|
|
- m = m + score.getScoreNum();
|
|
|
- }
|
|
|
- map.put("classAverage", new BigDecimal(m / stuScoreDOS1.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
- //一个班级
|
|
|
- List<Long> clazzIds = clazzMapper.getByClazzId(studentMapper.get(stuId).getClazzId());
|
|
|
- List<Long> list = new ArrayList<>();
|
|
|
- for (Long clazzId:clazzIds) {
|
|
|
- List<Long> stuIds = studentMapper.selectStuIdsByClazzId(clazzId);
|
|
|
- list.addAll(stuIds);
|
|
|
- }
|
|
|
- List<StuScoreDO> scores = stuScoreMapper.selectScoreListByStuId(list,ss.getScoreType(), ss.getSubjectId());
|
|
|
- Double n = 0.0;
|
|
|
- for (int k = 0; k < scores.size(); k++) {
|
|
|
- StuScoreDO score = scores.get(k);
|
|
|
- if (stuId.compareTo(score.getStuId()) == 0) {
|
|
|
- if ("全年级".equals(score.getScoreScope())) {
|
|
|
- map.put("schoolRank", k + 1);
|
|
|
- } else {
|
|
|
- map.put("schoolRank", "-");
|
|
|
- }
|
|
|
- }
|
|
|
- n = n + score.getScoreNum();
|
|
|
- }
|
|
|
- map.put("schoolAverage", new BigDecimal(n / scores.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
- maps.add(map);
|
|
|
- }
|
|
|
+ if (ObjectUtils.isNotEmpty(ss.getScoreType())&&ObjectUtils.isNotEmpty(ss.getSubjectId())){
|
|
|
+ List<StuScoreDO> stuScoreDOS1 = stuScoreMapper.selectScoreListByStuId(longs, ss.getScoreType(), ss.getSubjectId());
|
|
|
+ if (ObjectUtils.isNotEmpty(stuScoreDOS1)) {
|
|
|
+ Double m = 0.0;
|
|
|
+ for (int j = 0; j < stuScoreDOS1.size(); j++) {
|
|
|
+ StuScoreDO score = stuScoreDOS1.get(j);
|
|
|
+ Long stuId1 = score.getStuId();
|
|
|
+ if (stuId.compareTo(stuId1) == 0) {
|
|
|
+ score.setStuName(score.getStuName());
|
|
|
+ map.put("scoreBasic", score);
|
|
|
+ map.put("classRank", j + 1);
|
|
|
+ map.put("title",score.getExamTitle());
|
|
|
+ }
|
|
|
+ m = m + score.getScoreNum();
|
|
|
+ }
|
|
|
+ map.put("classAverage", new BigDecimal(m / stuScoreDOS1.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
+ //一个班级
|
|
|
+ List<Long> clazzIds = clazzMapper.getByClazzId(studentMapper.get(stuId).getClazzId());
|
|
|
+ List<Long> list = new ArrayList<>();
|
|
|
+ for (Long clazzId:clazzIds) {
|
|
|
+ List<Long> stuIds = studentMapper.selectStuIdsByClazzId(clazzId);
|
|
|
+ list.addAll(stuIds);
|
|
|
+ }
|
|
|
+ List<StuScoreDO> scores = stuScoreMapper.selectScoreListByStuId(list,ss.getScoreType(), ss.getSubjectId());
|
|
|
+ Double n = 0.0;
|
|
|
+ for (int k = 0; k < scores.size(); k++) {
|
|
|
+ StuScoreDO score = scores.get(k);
|
|
|
+ if (stuId.compareTo(score.getStuId()) == 0) {
|
|
|
+ if ("全年级".equals(score.getScoreScope())) {
|
|
|
+ map.put("schoolRank", k + 1);
|
|
|
+ } else {
|
|
|
+ map.put("schoolRank", "-");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ n = n + score.getScoreNum();
|
|
|
+ }
|
|
|
+ map.put("schoolAverage", new BigDecimal(n / scores.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
+ maps.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return maps;
|
|
|
}else {
|
|
|
throw new Exception("暂无数据");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*public List<Map> getScoreList(Long stuId, Integer pageIndex, Integer pageSize) throws Exception{
|
|
|
+ Integer pageStart = (pageIndex-1)*pageSize;
|
|
|
+ List<StuScoreDO> stuScoreDOS = stuScoreMapper.listByStu(stuId, pageStart, pageSize);
|
|
|
+ if (ObjectUtils.isNotEmpty(stuScoreDOS)){
|
|
|
+ List<Long> list = new ArrayList<>();
|
|
|
+ for (StuScoreDO ss:stuScoreDOS) {
|
|
|
+ Long classId = ss.getClassId();
|
|
|
+ if (ObjectUtils.isNotEmpty(classId)){
|
|
|
+ List<Long> longs = studentMapper.selectStuIdsByClazzId(classId);
|
|
|
+
|
|
|
+ list.addAll(longs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private static List removeDuplicate(List list){
|
|
|
+ List listTemp = new ArrayList();
|
|
|
+ for(int i=0;i<list.size();i++){
|
|
|
+ if(!listTemp.contains(list.get(i))){
|
|
|
+ listTemp.add(list.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return listTemp;
|
|
|
+ }
|
|
|
}
|