From 8d43111bd0e598bc0b2014cbfa69a32e74959dff Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 15 Dec 2021 19:24:05 +0800
Subject: [PATCH] ftp sql 同步封装

---
 src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml |  272 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 246 insertions(+), 26 deletions(-)

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 ca4f770..9645a24 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
@@ -6,7 +6,7 @@
     <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,
-        es.exam_time examTime,all_grade allGrade,exam_end_time examEndTime,qualified,
+        es.exam_time examTime,all_grade allGrade,exam_end_time examEndTime,qualified,es.candidate_no candidateNo,
         ke.exam_name examName,
         sa.is_exam isExam,
         bu.real_name securityName,company,bu.account,
@@ -40,6 +40,9 @@
         <if test="examScore.securityName!=null and  examScore.securityName!=''">
             and bu.real_name like concat('%', #{examScore.securityName},'%')
         </if>
+        <if test="examScore.account!=null and  examScore.account!=''">
+            and bu.account like concat('%', #{examScore.account},'%')
+        </if>
         <if test="examScore.userId!=null and  examScore.userId!=''">
             and es.user_id = #{examScore.userId}
         </if>
@@ -65,10 +68,10 @@
     <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,
+            es.exam_time examTime,all_grade allGrade,exam_end_time examEndTime,qualified,es.candidate_no candidateNo,
             ke.exam_name examName,
             str.is_exam isExam,
-            bu.real_name securityName,company,bu.account,
+            bu.real_name securityName,company,bu.account,bu.sex,bu.paper_time paperTime,bu.securitynumber securityNumber,bu.avatar,
             bd.dept_name companyName from
             exam_score es
         left join
@@ -89,7 +92,7 @@
         str.id = es.apply_id
         where
         1=1
-        and (str.is_exam = 2 or str.is_exam = 3)
+        and (str.is_exam = 2 or str.is_exam = 3 or str.is_exam = 4)
         <if test="examScore.examName!=null and  examScore.examName!=''">
             and ke.exam_name like concat('%', #{examScore.examName},'%')
         </if>
@@ -98,6 +101,12 @@
         </if>
         <if test="examScore.securityName!=null and  examScore.securityName!=''">
             and bu.real_name like concat('%', #{examScore.securityName},'%')
+        </if>
+        <if test="examScore.account!=null and  examScore.account!=''">
+            and bu.account like concat('%', #{examScore.account},'%')
+        </if>
+        <if test="examScore.trainUnitId!=null">
+            and str.training_unit_id = #{examScore.trainUnitId}
         </if>
         <if test="examScore.userId!=null and  examScore.userId!=''">
             and es.user_id = #{examScore.userId}
@@ -111,12 +120,22 @@
         <if test="examScore.examType!=null and  examScore.examType!=''">
             and ke.exam_type = #{examScore.examType}
         </if>
+        <if test="examScore.isAvatar==1">
+            and bu.avatar is not null and bu.avatar!=""
+        </if>
+        <if test="examScore.isAvatar==2">
+            and (bu.avatar is null or bu.avatar="")
+        </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>
+        <if test="examScore.examDate!=null  and examScore.examDate!=''">
+            and date_format(ke.start_time,'%Y-%m-%d') = #{examScore.examDate}
+        </if>
+        order by es.id desc
     </select>
 
     <!--考试成绩详情信息-->
@@ -136,39 +155,95 @@
 
 
     <!--考试成绩详情信息-->
+<!--    <select id="scoreStatistics" resultType="java.util.HashMap">-->
+<!--        SELECT * FROM(SELECT-->
+<!--        COUNT( CASE WHEN theory_grade &lt; 60 THEN 1 END ) AS 'bhg',-->
+<!--        COUNT( CASE WHEN theory_grade >= 60 AND theory_grade &lt; 80 THEN 1 END ) AS 'hg',-->
+<!--        COUNT( CASE WHEN theory_grade >= 80 AND theory_grade &lt; 90 THEN 1 END ) AS 'lh',-->
+<!--        COUNT( CASE WHEN theory_grade >= 90 THEN 1 END ) AS 'yx'-->
+<!--        FROM-->
+<!--        exam_score exam-->
+<!--	    LEFT JOIN blade_user user ON exam.user_id = user.id-->
+<!--        WHERE 1 = 1-->
+<!--        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1123598813738675201'">-->
+<!--             AND user.jurisdiction = #{jurisdiction}-->
+<!--        </if>-->
+<!--        <if test="deptid!=null and deptid==''">-->
+<!--            AND user.dept_id = #{deptid}-->
+<!--        </if>-->
+<!--        ) a UNION ALL-->
+<!--        SELECT * FROM( SELECT-->
+<!--        COUNT( CASE WHEN learn_grade &lt; 60 THEN 1 END ) AS 'bhg',-->
+<!--        COUNT( CASE WHEN learn_grade >= 60 AND learn_grade &lt; 80 THEN 1 END ) AS 'hg',-->
+<!--        COUNT( CASE WHEN learn_grade >= 80 AND learn_grade &lt; 90 THEN 1 END ) AS 'lh',-->
+<!--        COUNT( CASE WHEN learn_grade >= 90 THEN 1 END ) AS 'yx'-->
+<!--        FROM-->
+<!--        exam_score exam-->
+<!--        LEFT JOIN blade_user user ON exam.user_id = user.id-->
+<!--        WHERE 1 = 1-->
+<!--        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1123598813738675201'">-->
+<!--            AND user.jurisdiction = #{jurisdiction}-->
+<!--        </if>-->
+<!--        <if test="deptid!=null and deptid==''">-->
+<!--            AND user.dept_id = #{deptid}-->
+<!--        </if>-->
+<!--        ) b-->
+<!--    </select>-->
+
+    <!--考试成绩详情信息 理论-->
     <select id="scoreStatistics" resultType="java.util.HashMap">
-        SELECT * FROM(SELECT
-        COUNT( CASE WHEN theory_grade &lt; 60 THEN 1 END ) AS 'bhg',
-        COUNT( CASE WHEN theory_grade >= 60 AND theory_grade &lt; 80 THEN 1 END ) AS 'hg',
-        COUNT( CASE WHEN theory_grade >= 80 AND theory_grade &lt; 90 THEN 1 END ) AS 'lh',
-        COUNT( CASE WHEN theory_grade >= 90 THEN 1 END ) AS 'yx'
+        SELECT
+        theory_grade as fs,
+        COUNT( * ) AS count
         FROM
         exam_score exam
-	    LEFT JOIN blade_user user ON exam.user_id = user.id
-        WHERE 1 = 1
-        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1123598813738675201">
-             AND user.jurisdiction = #{jurisdiction}
+        LEFT JOIN blade_user user
+        ON exam.user_id = user.id
+        left join
+        sys_information si
+        on
+        si.departmentid = user.dept_id
+        left join
+        sys_jurisdiction sj
+        on
+        sj.id = si.jurisdiction
+        WHERE 1 = 1 AND theory_grade is not null
+        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1372091709474910209'">
+            and (sj.id = #{jurisdiction} or sj.parent_id = #{jurisdiction})
         </if>
-        <if test="deptid!=null and deptid==''">
+        <if test="deptid!=null and deptid!=''">
             AND user.dept_id = #{deptid}
         </if>
-        ) a UNION ALL
-        SELECT * FROM( SELECT
-        COUNT( CASE WHEN learn_grade &lt; 60 THEN 1 END ) AS 'bhg',
-        COUNT( CASE WHEN learn_grade >= 60 AND learn_grade &lt; 80 THEN 1 END ) AS 'hg',
-        COUNT( CASE WHEN learn_grade >= 80 AND learn_grade &lt; 90 THEN 1 END ) AS 'lh',
-        COUNT( CASE WHEN learn_grade >= 90 THEN 1 END ) AS 'yx'
+        GROUP BY
+        exam.theory_grade
+    </select>
+    <!--考试成绩详情信息 实操-->
+    <select id="scoreStatisticssc" resultType="java.util.HashMap">
+        SELECT
+        learn_grade as fs,
+        COUNT( * ) AS count
         FROM
         exam_score exam
-        LEFT JOIN blade_user user ON exam.user_id = user.id
+        LEFT JOIN blade_user user
+        ON exam.user_id = user.id
+        left join
+        sys_information si
+        on
+        si.departmentid = user.dept_id
+        left join
+        sys_jurisdiction sj
+        on
+        sj.id = si.jurisdiction
         WHERE 1 = 1
-        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1123598813738675201">
-            AND user.jurisdiction = #{jurisdiction}
+        AND learn_grade is not null
+        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1372091709474910209'">
+            and (sj.id = #{jurisdiction} or sj.parent_id = #{jurisdiction})
         </if>
-        <if test="deptid!=null and deptid==''">
+        <if test="deptid!=null and deptid!=''">
             AND user.dept_id = #{deptid}
         </if>
-        ) b
+        GROUP BY
+        exam.learn_grade
     </select>
 
     <!--根据用户身份证号查询考试成绩-->
@@ -181,8 +256,153 @@
             blade_user bu
         on
             bu.id = es.user_id
+        left join
+            ksxt_exam ke
+        on
+            ke.id = es.exam_id
         where
             bu.cardid = #{idCardNo}
-            and es.exam_id = #{examId}
+            and DATE_FORMAT(ke.start_time,'%Y-%m-%d') = #{startTime}
     </select>
+
+    <!--修改成绩信息-->
+    <update id="updateByIdAndQualifiee">
+        update exam_score set qualified = #{examScore.qualified} where id = #{examScore.id}
+    </update>
+
+    <select id="scorePage"  resultType="org.springblade.modules.exam.vo.ExamScoreVO">
+        SELECT
+        exam.*,
+        user.jurisdiction,
+        user.real_name securityName,
+        ke.exam_name examName
+        FROM
+        exam_score exam
+        LEFT JOIN blade_user user
+        ON exam.user_id = user.id
+        left join
+        sys_information si
+        on
+        si.departmentid = user.dept_id
+        left join
+        sys_jurisdiction sj
+        on
+        sj.id = si.jurisdiction
+        left join
+        ksxt_exam ke
+        on
+        exam.exam_id = ke.id
+        WHERE
+        1 = 1
+        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
+            and (sj.id = #{jurisdiction} or sj.parent_id = #{jurisdiction})
+        </if>
+        <if test="deptid!=null and deptid!=''">
+            AND user.dept_id = #{deptid}
+        </if>
+    </select>
+
+    <!--查询所有考试不合格的数据(取准考证号)-->
+    <select id="getDisqualificationExamInfo" resultType="org.springblade.modules.exam.entity.ExamScore">
+        select * from exam_score where qualified = 1
+    </select>
+
+
+    <!--根据准考证号查询培训信息-->
+    <select id="getTrainInfo" resultType="org.springblade.modules.training.entity.TrainingRegistration">
+        select * from sys_training_registration where 1=1
+        <if test="trainingRegistration.candidateNo!=null and trainingRegistration.candidateNo!=''">
+            and is_exam = 2
+            and candidate_no = #{trainingRegistration.candidateNo}
+        </if>
+        <if test="trainingRegistration.id!=null">
+            and id = #{trainingRegistration.id}
+        </if>
+    </select>
+
+    <!--查询所有无成绩的数据-->
+    <select id="getNoScoreInfo" resultType="org.springblade.modules.exam.entity.ExamScore">
+        select * from exam_score where theory_grade is null
+    </select>
+
+    <!--查询所有无成绩的数据-->
+    <select id="getLheoryGradeLess60" resultType="org.springblade.modules.exam.entity.ExamScore">
+        select * from exam_score where all_grade &lt; 30
+    </select>
+
+    <!--导出-按条件查询成绩数据-模拟考试-->
+    <select id="getExamScoreList" resultType="org.springblade.modules.exam.excel.ExportExamScoreExcel">
+        SELECT
+        ke.exam_name examName,bu.real_name securityName,bu.cardid idCardNo,
+        bd.dept_name companyName,
+        es.exam_time examTime,exam_end_time examEndTime,es.candidate_no candidateNo,
+        es.theory_grade theoryGrade,es.learn_grade learnGrade,
+        all_grade allGrade
+         from
+        exam_score es
+        left join
+        ksxt_exam ke
+        on
+        ke.id = es.exam_id
+        left join
+        blade_user bu
+        on
+        es.user_id = bu.id
+        left join
+        blade_dept bd
+        on
+        bd.id = bu.dept_id
+        left join
+        sys_training_registration str
+        on
+        str.id = es.apply_id
+        where
+        1=1
+        and (str.is_exam = 2 or str.is_exam = 3 or str.is_exam = 4)
+        <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.account!=null and  examScore.account!=''">
+            and bu.account like concat('%', #{examScore.account},'%')
+        </if>
+        <if test="examScore.trainUnitId!=null">
+            and str.training_unit_id = #{examScore.trainUnitId}
+        </if>
+        <if test="examScore.userId!=null and  examScore.userId!=''">
+            and es.user_id = #{examScore.userId}
+        </if>
+        <if test="examScore.deptId!=null and  examScore.deptId!=''">
+            and bd.id = #{examScore.deptId}
+        </if>
+        <if test="examScore.isExam!=null and  examScore.isExam!=''">
+            and str.is_exam = #{examScore.isExam}
+        </if>
+        <if test="examScore.isAvatar==1">
+            and bu.avatar is not null and bu.avatar!=""
+        </if>
+        <if test="examScore.isAvatar==2">
+            and (bu.avatar is null or bu.avatar="")
+        </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>
+        <if test="examScore.examDate!=null and examScore.examDate!=''">
+            and date_format(ke.start_time,'%Y-%m-%d') = #{examScore.examDate}
+        </if>
+        order by es.id desc
+    </select>
+
+
 </mapper>

--
Gitblit v1.9.3