<?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-01-21 10:29:37  -->
<mapper namespace="net.northking.cctp.dw.db.dao.MidManualExecJobDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.MidManualExecJob">
      <!--  -->
    <id column="id" jdbcType="BIGINT" property="id"/>
                                  <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 系统id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 执行时间 -->
    <result column="created_time" jdbcType="DATE" property="createdTime"/>
        <!-- 总数 -->
    <result column="total" jdbcType="INTEGER" property="total"/>
        <!-- 未执行数量 -->
    <result column="non_exec" jdbcType="INTEGER" property="nonExec"/>
        <!-- 无效数量 -->
    <result column="invalid" jdbcType="INTEGER" property="invalid"/>
        <!-- 失败数量 -->
    <result column="fail" jdbcType="INTEGER" property="fail"/>
        <!-- 阻塞数量 -->
    <result column="blocked" jdbcType="INTEGER" property="blocked"/>
        <!-- 挂起数量 -->
    <result column="hang_up" jdbcType="INTEGER" property="hangUp"/>
        <!-- 未完成数量 -->
    <result column="unfinished" jdbcType="INTEGER" property="unfinished"/>
        <!-- 通过数量 -->
    <result column="pass" jdbcType="INTEGER" property="pass"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,tenant_id
    ,project_id
    ,created_time
    ,total
    ,non_exec
    ,invalid
    ,fail
    ,blocked
    ,hang_up
    ,unfinished
    ,pass
  </sql>

  <sql id="Table_Name">
    mid_manual_exec_job
  </sql>

  <select id="findByPrimaryKey" parameterType="Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=BIGINT}
  </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=BIGINT}
    </foreach>
  </select>

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

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

  <delete id="deleteByExample" parameterType="net.northking.cctp.dw.db.entity.MidManualExecJob">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=DATE}
      </if>
      <if test="total != null">
          AND total=#{total,jdbcType=INTEGER}
      </if>
      <if test="nonExec != null">
          AND non_exec=#{nonExec,jdbcType=INTEGER}
      </if>
      <if test="invalid != null">
          AND invalid=#{invalid,jdbcType=INTEGER}
      </if>
      <if test="fail != null">
          AND fail=#{fail,jdbcType=INTEGER}
      </if>
      <if test="blocked != null">
          AND blocked=#{blocked,jdbcType=INTEGER}
      </if>
      <if test="hangUp != null">
          AND hang_up=#{hangUp,jdbcType=INTEGER}
      </if>
      <if test="unfinished != null">
          AND unfinished=#{unfinished,jdbcType=INTEGER}
      </if>
      <if test="pass != null">
          AND pass=#{pass,jdbcType=INTEGER}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.MidManualExecJob">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="total != null">
        total,
      </if>
      <if test="nonExec != null">
        non_exec,
      </if>
      <if test="invalid != null">
        invalid,
      </if>
      <if test="fail != null">
        fail,
      </if>
      <if test="blocked != null">
        blocked,
      </if>
      <if test="hangUp != null">
        hang_up,
      </if>
      <if test="unfinished != null">
        unfinished,
      </if>
      <if test="pass != null">
        pass,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=BIGINT},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=DATE},
      </if>
      <if test="total != null">
          #{total, jdbcType=INTEGER},
      </if>
      <if test="nonExec != null">
          #{nonExec, jdbcType=INTEGER},
      </if>
      <if test="invalid != null">
          #{invalid, jdbcType=INTEGER},
      </if>
      <if test="fail != null">
          #{fail, jdbcType=INTEGER},
      </if>
      <if test="blocked != null">
          #{blocked, jdbcType=INTEGER},
      </if>
      <if test="hangUp != null">
          #{hangUp, jdbcType=INTEGER},
      </if>
      <if test="unfinished != null">
          #{unfinished, jdbcType=INTEGER},
      </if>
      <if test="pass != null">
          #{pass, jdbcType=INTEGER},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    tenant_id,
    project_id,
    created_time,
    total,
    non_exec,
    invalid,
    fail,
    blocked,
    hang_up,
    unfinished,
    pass,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=BIGINT},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=DATE},
    #{item.total, jdbcType=INTEGER},
    #{item.nonExec, jdbcType=INTEGER},
    #{item.invalid, jdbcType=INTEGER},
    #{item.fail, jdbcType=INTEGER},
    #{item.blocked, jdbcType=INTEGER},
    #{item.hangUp, jdbcType=INTEGER},
    #{item.unfinished, jdbcType=INTEGER},
    #{item.pass, jdbcType=INTEGER},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.MidManualExecJob">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=DATE},
      </if>
      <if test="total != null">
        total = #{total, jdbcType=INTEGER},
      </if>
      <if test="nonExec != null">
        non_exec = #{nonExec, jdbcType=INTEGER},
      </if>
      <if test="invalid != null">
        invalid = #{invalid, jdbcType=INTEGER},
      </if>
      <if test="fail != null">
        fail = #{fail, jdbcType=INTEGER},
      </if>
      <if test="blocked != null">
        blocked = #{blocked, jdbcType=INTEGER},
      </if>
      <if test="hangUp != null">
        hang_up = #{hangUp, jdbcType=INTEGER},
      </if>
      <if test="unfinished != null">
        unfinished = #{unfinished, jdbcType=INTEGER},
      </if>
      <if test="pass != null">
        pass = #{pass, jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
    AND tenant_id = #{tenantId,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.MidManualExecJob">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=BIGINT}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=DATE}
      </if>
      <if test="total != null">
        AND total = #{total,jdbcType=INTEGER}
      </if>
      <if test="nonExec != null">
        AND non_exec = #{nonExec,jdbcType=INTEGER}
      </if>
      <if test="invalid != null">
        AND invalid = #{invalid,jdbcType=INTEGER}
      </if>
      <if test="fail != null">
        AND fail = #{fail,jdbcType=INTEGER}
      </if>
      <if test="blocked != null">
        AND blocked = #{blocked,jdbcType=INTEGER}
      </if>
      <if test="hangUp != null">
        AND hang_up = #{hangUp,jdbcType=INTEGER}
      </if>
      <if test="unfinished != null">
        AND unfinished = #{unfinished,jdbcType=INTEGER}
      </if>
      <if test="pass != null">
        AND pass = #{pass,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.MidManualExecJob">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=DATE}
      </if>
      <if test="total != null">
        AND total=#{total,jdbcType=INTEGER}
      </if>
      <if test="nonExec != null">
        AND non_exec=#{nonExec,jdbcType=INTEGER}
      </if>
      <if test="invalid != null">
        AND invalid=#{invalid,jdbcType=INTEGER}
      </if>
      <if test="fail != null">
        AND fail=#{fail,jdbcType=INTEGER}
      </if>
      <if test="blocked != null">
        AND blocked=#{blocked,jdbcType=INTEGER}
      </if>
      <if test="hangUp != null">
        AND hang_up=#{hangUp,jdbcType=INTEGER}
      </if>
      <if test="unfinished != null">
        AND unfinished=#{unfinished,jdbcType=INTEGER}
      </if>
      <if test="pass != null">
        AND pass=#{pass,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

</mapper>