| | |
| | | package com.qxueyou.scc.admin.score.action; |
| | | |
| | | import com.qxueyou.scc.admin.classes.model.ClsClassReSubject; |
| | | import com.qxueyou.scc.admin.score.model.Score; |
| | | import com.qxueyou.scc.admin.score.service.impl.ScoreService; |
| | | import com.qxueyou.scc.base.model.Pager; |
| | |
| | | import com.qxueyou.scc.exam.model.ExamReExamPaper; |
| | | import com.qxueyou.scc.exam.model.ExamResultV; |
| | | import com.qxueyou.scc.exercise.model.ExerciseRecord; |
| | | import com.qxueyou.scc.exercise.model.ExerciseResultV; |
| | | import com.qxueyou.scc.teach.subject.model.Subject; |
| | | import com.qxueyou.scc.teach.subject.model.SubjectUtils; |
| | | import com.qxueyou.scc.teach.subject.model.view.MyLectureV; |
| | | import com.qxueyou.scc.teach.subject.model.view.MySubjectV; |
| | | import com.qxueyou.scc.teach.subject.service.ILectureService; |
| | | import com.qxueyou.scc.teach.subject.service.impl.SubjectService; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Api(tags = "成绩管理接口") |
| | | @Api(tags = "成绩管理接口") |
| | | @Controller |
| | | @CrossOrigin(origins="*",maxAge=3600) |
| | | @RequestMapping(value = "admin/score") |
| | | public class ScoreController { |
| | | |
| | | // 分页查询中,默认记录条数和页数 |
| | | // 分页查询中,默认记录条数和页数 |
| | | private static final int DEFAULT_PAGE_SIZE = 10; |
| | | private static final int DEFAULT_PAGE_NUM = 2; |
| | | private static final int DEFAULT_PAGE_NUM = 1; |
| | | |
| | | @Autowired |
| | | ScoreService scoreService; |
| | | |
| | | @Autowired |
| | | ILectureService lectureService; |
| | | |
| | | @Autowired |
| | | SubjectService subjectService; |
| | | |
| | | @RequestMapping(value = "lstScore", method = RequestMethod.GET) |
| | | public @ResponseBody |
| | |
| | | pageNum = pageNum != null && pageNum > 0 ? pageNum : DEFAULT_PAGE_NUM; |
| | | Pager pager = new Pager(pageSize,pageNum); |
| | | if(classId == null){ |
| | | classId = "%"; |
| | | classId = ""; |
| | | }else { |
| | | classId += "%"; |
| | | } |
| | | //总成绩数量 |
| | | int totalCount = scoreService.findCount("from ExamResultV where class_Id Like ?",CollectionUtils.newList(classId)); |
| | | List<Map<String,Object>> mapList = new ArrayList<>(); |
| | | List<ExamResultV> examResultVS = scoreService.allExamResultV(classId); |
| | | List<ExerciseResultV> exerciseResultVS = scoreService.allExerciseResultV(classId); |
| | | //总成绩数量 |
| | | int totalCount = scoreService.findCount("from ExamResultV where class_Id Like ? and score != null and score != 0",CollectionUtils.newList(classId)); |
| | | if (examResultVS.size() < exerciseResultVS.size()){ |
| | | totalCount = exerciseResultVS.size(); |
| | | } |
| | | int totalPage = totalCount % pageSize > 0 ? totalCount/pageSize + 1 : totalCount/pageSize; |
| | | int currentPage = pageNum < totalPage? pageNum : totalPage; |
| | | int pageStart = (currentPage-1) * pageSize < 0 ? 0 : (currentPage-1) * pageSize; |
| | | int pageEnd = pageSize * currentPage > totalCount ? totalCount : pageSize * currentPage; |
| | | pager.setTotalCount(totalCount); |
| | | List<ExamResultV> list = scoreService.allExamResultV(classId,pager); |
| | | return new Result(true,"success",CollectionUtils.newObjectMap("data", list, "scoreCount", totalCount)); |
| | | |
| | | if(examResultVS.size() > exerciseResultVS.size()) { |
| | | for (ExamResultV e : examResultVS) { |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | boolean esisNull = true; |
| | | BigDecimal examScore; |
| | | if (e.getScore() == null) { |
| | | examScore = BigDecimal.ZERO; |
| | | System.out.println(examScore); |
| | | } else { |
| | | examScore = e.getScore(); |
| | | } |
| | | for (ExerciseResultV es : exerciseResultVS) { |
| | | if (e.getId().getStudentNo().equals(es.getStudentNo())) { |
| | | esisNull = false; |
| | | Double exerciseInfoScore = es.getScore() == null ? 0.0 : es.getScore().doubleValue(); |
| | | map.put("studentName", es.getStudentName()); |
| | | map.put("studentNumber", es.getStudentNo()); |
| | | map.put("sex", es.getSex()); |
| | | map.put("status", e.getStatus()); |
| | | map.put("studyTime", 0); |
| | | map.put("subjectScore", 0); |
| | | map.put("exerciseInfoScore", exerciseInfoScore); |
| | | map.put("examScore", examScore); |
| | | map.put("totalScore", exerciseInfoScore + examScore.doubleValue()); |
| | | } |
| | | } |
| | | if (esisNull) { |
| | | map.put("studentName", e.getStudentName()); |
| | | map.put("studentNumber", e.getId().getStudentNo()); |
| | | map.put("sex", e.getSex()); |
| | | map.put("status", e.getStatus()); |
| | | map.put("studyTime", 0); |
| | | map.put("subjectScore", 0); |
| | | map.put("exerciseInfoScore", 0); |
| | | map.put("examScore", examScore); |
| | | map.put("totalScore", examScore); |
| | | } |
| | | mapList.add(map); |
| | | } |
| | | }else { |
| | | for (ExerciseResultV es : exerciseResultVS) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | boolean esisNull = true; |
| | | BigDecimal exerciseInfoScore; |
| | | if (es.getScore() == null) { |
| | | exerciseInfoScore = BigDecimal.ZERO; |
| | | } else { |
| | | exerciseInfoScore = es.getScore(); |
| | | } |
| | | for (ExamResultV e : examResultVS) { |
| | | if (e.getId().getStudentNo().equals(es.getStudentNo())) { |
| | | esisNull = false; |
| | | Double examScore = e.getScore() == null ? 0.0 : e.getScore().doubleValue(); |
| | | map.put("studentName", es.getStudentName()); |
| | | map.put("studentNumber", es.getStudentNo()); |
| | | map.put("sex", es.getSex()); |
| | | map.put("status", e.getStatus()); |
| | | map.put("studyTime", 0); |
| | | map.put("subjectScore", 0); |
| | | map.put("exerciseInfoScore", exerciseInfoScore); |
| | | map.put("examScore", examScore); |
| | | map.put("totalScore", examScore + exerciseInfoScore.doubleValue()); |
| | | } |
| | | } |
| | | if (esisNull) { |
| | | map.put("studentName", es.getStudentName()); |
| | | map.put("studentNumber", es.getStudentNo()); |
| | | map.put("sex", es.getSex()); |
| | | map.put("status", 0); |
| | | map.put("studyTime", 0); |
| | | map.put("subjectScore", 0); |
| | | map.put("exerciseInfoScore", exerciseInfoScore); |
| | | map.put("examScore", 0); |
| | | map.put("totalScore", exerciseInfoScore); |
| | | } |
| | | mapList.add(map); |
| | | } |
| | | } |
| | | return new Result(true,"success",CollectionUtils.newObjectMap("data", mapList.subList(pageStart,pageEnd), "scoreCount", totalCount)); |
| | | } |
| | | |
| | | @RequestMapping(value = "getScoreDetail", method = RequestMethod.GET) |
| | | @ResponseBody |
| | | public Result getScoreDetail(String studentNo){ |
| | | List<ExamResultV> examLst = scoreService.find("from ExamResultV where id.studentNo = ?",CollectionUtils.newList(studentNo),ExamResultV.class); |
| | | List<ExerciseResultV> exerciseInfoLst = scoreService.find("from ExerciseResultV where studentNo = ?",CollectionUtils.newList(studentNo),ExerciseResultV.class); |
| | | // List<MyLectureV> myLectureVList = scoreService .find("from MyLectureV where id.userId = ?",CollectionUtils.newList(examLst.get(0).getUserId()),MyLectureV.class); |
| | | List<Map<String,Object>> mapList = new ArrayList<>(); |
| | | List<ClsClassReSubject> clsClassReSubjects = scoreService.find("from ClsClassReSubject where classId = ? and deleteFlag is false",CollectionUtils.newList(examLst.get(0).getId().getClassId()),ClsClassReSubject.class); |
| | | for(ClsClassReSubject c : clsClassReSubjects) { |
| | | Double percent = 0.0; |
| | | Double progressValue = 0.0; |
| | | Double percentAvg = 0.0; |
| | | List<MyLectureV> myLectureVList = lectureService.listLectureVBySubjectId(examLst.get(0).getUserId(), c.getSubjectId(), "", 1000, 1, null); |
| | | if (!myLectureVList.isEmpty()) { |
| | | for (MyLectureV myLectureV : myLectureVList) { |
| | | if (myLectureV.getPercent() != null && myLectureV.getProgressValue() != null) { |
| | | percent += myLectureV.getPercent(); |
| | | progressValue += myLectureV.getProgressValue().intValue(); |
| | | } |
| | | } |
| | | if (percentAvg.isNaN()) { |
| | | percentAvg = 0.0; |
| | | } |
| | | percentAvg = percent / myLectureVList.size() * 100;; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("subjectName", myLectureVList.get(0).getSubjectName()); |
| | | map.put("percent", percentAvg.intValue()); |
| | | map.put("durationTime", progressValue); |
| | | map.put("endStudyTime", myLectureVList.get(0).getLectureUpdateTime()); |
| | | mapList.add(map); |
| | | }else { |
| | | MySubjectV mySubjectV = scoreService.findUnique("from MySubjectV where subjectId = ?",CollectionUtils.newList(c.getSubjectId()),MySubjectV.class); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("subjectName", mySubjectV.getSubjectName()); |
| | | map.put("percent", 0); |
| | | map.put("durationTime", 0); |
| | | map.put("endStudyTime", null); |
| | | mapList.add(map); |
| | | } |
| | | } |
| | | return new Result(true,"success",CollectionUtils.newObjectMap("subjectLst",mapList,"examLst",examLst,"exerciseInfoLst",exerciseInfoLst)); |
| | | } |
| | | } |