<?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.qmth.themis.business.dao.TOeLivenessVerifyHistoryMapper">

    <select id="livenessActionError" resultType="java.util.Map">
        select
        count(1) as tmpCount,
        group_concat(t.photoUrl) as photoUrls,
        min(t.create_time) as createTime
        from
        (
        select
        CONVERT((tolvh.actions->>'$.faceCount')
        USING utf8) as faceCount, tolvh.`exception`,
        REPLACE(REPLACE(substring_index(substring_index(CONVERT((tolvh.actions->>'$[*].photoUrl')
        USING utf8), ']', 1), '[',-1),' "','"'),'"','') as photoUrl,tolvh.create_time
        from
        (
        select
        tolvh.actions->>'$[*]' as actions,
        tolvh.`exception`,
        tolvh.create_time
        from
        t_oe_liveness_verify_history tolvh
        <where>
            <if test="recordId != null and recordId != ''">
                and tolvh.exam_record_id = #{recordId}
            </if>
            <if test="exception != null and exception != ''">
                and tolvh.`exception` = #{exception}
            </if>
            <if test="type != null and type != ''">
                and tolvh.`type` = #{type}
            </if>
            <if test="batchNo != null and batchNo != ''">
                and tolvh.batch_no = #{batchNo}
            </if>
        </where>
        ) tolvh
        ) t
        group by t.`exception`
    </select>
</mapper>
