<?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 2024 . All rights reserved. -->
<!--  Mybatis数据库持久层（底层映射文件）：任务执行记录表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2024-10-16 17:02:48  -->
<mapper namespace="net.northking.cctp.executePlan.db.dao.AtuPlanTaskRecordDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.executePlan.db.entity.AtuPlanTaskRecord">
      <!-- 记录id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                <!-- 任务id -->
    <result column="task_id" jdbcType="VARCHAR" property="taskId"/>
        <!-- 批次id -->
    <result column="batch_id" jdbcType="VARCHAR" property="batchId"/>
        <!-- 执行序号 -->
    <result column="exec_idx" jdbcType="INTEGER" property="execIdx"/>
        <!-- 开始时间 -->
    <result column="start_time" jdbcType="BIGINT" property="startTime"/>
        <!-- 结束时间 -->
    <result column="end_time" jdbcType="BIGINT" property="endTime"/>
        <!-- 执行类型，0-正常执行|1-自动重试|2-手动重试 -->
    <result column="execute_type" jdbcType="VARCHAR" property="executeType"/>
        <!-- 状态 -->
    <result column="status" jdbcType="VARCHAR" property="status"/>
        <!-- 错误信息 -->
    <result column="error_msg" jdbcType="LONGVARCHAR" property="errorMsg"/>
        <!-- 视频地址 -->
    <result column="video_url" jdbcType="VARCHAR" property="videoUrl"/>
        <!-- 执行结果文件 -->
    <result column="exec_result_file" jdbcType="VARCHAR" property="execResultFile"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,task_id
    ,batch_id
    ,exec_idx
    ,start_time
    ,end_time
    ,execute_type
    ,status
    ,error_msg
    ,video_url
    ,exec_result_file
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.atu_plan_task_record
  </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.executePlan.db.entity.AtuPlanTaskRecord">
    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="taskId != null">
          AND task_id=#{taskId,jdbcType=VARCHAR}
        </if>
              <if test="batchId != null">
          AND batch_id=#{batchId,jdbcType=VARCHAR}
        </if>
              <if test="execIdx != null">
          AND exec_idx=#{execIdx,jdbcType=INTEGER}
        </if>
              <if test="startTime != null">
          AND start_time=#{startTime,jdbcType=BIGINT}
        </if>
              <if test="endTime != null">
          AND end_time=#{endTime,jdbcType=BIGINT}
        </if>
              <if test="executeType != null">
          AND execute_type=#{executeType,jdbcType=VARCHAR}
        </if>
              <if test="status != null">
          AND status=#{status,jdbcType=VARCHAR}
        </if>
              <if test="errorMsg != null">
          AND error_msg=#{errorMsg,jdbcType=LONGVARCHAR}
        </if>
              <if test="videoUrl != null">
          AND video_url=#{videoUrl,jdbcType=VARCHAR}
        </if>
              <if test="execResultFile != null">
          AND exec_result_file=#{execResultFile,jdbcType=VARCHAR}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanTaskRecord">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="taskId != null">
        task_id,
      </if>
      <if test="batchId != null">
        batch_id,
      </if>
      <if test="execIdx != null">
        exec_idx,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="executeType != null">
        execute_type,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="errorMsg != null">
        error_msg,
      </if>
      <if test="videoUrl != null">
        video_url,
      </if>
      <if test="execResultFile != null">
        exec_result_file,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="taskId != null">
          #{taskId, jdbcType=VARCHAR},
      </if>
      <if test="batchId != null">
          #{batchId, jdbcType=VARCHAR},
      </if>
      <if test="execIdx != null">
          #{execIdx, jdbcType=INTEGER},
      </if>
      <if test="startTime != null">
          #{startTime, jdbcType=BIGINT},
      </if>
      <if test="endTime != null">
          #{endTime, jdbcType=BIGINT},
      </if>
      <if test="executeType != null">
          #{executeType, jdbcType=VARCHAR},
      </if>
      <if test="status != null">
          #{status, jdbcType=VARCHAR},
      </if>
      <if test="errorMsg != null">
          #{errorMsg, jdbcType=LONGVARCHAR},
      </if>
      <if test="videoUrl != null">
          #{videoUrl, jdbcType=VARCHAR},
      </if>
      <if test="execResultFile != null">
          #{execResultFile, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    task_id,
    batch_id,
    exec_idx,
    start_time,
    end_time,
    execute_type,
    status,
    error_msg,
    video_url,
    exec_result_file,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.taskId, jdbcType=VARCHAR},
    #{item.batchId, jdbcType=VARCHAR},
    #{item.execIdx, jdbcType=INTEGER},
    #{item.startTime, jdbcType=BIGINT},
    #{item.endTime, jdbcType=BIGINT},
    #{item.executeType, jdbcType=VARCHAR},
    #{item.status, jdbcType=VARCHAR},
    #{item.errorMsg, jdbcType=LONGVARCHAR},
    #{item.videoUrl, jdbcType=VARCHAR},
    #{item.execResultFile, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanTaskRecord">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="taskId != null">
        task_id = #{taskId, jdbcType=VARCHAR},
      </if>
      <if test="batchId != null">
        batch_id = #{batchId, jdbcType=VARCHAR},
      </if>
      <if test="execIdx != null">
        exec_idx = #{execIdx, jdbcType=INTEGER},
      </if>
      <if test="startTime != null">
        start_time = #{startTime, jdbcType=BIGINT},
      </if>
      <if test="endTime != null">
        end_time = #{endTime, jdbcType=BIGINT},
      </if>
      <if test="executeType != null">
        execute_type = #{executeType, jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        status = #{status, jdbcType=VARCHAR},
      </if>
      <if test="errorMsg != null">
        error_msg = #{errorMsg, jdbcType=LONGVARCHAR},
      </if>
      <if test="videoUrl != null">
        video_url = #{videoUrl, jdbcType=VARCHAR},
      </if>
      <if test="execResultFile != null">
        exec_result_file = #{execResultFile, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanTaskRecord">
    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="taskId != null">
        AND task_id = #{taskId,jdbcType=VARCHAR}
      </if>
      <if test="batchId != null">
        AND batch_id = #{batchId,jdbcType=VARCHAR}
      </if>
      <if test="execIdx != null">
        AND exec_idx = #{execIdx,jdbcType=INTEGER}
      </if>
      <if test="startTime != null">
        AND start_time = #{startTime,jdbcType=BIGINT}
      </if>
      <if test="endTime != null">
        AND end_time = #{endTime,jdbcType=BIGINT}
      </if>
      <if test="executeType != null">
        AND execute_type = #{executeType,jdbcType=VARCHAR}
      </if>
      <if test="status != null">
        AND status = #{status,jdbcType=VARCHAR}
      </if>
      <if test="errorMsg != null">
        AND error_msg = #{errorMsg,jdbcType=LONGVARCHAR}
      </if>
      <if test="videoUrl != null">
        AND video_url = #{videoUrl,jdbcType=VARCHAR}
      </if>
      <if test="execResultFile != null">
        AND exec_result_file = #{execResultFile,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanTaskRecord">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="taskId != null">
        AND task_id=#{taskId,jdbcType=VARCHAR}
      </if>
      <if test="batchId != null">
        AND batch_id=#{batchId,jdbcType=VARCHAR}
      </if>
      <if test="execIdx != null">
        AND exec_idx=#{execIdx,jdbcType=INTEGER}
      </if>
      <if test="startTime != null">
        AND start_time=#{startTime,jdbcType=BIGINT}
      </if>
      <if test="endTime != null">
        AND end_time=#{endTime,jdbcType=BIGINT}
      </if>
      <if test="executeType != null">
        AND execute_type=#{executeType,jdbcType=VARCHAR}
      </if>
      <if test="status != null">
        AND status=#{status,jdbcType=VARCHAR}
      </if>
      <if test="errorMsg != null">
        AND error_msg=#{errorMsg,jdbcType=LONGVARCHAR}
      </if>
      <if test="videoUrl != null">
        AND video_url=#{videoUrl,jdbcType=VARCHAR}
      </if>
      <if test="execResultFile != null">
        AND exec_result_file=#{execResultFile,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>