<?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.hzya.frame.home.dao.impl.HomeDaoImpl">

    <!-- 查询 采用==查询 -->
    <select id="getAppErrorNum" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
        SELECT
            receive_app as appId,
            count( 1 )  as num
        FROM
            sys_message_manage_log
            WHERE sts = 'Y' and status = '4'
        GROUP BY
            receive_app
    </select>

    <!-- 查询 采用==查询 -->
    <select id="appApiNum" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
      SELECT
        api.app_id as appId,
        app.app_logo as path,
        count( 1 ) as num
    FROM
        sys_application_api  api
            left join sys_application  app on app.id = api.app_id and app.sts = 'Y'
        WHERE api.sts = 'Y' and api.app_id is not null
    GROUP BY
        api.app_id,app.app_logo
    </select>

    <!-- 查询 采用==查询 -->
    <select id="useApiNum" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
        SELECT
            a.app_id as appId,
            COUNT( a.api_id ) as normalNum
        FROM
            (
            SELECT
                app_id,
                api_id
            FROM
                sys_application_api_auth_detail
            WHERE
                sts = 'Y'
            GROUP BY
                api_id,app_id
            ) a
			left join sys_application_api  api on api.id = a.api_id and api.sts = 'Y'
			WHERE api.id is not null
        GROUP BY
            a.app_id

    </select>
    <!-- 查询 采用==查询 -->
    <select id="taskNumRun" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
SELECT
	count( 1 ) as normalNum
FROM
	integration_task
WHERE
	sts = 'Y'
	AND task_status = '1'
    </select>
    <!-- 查询 采用==查询 -->
    <select id="taskNumStop" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
SELECT
	count( 1 ) as abnormalNum
FROM
	integration_task
WHERE
	sts = 'Y'
	AND task_status = '2'
    </select>


    <!-- 查询 采用==查询 -->
    <select id="sevenerrornum" databaseId="mysql" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
        SELECT
            count( id ) as abnormalNum,
            DATE_FORMAT( create_time, '%Y-%m-%d' ) as name
        FROM
            sys_message_manage_log
        WHERE sts = 'Y' and status = '4' and
            create_time BETWEEN DATE_SUB( NOW(), INTERVAL 6 DAY ) AND NOW()
        GROUP BY
            DATE_FORMAT( create_time, '%Y-%m-%d' )
        ORDER BY
            DATE_FORMAT(
            create_time,
            '%Y-%m-%d')
    </select>
    <!-- 查询 采用==查询 -->
    <select id="sevenerrornum" databaseId="oracle" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
        SELECT
            count( id ) as abnormalNum,
            DATE_FORMAT( create_time, '%Y-%m-%d' ) as name
        FROM
            sys_message_manage_log
        WHERE sts = 'Y' and status = '4' and
            create_time between add_days( NOW(), -6 ) AND NOW()
        GROUP BY
            DATE_FORMAT( create_time, '%Y-%m-%d' )
        ORDER BY
            DATE_FORMAT(
            create_time,
            '%Y-%m-%d')
    </select>
    <!-- 查询 采用==查询 -->
    <select id="sevensuccessnum"  databaseId="mysql" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
        SELECT
            count( id ) as normalNum,
            DATE_FORMAT( create_time, '%Y-%m-%d' ) as name
        FROM
            sys_message_manage_log_success
        WHERE sts = 'Y' and status = '3' and
            create_time BETWEEN DATE_SUB( NOW(), INTERVAL 6 DAY ) AND NOW()
        GROUP BY
            DATE_FORMAT( create_time, '%Y-%m-%d' )
        ORDER BY
            DATE_FORMAT(
            create_time,
            '%Y-%m-%d')
    </select>
    <!-- 查询 采用==查询 -->
    <select id="sevensuccessnum"  databaseId="oracle" resultType="com.hzya.frame.home.entity.HomeEntity" parameterType="com.hzya.frame.home.entity.HomeEntity">
        SELECT
            count( id ) as normalNum,
            DATE_FORMAT( create_time, '%Y-%m-%d' ) as name
        FROM
            sys_message_manage_log_success
        WHERE sts = 'Y' and status = '3' and
            create_time between add_days( NOW(), -6 ) AND NOW()
        GROUP BY
            DATE_FORMAT( create_time, '%Y-%m-%d' )
        ORDER BY
            DATE_FORMAT(
            create_time,
            '%Y-%m-%d')
    </select>
</mapper>

