From 3e6b676e210e22e4b7b4183d908dbca880093b86 Mon Sep 17 00:00:00 2001
From: qirong <2032486488@qq.com>
Date: 星期五, 27 十月 2023 13:33:42 +0800
Subject: [PATCH] 部门修改

---
 src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 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 ee85f4b..9614957 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
@@ -8,8 +8,10 @@
 import com.mindskip.xzs.domain.exam.ExamPaperQuestionItemObject;
 import com.mindskip.xzs.domain.exam.ExamPaperTitleItemObject;
 import com.mindskip.xzs.domain.other.KeyValue;
+import com.mindskip.xzs.domain.vo.PaperExcelVO;
 import com.mindskip.xzs.repository.ExamPaperMapper;
 import com.mindskip.xzs.repository.QuestionMapper;
+import com.mindskip.xzs.repository.UserDepartmentMapper;
 import com.mindskip.xzs.service.*;
 import com.mindskip.xzs.service.enums.ActionEnum;
 import com.mindskip.xzs.utility.DateTimeUtil;
@@ -52,9 +54,11 @@
     private final QuestionSubjectService questionSubjectService;
     private final ExamPaperUserService examPaperUserService;
     private final UserService userService;
+    private final UserDepartmentMapper userDepartmentMapper;
+    private final DepartmentService departmentService;
 
     @Autowired
-    public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService) {
+    public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService, UserDepartmentMapper userDepartmentMapper, DepartmentService departmentService) {
         super(examPaperMapper);
         this.examPaperMapper = examPaperMapper;
         this.questionMapper = questionMapper;
@@ -66,6 +70,8 @@
         this.questionSubjectService = questionSubjectService;
         this.examPaperUserService = examPaperUserService;
         this.userService = userService;
+        this.userDepartmentMapper = userDepartmentMapper;
+        this.departmentService = departmentService;
     }
 
 
@@ -234,6 +240,22 @@
         return examPaperMapper.gets(ids);
     }
 
+    @Override
+    public List<PaperExcelVO> getPaperExcelById(Integer id) {
+        List<PaperExcelVO> paperExcel = examPaperMapper.getPaperExcelById(id);
+        paperExcel = paperExcel.stream().map(e->{
+            e.setPaperScore(ExamUtil.scoreToVM(Integer.parseInt(e.getPaperScore())));
+            e.setUserScore(ExamUtil.scoreToVM(Integer.parseInt(e.getUserScore())));
+            List<UserDepartment> userDepartments = userDepartmentMapper.selectByUserId(Integer.parseInt(e.getUserId()));
+            if(userDepartments.size() != 0){
+                Department byId = departmentService.getById(userDepartments.get(0).getDepartmentId());
+                e.setDepartmentName(byId.getName());
+            }
+            return e;
+        }).collect(Collectors.toList());
+        return paperExcel;
+    }
+
     private void examPaperFromVM(ExamPaperEditRequestVM examPaperEditRequestVM, ExamPaper examPaper, List<ExamPaperTitleItemVM> titleItemsVM) {
 //        Integer gradeLevel = subjectService.levelBySubjectId(examPaperEditRequestVM.getSubjectId());
         Integer questionCount = titleItemsVM.stream()
@@ -364,7 +386,7 @@
      * @param frameTextContentList
      * @param titleItemsVM           title
      */
-    private void randomQuestion(ExamPaperEditRequestVM examPaperEditRequestVM, List<ExamPaperTitleItemObject> frameTextContentList, List<ExamPaperTitleItemVM> titleItemsVM) throws QuestionException {
+    private void randomQuesrandomQuestiontion(ExamPaperEditRequestVM examPaperEditRequestVM, List<ExamPaperTitleItemObject> frameTextContentList, List<ExamPaperTitleItemVM> titleItemsVM) throws QuestionException {
         Map<Integer, Integer> subjectSource = examPaperEditRequestVM.getSubjectSource();
         //鎬绘暟閲�
         Integer sum = subjectSource.values().stream().mapToInt(Integer::intValue).sum();
@@ -463,7 +485,7 @@
         Integer multipleChoice = examPaperEditRequestVM.getQuestionTypeVMS().stream().mapToInt(QuestionTypeVM::getMultipleChoice).sum();
         //鍒ゆ柇
         Integer judgment = examPaperEditRequestVM.getQuestionTypeVMS().stream().mapToInt(QuestionTypeVM::getTrueFalse).sum();
-        if ((singleChoice * 4 + multipleChoice * 5 + judgment * 2) != new Integer(20)) {
+        if ((singleChoice * 2 + multipleChoice * 2 + judgment * 2) != new Integer(20)) {
             throw new QuestionException();
         }
 

--
Gitblit v1.8.0