<?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.BmCompanyInfoMapper">

    <select id="selectTypeList" resultType="com.bonus.zlpt.bigscreen.domain.vo.CoTypeVo">
            SELECT company_type as coType, COUNT(*) AS count
            FROM bm_company_info
            WHERE company_type IN ('社会企业', '南网集团企业', '南网控股企业')
            GROUP BY company_type
    </select>

    <select id="selectColtdList" resultType="com.bonus.zlpt.bigscreen.domain.vo.ColtdTypeVo">
        SELECT
            c.company_ltd AS companyType,
            m.ma_status AS maStatus,
            COUNT(m.ma_id) AS count,
               g.lon AS lon,
               g.lat AS lat,
                m.ma_id AS maId
        FROM ma_dev_info m
            JOIN bm_company_info c ON m.own_co = c.company_id
            JOIN gps_real_info g ON m.gps_code = g.gps_code
        WHERE
            m.ma_status IN ('在租', '自有', '待租') and m.is_active = '1'
        GROUP BY
            c.company_ltd, m.ma_status, g.lon, g.lat,maId


    </select>

    <select id="selectTimeList" resultType="com.bonus.zlpt.bigscreen.domain.vo.LatVo">
        SELECT gh.lon AS lon, gh.lat AS lat
        FROM ma_dev_info md
        LEFT JOIN gps_his_info gh ON md.gps_code = gh.gps_code
        <where>
            <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
                and date_format( gh.time, '%Y-%m-%d' )
                BETWEEN date_format( #{beginTime}, '%Y-%m-%d' )
                and date_format( #{endTime}, '%Y-%m-%d' )
            </if>
            <if test="maId != null and maId != '' ">
                and md.ma_id = #{maId}
            </if>
            and md.is_active = '1'
        </where>
    </select>
</mapper>