From 65a7eb1292898e73f46cf8b4878a22023bec6b5c Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 17 Aug 2021 11:45:11 +0800
Subject: [PATCH] 成绩查询接口修改

---
 src/main/java/org/springblade/modules/training/controller/TrainingRegistrationController.java    |   16 ++++----
 src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java                           |    9 ++++
 src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java |    2 
 src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java                   |   19 ++++-----
 src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java                |    8 ++++
 src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml                            |   58 ++++++++++++++++++++++++++++
 6 files changed, 91 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java b/src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
index 07a59a0..a0fd1e3 100644
--- a/src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
+++ b/src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
@@ -292,25 +292,22 @@
 		//正式考试
 		if (apply.getApplyExamType()==1){
 			ApplyPaPerVO applyPaPerVO = baseMapper.getApplyInfo(apply);
-			String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()).split(" ")[0];
-			String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()).split(" ")[1];
-			String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getEndTime()).split(" ")[1];
-			applyPaPerVO.setStringTime(time+" "+startTime.substring(0,startTime.length()-3) +"-"+ endTime.substring(0,endTime.length()-3));
+//			String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()).split(" ")[0];
+//			String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()).split(" ")[1];
+//			String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getEndTime()).split(" ")[1];
+			applyPaPerVO.setStringTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()));
 			return applyPaPerVO;
 		}
 
 		//模拟考试
 		if (apply.getApplyExamType()==2){
 			ApplyPaPerVO applyPaPerVO = baseMapper.getTrainApplyInfo(apply);
-			String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()).split(" ")[0];
-			String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()).split(" ")[1];
-			String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getEndTime()).split(" ")[1];
-			applyPaPerVO.setStringTime(time+" "+startTime.substring(0,startTime.length()-3) +"-"+ endTime.substring(0,endTime.length()-3));
+//			String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()).split(" ")[0];
+//			String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()).split(" ")[1];
+//			String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getEndTime()).split(" ")[1];
+			applyPaPerVO.setStringTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(applyPaPerVO.getStartTime()));
 			return applyPaPerVO;
 		}
-
-
-
 		return null;
 	}
 
diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java b/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java
index 5ce0b6d..a272dfb 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java
@@ -26,6 +26,15 @@
 	List<ExamScoreVO> selectExamScorePage(IPage page, @Param("examScore") ExamScoreVO examScore);
 
 	/**
+	 * 自定义分页-模拟考试
+	 *
+	 * @param page  分页
+	 * @param examScore 实体
+	 * @return
+	 */
+	List<ExamScoreVO> selectTrainExamScorePage(IPage page, @Param("examScore") ExamScoreVO examScore);
+
+	/**
 	 * 详情
 	 *
 	 * @param examScore 考试成绩信息对象
diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml b/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
index 2ef898b..63e8275 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.springblade.modules.exam.mapper.ExamScoreMapper">
 
-    <!--考试成绩分页信息-->
+    <!--考试成绩分页信息-正式考试-->
     <select id="selectExamScorePage" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
         SELECT
          es.id,es.theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade,es.user_id userId,es.exam_id examId,
@@ -57,6 +57,62 @@
         </if>
     </select>
 
+
+    <!--考试成绩分页信息-模拟考试-->
+    <select id="selectTrainExamScorePage" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
+        SELECT
+         es.id,es.theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade,es.user_id userId,es.exam_id examId,
+         es.exam_time examTime,all_grade allGrade,exam_end_time examEndTime,qualified,
+         ke.exam_name examName,
+         bu.real_name securityName,company,bu.account,
+         str.is_exam isExam,
+         bd.dept_name companyName
+        FROM
+            exam_score es
+        left join
+            blade_user bu
+        on
+            es.user_id = bu.id
+        left join
+            blade_dept bd
+        on
+            bd.id = es.company
+        left join
+            ksxt_exam ke
+        on
+            ke.id = es.exam_id
+        left join
+            sys_training_registration str
+        on
+            str.user_id = bu.id
+        WHERE
+            1=1
+        <if test="examScore.examName!=null and  examScore.examName!=''">
+            and ke.exam_name like concat('%', #{examScore.examName},'%')
+        </if>
+        <if test="examScore.companyName!=null and  examScore.companyName!=''">
+            and bd.dept_name like concat('%', #{examScore.companyName},'%')
+        </if>
+        <if test="examScore.securityName!=null and  examScore.securityName!=''">
+            and bu.real_name like concat('%', #{examScore.securityName},'%')
+        </if>
+        <if test="examScore.userId!=null and  examScore.userId!=''">
+            and es.user_id = #{examScore.userId}
+        </if>
+        <if test="examScore.isExam!=null and  examScore.isExam!=''">
+            and str.is_exam = #{examScore.isExam}
+        </if>
+        <if test="examScore.examType!=null and  examScore.examType!=''">
+            and ke.exam_type = #{examScore.examType}
+        </if>
+        <if test="examScore.candidateNo!=null and  examScore.candidateNo!=''">
+            and es.candidate_no = #{examScore.candidateNo}
+        </if>
+        <if test="examScore.qualified!=null">
+            and es.qualified = #{examScore.qualified}
+        </if>
+    </select>
+
     <!--考试成绩详情信息-->
     <select id="selectExamScoreInfo" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
         SELECT
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 4eb7edc..cd34060 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
@@ -61,6 +61,14 @@
 	 */
 	@Override
 	public IPage<ExamScoreVO> selectExamScorePage(IPage<ExamScoreVO> page, ExamScoreVO examScore) {
+		if (null!=examScore.getExamType()){
+			if (examScore.getExamType()==1){
+				return page.setRecords(baseMapper.selectExamScorePage(page, examScore));
+			}
+			if (examScore.getExamType()==2){
+				return page.setRecords(baseMapper.selectTrainExamScorePage(page, examScore));
+			}
+		}
 		return page.setRecords(baseMapper.selectExamScorePage(page, examScore));
 	}
 
diff --git a/src/main/java/org/springblade/modules/training/controller/TrainingRegistrationController.java b/src/main/java/org/springblade/modules/training/controller/TrainingRegistrationController.java
index 4c90904..4ebc65a 100644
--- a/src/main/java/org/springblade/modules/training/controller/TrainingRegistrationController.java
+++ b/src/main/java/org/springblade/modules/training/controller/TrainingRegistrationController.java
@@ -95,7 +95,7 @@
 			if (1==user.getIsTrain()){
 				return R.data(201,"已报名,不能重复报名");
 			}
-			if (2==user.getIsTrain()){
+			if (2==user.getIsTrain()  || -1==user.getIsTrain()){
 				//已报名
 				trainingRegistration.setCancel(1);
 				//默认为未考试状态
@@ -174,7 +174,7 @@
 				user.setIsTrain(1);
 				userService.updateById(user);
 			}else {
-				if (user.getIsTrain()==2) {
+				if (user.getIsTrain()==2 || -1==user.getIsTrain()) {
 					TrainingRegistration trainingRegistration1 = new TrainingRegistration();
 					trainingRegistration1.setCancel(1);
 					//默认为未考试状态
@@ -407,17 +407,17 @@
 	 */
 	@PostMapping("/batchExam")
 	public R batchExam(@RequestParam String ids,
-					   @RequestParam String examTime,
+					   String examTime,
 					   @RequestParam Date startTime,
-					   @RequestParam Date endTime){
+					   Date endTime){
 		if (!ids.equals("")){
 			List<String> list = Arrays.asList(ids.split(","));
 			if (list.size()>0){
 				ExamPaper examPaper = new ExamPaper();
-				examPaper.setExamTime(examTime);
+//				examPaper.setExamTime(examTime);
 				examPaper.setExamType(2);
 				examPaper.setStartTime(startTime);
-				examPaper.setEndTime(endTime);
+//				examPaper.setEndTime(endTime);
 				Calendar instance = Calendar.getInstance();
 				instance.setTime(startTime);
 				int year = instance.get(Calendar.YEAR);
@@ -444,10 +444,10 @@
 			if (applyIds.size()>0){
 				//生成考试
 				ExamPaper examPaper = new ExamPaper();
-				examPaper.setExamTime(examTime);
+//				examPaper.setExamTime(examTime);
 				examPaper.setExamType(2);
 				examPaper.setStartTime(startTime);
-				examPaper.setEndTime(endTime);
+//				examPaper.setEndTime(endTime);
 				Calendar instance = Calendar.getInstance();
 				instance.setTime(startTime);
 				int year = instance.get(Calendar.YEAR);
diff --git a/src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java b/src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java
index 59bc92a..e9a6d6c 100644
--- a/src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java
+++ b/src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java
@@ -95,7 +95,7 @@
 						user.setIsTrain(1);
 						userService.updateById(user);
 					}else {
-						if (2 == user.getIsTrain()) {
+						if (2 == user.getIsTrain()  || -1==user.getIsTrain()) {
 							trainingRegistration.setIsExam(1);
 							trainingRegistration.setCancel(1);
 							trainingRegistration.setTrainingTime(new Date());

--
Gitblit v1.9.3