From f63fff71fcd7a62ad73b0b9eda614f3b1fa3badf Mon Sep 17 00:00:00 2001
From: 钟日健 <5689795+arsn@user.noreply.gitee.com>
Date: Fri, 22 Oct 2021 22:51:09 +0800
Subject: [PATCH] 考试成绩修改状态重置

---
 src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java |   79 +++++++++++++++++++++++++++++++++++----
 1 files changed, 71 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java b/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
index 9782686..21d750c 100644
--- a/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
+++ b/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -10,13 +10,11 @@
 import org.springblade.modules.FTP.FtpUtil;
 import org.springblade.modules.apply.entity.Apply;
 import org.springblade.modules.apply.service.ApplyService;
-import org.springblade.modules.exam.entity.ExamExaminationSubject;
-import org.springblade.modules.exam.entity.ExamPaper;
-import org.springblade.modules.exam.entity.ExamScore;
-import org.springblade.modules.exam.entity.ExamSubjectChoices;
+import org.springblade.modules.exam.entity.*;
 import org.springblade.modules.exam.excel.ExamScoreExcel;
 import org.springblade.modules.exam.excel.ExportExamScoreExcel;
 import org.springblade.modules.exam.mapper.ExamScoreMapper;
+import org.springblade.modules.exam.service.ExamAnswerRecordService;
 import org.springblade.modules.exam.service.ExamPaperService;
 import org.springblade.modules.exam.service.ExamScoreService;
 import org.springblade.modules.exam.service.ExamSubjectChoicesService;
@@ -38,10 +36,7 @@
 import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static com.bstek.ureport.expression.model.condition.Join.and;
 
@@ -69,6 +64,10 @@
 
 	@Autowired
 	private IRoleService roleService;
+
+
+	@Autowired
+	private ExamAnswerRecordService examAnswerRecordService;
 
 	/**
 	 * 自定义分页数据
@@ -553,4 +552,68 @@
 	public List<ExportExamScoreExcel> exportExamScoreList(ExamScoreVO examScoreVO) {
 		return baseMapper.getExamScoreList(examScoreVO);
 	}
+
+
+	/**
+	 * 考试状态修改,考试成绩恢复
+	 * @param
+	 * @return
+	 */
+	@Override
+	public Boolean refreshTrainExamScore() {
+		int a = 654;
+		List<Integer> list = new ArrayList<>();
+		list.add(a);
+		while (a>=654 && a<=702){
+			a++;
+			list.add(a);
+		}
+		//遍历集合
+		list.forEach(b->{
+			//查询考试记录
+			if (b!=698) {
+				ExamAnswerRecord examAnswerRecord = new ExamAnswerRecord();
+				examAnswerRecord.setScoreId(Long.parseLong(b.toString()));
+				//查询考试成绩
+				ExamScore examScore = this.getById(b);
+				//查询考试记录
+				List<ExamAnswerRecord> examAnswerRecords = examAnswerRecordService.list(Condition.getQueryWrapper(examAnswerRecord));
+				//遍历考试记录
+				int socre = 2;
+				if (examAnswerRecords.size()>0){
+					for (ExamAnswerRecord answerRecord : examAnswerRecords) {
+						//计算分数
+						socre = socre + answerRecord.getAnswerScore();
+					}
+					//修改考试成绩
+					examScore.setTheoryGrade(socre);
+					examScore.setAllGrade(socre/2);
+					String endDate = "2021-10-16 15:30:25";
+					try {
+						examScore.setExamEndTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(endDate));
+					} catch (ParseException e) {
+						e.printStackTrace();
+					}
+					if (socre>=60){
+						examScore.setQualified(2);
+					}else {
+						examScore.setQualified(1);
+					}
+					//更新数据
+					this.updateById(examScore);
+
+					//修改培训考试状态
+					User user = new User();
+					user.setId(Long.parseLong(examScore.getUserId()));
+					user.setIsTrain(3);
+					userService.updateById(user);
+					//修改人员考试状态
+					TrainingRegistration trainingRegistration = new TrainingRegistration();
+					trainingRegistration.setId(examScore.getApplyId());
+					trainingRegistration.setIsExam(2);
+				}
+			}
+		});
+		return false;
+	}
 }

--
Gitblit v1.9.3