fuliqi
2025-02-10 db75b45e9a7ce347162b8d3a36e4a7f46cfe199e
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?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="com.ycl.platform.mapper.CheckIndexFaceMapper">
 
    <resultMap type="com.ycl.platform.domain.entity.CheckIndexFace" id="CheckIndexFaceResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="examineTag"    column="examine_tag"    />
        <result property="num"    column="num"    />
        <result property="score"    column="score"    />
        <result property="createTime"    column="create_time"    />
        <result property="viewConnectStability"    column="view_connect_stability"    />
        <result property="siteOnline"    column="site_online"    />
        <result property="deviceDirectoryConsistent"    column="device_directory_consistent"    />
        <result property="faceInformationCollectionAccuracy"    column="face_information_collection_accuracy"    />
        <result property="facePictureQualification"    column="face_picture_qualification"    />
        <result property="faceTimingAccuracy"    column="face_timing_accuracy"    />
        <result property="faceUploadTimeliness"    column="face_upload_timeliness"    />
        <result property="facePictureAvailability"    column="face_picture_availability"    />
    </resultMap>
 
    <sql id="selectCheckIndexFaceVo">
        select id, dept_id, examine_tag, create_time, view_connect_stability, site_online, device_directory_consistent, face_information_collection_accuracy, face_picture_qualification, face_timing_accuracy, face_upload_timeliness, face_picture_availability from t_check_index_face
    </sql>
 
    <select id="selectCheckIndexFaceList"  resultMap="CheckIndexFaceResult">
        select tcif.*,sd.dept_name,tcs.score,IFNULL(tcs.device_count,0) as num
        from t_check_index_face tcif left join sys_dept sd on tcif.dept_id = sd.dept_id
        left join t_check_score tcs on tcif.id = tcs.index_id
        <where>
            tcs.examine_category = 3
            <if test="deptId != null "> and tcif.dept_id = #{deptId}</if>
            <if test="examineTag != null "> and tcif.examine_tag = #{examineTag}</if>
            <if test="quarter != null and quarter.size > 0">
                and date_format(tcs.create_time, '%Y-%m') between #{quarter[0]} and #{quarter[1]}
            </if>
            <if test="date != null "> and  date_format(tcif.create_time,'%Y-%m') = #{date}</if>
            <if test="day != null "> and  date(tcif.create_time) = #{day}</if>
            <if test="params.publish != null  and params.publish != ''">and tcif.publish = #{params.publish}</if>
            <if test="deptIds != null ">and tcif.dept_id in
                <foreach collection="deptIds" separator="," open="(" close=")" item="deptId">
                    #{deptId}
                </foreach>
            </if>
        </where>
        order by tcif.examine_tag desc,sd.area_code,tcif.create_time
    </select>
 
    <select id="getCheckIndexFaceList"  resultMap="CheckIndexFaceResult">
        select tcif.*,sd.dept_name
        from t_check_index_face tcif left join sys_dept sd on tcif.dept_id = sd.dept_id
        <where>
            <if test="examineTag != null "> and tcif.examine_tag = #{examineTag}</if>
            <if test="day != null "> and  date(tcif.create_time) = #{day}</if>
            <if test="deptIds != null ">and tcif.dept_id in
                <foreach collection="deptIds" separator="," open="(" close=")" item="deptId">
                    #{deptId}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="selectCheckIndexFaceById"  resultMap="CheckIndexFaceResult">
        <include refid="selectCheckIndexFaceVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertCheckIndexFace"  useGeneratedKeys="true" keyProperty="id">
        insert into t_check_index_face
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="examineTag != null">examine_tag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="viewConnectStability != null">view_connect_stability,</if>
            <if test="siteOnline != null">site_online,</if>
            <if test="deviceDirectoryConsistent != null">device_directory_consistent,</if>
            <if test="faceInformationCollectionAccuracy != null">face_information_collection_accuracy,</if>
            <if test="facePictureQualification != null">face_picture_qualification,</if>
            <if test="faceTimingAccuracy != null">face_timing_accuracy,</if>
            <if test="faceUploadTimeliness != null">face_upload_timeliness,</if>
            <if test="facePictureAvailability != null">face_picture_availability,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="examineTag != null">#{examineTag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="viewConnectStability != null">#{viewConnectStability},</if>
            <if test="siteOnline != null">#{siteOnline},</if>
            <if test="deviceDirectoryConsistent != null">#{deviceDirectoryConsistent},</if>
            <if test="faceInformationCollectionAccuracy != null">#{faceInformationCollectionAccuracy},</if>
            <if test="facePictureQualification != null">#{facePictureQualification},</if>
            <if test="faceTimingAccuracy != null">#{faceTimingAccuracy},</if>
            <if test="faceUploadTimeliness != null">#{faceUploadTimeliness},</if>
            <if test="facePictureAvailability != null">#{facePictureAvailability},</if>
         </trim>
    </insert>
 
    <update id="updateCheckIndexFace">
        update t_check_index_face
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="examineTag != null">examine_tag = #{examineTag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="viewConnectStability != null">view_connect_stability = #{viewConnectStability},</if>
            <if test="siteOnline != null">site_online = #{siteOnline},</if>
            <if test="deviceDirectoryConsistent != null">device_directory_consistent = #{deviceDirectoryConsistent},</if>
            <if test="faceInformationCollectionAccuracy != null">face_information_collection_accuracy = #{faceInformationCollectionAccuracy},</if>
            <if test="facePictureQualification != null">face_picture_qualification = #{facePictureQualification},</if>
            <if test="faceTimingAccuracy != null">face_timing_accuracy = #{faceTimingAccuracy},</if>
            <if test="faceUploadTimeliness != null">face_upload_timeliness = #{faceUploadTimeliness},</if>
            <if test="facePictureAvailability != null">face_picture_availability = #{facePictureAvailability},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteCheckIndexFaceById" >
        delete from t_check_index_face where id = #{id}
    </delete>
 
    <delete id="deleteCheckIndexFaceByIds" >
        delete from t_check_index_face where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="selectToday" resultType="com.ycl.platform.domain.entity.CheckIndexFace">
        select * from t_check_index_face where DATE(create_time) = #{today}
    </select>
 
    <select id="dashboard" resultType="com.ycl.platform.domain.entity.CheckIndexFace">
<!--        SELECT-->
<!--        IFNULL(ROUND(AVG(view_connect_stability * 100), 0), 0) AS view_connect_stability,-->
<!--        IFNULL(ROUND(AVG(site_online * 100), 0), 0) AS site_online,-->
<!--        IFNULL(ROUND(AVG(device_directory_consistent * 100), 0), 0) AS device_directory_consistent,-->
<!--        IFNULL(ROUND(AVG(face_information_collection_accuracy * 100), 0), 0) AS face_information_collection_accuracy,-->
<!--        IFNULL(ROUND(AVG(face_picture_qualification * 100), 0), 0) AS face_picture_qualification,-->
<!--        IFNULL(ROUND(AVG(face_timing_accuracy * 100), 0), 0) AS face_timing_accuracy,-->
<!--        IFNULL(ROUND(AVG(face_upload_timeliness * 100), 0), 0) AS face_upload_timeliness,-->
<!--        IFNULL(ROUND(AVG(face_picture_availability * 100), 0), 0) AS face_picture_availability-->
<!--        FROM-->
<!--        t_check_index_face-->
<!--        <where>-->
<!--            <if test="deptId != null">-->
<!--                AND dept_id = #{deptId}-->
<!--            </if>-->
<!--            <if test="dataScope == 1">-->
<!--                AND examine_tag = 0-->
<!--            </if>-->
<!--            <if test="dataScope == 2">-->
<!--                AND examine_tag = 1-->
<!--            </if>-->
<!--            <if test="dataScope == 3">-->
<!--                AND examine_tag = 2-->
<!--            </if>-->
<!--        </where>-->
<!--        ORDER BY-->
<!--        create_time DESC-->
<!--        <if test="deptId == null">-->
<!--            LIMIT 7-->
<!--        </if>-->
<!--        <if test="deptId != null">-->
<!--            LIMIT 1-->
<!--        </if>-->
 
        WITH LatestRecords AS (
        SELECT *
        FROM t_check_index_face
        <where>
            <if test="deptId != null">
                AND dept_id = #{deptId}
            </if>
            <if test="dataScope == 1">
                AND examine_tag = 0
            </if>
            <if test="dataScope == 2">
                AND examine_tag = 1
            </if>
            <if test="dataScope == 3">
                AND examine_tag = 2
            </if>
        </where>
        ORDER BY create_time DESC
        <if test="deptId == null">
            LIMIT 7
        </if>
        <if test="deptId != null">
            LIMIT 1
        </if>
        )
        SELECT
        IFNULL(ROUND(AVG(view_connect_stability * 100), 0), 0) AS view_connect_stability,
        IFNULL(ROUND(AVG(site_online * 100), 0), 0) AS site_online,
        IFNULL(ROUND(AVG(device_directory_consistent * 100), 0), 0) AS device_directory_consistent,
        IFNULL(ROUND(AVG(face_information_collection_accuracy * 100), 0), 0) AS face_information_collection_accuracy,
        IFNULL(ROUND(AVG(face_picture_qualification * 100), 0), 0) AS face_picture_qualification,
        IFNULL(ROUND(AVG(face_timing_accuracy * 100), 0), 0) AS face_timing_accuracy,
        IFNULL(ROUND(AVG(face_upload_timeliness * 100), 0), 0) AS face_upload_timeliness,
        IFNULL(ROUND(AVG(face_picture_availability * 100), 0), 0) AS face_picture_availability
        FROM
        LatestRecords;
    </select>
</mapper>