From d4daa1ea31db6fd421c0e86bab178a9f3b512141 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 23 九月 2024 18:02:54 +0800
Subject: [PATCH] 使用新导入
---
src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
index 88c8287..4d74e62 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
@@ -121,6 +121,7 @@
String frameTextContentStr = JsonUtil.toJsonStr(frameTextContentList);
ExamPaper examPaper;
+ Integer[] userIds = examPaperEditRequestVM.getUserIds();
if (actionEnum == ActionEnum.ADD) {
examPaper = modelMapper.map(examPaperEditRequestVM, ExamPaper.class);
TextContent frameTextContent = new TextContent(frameTextContentStr, now);
@@ -138,7 +139,10 @@
TextContent frameTextContent = textContentService.selectById(examPaper.getFrameTextContentId());
frameTextContent.setContent(frameTextContentStr);
textContentService.updateByIdFilter(frameTextContent);
+ examPaperEditRequestVM.setScore(null);
+ examPaperEditRequestVM.setUserIds(null);
modelMapper.map(examPaperEditRequestVM, examPaper);
+ examPaperEditRequestVM.setUserIds(userIds);
examPaperFromVM(examPaperEditRequestVM, examPaper, titleItemsVM);
examPaperMapper.updateByPrimaryKeySelective(examPaper);
//鎵归噺淇敼
@@ -167,6 +171,7 @@
throw new RuntimeException("璇ヨ瘯鍗锋病鏈夐鐩�");
}
List<Question> questions = questionMapper.selectByIds(questionIds);
+
//鍗曢�夋暟閲�
Integer singleChoice = questions.stream().filter(e -> e.getQuestionType() == 1).collect(Collectors.toList()).size();
//澶氶�夋暟閲�
@@ -182,6 +187,7 @@
List<ExamQuestionVO> questionItemsVM = t.getQuestionItems().stream().map(i -> {
Question question = questions.stream().filter(q -> q.getId().equals(i.getId())).findFirst().get();
ExamQuestionVO questionEditRequestVM = questionService.getQuestionEditRequestVM(question);
+
questionEditRequestVM.setTitle("(" + QuestionTypeEnum.fromCode(questionEditRequestVM.getQuestionType()).getName() + ") " + questionEditRequestVM.getTitle());
questionEditRequestVM.setItemOrder(generateRandomNumber(questionEditRequestVM.getQuestionType() == 1 ? 0 : ((questionEditRequestVM.getQuestionType() == 2 ? singleChoice : multipleChoice + singleChoice)),
questionEditRequestVM.getQuestionType() == 1 ? singleChoice : ((questionEditRequestVM.getQuestionType() == 2 ? multipleChoice + singleChoice : trueFalse + multipleChoice + singleChoice)),
@@ -265,10 +271,36 @@
if(userDepartments.size() != 0){
Department byId = departmentService.getById(userDepartments.get(0).getDepartmentId());
e.setDepartmentName(byId.getName());
+ e.setDeptId(byId.getId());
}
return e;
}).collect(Collectors.toList());
return paperExcel;
+ }
+
+ @Override
+ public List<PaperExcelVO> getRandomPaperExcelById(Integer id) {
+ List<PaperExcelVO> paperExcel = examPaperMapper.getRandomPaperExcelById(id);
+ // 濡傛灉鏌愯�冪敓瀛樺湪澶氫釜閮ㄩ棬锛屾瘡涓儴闂ㄩ兘鍔犱竴閬嶆暟鎹�
+ List<PaperExcelVO> needAdd = new ArrayList<>();
+ List<PaperExcelVO> needRemove = new ArrayList<>();
+ paperExcel = paperExcel.stream().map(e->{
+ e.setPaperScore(ExamUtil.scoreToVM(Integer.parseInt(e.getPaperScore())));
+ e.setUserScore(ExamUtil.scoreToVM(Integer.parseInt(e.getUserScore())));
+ List<Department> userDepartments = userDepartmentMapper.selectDeptByUserId(Integer.parseInt(e.getUserId()));
+ for (Department dept : userDepartments) {
+ PaperExcelVO vo = new PaperExcelVO();
+ BeanUtils.copyProperties(e, vo);
+ vo.setDepartmentName(dept.getName());
+ vo.setDeptId(dept.getId());
+ needAdd.add(vo);
+ needRemove.add(e);
+ }
+ return e;
+ }).collect(Collectors.toList());
+ paperExcel.removeAll(needRemove);
+ paperExcel.addAll(needAdd);
+ return paperExcel.stream().filter(e -> Objects.nonNull(e.getDeptId())).collect(Collectors.toList());
}
private void examPaperFromVM(ExamPaperEditRequestVM examPaperEditRequestVM, ExamPaper examPaper, List<ExamPaperTitleItemVM> titleItemsVM) {
@@ -523,9 +555,10 @@
Integer order = 0;
for (QuestionTypeVM questionTypeVM : questionTypeVMList) {
- List<Integer> questions = questionSubjectService.getSubject(questionTypeVM.getSubjectId())
+ List<Integer> questions = questionSubjectService.getSubjectBySubjectIds(examPaperEditRequestVM.getSubjectId())
.stream().map(QuestionSubject::getQuestionId).collect(Collectors.toList());
List<Question> list = questionService.selectByIds(questions);
+ // List<Question> list = questionService.getAll();
Map<Integer, Integer> multiple = new HashMap<>();
//澶氶��
--
Gitblit v1.8.0