<?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">
<!--  Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved. -->
<!--  Mybatis数据库持久层（业务层映射文件）：脚本信息同步表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2022-11-25 11:15:19  -->
<mapper namespace="net.northking.cctp.dw.db.dao.DwAtuPlanBatchDao">


    <!-- 请在本文件内添加自定义SQL语句 -->
    <select id="failPlanQuery" resultType="net.northking.cctp.dw.dto.FailPlanInfoDto">
        select distinct
        plan_id as planId,
        start_time as executeTime,
        success_num as successNum,
        exec_fail_num as execFailNum,
        assert_fail_num as assertFailNum,
        timeout_num as timeoutNum,
        cancel_num as cancelNum
        from dw_atu_plan_batch
        where 1=1
        <if test="successFlag=='fail'">
            and status in ('2','3') and success_rate!='100%'
        </if>
        <if test="successFlag=='success'">
            and status ='2' and success_rate ='100%'
        </if>
        <if test="planIdList != null and planIdList.size > 0">
            and plan_id in
            <foreach collection="planIdList" open="(" index="index" item="item" close=")" separator=",">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="userId!=null">
            and executed_by=#{userId}
        </if>
        GROUP BY plan_id order by start_time desc
    </select>
</mapper>