<?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.huiju.estateagents.property.dao.IndexCountMapper">

 <select id="getTicketList" resultType="com.huiju.estateagents.property.model.TpTicket">
    SELECT
        id,
        org_id,
        `status`,
        type,
        repair_type,
        create_date
    FROM
        tp_ticket
    WHERE org_id = #{orgId}
 </select>

    <select id="selectCommunityOpenDoorCount" parameterType="java.lang.Integer" resultType="java.lang.Integer" >
    select count(*)
    from mq_message
    where event_type = '199941' AND source_idx in('94bac7e217fb4a698ad086876d347c6a','efcb9a3fe4e64e2f9c0f546c54465524')
    </select>

    <select id="selectUnitsOpenDoorCount" parameterType="java.lang.Integer" resultType="java.lang.Integer" >
    select count(*)
    from mq_message
    where event_type = #{eventType,jdbcType=INTEGER}
    </select>

    <select id="getPublicCameraCount" resultType="java.lang.Integer">
        SELECT count(id) FROM ta_public_monitor WHERE org_id = #{orgId}
    </select>

    <select id="getRemoteMonitoringCount" resultType="java.lang.Integer">
        SELECT count(id) FROM ta_remotely_monitor WHERE org_id = #{orgId}
    </select>

    <select id="getRemoteUnitCount" resultType="java.lang.Integer">
        SELECT count(id) FROM ta_remotely_door WHERE org_id = #{orgId}
    </select>

    <select id="getBillInvoiceCountList" resultType="com.huiju.estateagents.property.model.TpBillInvoiceCount">
        SELECT
            price_total as priceTotal,
            create_date AS createDate
        FROM
            tp_bill_invoice_count
        WHERE
            org_id = #{orgId}
            ORDER BY create_date desc LIMIT 7
    </select>

    <select id="getUserLicenseCountList" resultType="com.huiju.estateagents.property.model.TaUserLicenseCount">
        SELECT
            price_total as priceTotal,
            create_date AS createDate
        FROM
            ta_user_license_count
        WHERE
            org_id = #{orgId}
            ORDER BY create_date desc LIMIT 7
    </select>
    <select id="getTemporaryLicenseCountList" resultType="com.huiju.estateagents.property.model.TaTemporaryLicenseCount">
        SELECT
            price_total as priceTotal,
            create_date AS createDate
        FROM
            ta_temporary_license_count
        WHERE
            org_id = #{orgId}
            ORDER BY create_date desc LIMIT 7
    </select>

    <select id="getRegisterUserCount" resultType="java.lang.Integer">
        SELECT
            count( id )
        FROM
            ta_user_verify
        WHERE
            org_id = #{orgId}
        AND role_id = #{roleId}
    </select>

    <select id="getBriskUserList" resultType="com.huiju.estateagents.property.model.TaBriskUser">
        SELECT
            count(id) as briskCount,
            create_date as createDate
        FROM
            ta_brisk_user
        WHERE
            org_id = #{orgId}
            GROUP BY TO_DAYS(create_date)
            ORDER BY TO_DAYS(create_date)  desc limit 7
    </select>

    <select id="getAnnouncementCount" resultType="java.lang.Integer">
        SELECT
            count( id )
        FROM
            tp_announcement
        WHERE
            org_id = #{orgId}
    </select>

    <select id="getActivityCount" resultType="java.lang.Integer">
        SELECT
            count( id )
        FROM
            tp_activity
        WHERE
            org_id = #{orgId}
    </select>

    <select id="getTopicCount" resultType="java.lang.Integer">
        SELECT
            count( id )
        FROM
            tp_transaction
        WHERE
            org_id = #{orgId}
    </select>
</mapper>