From fc36338476ccb0e8fa641794de4022f300f59a2e Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 16 七月 2024 13:59:01 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java | 66 +++++++++++++++++++++++++++++----
1 files changed, 58 insertions(+), 8 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 beeb070..aa48ad1 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
@@ -9,6 +9,7 @@
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.ExamTemplatesVO;
import com.mindskip.xzs.domain.vo.PaperExcelVO;
import com.mindskip.xzs.domain.vo.UserVO;
import com.mindskip.xzs.repository.ExamPaperAnswerMapper;
@@ -120,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);
@@ -137,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);
//鎵归噺淇敼
@@ -166,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();
//澶氶�夋暟閲�
@@ -181,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)),
@@ -206,15 +213,18 @@
vm.setDepartmentIds(examPaperDepartmentService.getByExamPaperId(examPaper.getId())
.stream().map(ExamPaperDepartment::getDepartmentId).toArray(Integer[]::new));
List<ExamPaperUser> examPaperUsers = examPaperUserService.getByExamPaperId(examPaper.getId());
- Integer[][] userIds = new Integer[examPaperUsers.size()][2];
+ List<Integer> userIds = new ArrayList();
+ List<String> userNames = new ArrayList();
for (int i = 0; i < examPaperUsers.size(); i++) {
User user = userService.getUserById(examPaperUsers.get(i).getUserId());
if (ObjectUtils.isNotEmpty(user)) {
- Integer[] userId = {user.getUserLevel(), examPaperUsers.get(i).getUserId()};
- userIds[i] = userId;
+ Integer userId = examPaperUsers.get(i).getUserId();
+ userIds.add(userId);
+ userNames.add(user.getRealName());
}
}
- vm.setUserId(userIds);
+ vm.setUserIds(userIds);
+ vm.setUserNames(userNames);
return vm;
}
@@ -261,6 +271,24 @@
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);
+ 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()));
+ if(userDepartments.size() != 0) {
+ Department department = userDepartments.get(0);
+ e.setDepartmentName(department.getName());
+ e.setDeptId(department.getId());
}
return e;
}).collect(Collectors.toList());
@@ -519,9 +547,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<>();
//澶氶��
@@ -626,13 +655,34 @@
}
@Override
- public List<ExamPaper> list(List<Integer> deptIds) {
- return examPaperMapper.list(deptIds);
+ @Transactional
+ public void missExamByTemplateId(ExamTemplatesVO model) {
+ List<Integer> id = examPaperMapper.getExamPaperByTemplateId(model);
+ model.setPaperIds(id);
+ // 鏍规嵁鑰冭瘯id灏嗛�夋嫨鐨勮ˉ鑰冭�冪敓鐨勮�冭瘯鎴愮哗璁剧疆涓烘棤鏁�
+ examPaperAnswerMapper.setMissExamByTemplate(model);
}
@Override
- public PageInfo<UserVO> selectStudent(UserVO userVO) {
+ public List<ExamPaper> list(List<Integer> deptIds) {
+ List<ExamPaper> list = examPaperMapper.list(deptIds);
+ List<ExamPaper> template = examPaperMapper.template(deptIds);
+ list.addAll(template);
+ return list.stream().sorted(Comparator.comparing(ExamPaper::getCreateTime).reversed()).collect(Collectors.toList());
+ }
+
+ @Override
+ public PageInfo<UserVO> selectStudent(UserVO userVO, List<Integer> adminDeptIds) {
+ userVO.setDeptIds(ObjectUtils.isNotEmpty(userVO.getDeptIds()) ? userVO.getDeptIds() : adminDeptIds);
return PageHelper.startPage(userVO.getPageIndex(), userVO.getPageSize()).doSelectPageInfo(() ->
examPaperMapper.selectStudent(userVO));
}
+
+ @Override
+ public List<ExamPaper> queryCondition() {
+ List<ExamPaper> examPaperList = examPaperMapper.getExamPaper();
+ List<ExamPaper> templateList = examPaperMapper.getTemplate();
+ examPaperList.addAll(templateList);
+ return examPaperList.stream().sorted(Comparator.comparing(ExamPaper::getCreateTime).reversed()).collect(Collectors.toList());
+ }
}
--
Gitblit v1.8.0