From c2dc62c3d40be033cdb65fa54473f7f355e67e88 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期四, 06 六月 2024 15:52:02 +0800 Subject: [PATCH] 班级学员新增、修改 --- src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java | 119 ++++++++++++++++++++++++++++------------------------------- 1 files changed, 56 insertions(+), 63 deletions(-) diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java index c213d8d..f661b55 100644 --- a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java +++ b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java @@ -1,9 +1,8 @@ package com.ycl.jxkg.service.impl; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ycl.jxkg.domain.TextContent; -import com.ycl.jxkg.domain.enums.ExamPaperTypeEnum; +import com.ycl.jxkg.domain.entity.TextContent; +import com.ycl.jxkg.enums.ExamPaperTypeEnum; import com.ycl.jxkg.domain.exam.ExamPaperQuestionItemObject; import com.ycl.jxkg.domain.exam.ExamPaperTitleItemObject; import com.ycl.jxkg.domain.other.KeyValue; @@ -16,30 +15,24 @@ import com.ycl.jxkg.service.enums.ActionEnum; import com.ycl.jxkg.utils.DateTimeUtil; import com.ycl.jxkg.utils.JsonUtil; -import com.ycl.jxkg.utils.ExamUtil; -import com.ycl.jxkg.vo.admin.exam.ExamPaperEditRequestVO; -import com.ycl.jxkg.vo.admin.exam.ExamPaperPageRequestVO; -import com.ycl.jxkg.vo.admin.exam.ExamPaperTitleItemVO; -import com.ycl.jxkg.vo.admin.question.QuestionEditRequestVO; -import com.ycl.jxkg.vo.student.dashboard.PaperFilter; -import com.ycl.jxkg.vo.student.dashboard.PaperInfo; -import com.ycl.jxkg.vo.student.exam.ExamPaperPageVO; +import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO; +import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperPageRequestVO; +import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperTitleItemVO; +import com.ycl.jxkg.domain.vo.student.dashboard.PaperFilter; +import com.ycl.jxkg.domain.vo.student.dashboard.PaperInfo; +import com.ycl.jxkg.domain.vo.student.exam.ExamPaperPageVO; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import com.ycl.jxkg.domain.ExamPaper; -import com.ycl.jxkg.domain.Question; -import com.ycl.jxkg.domain.User; +import com.ycl.jxkg.domain.entity.ExamPaper; +import com.ycl.jxkg.domain.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Function; import java.util.stream.Collectors; @Service @@ -88,17 +81,16 @@ frameTextContent.setContent(frameTextContentStr); frameTextContent.setCreateTime(now); textContentService.save(frameTextContent); - examPaper.setFrameTextContentId(frameTextContent.getId()); examPaper.setCreateTime(now); examPaper.setCreateUser(user.getId()); - examPaper.setDeleted(false); examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM); examPaperMapper.insert(examPaper); } else { examPaper = examPaperMapper.selectById(examPaperEditRequestVO.getId()); - TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()); - frameTextContent.setContent(frameTextContentStr); - textContentService.updateById(frameTextContent); + //TODO:寰呭畬鎴� +// TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()); +// frameTextContent.setContent(frameTextContentStr); +// textContentService.updateById(frameTextContent); examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM); examPaperMapper.updateById(examPaper); } @@ -110,32 +102,32 @@ ExamPaper examPaper = examPaperMapper.selectById(id); ExamPaperEditRequestVO vo = new ExamPaperEditRequestVO(); BeanUtils.copyProperties(examPaper, vo); - vo.setLevel(examPaper.getGradeLevel()); - TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()); - List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent.getContent(), ExamPaperTitleItemObject.class); - List<Integer> questionIds = examPaperTitleItemObjects.stream() - .flatMap(t -> t.getQuestionItems().stream() - .map(q -> q.getId())) - .collect(Collectors.toList()); - List<Question> questions = questionMapper.selectByIds(questionIds); - List<ExamPaperTitleItemVO> examPaperTitleItemVOS = examPaperTitleItemObjects.stream().map(t -> { - ExamPaperTitleItemVO tTitleVM = new ExamPaperTitleItemVO(); - BeanUtils.copyProperties(t, tTitleVM); - List<QuestionEditRequestVO> questionItemsVM = t.getQuestionItems().stream().map(i -> { - Question question = questions.stream().filter(q -> q.getId().equals(i.getId())).findFirst().get(); - QuestionEditRequestVO questionEditRequestVO = questionService.getQuestionEditRequestVM(question); - questionEditRequestVO.setItemOrder(i.getItemOrder()); - return questionEditRequestVO; - }).collect(Collectors.toList()); - tTitleVM.setQuestionItems(questionItemsVM); - return tTitleVM; - }).collect(Collectors.toList()); - vo.setTitleItems(examPaperTitleItemVOS); - vo.setScore(ExamUtil.scoreToVM(examPaper.getScore())); - if (ExamPaperTypeEnum.TimeLimit == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { - List<String> limitDateTime = Arrays.asList(DateTimeUtil.dateFormat(examPaper.getLimitStartTime()), DateTimeUtil.dateFormat(examPaper.getLimitEndTime())); - vo.setLimitDateTime(limitDateTime); - } + //TODO:寰呭畬鎴� +// TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()); +// List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent.getContent(), ExamPaperTitleItemObject.class); +// List<Integer> questionIds = examPaperTitleItemObjects.stream() +// .flatMap(t -> t.getQuestionItems().stream() +// .map(q -> q.getId())) +// .collect(Collectors.toList()); +// List<Question> questions = questionMapper.selectByIds(questionIds); +// List<ExamPaperTitleItemVO> examPaperTitleItemVOS = examPaperTitleItemObjects.stream().map(t -> { +// ExamPaperTitleItemVO tTitleVM = new ExamPaperTitleItemVO(); +// BeanUtils.copyProperties(t, tTitleVM); +// List<QuestionEditRequestVO> questionItemsVM = t.getQuestionItems().stream().map(i -> { +// Question question = questions.stream().filter(q -> q.getId().equals(i.getId())).findFirst().get(); +// QuestionEditRequestVO questionEditRequestVO = questionService.getQuestionEditRequestVM(question); +// questionEditRequestVO.setItemOrder(i.getItemOrder()); +// return questionEditRequestVO; +// }).collect(Collectors.toList()); +// tTitleVM.setQuestionItems(questionItemsVM); +// return tTitleVM; +// }).collect(Collectors.toList()); +// vo.setTitleItems(examPaperTitleItemVOS); +// vo.setScore(ExamUtil.scoreToVM(examPaper.getScore())); +// if (ExamPaperTypeEnum.Random == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { +// List<String> limitDateTime = Arrays.asList(DateTimeUtil.dateFormat(examPaper.getLimitStartTime()), DateTimeUtil.dateFormat(examPaper.getLimitEndTime())); +// vo.setLimitDateTime(limitDateTime); +// } return vo; } @@ -163,21 +155,22 @@ } private void examPaperFromVM(ExamPaperEditRequestVO examPaperEditRequestVO, ExamPaper examPaper, List<ExamPaperTitleItemVO> titleItemsVM) { - Integer gradeLevel = subjectService.levelBySubjectId(examPaperEditRequestVO.getSubjectId()); - Integer questionCount = titleItemsVM.stream() - .mapToInt(t -> t.getQuestionItems().size()).sum(); - Integer score = titleItemsVM.stream(). - flatMapToInt(t -> t.getQuestionItems().stream() - .mapToInt(q -> ExamUtil.scoreFromVM(q.getScore())) - ).sum(); - examPaper.setQuestionCount(questionCount); - examPaper.setScore(score); - examPaper.setGradeLevel(gradeLevel); - List<String> dateTimes = examPaperEditRequestVO.getLimitDateTime(); - if (ExamPaperTypeEnum.TimeLimit == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { - examPaper.setLimitStartTime(DateTimeUtil.parse(dateTimes.get(0), DateTimeUtil.STANDER_FORMAT)); - examPaper.setLimitEndTime(DateTimeUtil.parse(dateTimes.get(1), DateTimeUtil.STANDER_FORMAT)); - } + //TODO:寰呭畬鎴� +// Integer gradeLevel = subjectService.levelBySubjectId(examPaperEditRequestVO.getSubjectId()); +// Integer questionCount = titleItemsVM.stream() +// .mapToInt(t -> t.getQuestionItems().size()).sum(); +// Integer score = titleItemsVM.stream(). +// flatMapToInt(t -> t.getQuestionItems().stream() +// .mapToInt(q -> ExamUtil.scoreFromVM(q.getScore())) +// ).sum(); +// examPaper.setQuestionCount(questionCount); +// examPaper.setScore(score); +// examPaper.setGradeLevel(gradeLevel); +// List<String> dateTimes = examPaperEditRequestVO.getLimitDateTime(); +// if (ExamPaperTypeEnum.Random == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { +// examPaper.setLimitStartTime(DateTimeUtil.parse(dateTimes.get(0), DateTimeUtil.STANDER_FORMAT)); +// examPaper.setLimitEndTime(DateTimeUtil.parse(dateTimes.get(1), DateTimeUtil.STANDER_FORMAT)); +// } } private List<ExamPaperTitleItemObject> frameTextContentFromVM(List<ExamPaperTitleItemVO> titleItems) { -- Gitblit v1.8.0