heheng
8 天以前 7f89db04cc75a842352087099ee6a7431b7357e0
multi-system/src/main/java/com/gkhy/exam/system/service/impl/ExPaperStudentServiceImpl.java
@@ -1,6 +1,8 @@
package com.gkhy.exam.system.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.common.api.CommonPage;
@@ -24,6 +26,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -296,7 +300,7 @@
            }
            updateStudentAnswers.add(sa);
        }
        ExPaperStudent exPaperStudent = baseMapper.selectByPaperStudentId(paperStudent);
        studentAnswerService.saveOrUpdateBatch(updateStudentAnswers);
        paperStudent.setScore(totalScore);
        if(!easyViewFlag){
@@ -306,6 +310,16 @@
                paperStudent.setPassed(Constant.EXAM_UNPASS);
            }else{
                paperStudent.setPassed(Constant.EXAM_PASS);
                //生成考试证书编号
                DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                String format = LocalDate.now().format(dateTimeFormatter);
                String timestamp = String.valueOf(System.currentTimeMillis()).substring(9, 13);
                paperStudent.setNumber("AQSC-"+format+"-"+timestamp);
            }
            if (exPaperStudent.getScore()>=paperStudent.getScore()){
                paperStudent.setScore(exPaperStudent.getScore());
                paperStudent.setNumber(exPaperStudent.getNumber());
            }
        }
        int row=baseMapper.updateById(paperStudent);
@@ -314,6 +328,21 @@
        }
    }
    @Override
    @Transactional
    public void againExam(ExPaperStudent exPaperStudent) {
//        baseMapper.deleteByPaperStudentId(exPaperStudent.getPaperId(),exPaperStudent.getStudentId());
//        studentAnswerMapper.deletedByPaperStudentId(exPaperStudent.getPaperId(),exPaperStudent.getStudentId());
//        BatchPaperStudentVO batchPaperStudentVO = new BatchPaperStudentVO();
//        batchPaperStudentVO.setPaperId(exPaperStudent.getPaperId());
//        List<Long> longs = new ArrayList<>();
//        longs.add(exPaperStudent.getStudentId());
//        batchPaperStudentVO.setStudentIds(longs);
//        batchAddPaperStudent(batchPaperStudentVO);
        baseMapper.updateByPaperStudentId(exPaperStudent);
        studentAnswerMapper.updateState(exPaperStudent);
    }
    private Integer getScore(ExExamPaper examPaper,Integer questionType){
        if(questionType.equals(QuestionTypeEnum.SINGLE.getCode())){
            return examPaper.getSingleScore();