fuliqi
2024-06-28 16b4725365f3286c2d2a80945e26f35f89b53f24
src/main/java/com/ycl/jxkg/service/impl/ExamPaperScoreDetailServiceImpl.java
File was renamed from src/main/java/com/ycl/jxkg/service/impl/ExamPaperQuestionCustomerAnswerServiceImpl.java
@@ -1,13 +1,13 @@
package com.ycl.jxkg.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.jxkg.domain.entity.ExamPaperQuestionCustomerAnswer;
import com.ycl.jxkg.domain.entity.ExamPaperScoreDetail;
import com.ycl.jxkg.domain.other.ExamPaperAnswerUpdate;
import com.ycl.jxkg.domain.other.KeyValue;
import com.ycl.jxkg.domain.entity.TextContent;
import com.ycl.jxkg.enums.QuestionTypeEnum;
import com.ycl.jxkg.mapper.ExamPaperQuestionCustomerAnswerMapper;
import com.ycl.jxkg.service.ExamPaperQuestionCustomerAnswerService;
import com.ycl.jxkg.mapper.ExamPaperScoreDetailMapper;
import com.ycl.jxkg.service.ExamPaperScoreDetailService;
import com.ycl.jxkg.service.TextContentService;
import com.ycl.jxkg.utils.DateTimeUtil;
import com.ycl.jxkg.utils.ExamUtil;
@@ -25,32 +25,32 @@
@Service
@RequiredArgsConstructor
public class ExamPaperQuestionCustomerAnswerServiceImpl extends ServiceImpl<ExamPaperQuestionCustomerAnswerMapper, ExamPaperQuestionCustomerAnswer> implements ExamPaperQuestionCustomerAnswerService {
public class ExamPaperScoreDetailServiceImpl extends ServiceImpl<ExamPaperScoreDetailMapper, ExamPaperScoreDetail> implements ExamPaperScoreDetailService {
    private final ExamPaperQuestionCustomerAnswerMapper examPaperQuestionCustomerAnswerMapper;
    private final ExamPaperScoreDetailMapper examPaperScoreDetailMapper;
    private final TextContentService textContentService;
    @Override
    public PageInfo<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVO requestVM) {
    public PageInfo<ExamPaperScoreDetail> studentPage(QuestionPageStudentRequestVO requestVM) {
        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
                examPaperQuestionCustomerAnswerMapper.studentPage(requestVM)
                examPaperScoreDetailMapper.studentPage(requestVM)
        );
    }
    @Override
    public List<ExamPaperQuestionCustomerAnswer> selectListByPaperAnswerId(Integer id) {
        return examPaperQuestionCustomerAnswerMapper.selectListByPaperAnswerId(id);
    public List<ExamPaperScoreDetail> selectListByPaperAnswerId(Integer id) {
        return examPaperScoreDetailMapper.selectListByPaperAnswerId(id);
    }
    @Override
    public void insertList(List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers) {
        examPaperQuestionCustomerAnswerMapper.insertList(examPaperQuestionCustomerAnswers);
    public void insertList(List<ExamPaperScoreDetail> examPaperScoreDetails) {
        examPaperScoreDetailMapper.insertList(examPaperScoreDetails);
    }
    @Override
    public ExamPaperSubmitItemVO examPaperQuestionCustomerAnswerToVM(ExamPaperQuestionCustomerAnswer qa) {
    public ExamPaperSubmitItemVO examPaperQuestionCustomerAnswerToVM(ExamPaperScoreDetail qa) {
        ExamPaperSubmitItemVO examPaperSubmitItemVO = new ExamPaperSubmitItemVO();
        examPaperSubmitItemVO.setId(qa.getId());
        examPaperSubmitItemVO.setQuestionId(qa.getQuestionId());
@@ -64,14 +64,14 @@
    @Override
    public Integer selectAllCount() {
        return examPaperQuestionCustomerAnswerMapper.selectAllCount();
        return examPaperScoreDetailMapper.selectAllCount();
    }
    @Override
    public List<Integer> selectMothCount() {
        Date startTime = DateTimeUtil.getMonthStartDay();
        Date endTime = DateTimeUtil.getMonthEndDay();
        List<KeyValue> mouthCount = examPaperQuestionCustomerAnswerMapper.selectCountByDate(startTime, endTime);
        List<KeyValue> mouthCount = examPaperScoreDetailMapper.selectCountByDate(startTime, endTime);
        List<String> mothStartToNowFormat = DateTimeUtil.MothStartToNowFormat();
        return mothStartToNowFormat.stream().map(md -> {
            KeyValue keyValue = mouthCount.stream().filter(kv -> kv.getName().equals(md)).findAny().orElse(null);
@@ -81,27 +81,27 @@
    @Override
    public int updateScore(List<ExamPaperAnswerUpdate> examPaperAnswerUpdates) {
        return examPaperQuestionCustomerAnswerMapper.updateScore(examPaperAnswerUpdates);
        return examPaperScoreDetailMapper.updateScore(examPaperAnswerUpdates);
    }
    private void setSpecialToVM(ExamPaperSubmitItemVO examPaperSubmitItemVO, ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer) {
        QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperQuestionCustomerAnswer.getQuestionType());
    private void setSpecialToVM(ExamPaperSubmitItemVO examPaperSubmitItemVO, ExamPaperScoreDetail examPaperScoreDetail) {
        QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperScoreDetail.getQuestionType());
        switch (questionTypeEnum) {
            case MultipleChoice:
                examPaperSubmitItemVO.setContent(examPaperQuestionCustomerAnswer.getAnswer());
                examPaperSubmitItemVO.setContentArray(ExamUtil.contentToArray(examPaperQuestionCustomerAnswer.getAnswer()));
                examPaperSubmitItemVO.setContent(examPaperScoreDetail.getAnswer());
                examPaperSubmitItemVO.setContentArray(ExamUtil.contentToArray(examPaperScoreDetail.getAnswer()));
                break;
            case GapFilling:
                TextContent textContent = textContentService.getById(examPaperQuestionCustomerAnswer.getTextContentId());
                TextContent textContent = textContentService.getById(examPaperScoreDetail.getTextContentId());
                List<String> correctAnswer = JsonUtil.toJsonListObject(textContent.getContent(), String.class);
                examPaperSubmitItemVO.setContentArray(correctAnswer);
                break;
            default:
                if (QuestionTypeEnum.needSaveTextContent(examPaperQuestionCustomerAnswer.getQuestionType())) {
                    TextContent content = textContentService.getById(examPaperQuestionCustomerAnswer.getTextContentId());
                if (QuestionTypeEnum.needSaveTextContent(examPaperScoreDetail.getQuestionType())) {
                    TextContent content = textContentService.getById(examPaperScoreDetail.getTextContentId());
                    examPaperSubmitItemVO.setContent(content.getContent());
                } else {
                    examPaperSubmitItemVO.setContent(examPaperQuestionCustomerAnswer.getAnswer());
                    examPaperSubmitItemVO.setContent(examPaperScoreDetail.getAnswer());
                }
                break;
        }