智慧保安后台管理-外网项目备份
guoshilong
2023-12-18 3ae3b225cf2c4f6fa8c1fb3d33d0cf428e724514
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.signinrecords.mapper.SignInRecordsMapper">
 
    <!--查詢考試簽到記錄分頁數據-->
    <select id="selectSignInRecordsPage" resultType="org.springblade.modules.signinrecords.vo.SignInRecordsVo">
        select
        ssir.*,
        bu.real_name realName,
        bu.cardid idCardNo,
        bd.dept_name deptName
        from sys_sign_in_records ssir
        left join
        blade_user bu
        on
        bu.id = ssir.user_id
        left join
        blade_dept bd
        on
        bu.dept_id = bd.id
        left join
        sys_training_registration str
        on
        str.id = ssir.apply_id
        where 1=1
        <if test="signInRecords.realName!=null and signInRecords.realName!=''">
            and bu.real_name like concat('%',#{signInRecords.realName},'%')
        </if>
        <if test="signInRecords.idCardNo!=null and signInRecords.idCardNo!=''">
            and bu.cardid like concat('%',#{signInRecords.idCardNo},'%')
        </if>
        <if test="signInRecords.deptName!=null and signInRecords.deptName!=''">
            and bd.dept_name like concat('%',#{signInRecords.deptName},'%')
        </if>
        <if test="signInRecords.signTime!=null and signInRecords.signTime!=''">
            and date_format(ssir.update_time,'%Y-%m-%d') = #{signInRecords.signTime}
        </if>
        <if test="signInRecords.trainingUnitId!=null and  signInRecords.trainingUnitId!=''">
            and str.training_unit_id = #{signInRecords.trainingUnitId}
        </if>
        order by ssir.id desc
    </select>
 
 
    <select id="getSignStatisticsPie" resultType="org.springblade.modules.signinrecords.vo.SignStatistics">
        SELECT
            basic.shouldNum,basic.realNum,(basic.shouldNum-basic.realNum) as unArriveNum,
            (basic.realNum/basic.shouldNum) as sign,((basic.shouldNum-basic.realNum)/basic.shouldNum) as unSign
        FROM(
                SELECT
                    (SELECT COUNT(*) FROM sys_training_registration
                        WHERE
                        cancel = '1' and audit_status = '1'
                        <if test="statistics.examId != null and statistics.examId !='' ">
                            AND train_exam_id = #{statistics.examId}
                        </if>
                         ) as shouldNum,
                    (SELECT COUNT(*) FROM sys_sign_in_records
                                     WHERE 1=1
                                    <if test="statistics.examId != null and statistics.examId !='' ">
                                        AND exam_id = #{statistics.examId}
                                    </if>
                                     ) as realNum
            )basic
    </select>
 
 
    <select id="getSignStatisticsBar" resultType="org.springblade.modules.signinrecords.vo.SignStatistics">
        SELECT
            shouldTemp.shouldNum,
            realTemp.realNum,
            shouldTemp.shouldNum - realTemp.realNum AS unArriveNum,
            shouldTemp.dept_name
        FROM
            (
                SELECT
                    COUNT(*) shouldNum,
                    bd.dept_name,
                    bd.id
                FROM
                    sys_training_registration str
                        LEFT JOIN blade_user bu ON bu.id = str.user_id
                        LEFT JOIN blade_dept bd ON bd.id = bu.dept_id
                WHERE 1=1
                    <if test="statistics.examId != null and statistics.examId !='' ">
                        AND str.train_exam_id = #{statistics.examId}
                    </if>
                GROUP BY
                    bd.dept_name,
                    bd.id
                ORDER BY
                    dept_name DESC
            ) shouldTemp
                LEFT JOIN (
                SELECT
                    COUNT(*) realNum,
                    bd.dept_name,
                    bd.id
                FROM
                    sys_sign_in_records ssir
                        LEFT JOIN blade_user bu ON bu.id = ssir.user_id
                        LEFT JOIN blade_dept bd ON bd.id = bu.dept_id
                WHERE
                    1=1
                    <if test="statistics.examId != null and statistics.examId !='' ">
                        AND ssir.exam_id = #{statistics.examId}
                    </if>
                GROUP BY
                    bd.dept_name,
                    bd.id
                ORDER BY
                    dept_name DESC
            ) realTemp ON shouldTemp.id = realTemp.id
    </select>
    <select id="getSignSituationList" resultType="org.springblade.modules.signinrecords.vo.SignInfo">
        SELECT
            str.candidate_no,
            bu.avatar,
            bu.real_name,
            bu.cardId,
            str.train_exam_id as examId,
            bu.sex,
            CASE WHEN ssir.id IS NULL THEN
                     '未签到' ELSE '已签到'
                END AS state
        FROM
            sys_training_registration str
                LEFT JOIN blade_user bu ON bu.id = str.user_id
                LEFT JOIN sys_sign_in_records ssir ON ssir.candidate_no = str.candidate_no
                <if test="signInfo.examId != null and signInfo.examId !='' ">
                    AND ssir.exam_id = #{signInfo.examId}
                </if>
        WHERE str.audit_status = '1' and str.cancel = '1'
        <if test="signInfo.examId != null and signInfo.examId !='' ">
            and str.train_exam_id = #{signInfo.examId}
        </if>
        ORDER BY str.candidate_no ASC
    </select>
 
</mapper>