<?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.metric.mapper.MetricTaskAllocMapper">
    <select id="queryTaskAlloc" resultType="org.jeecg.modules.stm.metric.pojo.QueryMetricTaskAllocVo">
        SELECT A.mtrc_no AS mtrcNo,A.mtrc_name AS mtrcName,A.id,A.des,A.coll_freq as collFreq,
        A.coll_method as collMethod,
        GROUP_CONCAT(U.realname SEPARATOR ', ') AS realname
        FROM   metric_monitor_set A
        LEFT JOIN metric_task_alloc B ON A.mtrc_no = B.mtrc_no
        LEFT JOIN sys_user U ON B.reporter=U.id
        <where>
            A.mtrc_ctp =1 and (A.coll_method = 1 or A.coll_method=3)
            <if test="query.mtrcNo!=null">
               and  A.mtrc_no = #{query.mtrcNo}
            </if>
            <if test="query.collFreq!=null">
                and A.coll_freq = #{query.collFreq}
            </if>
            <if test="query.mtrcName!=null">
               and A.mtrc_name like  concat('%',#{query.mtrcName},'%')
            </if>
        </where>
        GROUP BY  A.id,A.mtrc_no
        ORDER BY A.mtrc_no
    </select>
</mapper>