|
@@ -10,6 +10,7 @@ import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.RowMapper;
|
|
@@ -27,191 +28,206 @@ import cn.com.qmth.examcloud.examwork.api.response.GetExamPropertyResp;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @author chenken
|
|
|
- * @date 2018年9月19日 下午3:20:29
|
|
|
- * @company QMTH
|
|
|
+ * @author chenken
|
|
|
+ * @date 2018年9月19日 下午3:20:29
|
|
|
+ * @company QMTH
|
|
|
* @description ExamRecordForMarkingServiceImpl.java
|
|
|
*/
|
|
|
@Service("examRecordForMarkingService")
|
|
|
public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordForMarkingRepo examRecordForMarkingRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamCloudService examCloudService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordForMarkingRepo examRecordForMarkingRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamCloudService examCloudService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
- @Override
|
|
|
- public List<ExamRecordForMarkingEntity> queryValidExamRecordInfoByStuIds(Long examId,Long courseId,List<Long> examStudentIds) {
|
|
|
- GetExamReq getExamReq = new GetExamReq();
|
|
|
- getExamReq.setId(examId);
|
|
|
- GetExamResp getExamResp = examCloudService.getExam(getExamReq);
|
|
|
- ExamType examType = ExamType.strToEnum(getExamResp.getExamBean().getExamType());
|
|
|
-
|
|
|
- List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingRepo.findByExamIdAndCourseIdAndExamStudentIds(examId, courseId, examStudentIds);
|
|
|
- if(examType == ExamType.OFFLINE){
|
|
|
- return examRecordForMarkingList;
|
|
|
- }else if(examType == ExamType.ONLINE){
|
|
|
- GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
|
|
|
- getExamPropertyReq.setExamId(examId);
|
|
|
- getExamPropertyReq.setKey("MARKING_TYPE");
|
|
|
- GetExamPropertyResp getExamPropertyResp = examCloudService.getExamProperty(getExamPropertyReq);
|
|
|
-
|
|
|
- String markingType = getExamPropertyResp.getValue();
|
|
|
- if(markingType.equals(MarkingType.ALL.name())){
|
|
|
- return examRecordForMarkingList;
|
|
|
- }else if(markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())){
|
|
|
- return queryStudentPapersByObjectScoreMax(examRecordForMarkingList);
|
|
|
- }else if(markingType.equals(MarkingType.LAST_SUBMIT.name())){
|
|
|
- return queryStudentPapersByLastSubmit(examRecordForMarkingList);
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
- @Override
|
|
|
- public List<ExamRecordForMarkingEntity> queryValidExamRecordInfo(Long examId,Long courseId) {
|
|
|
- GetExamReq getExamReq = new GetExamReq();
|
|
|
- getExamReq.setId(examId);
|
|
|
- GetExamResp getExamResp = examCloudService.getExam(getExamReq);
|
|
|
- ExamType examType = ExamType.strToEnum(getExamResp.getExamBean().getExamType());
|
|
|
-
|
|
|
- List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingRepo.findByExamIdAndCourseId(examId, courseId);
|
|
|
- if(examType == ExamType.OFFLINE){
|
|
|
- return examRecordForMarkingList;
|
|
|
- }else if(examType == ExamType.ONLINE){
|
|
|
- GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
|
|
|
- getExamPropertyReq.setExamId(examId);
|
|
|
- getExamPropertyReq.setKey("MARKING_TYPE");
|
|
|
- GetExamPropertyResp getExamPropertyResp = examCloudService.getExamProperty(getExamPropertyReq);
|
|
|
-
|
|
|
- String markingType = getExamPropertyResp.getValue();
|
|
|
- if(markingType.equals(MarkingType.ALL.name())){
|
|
|
- return examRecordForMarkingList;
|
|
|
- }else if(markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())){
|
|
|
- return queryStudentPapersByObjectScoreMax(examRecordForMarkingList);
|
|
|
- }else if(markingType.equals(MarkingType.LAST_SUBMIT.name())){
|
|
|
- return queryStudentPapersByLastSubmit(examRecordForMarkingList);
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 最后一次提交
|
|
|
- * @param examRecordForMarkingList
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<ExamRecordForMarkingEntity> queryStudentPapersByLastSubmit(List<ExamRecordForMarkingEntity> examRecordForMarkingAllList) {
|
|
|
- Map<Long,List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = groupByExamStudentId(examRecordForMarkingAllList);
|
|
|
- Iterator<Entry<Long,List<ExamRecordForMarkingEntity>>> iterator = groupByExamStudentIdMap.entrySet().iterator();
|
|
|
- List<ExamRecordForMarkingEntity> finalExamRecordForMarkingEntityList = new ArrayList<ExamRecordForMarkingEntity>();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- Entry<Long,List<ExamRecordForMarkingEntity>> entry = iterator.next();
|
|
|
- List<ExamRecordForMarkingEntity> examRecordForMarkingList = entry.getValue();
|
|
|
- List<ExamRecordForMarkingEntity> listSortByExamRecordDataId = examRecordForMarkingList.stream().sorted((p1,p2) -> p2.getExamRecordDataId().compareTo(p1.getExamRecordDataId())).collect(Collectors.toList());
|
|
|
- finalExamRecordForMarkingEntityList.add(listSortByExamRecordDataId.get(0));
|
|
|
- }
|
|
|
- /**
|
|
|
- * 解决下面的问题:
|
|
|
- * 当一个课程下设置两套试卷一套有主观题,一套没有主观题时,考试完成后给阅卷端传试卷时会传错,例如:
|
|
|
- * 考试批次设置为取最后一次考试成绩;
|
|
|
- * 在调卷规则中给课程A设置了两份试卷A1和A2,A1试卷中有主观题,A2试卷没有主观题;
|
|
|
- * 考生AA在考试时,第一次抽取到了A1试卷,第二次抽取到了A2试卷;
|
|
|
- * 考试完成后考生AA应该没有试卷传给阅卷端,但实际上系统将A1试卷传给了阅卷端
|
|
|
- */
|
|
|
- //todo
|
|
|
- return finalExamRecordForMarkingEntityList;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 客观分最高
|
|
|
- * @param examRecordForMarkingList
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<ExamRecordForMarkingEntity> queryStudentPapersByObjectScoreMax(List<ExamRecordForMarkingEntity> examRecordForMarkingAllList) {
|
|
|
- Map<Long,List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = groupByExamStudentId(examRecordForMarkingAllList);
|
|
|
- Iterator<Entry<Long,List<ExamRecordForMarkingEntity>>> iterator = groupByExamStudentIdMap.entrySet().iterator();
|
|
|
- List<ExamRecordForMarkingEntity> finalExamRecordForMarkingEntityList = new ArrayList<ExamRecordForMarkingEntity>();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- Entry<Long,List<ExamRecordForMarkingEntity>> entry = iterator.next();
|
|
|
- List<ExamRecordForMarkingEntity> examRecordForMarkingList = entry.getValue();
|
|
|
- //得出该考生的最高客观分
|
|
|
- double maxObjectiveScore = examRecordForMarkingList.stream().sorted((p1,p2) -> p2.getObjectiveScore().compareTo(p1.getObjectiveScore()))
|
|
|
- .limit(1).findFirst().get().getObjectiveScore();
|
|
|
- //过滤出最高分集合
|
|
|
- List<ExamRecordForMarkingEntity> examRecordForMarkingByFilterList = examRecordForMarkingList.stream().filter(score -> {
|
|
|
- return score.getObjectiveScore() == maxObjectiveScore;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- //如果最高客观分的有多个,继续按主观题答案长度过滤
|
|
|
- if(examRecordForMarkingByFilterList.size()>1){
|
|
|
- int maxAnswerLength = examRecordForMarkingByFilterList.stream().sorted((p1,p2) -> p2.getSubjectiveAnswerLength()-p1.getSubjectiveAnswerLength())
|
|
|
- .limit(1).findFirst().get().getSubjectiveAnswerLength();
|
|
|
- examRecordForMarkingByFilterList = examRecordForMarkingList.stream().filter(score -> {
|
|
|
- return score.getSubjectiveAnswerLength() == maxAnswerLength;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- //如果主观题答案最长长度一样的还有多个,继续按时间(考试记录ID)过滤出最新的那条
|
|
|
- if(examRecordForMarkingByFilterList.size()>1){
|
|
|
- examRecordForMarkingByFilterList = examRecordForMarkingByFilterList.stream().sorted((p1,p2) -> p2.getExamRecordDataId().compareTo(p1.getExamRecordDataId()))
|
|
|
- .limit(1)
|
|
|
- .collect(Collectors.toList());
|
|
|
- }
|
|
|
- }
|
|
|
- finalExamRecordForMarkingEntityList.add(examRecordForMarkingByFilterList.get(0));
|
|
|
- }
|
|
|
- return finalExamRecordForMarkingEntityList;
|
|
|
- }
|
|
|
-
|
|
|
- private Map<Long,List<ExamRecordForMarkingEntity>> groupByExamStudentId(List<ExamRecordForMarkingEntity> examRecordForMarkingList){
|
|
|
- Map<Long,List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = new HashMap<Long,List<ExamRecordForMarkingEntity>>();
|
|
|
- for(ExamRecordForMarkingEntity examRecordForMarkingEntity:examRecordForMarkingList){
|
|
|
- Long examStudentId = examRecordForMarkingEntity.getExamStudentId();
|
|
|
- List<ExamRecordForMarkingEntity> value = null;
|
|
|
- if(groupByExamStudentIdMap.containsKey(examStudentId)){
|
|
|
- value = groupByExamStudentIdMap.get(examStudentId);
|
|
|
- }else{
|
|
|
- value = new ArrayList<ExamRecordForMarkingEntity>();
|
|
|
- }
|
|
|
- value.add(examRecordForMarkingEntity);
|
|
|
- groupByExamStudentIdMap.put(examStudentId, value);
|
|
|
- }
|
|
|
- return groupByExamStudentIdMap;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<ExamRecordForMarkingEntity> findExamRecordForMarkingInfo(Long id,Long examId,Long courseId) {
|
|
|
- if(id == null && examId == null){
|
|
|
- return null;
|
|
|
- }
|
|
|
- StringBuffer sql = new StringBuffer();
|
|
|
- sql.append("select id,exam_id,base_paper_id,paper_type,course_id,offline_file_name,offline_file_url "+
|
|
|
- " from ec_oe_exam_record_4_marking where 1=1 ");
|
|
|
- if(id != null){
|
|
|
- sql.append(" and id = "+id);
|
|
|
- }
|
|
|
- if(examId != null){
|
|
|
- sql.append(" and exam_id = "+examId);
|
|
|
- }
|
|
|
- if(courseId != null){
|
|
|
- sql.append(" and course_id = '"+courseId+"'");
|
|
|
- }
|
|
|
- sql.append(" group by base_paper_id");
|
|
|
- return jdbcTemplate.query(sql.toString(), new RowMapper<ExamRecordForMarkingEntity>(){
|
|
|
- @Override
|
|
|
- public ExamRecordForMarkingEntity mapRow(ResultSet rs, int arg1) throws SQLException {
|
|
|
- ExamRecordForMarkingEntity entity = new ExamRecordForMarkingEntity();
|
|
|
- entity.setId(rs.getLong("id"));
|
|
|
- entity.setExamId(rs.getLong("exam_id"));
|
|
|
- entity.setBasePaperId(rs.getString("base_paper_id"));
|
|
|
- entity.setPaperType(rs.getString("paper_type"));
|
|
|
- entity.setCourseId(rs.getLong("course_id"));
|
|
|
- entity.setOfflineFileName(rs.getString("offline_file_name"));
|
|
|
- entity.setOfflineFileUrl(rs.getString("offline_file_url"));
|
|
|
- return entity;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamRecordForMarkingEntity> queryValidExamRecordInfoByStuIds(
|
|
|
+ Long examId, Long courseId, List<Long> examStudentIds, String batchNum) {
|
|
|
+ GetExamReq getExamReq = new GetExamReq();
|
|
|
+ getExamReq.setId(examId);
|
|
|
+ GetExamResp getExamResp = examCloudService.getExam(getExamReq);
|
|
|
+ ExamType examType = ExamType.strToEnum(getExamResp.getExamBean().getExamType());
|
|
|
+
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList;
|
|
|
+ if (StringUtils.isEmpty(batchNum)){
|
|
|
+ examRecordForMarkingList =
|
|
|
+ examRecordForMarkingRepo.findByExamIdAndCourseIdAndExamStudentIds(examId, courseId, examStudentIds);
|
|
|
+ }else {
|
|
|
+ examRecordForMarkingList =
|
|
|
+ examRecordForMarkingRepo.findByExamIdAndCourseIdAndExamStudentIdsAndBatchNum(examId, courseId, examStudentIds,batchNum);
|
|
|
+ }
|
|
|
+ if (examType == ExamType.OFFLINE) {
|
|
|
+ return examRecordForMarkingList;
|
|
|
+ } else if (examType == ExamType.ONLINE) {
|
|
|
+ GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
|
|
|
+ getExamPropertyReq.setExamId(examId);
|
|
|
+ getExamPropertyReq.setKey("MARKING_TYPE");
|
|
|
+ GetExamPropertyResp getExamPropertyResp = examCloudService.getExamProperty(getExamPropertyReq);
|
|
|
+
|
|
|
+ String markingType = getExamPropertyResp.getValue();
|
|
|
+ if (markingType.equals(MarkingType.ALL.name())) {
|
|
|
+ return examRecordForMarkingList;
|
|
|
+ } else if (markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())) {
|
|
|
+ return queryStudentPapersByObjectScoreMax(examRecordForMarkingList);
|
|
|
+ } else if (markingType.equals(MarkingType.LAST_SUBMIT.name())) {
|
|
|
+ return queryStudentPapersByLastSubmit(examRecordForMarkingList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamRecordForMarkingEntity> queryValidExamRecordInfo(Long examId, Long courseId) {
|
|
|
+ GetExamReq getExamReq = new GetExamReq();
|
|
|
+ getExamReq.setId(examId);
|
|
|
+ GetExamResp getExamResp = examCloudService.getExam(getExamReq);
|
|
|
+ ExamType examType = ExamType.strToEnum(getExamResp.getExamBean().getExamType());
|
|
|
+
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingRepo.findByExamIdAndCourseId(examId, courseId);
|
|
|
+ if (examType == ExamType.OFFLINE) {
|
|
|
+ return examRecordForMarkingList;
|
|
|
+ } else if (examType == ExamType.ONLINE) {
|
|
|
+ GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
|
|
|
+ getExamPropertyReq.setExamId(examId);
|
|
|
+ getExamPropertyReq.setKey("MARKING_TYPE");
|
|
|
+ GetExamPropertyResp getExamPropertyResp = examCloudService.getExamProperty(getExamPropertyReq);
|
|
|
+
|
|
|
+ String markingType = getExamPropertyResp.getValue();
|
|
|
+ if (markingType.equals(MarkingType.ALL.name())) {
|
|
|
+ return examRecordForMarkingList;
|
|
|
+ } else if (markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())) {
|
|
|
+ return queryStudentPapersByObjectScoreMax(examRecordForMarkingList);
|
|
|
+ } else if (markingType.equals(MarkingType.LAST_SUBMIT.name())) {
|
|
|
+ return queryStudentPapersByLastSubmit(examRecordForMarkingList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 最后一次提交
|
|
|
+ *
|
|
|
+ * @param examRecordForMarkingAllList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<ExamRecordForMarkingEntity> queryStudentPapersByLastSubmit(List<ExamRecordForMarkingEntity> examRecordForMarkingAllList) {
|
|
|
+ Map<Long, List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = groupByExamStudentId(examRecordForMarkingAllList);
|
|
|
+ Iterator<Entry<Long, List<ExamRecordForMarkingEntity>>> iterator = groupByExamStudentIdMap.entrySet().iterator();
|
|
|
+ List<ExamRecordForMarkingEntity> finalExamRecordForMarkingEntityList = new ArrayList<ExamRecordForMarkingEntity>();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ Entry<Long, List<ExamRecordForMarkingEntity>> entry = iterator.next();
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList = entry.getValue();
|
|
|
+ List<ExamRecordForMarkingEntity> listSortByExamRecordDataId = examRecordForMarkingList.stream().sorted((p1, p2) -> p2.getExamRecordDataId().compareTo(p1.getExamRecordDataId())).collect(Collectors.toList());
|
|
|
+ finalExamRecordForMarkingEntityList.add(listSortByExamRecordDataId.get(0));
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 解决下面的问题:
|
|
|
+ * 当一个课程下设置两套试卷一套有主观题,一套没有主观题时,考试完成后给阅卷端传试卷时会传错,例如:
|
|
|
+ * 考试批次设置为取最后一次考试成绩;
|
|
|
+ * 在调卷规则中给课程A设置了两份试卷A1和A2,A1试卷中有主观题,A2试卷没有主观题;
|
|
|
+ * 考生AA在考试时,第一次抽取到了A1试卷,第二次抽取到了A2试卷;
|
|
|
+ * 考试完成后考生AA应该没有试卷传给阅卷端,但实际上系统将A1试卷传给了阅卷端
|
|
|
+ */
|
|
|
+ //todo
|
|
|
+ return finalExamRecordForMarkingEntityList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客观分最高
|
|
|
+ *
|
|
|
+ * @param examRecordForMarkingList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<ExamRecordForMarkingEntity> queryStudentPapersByObjectScoreMax(List<ExamRecordForMarkingEntity> examRecordForMarkingAllList) {
|
|
|
+ Map<Long, List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = groupByExamStudentId(examRecordForMarkingAllList);
|
|
|
+ Iterator<Entry<Long, List<ExamRecordForMarkingEntity>>> iterator = groupByExamStudentIdMap.entrySet().iterator();
|
|
|
+ List<ExamRecordForMarkingEntity> finalExamRecordForMarkingEntityList = new ArrayList<ExamRecordForMarkingEntity>();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ Entry<Long, List<ExamRecordForMarkingEntity>> entry = iterator.next();
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList = entry.getValue();
|
|
|
+ //得出该考生的最高客观分
|
|
|
+ double maxObjectiveScore = examRecordForMarkingList.stream().sorted((p1, p2) -> p2.getObjectiveScore().compareTo(p1.getObjectiveScore()))
|
|
|
+ .limit(1).findFirst().get().getObjectiveScore();
|
|
|
+ //过滤出最高分集合
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingByFilterList = examRecordForMarkingList.stream().filter(score -> {
|
|
|
+ return score.getObjectiveScore() == maxObjectiveScore;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //如果最高客观分的有多个,继续按主观题答案长度过滤
|
|
|
+ if (examRecordForMarkingByFilterList.size() > 1) {
|
|
|
+ int maxAnswerLength = examRecordForMarkingByFilterList.stream().sorted((p1, p2) -> p2.getSubjectiveAnswerLength() - p1.getSubjectiveAnswerLength())
|
|
|
+ .limit(1).findFirst().get().getSubjectiveAnswerLength();
|
|
|
+ examRecordForMarkingByFilterList = examRecordForMarkingList.stream().filter(score -> {
|
|
|
+ return score.getSubjectiveAnswerLength() == maxAnswerLength;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //如果主观题答案最长长度一样的还有多个,继续按时间(考试记录ID)过滤出最新的那条
|
|
|
+ if (examRecordForMarkingByFilterList.size() > 1) {
|
|
|
+ examRecordForMarkingByFilterList = examRecordForMarkingByFilterList.stream().sorted((p1, p2) -> p2.getExamRecordDataId().compareTo(p1.getExamRecordDataId()))
|
|
|
+ .limit(1)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finalExamRecordForMarkingEntityList.add(examRecordForMarkingByFilterList.get(0));
|
|
|
+ }
|
|
|
+ return finalExamRecordForMarkingEntityList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<Long, List<ExamRecordForMarkingEntity>> groupByExamStudentId(List<ExamRecordForMarkingEntity> examRecordForMarkingList) {
|
|
|
+ Map<Long, List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = new HashMap<Long, List<ExamRecordForMarkingEntity>>();
|
|
|
+ for (ExamRecordForMarkingEntity examRecordForMarkingEntity : examRecordForMarkingList) {
|
|
|
+ Long examStudentId = examRecordForMarkingEntity.getExamStudentId();
|
|
|
+ List<ExamRecordForMarkingEntity> value = null;
|
|
|
+ if (groupByExamStudentIdMap.containsKey(examStudentId)) {
|
|
|
+ value = groupByExamStudentIdMap.get(examStudentId);
|
|
|
+ } else {
|
|
|
+ value = new ArrayList<ExamRecordForMarkingEntity>();
|
|
|
+ }
|
|
|
+ value.add(examRecordForMarkingEntity);
|
|
|
+ groupByExamStudentIdMap.put(examStudentId, value);
|
|
|
+ }
|
|
|
+ return groupByExamStudentIdMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamRecordForMarkingEntity> findExamRecordForMarkingInfo(Long id, Long examId, Long courseId, String batchNum) {
|
|
|
+ if (id == null && examId == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ StringBuffer sql = new StringBuffer();
|
|
|
+ sql.append("select id,exam_id,base_paper_id,paper_type,course_id,offline_file_name,offline_file_url " +
|
|
|
+ " from ec_oe_exam_record_4_marking where 1=1 ");
|
|
|
+ if (id != null) {
|
|
|
+ sql.append(" and id = " + id);
|
|
|
+ }
|
|
|
+ if (examId != null) {
|
|
|
+ sql.append(" and exam_id = " + examId);
|
|
|
+ }
|
|
|
+ if (courseId != null) {
|
|
|
+ sql.append(" and course_id = '" + courseId + "'");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(batchNum)) {
|
|
|
+ sql.append(" and (batch_num is null or batch_num != '" + batchNum + "')");
|
|
|
+ }
|
|
|
+ sql.append(" group by base_paper_id");
|
|
|
+ return jdbcTemplate.query(sql.toString(), new RowMapper<ExamRecordForMarkingEntity>() {
|
|
|
+ @Override
|
|
|
+ public ExamRecordForMarkingEntity mapRow(ResultSet rs, int arg1) throws SQLException {
|
|
|
+ ExamRecordForMarkingEntity entity = new ExamRecordForMarkingEntity();
|
|
|
+ entity.setId(rs.getLong("id"));
|
|
|
+ entity.setExamId(rs.getLong("exam_id"));
|
|
|
+ entity.setBasePaperId(rs.getString("base_paper_id"));
|
|
|
+ entity.setPaperType(rs.getString("paper_type"));
|
|
|
+ entity.setCourseId(rs.getLong("course_id"));
|
|
|
+ entity.setOfflineFileName(rs.getString("offline_file_name"));
|
|
|
+ entity.setOfflineFileUrl(rs.getString("offline_file_url"));
|
|
|
+ entity.setBatchNum(rs.getString("batch_num"));
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
}
|