From cc057177b2fb17aee9a173a6adbabdc578fd74c7 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Mon, 06 Dec 2021 10:30:44 +0800
Subject: [PATCH] 1.许可

---
 src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml |  317 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 306 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml b/src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
index 38f60b0..74907ac 100644
--- a/src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
+++ b/src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
@@ -6,8 +6,10 @@
     <select id="selectApplyPage" resultType="org.springblade.modules.apply.vo.ApplyVO">
         SELECT
             sa.id,sa.apply_status applyStatus,sa.user_id userId,sa.candidate_no candidateNo,apply_time,exam_id examId,
+            sa.examination_type examinationType,sa.examination_mx examinationMx,
             ke.total_score paperScore,ke.exam_type examType,ke.start_time examTime,ke.exam_name examName,
-            bu.real_name name,sa.examination_type,sa.examination_mx,
+            bu.real_name realName,bu.is_apply isApply, ifnull(DATE_FORMAT(NOW(), '%Y') - SUBSTRING(bu.cardid,7,4),0) age,
+            bu.sex,bu.phone,bu.nativePlace,
             bd.dept_name deptName,bu.cardid idCardNo,"保安证" applyCard
         FROM
             sys_apply sa
@@ -16,7 +18,12 @@
         on
             sa.exam_id = ke.id
         left join
-            blade_user bu
+            (
+                select * from blade_user where 1=1
+                <if test="apply.deptId!=null and  apply.deptId!=''">
+                    and dept_id = #{apply.deptId}
+                </if>
+            ) bu
         on
             sa.user_id = bu.id
         left join
@@ -26,8 +33,28 @@
         WHERE
             1=1
             and is_exam = 1
-        <if test="apply.name!=null and  apply.name!=''">
-            and sa.name like concat('%', #{apply.name},'%')
+        <if test="apply.applyStatus==2">
+            and sa.exam_id is null
+            and bu.is_apply = 1
+            and sa.apply_status = 2
+        </if>
+        <if test="apply.applyStatus==4">
+            and sa.apply_status = 4
+        </if>
+        <if test="apply.applyStatus==1">
+            and
+            (
+             sa.exam_id is null
+            and bu.is_apply = 1
+            and sa.apply_status = 2
+            )
+            or
+            (
+             sa.apply_status = 4
+            )
+        </if>
+        <if test="apply.realName!=null and  apply.realName!=''">
+            and bu.real_name like concat('%', #{apply.realName},'%')
         </if>
         <if test="apply.deptName!=null and  apply.deptName!=''">
             and bd.dept_name like concat('%', #{apply.deptName},'%')
@@ -35,14 +62,95 @@
         <if test="apply.userId!=null and  apply.userId!=''">
             and sa.user_id like concat('%', #{apply.userId},'%')
         </if>
-        <if test="apply.applyStatus!=null">
-            and apply_status = #{apply.applyStatus}
+        <if test="apply.idCardNo!=null and  apply.idCardNo!=''">
+            and bu.cardid like concat('%', #{apply.idCardNo},'%')
+        </if>
+        <if test="apply.examinationType!=null and  apply.examinationType!=''">
+            and sa.examination_type = #{apply.examinationType}
+        </if>
+        <if test="apply.deptId!=null and  apply.deptId!=''">
+            and bu.dept_id = #{apply.deptId}
         </if>
         <if test="apply.applyExamType!=null">
             and apply_exam_type = #{apply.applyExamType}
         </if>
         <if test="apply.examId!=null">
             and sa.exam_id = #{apply.examId}
+        </if>
+        <if test="apply.beginTime!=null and apply.beginTime!=''">
+            and sa.apply_time &gt;= #{apply.beginTime}
+        </if>
+        <if test="apply.overTime!=null and apply.overTime!=''">
+            and sa.apply_time &lt;= #{apply.overTime}
+        </if>
+    </select>
+
+
+    <!--考试报名分页信息 清册-->
+    <select id="selectApplyPageStatis" resultType="org.springblade.modules.apply.vo.ApplyVO">
+        SELECT
+            sa.id,sa.apply_status applyStatus,sa.user_id userId,sa.candidate_no candidateNo,apply_time,exam_id examId,
+            sa.examination_type examinationType,sa.examination_mx examinationMx,
+            ke.total_score paperScore,ke.exam_type examType,ke.start_time examTime,ke.exam_name examName,
+            bu.real_name realName,bu.is_apply isApply, ifnull(DATE_FORMAT(NOW(), '%Y') - SUBSTRING(bu.cardid,7,4),0) age,
+            bu.sex,bu.phone,bu.nativePlace,
+            bd.dept_name deptName,bu.cardid idCardNo,"保安证" applyCard
+        FROM
+            sys_apply sa
+        left join
+            ksxt_exam ke
+        on
+            sa.exam_id = ke.id
+        left join
+            (
+                select * from blade_user where 1=1
+                <if test="apply.deptId!=null and  apply.deptId!=''">
+                    and dept_id = #{apply.deptId}
+                </if>
+            ) bu
+        on
+            sa.user_id = bu.id
+        left join
+            blade_dept bd
+        on
+            bd.id = bu.dept_id
+        WHERE
+            1=1
+        <if test="apply.applyStatus==3">
+            and sa.apply_status = 2
+        </if>
+        <if test="apply.applyStatus==4">
+            and sa.apply_status = 4
+        </if>
+        <if test="apply.realName!=null and  apply.realName!=''">
+            and bu.real_name like concat('%', #{apply.realName},'%')
+        </if>
+        <if test="apply.deptName!=null and  apply.deptName!=''">
+            and bd.dept_name like concat('%', #{apply.deptName},'%')
+        </if>
+        <if test="apply.userId!=null and  apply.userId!=''">
+            and sa.user_id like concat('%', #{apply.userId},'%')
+        </if>
+        <if test="apply.idCardNo!=null and  apply.idCardNo!=''">
+            and bu.cardid like concat('%', #{apply.idCardNo},'%')
+        </if>
+        <if test="apply.examinationType!=null and  apply.examinationType!=''">
+            and sa.examination_type = #{apply.examinationType}
+        </if>
+        <if test="apply.deptId!=null and  apply.deptId!=''">
+            and bu.dept_id = #{apply.deptId}
+        </if>
+        <if test="apply.applyExamType!=null">
+            and apply_exam_type = #{apply.applyExamType}
+        </if>
+        <if test="apply.examId!=null">
+            and sa.exam_id = #{apply.examId}
+        </if>
+        <if test="apply.beginTime!=null and apply.beginTime!=''">
+            and sa.apply_time &gt;= #{apply.beginTime}
+        </if>
+        <if test="apply.overTime!=null and apply.overTime!=''">
+            and sa.apply_time &lt;= #{apply.overTime}
         </if>
     </select>
 
@@ -91,10 +199,11 @@
     <!--获取准考证信息(正式考试)-->
     <select id="getApplyInfo" resultType="org.springblade.modules.apply.vo.ApplyPaPerVO">
         SELECT
-            sa.id,sa.candidate_no candidateNo,
+            sa.id,sa.candidate_no candidateNo,sa.apply_code applyCode,
             ke.exam_type examType,ke.start_time startTime,ke.end_time endTime,ke.exam_name examName,
-            bu.real_name realName,bu.cardid idCardNo,ifnull(bu.sex,0) sex,bu.my_picture myPicture,
-            bd.dept_name deptName,"保安证" applyCard
+            bu.real_name realName,bu.cardid idCardNo,ifnull(bu.sex,0) sex,bu.avatar myPicture,
+            bd.dept_name deptName,"保安证" applyCard,
+            er.exam_room_name examRoomName,er.address,er.exam_room_no examRoomNo
         FROM
             sys_apply sa
         left join
@@ -109,6 +218,10 @@
             blade_dept bd
         on
             bd.id = bu.dept_id
+        left join
+            exam_room er
+        on
+            er.id = ke.exam_room_id
         WHERE
             sa.id = #{apply.id}
     </select>
@@ -119,8 +232,9 @@
         select
             sr.candidate_no candidateNo,
             bt.dept_name AS deptName,"保安证" applyCard,
-            bu.real_name realName,bu.cardid idCardNo,ifnull(bu.sex,0) sex,bu.my_picture myPicture,
-            ke.exam_type examType,ke.start_time startTime,ke.end_time endTime,ke.exam_name examName
+            bu.real_name realName,bu.cardid idCardNo,ifnull(bu.sex,0) sex,bu.avatar myPicture,
+            ke.exam_type examType,ke.start_time startTime,ke.end_time endTime,ke.exam_name examName,
+            si.enterpriseName company,si.address
         FROM
         sys_training_registration sr
         LEFT JOIN
@@ -139,6 +253,10 @@
         ksxt_exam ke
         on
         ke.id = sr.train_exam_id
+        left join
+        sys_information si
+        on
+        si.departmentid = sr.training_unit_id
         WHERE
         1=1
           and sr.id = #{apply.id}
@@ -196,4 +314,181 @@
         and (apply_status = 1 or apply_status = 2)
         limit 1
     </select>
+
+    <!--查询人员是否已经报名-->
+    <select id="getSecurityApplyInfo" resultType="org.springblade.modules.apply.entity.Apply">
+        select * from sys_apply
+        where 1=1
+        and is_exam = 1
+        and user_id = #{apply.userId}
+        and apply_status = 2
+        limit 1
+    </select>
+
+    <!--查询报名人员未关联考试的ids集合-->
+    <select id="getApplyIds" resultType="org.springblade.modules.apply.entity.Apply">
+        SELECT
+        sa.id,sa.exam_id
+        FROM
+        sys_apply sa
+        left join
+        ksxt_exam ke
+        on
+        sa.exam_id = ke.id
+        left join
+        blade_user bu
+        on
+        sa.user_id = bu.id
+        left join
+        blade_dept bd
+        on
+        bd.id = bu.dept_id
+        WHERE
+        1=1
+        and is_exam = 1
+        and sa.apply_status = 2
+        and bu.is_apply = 1
+        <if test="apply.realName!=null and  apply.realName!=''">
+            and bu.real_name like concat('%', #{apply.realName},'%')
+        </if>
+        <if test="apply.deptName!=null and  apply.deptName!=''">
+            and bd.dept_name like concat('%', #{apply.deptName},'%')
+        </if>
+        <if test="apply.userId!=null and  apply.userId!=''">
+            and sa.user_id like concat('%', #{apply.userId},'%')
+        </if>
+        <if test="apply.examinationType!=null and  apply.examinationType!=''">
+            and sa.examination_type = #{apply.examinationType}
+        </if>
+        <if test="apply.deptId!=null and  apply.deptId!=''">
+            and bu.dept_id = #{apply.deptId}
+        </if>
+        <if test="apply.applyStatus==2">
+            and exam_id is null
+        </if>
+        <if test="apply.applyStatus==4">
+            and sa.apply_status = 4
+            and bu.is_apply = 2
+        </if>
+        <if test="apply.applyExamType!=null">
+            and apply_exam_type = #{apply.applyExamType}
+        </if>
+        <if test="apply.examId!=null">
+            and sa.exam_id = #{apply.examId}
+        </if>
+        limit #{apply.serialStart},#{apply.serialEnd}
+    </select>
+
+    <!--查询考试人数-->
+    <select id="getApplyDeatailNum" resultType="java.lang.Integer">
+        SELECT
+        count(*)
+        FROM
+        sys_apply sa
+        left join
+        blade_user bu
+        on
+        sa.user_id = bu.id
+        WHERE
+        1=1
+        and sa.apply_status = 2
+        and sa.exam_id = #{id}
+    </select>
+
+    <!-- 查询培训考试人数-->
+    <select id="getTrainDeatailNum" resultType="java.lang.Integer">
+        SELECT
+        count(*)
+        FROM
+        sys_training_registration sr
+        left join
+        blade_user bu
+        on
+        sr.user_id = bu.id
+        WHERE
+        1=1
+        and sr.cancel = 1
+        and sr.train_exam_id = #{id}
+    </select>
+
+    <!--查询已报名的的人信息集合-->
+    <select id="getApplyDetailList" resultType="org.springblade.modules.apply.vo.ApplyVO">
+        SELECT
+            sa.candidate_no candidateNo,sa.apply_time applyTime,
+            ke.exam_name examName,
+            bu.real_name realName,bu.cardid idCardNo,bu.sex,
+            bd.dept_name deptName,"保安证" applyCard
+        FROM
+        sys_apply sa
+        left join
+        blade_user bu
+        on
+        sa.user_id = bu.id
+        left join
+        ksxt_exam ke
+        on
+        ke.id = sa.exam_id
+        left join
+        blade_dept bd
+        on
+        bd.id = bu.dept_id
+        WHERE
+        1=1
+        and sa.apply_status = 2
+        and sa.exam_id  = #{id}
+    </select>
+
+    <!--查询已培训报名的的人信息集合-->
+    <select id="getTrainDetailList" resultType="org.springblade.modules.apply.vo.ApplyVO">
+        SELECT
+            sr.candidate_no candidateNo,sr.training_time applyTime,
+            ke.exam_name examName,
+            bu.real_name realName,bu.cardid idCardNo,bu.sex,
+            bd.dept_name deptName,"保安证" applyCard
+        FROM
+        sys_training_registration sr
+        left join
+        blade_user bu
+        on
+        sr.user_id = bu.id
+        left join
+        ksxt_exam ke
+        on
+        ke.id = sr.train_exam_id
+        left join
+        blade_dept bd
+        on
+        bd.id = bu.dept_id
+        WHERE
+        1=1
+        and sr.cancel = 1
+        and sr.train_exam_id = #{id}
+    </select>
+
+
+    <!--查询保安员个人报名信息-->
+    <select id="getSecurityApplyDetail" resultType="org.springblade.modules.apply.vo.ApplyVO">
+        select
+        bu.id userId,bu.real_name realName,bu.sex,bu.is_apply isApply,
+        MAX(sa.id) id
+        from
+        blade_user bu
+        left join
+        sys_apply sa
+        on
+        sa.user_id = bu.id
+        where 1=1
+        <if test="apply.userId!=null and apply.userId!=''">
+            and bu.id = #{apply.userId}
+        </if>
+        <if test="apply.id!=null and apply.id!=''">
+            and sa.id = #{apply.id}
+        </if>
+    </select>
+
+    <!--查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录-->
+    <select id="getMaxApplyIdByUserIdInfo" resultType="org.springblade.modules.apply.entity.Apply">
+        select MAX(id) id from sys_apply where user_id = #{userId}
+    </select>
+
 </mapper>

--
Gitblit v1.9.3