<?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="org.jeecg.modules.stm.page.mapper.PageTitleconfigMapper">

    <resultMap id="pageMetricMonires" type="org.jeecg.modules.stm.page.vo.PageMetricMoniVo" >
        <result column="coll_freq" property="collFreq" />
        <result column="year" property="year" />
        <result column="mon" property="mon" />
        <result column="qua" property="qua" />
        <result column="fill_vals" property="fillVals" />
    </resultMap>


    <select id="getMetricReportList" parameterType="org.jeecg.modules.stm.metric.entity.MetricReport" resultMap="pageMetricMonires">
        SELECT A.coll_freq, YEAR(B.fill_time) AS year, MONTH(B.fill_time) AS mon, QUARTER(B.fill_time) AS qua,
        B.fill_vals
        FROM metric_monitor_set A
        INNER JOIN metric_report B ON A.mtrc_no=B.mtrc_no
        WHERE B.mtrc_no=#{mtrcNo} AND YEAR(B.fill_time)=#{id}
        ORDER BY B.fill_time desc
    </select>

    <select id="getTjByFxjcList" resultType="org.jeecg.modules.stm.page.entity.PageTitleconfig">
            select tj.risk_level as tabname,count(tj.id) as pjid from (
            select t.id,t.risk_level from metric_report t INNER join (
            select  r.mtrc_no,max(r.fill_time) as fill_time from metric_report r group by r.mtrc_no) z
            on t.mtrc_no=z.mtrc_no and t.fill_time=z.fill_time
            where t.mtrc_no in (select m.mtrc_no from page_metricconfig p,metric_monitor_set m where p.id=m.id )
            and t.risk_level is not null
            ) tj
            group by tj.risk_level

    </select>

    <select id="getTjByFxjcListZs" resultType="java.lang.Integer">
            select count(tj.id) as pjid from (
            select t.id,t.risk_level from metric_report t INNER join (
            select  r.mtrc_no,max(r.fill_time) as fill_time from metric_report r group by r.mtrc_no) z
            on t.mtrc_no=z.mtrc_no and t.fill_time=z.fill_time
            where t.mtrc_no in (select m.mtrc_no from page_metricconfig p,metric_monitor_set m where p.id=m.id )
            and t.risk_level is not null
            )tj
    </select>
    <select id="getFirstPageFxcStat" resultType="java.util.Map">
        SELECT B.itemid,B.content FROM page_titleconfig A
        INNER JOIN baosong_task_record B ON A.tpl_item_dt_id=B.itemid
        ORDER BY A.show_sort
    </select>
</mapper>