<?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.zcloud.fire.check.persistence.mapper.FireCheckStandardMapper">
    <select id="getDeviceStandardList"
            resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckStandardStatisticDO">
        select d.fire_device_type,d.fire_device_type_name,count(cs.id) as statisticCount
        from fire_check_list_item cli left join fire_device d on cli.fire_device_id = d.fire_device_id and
        d.delete_enum='FALSE'
        left join fire_check_standard cs on d.fire_device_type = cs.fire_device_type and cs.delete_enum='FALSE'
        where cli.fire_check_id = #{fireCheckId}
        and cli.delete_enum='FALSE'
        group by cli.fire_device_id
    </select>

    <select id="listPage" resultType="com.zcloud.fire.check.persistence.dataobject.FireCheckStandardDO">
        select cs.*
        from fire_check_standard cs
        where cs.delete_enum = 'FALSE'
        <if test="params.likeFireCheckStandardItem != null and params.likeFireCheckStandardItem != ''">
           and cs.fire_check_standard_item like concat('%',#{params.likeFireCheckStandardItem},'%')
        </if>
        <if test="params.eqFireDeviceType != null and params.eqFireDeviceType != ''">
           and cs.fire_device_type = #{params.eqFireDeviceType}
        </if>
        <if test="params.likeDeviceName != null and params.likeDeviceName != ''">
           and cs.device_name like concat('%',#{params.likeDeviceName},'%')
        </if>
        order by cs.device_name desc,cs.fire_device_type desc,cs.create_time desc
    </select>
</mapper>

