<?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">
    <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.DwAtuPlanBatch">
        <!--  -->
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <!--  -->
        <result column="plan_id" jdbcType="VARCHAR" property="planId"/>
        <!--  -->
        <result column="batch" jdbcType="INTEGER" property="batch"/>

        <result column="status" jdbcType="INTEGER" property="status"/>

        <result column="start_time" jdbcType="DATE" property="startTime"/>

        <result column="end_time" jdbcType="DATE" property="endTime"/>

        <result column="task_total" jdbcType="INTEGER" property="taskTotal"/>

        <result column="success_num" jdbcType="INTEGER" property="successNum"/>
        <result column="exec_fail_num" jdbcType="INTEGER" property="execFailNum"/>
        <result column="assert_fail_num" jdbcType="INTEGER" property="assertFailNum"/>
        <result column="timeout_num" jdbcType="INTEGER" property="timeoutNum"/>
        <result column="cancel_num" jdbcType="INTEGER" property="cancelNum"/>
        <result column="trigger_type" jdbcType="VARCHAR" property="triggerType" />
        <result column="success_rate" jdbcType="VARCHAR" property="successRate"/>
        <result column="executed_by" jdbcType="VARCHAR" property="executedBy" />
        <result column="executed_name" jdbcType="VARCHAR" property="executedName" />
        <result column="manager_oper_code" jdbcType="VARCHAR" property="managerOperCode" />
        <result column="manager_company" jdbcType="VARCHAR" property="managerCompany" />
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,plan_id
        ,batch
        ,status
        ,start_time
        ,end_time
        ,task_total
        ,success_num
        ,exec_fail_num
        ,assert_fail_num
        ,timeout_num
        ,cancel_num
        ,trigger_type
        ,success_rate
        ,executed_by
        ,executed_name
        ,manager_oper_code
        ,manager_company
    </sql>

    <sql id="Table_Name">
        ${defaultSchema}.dw_atu_plan_batch
    </sql>

    <select id="findByPrimaryKey" parameterType="String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        <include refid="Table_Name"/>
        where id = #{id,jdbcType=VARCHAR}
    </select>

    <select id="findByPrimaryKeys" parameterType="java.util.List">
        select
        <include refid="Base_Column_List"/>
        from
        <include refid="Table_Name"/>
        where id in
        <foreach collection="list" item="idItem" open="(" separator="," close=")">
            #{idItem, jdbcType=VARCHAR}
        </foreach>
    </select>

    <delete id="deleteByPrimaryKey" parameterType="String">
        delete from
        <include refid="Table_Name"/>
        where id = #{id,jdbcType=VARCHAR}
    </delete>

    <delete id="deleteByPrimaryKeys" parameterType="String">
        delete from
        <include refid="Table_Name"/>
        where id in
        <foreach collection="list" item="idItem" open="(" separator="," close=")">
            #{idItem, jdbcType=VARCHAR}
        </foreach>
    </delete>

    <delete id="deleteByExample" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanBatch">
        delete from
        <include refid="Table_Name"/>
        <trim prefix="WHERE" prefixOverrides="AND" >
            <choose>
                <when test="id != null">
                    id = #{id,jdbcType=VARCHAR}
                </when>
            </choose>
            <if test="id != null">
                AND id=#{id,jdbcType=VARCHAR}
            </if>
            <if test="planId != null">
                AND plan_id=#{planId,jdbcType=VARCHAR}
            </if>
            <if test="batch != null">
                AND batch=#{batch,jdbcType=VARCHAR}
            </if>
            <if test="status != null">
                AND status=#{status,jdbcType=DATE}
            </if>
            <if test="startTime != null">
                AND start_time=#{startTime,jdbcType=DATE}
            </if>
            <if test="endTime != null">
                AND end_time=#{endTime,jdbcType=DATE}
            </if>
            <if test="taskTotal != null">
                AND task_total=#{taskTotal,jdbcType=INTEGER}
            </if>
            <if test="successNum != null">
                AND success_num=#{successNum,jdbcType=INTEGER}
            </if>
            <if test="execFailNum != null">
                AND exec_fail_num=#{execFailNum,jdbcType=INTEGER}
            </if>
            <if test="assertFailNum != null">
                AND assert_fail_num=#{assertFailNum,jdbcType=INTEGER}
            </if>
            <if test="timeoutNum != null">
                AND timeout_num=#{timeoutNum,jdbcType=INTEGER}
            </if>
            <if test="cancelNum != null">
                AND cancel_num=#{cancelNum,jdbcType=INTEGER}
            </if>
            <if test="successRate != null">
                AND success_rate=#{successRate,jdbcType=VARCHAR}
            </if>

            <if test="triggerType!=null">
                AND trigger_type = #{triggerType,jdbcType=VARCHAR}
            </if>
        </trim>
    </delete>

    <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanBatch">
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="planId != null">
                plan_id,
            </if>
            <if test="batch != null">
                batch,
            </if>
            <if test="status != null">
                status,
            </if>

            <if test="startTime != null">
                start_time,
            </if>
            <if test="endTime != null">
                end_time,
            </if>
            <if test="taskTotal != null">
                task_total,
            </if>
            <if test="successNum != null">
                success_num,
            </if>
            <if test="execFailNum != null">
                exec_fail_num,
            </if>
            <if test="assertFailNum != null">
                assert_fail_num,
            </if>
            <if test="timeoutNum != null">
                timeout_num,
            </if>
            <if test="cancelNum != null">
                cancel_num,
            </if>
            <if test="successRate != null">
                success_rate,
            </if>
            <if test="triggerType != null">
                trigger_type,
            </if>
            <if test="updatedTime!=null">
                updated_time,
            </if>
            <if test="executedBy!=null" >
                executed_by,
            </if>
            <if test="executedName!=null" >
                executed_name,
            </if>
            <if test="managerOperCode!=null" >
                manager_oper_code,
            </if>
            <if test="managerCompany!=null" >
                manager_company,
            </if>
            <if test="testTeam!=null" >
                test_team,
            </if>
            <if test="testTeamId!=null" >
                test_team_id,
            </if>
            <if test="testTeamManager!=null" >
                test_team_manager,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=VARCHAR},
            </if>
            <if test="planId != null">
                #{planId,jdbcType=VARCHAR},
            </if>
            <if test="batch != null">
                #{batch,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=DATE},
            </if>
            <if test="startTime != null">
                #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="taskTotal != null">
                #{taskTotal,jdbcType=INTEGER},
            </if>
            <if test="successNum != null">
                #{successNum,jdbcType=INTEGER},
            </if>
            <if test="execFailNum != null">
                #{execFailNum,jdbcType=INTEGER},
            </if>
            <if test="assertFailNum != null">
                #{assertFailNum,jdbcType=INTEGER},
            </if>
            <if test="timeoutNum != null">
                #{timeoutNum,jdbcType=INTEGER},
            </if>
            <if test="cancelNum != null">
                #{cancelNum,jdbcType=INTEGER},
            </if>
            <if test="successRate != null">
                #{successRate,jdbcType=VARCHAR},
            </if>
            <if test="triggerType != null">
                #{triggerType,jdbcType=VARCHAR},
            </if>
            <if test="updatedTime!=null">
                #{updatedTime,jdbcType=TIMESTAMP},
            </if>
            <if test="executedBy!=null">
                #{executedBy,jdbcType=VARCHAR},
            </if>
            <if test="executedName!=null">
                #{executedName,jdbcType=VARCHAR},
            </if>
            <if test="managerOperCode!=null">
                #{managerOperCode,jdbcType=VARCHAR},
            </if>
            <if test="managerCompany!=null">
                #{managerCompany,jdbcType=VARCHAR},
            </if>
            <if test="testTeam!=null" >
                #{testTeam,jdbcType=VARCHAR},
            </if>
            <if test="testTeamId!=null" >
                #{testTeamId,jdbcType=VARCHAR},
            </if>
            <if test="testTeamManager!=null" >
                #{testTeamManager,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>

    <insert id="insertByBatch" parameterType="java.util.List">
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            id
            ,plan_id
            ,batch
            ,status
            ,start_time
            ,end_time
            ,task_total
            ,success_num
            ,exec_fail_num
            ,assert_fail_num
            ,timeout_num
            ,cancel_num
            ,success_rate
            ,trigger_type
            ,executed_by
            ,executed_name
            ,manager_oper_code
            ,manager_company
        </trim>
        values
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.id,jdbcType=VARCHAR},
                #{item.planId,jdbcType=VARCHAR},
                #{item.batch,jdbcType=VARCHAR},
                #{item.status,jdbcType=DATE},
                #{item.startTime,jdbcType=DATE},
                #{item.endTime,jdbcType=DATE},
                #{item.taskTotal,jdbcType=INTEGER},
                #{item.successNum,jdbcType=INTEGER},
                #{item.execFailNum,jdbcType=INTEGER},
                #{item.assertFailNum,jdbcType=INTEGER},
                #{item.timeoutNum,jdbcType=INTEGER},
                #{item.cancelNum,jdbcType=INTEGER},
                #{item.successRate,jdbcType=VARCHAR},
                #{item.triggerType,jdbcType=VARCHAR},
                #{item.executedBy,jdbcType=VARCHAR},
                #{item.executedName,jdbcType=VARCHAR},
                #{item.managerOperCode,jdbcType=VARCHAR},
                #{item.managerCompany,jdbcType=VARCHAR},
            </trim>
        </foreach>
    </insert>

    <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanBatch">
        update
        <include refid="Table_Name"/>
        <set>
            <if test="id != null">
                id=#{id,jdbcType=VARCHAR},
            </if>
            <if test="planId != null">
                plan_id=#{planId,jdbcType=VARCHAR},
            </if>
            <if test="batch != null">
                batch=#{batch,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                status=#{status,jdbcType=DATE},
            </if>
            <if test="status != null">
                status=#{status,jdbcType=VARCHAR},
            </if>
            <if test="startTime != null">
                start_time=#{startTime,jdbcType=DATE},
            </if>
            <if test="endTime != null">
                end_time=#{endTime,jdbcType=DATE},
            </if>
            <if test="taskTotal != null">
                task_total=#{taskTotal,jdbcType=INTEGER},
            </if>
            <if test="successNum != null">
                success_num=#{successNum,jdbcType=INTEGER},
            </if>
            <if test="execFailNum != null">
                exec_fail_num=#{execFailNum,jdbcType=INTEGER},
            </if>
            <if test="assertFailNum != null">
                assert_fail_num=#{assertFailNum,jdbcType=INTEGER},
            </if>
            <if test="timeoutNum != null">
                timeout_num=#{timeoutNum,jdbcType=INTEGER},
            </if>
            <if test="cancelNum != null">
                cancel_num=#{cancelNum,jdbcType=INTEGER},
            </if>
            <if test="successRate != null">
                success_rate=#{successRate,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>

    <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanBatch">
        select
        <include refid="Base_Column_List" />
        from
        <include refid="Table_Name"/>
        <trim prefix="WHERE" prefixOverrides="AND" >
            <if test="id != null">
                AND id=#{id,jdbcType=VARCHAR}
            </if>
            <if test="planId != null">
                AND plan_id=#{planId,jdbcType=VARCHAR}
            </if>
            <if test="batch != null">
                AND batch=#{batch,jdbcType=VARCHAR}
            </if>
            <if test="status != null">
                AND status=#{status,jdbcType=DATE}
            </if>
            <if test="status != null">
                AND status=#{status,jdbcType=VARCHAR}
            </if>
            <if test="startTime != null">
                AND start_time=#{startTime,jdbcType=DATE}
            </if>
            <if test="endTime != null">
                AND end_time=#{endTime,jdbcType=DATE}
            </if>
            <if test="taskTotal != null">
                AND task_total=#{taskTotal,jdbcType=INTEGER}
            </if>
            <if test="successNum != null">
                AND success_num=#{successNum,jdbcType=INTEGER}
            </if>
            <if test="execFailNum != null">
                AND exec_fail_num=#{execFailNum,jdbcType=INTEGER}
            </if>
            <if test="assertFailNum != null">
                AND assert_fail_num=#{assertFailNum,jdbcType=INTEGER}
            </if>
            <if test="timeoutNum != null">
                AND timeout_num=#{timeoutNum,jdbcType=INTEGER}
            </if>
            <if test="cancelNum != null">
                AND cancel_num=#{cancelNum,jdbcType=INTEGER}
            </if>
            <if test="successRate != null">
                AND success_rate=#{successRate,jdbcType=VARCHAR}
            </if>
        </trim>
    </select>

    <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.DwAtuCaseDesign">
        select count(*) from
        <include refid="Table_Name"/>
        <trim prefix="WHERE" prefixOverrides="AND" >
            <if test="id != null">
                AND id=#{id,jdbcType=VARCHAR}
            </if>
            <if test="planId != null">
                AND plan_id=#{planId,jdbcType=VARCHAR}
            </if>
            <if test="batch != null">
                AND batch=#{batch,jdbcType=VARCHAR}
            </if>
            <if test="status != null">
                AND status=#{status,jdbcType=DATE}
            </if>
            <if test="status != null">
                AND status=#{status,jdbcType=VARCHAR}
            </if>
            <if test="startTime != null">
                AND start_time=#{startTime,jdbcType=DATE}
            </if>
            <if test="endTime != null">
                AND end_time=#{endTime,jdbcType=DATE}
            </if>
            <if test="taskTotal != null">
                AND task_total=#{taskTotal,jdbcType=INTEGER}
            </if>
            <if test="successNum != null">
                AND success_num=#{successNum,jdbcType=INTEGER}
            </if>
            <if test="execFailNum != null">
                AND exec_fail_num=#{execFailNum,jdbcType=INTEGER}
            </if>
            <if test="assertFailNum != null">
                AND assert_fail_num=#{assertFailNum,jdbcType=INTEGER}
            </if>
            <if test="timeoutNum != null">
                AND timeout_num=#{timeoutNum,jdbcType=INTEGER}
            </if>
            <if test="cancelNum != null">
                AND cancel_num=#{cancelNum,jdbcType=INTEGER}
            </if>
            <if test="successRate != null">
                AND success_rate=#{successRate,jdbcType=VARCHAR}
            </if>
        </trim>
    </select>
    <select id="getPlanId" resultType="java.lang.String">
        select plan_id from dw_atu_plan_batch where id=#{batchId}
    </select>

</mapper>