<?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.casic.missiles.modular.system.dao.ScreenDataServiceMapper">

    <sql id="date_toChar" databaseId="mysql">
       DATE_FORMAT(${paramTime},'%Y-%m-%d %H:%i:%s')
    </sql>

    <sql id="date_toChar" databaseId="pgsql">
        TO_CHAR(${paramTime},'yyyy-MM-dd HH24:mi:ss')
    </sql>

    <sql id="date_toChar" databaseId="oracle">
        TO_CHAR(${paramTime},'yyyy-MM-dd HH24:mi:ss')
    </sql>

    <sql id="char_toDate" databaseId="mysql">
       ${paramStr}
    </sql>

    <sql id="char_toDate" databaseId="pgsql">
        TO_DATE(${paramStr},'yyyy-MM-dd HH24:mi:ss')
    </sql>

    <sql id="char_toDate" databaseId="oracle">
        TO_DATE(${paramStr},'yyyy-MM-dd HH24:mi:ss')
    </sql>

    <sql id="keywords_sql" databaseId="oracle">
        '%' || #{keywords}|| '%'
    </sql>
    <sql id="keywords_sql" databaseId="mysql">
        CONCAT('%',#{keywords},'%')
    </sql>
    <sql id="keywords_sql" databaseId="pgsql">
        CONCAT('%',#{keywords},'%')
    </sql>


    <select id="countAlarmType" resultType="Map">
        SELECT  count(*)  as  count,bd.DEVICE_TYPE  as  "deviceType"
        FROM alarm_records  ar
        INNER JOIN  bus_device  bd ON   ar.devcode=bd.DEVCODE
        GROUP BY  bd.DEVICE_TYPE
    </select>

    <select id="getTypeName" resultType="Map">
        SELECT  id,type_name  AS "typeName"
        FROM   base_device_type
    </select>

    <select id="countDeviceByType" resultType="Map">
        SELECT  count(*)  AS  count,DEVICE_TYPE AS "deviceType"
        FROM bus_device
        GROUP BY  DEVICE_TYPE
    </select>


</mapper>