<?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.dromara.elevator.mapper.EFaultStatisticsMapper">

    <select id="queryFaultPageList" resultType="org.dromara.elevator.domain.vo.ProjectFaultVo">
        SELECT
            dept_id,
            COUNT ( id ) fault_total
        FROM
            e_fault_statistics
        <where>
            <if test="params.faultCodeList != null and params.faultCodeList.size > 0">
              AND fault_code IN
              <foreach collection="params.faultCodeList" item="faultCode" open="(" separator="," close=")">
                    #{faultCode}
              </foreach>
            </if>
            <if test="params.startTime != null and params.endTime != null">
                AND fault_time BETWEEN  #{params.startTime} AND  #{params.endTime}
            </if>
        </where>
        GROUP BY dept_id
        ORDER BY fault_total desc
    </select>
</mapper>
