<?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.bonus.zlpt.bigscreen.mapper.MaDevInfoMapper">

    <select id="selectMaDevInfoList" resultType="com.bonus.zlpt.bigscreen.domain.vo.CoTypeVo">

        SELECT bc.company_ltd AS coType, COUNT(*) AS Count
        FROM ma_dev_info md
            JOIN bm_company_info bc ON md.own_co = bc.company_id
        WHERE md.ma_status = '自有' and md.is_active = '1'
        GROUP BY bc.company_ltd

    </select>

    <select id="selectmaList" resultType="com.bonus.zlpt.bigscreen.domain.vo.CompanyInfoVo">

        SELECT mti.type_name as ownCo, COUNT(*) as count
        FROM ma_type_info mti
            INNER JOIN ma_dev_info mdi ON mti.type_id = mdi.type_id
        WHERE mdi.ma_status = '在租' and mdi.is_active = '1'
        GROUP BY mti.type_name
        ORDER BY count DESC
    </select>

    <select id="selectList" resultType="java.lang.Integer">
        SELECT COUNT(*) AS count FROM ma_dev_info m
        WHERE m.is_active = '1'
    </select>

    <select id="selectTypeList" resultType="com.bonus.zlpt.bigscreen.domain.vo.TypeVo">
            SELECT ma_status as maStatus, COUNT(*) AS count
            FROM ma_dev_info
            WHERE ma_status IN ('自有', '待租') and is_active = '1'
            GROUP BY ma_status
    </select>

    <select id="selectMaTypeList" resultType="com.bonus.zlpt.bigscreen.domain.vo.TypeVo">
        SELECT ma_status as maStatus, COUNT(*) AS count
        FROM ma_dev_info
        WHERE ma_status IN ('在租', '待租') and is_active = '1'
        GROUP BY ma_status
    </select>

    <select id="selecthotList" resultType="com.bonus.zlpt.bigscreen.domain.vo.CompanyInfoVo">
        SELECT bc.company_name AS ownCo, COUNT(*) AS count
        FROM ma_hot_search hs
        LEFT JOIN ma_dev_info md ON hs.ma_id = md.ma_id
        LEFT JOIN bm_company_info bc ON md.own_co = bc.company_id
        WHERE md.is_active = '1'
        GROUP BY bc.company_name
        ORDER BY count DESC
    </select>

    <select id="selectListById" resultType="com.bonus.zlpt.bigscreen.domain.vo.MaIdVo">
        SELECT mt.type_name AS maName,
               md.ma_status AS maStatus,
               mo.need_company AS needCompany,
               mo.plan_start_time AS planStartTime,
               mo.duration AS duration
        FROM ma_dev_info md
            LEFT JOIN ma_type_info mt ON md.type_id = mt.type_id
            LEFT JOIN ma_order_details mo ON md.ma_id = mo.ma_id
        where md.ma_id = #{maId} and md.is_active = '1'
        GROUP BY maName,maStatus,needCompany,planStartTime,duration
    </select>

</mapper>