<?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.MtCaseExecOverallDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.MtCaseExecOverall">
      <!--  -->
    <id column="id" jdbcType="BIGINT" property="id"/>
                                  <!-- 子节点目录名 -->
    <result column="dir_name" jdbcType="VARCHAR" property="dirName"/>
        <!-- 计划执行：目录计划执行的总数 -->
    <result column="plan_exec" jdbcType="INTEGER" property="planExec"/>
        <!-- 已执行：通过+失败 -->
    <result column="executed" jdbcType="INTEGER" property="executed"/>
        <!-- 通过 -->
    <result column="pass" jdbcType="INTEGER" property="pass"/>
        <!-- 未通过 -->
    <result column="not_pass" jdbcType="INTEGER" property="notPass"/>
        <!-- 未完成 -->
    <result column="unfinished" jdbcType="INTEGER" property="unfinished"/>
        <!-- 受阻执行 -->
    <result column="blocked_exec" jdbcType="INTEGER" property="blockedExec"/>
        <!-- 案例执行率：已执行案例数/计划执行案例数 -->
    <result column="case_exec_rate" jdbcType="VARCHAR" property="caseExecRate"/>
        <!-- 案例通过率：执行通过的案例数/已执行案例数 -->
    <result column="case_pass_rate" jdbcType="VARCHAR" property="casePassRate"/>
        <!-- 系统id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 无效 -->
    <result column="invalid" jdbcType="INTEGER" property="invalid"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,dir_name
    ,plan_exec
    ,executed
    ,pass
    ,not_pass
    ,unfinished
    ,blocked_exec
    ,case_exec_rate
    ,case_pass_rate
    ,project_id
    ,tenant_id
    ,invalid
  </sql>

  <sql id="Table_Name">
    mt_case_exec_overall
  </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.MtCaseExecOverall">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="dirName != null">
          AND dir_name=#{dirName,jdbcType=VARCHAR}
      </if>
      <if test="planExec != null">
          AND plan_exec=#{planExec,jdbcType=INTEGER}
      </if>
      <if test="executed != null">
          AND executed=#{executed,jdbcType=INTEGER}
      </if>
      <if test="pass != null">
          AND pass=#{pass,jdbcType=INTEGER}
      </if>
      <if test="notPass != null">
          AND not_pass=#{notPass,jdbcType=INTEGER}
      </if>
      <if test="unfinished != null">
          AND unfinished=#{unfinished,jdbcType=INTEGER}
      </if>
      <if test="blockedExec != null">
          AND blocked_exec=#{blockedExec,jdbcType=INTEGER}
      </if>
      <if test="caseExecRate != null">
          AND case_exec_rate=#{caseExecRate,jdbcType=VARCHAR}
      </if>
      <if test="casePassRate != null">
          AND case_pass_rate=#{casePassRate,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="invalid != null">
        AND invalid=#{invalid,jdbcType=INTEGER}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.MtCaseExecOverall">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="dirName != null">
        dir_name,
      </if>
      <if test="planExec != null">
        plan_exec,
      </if>
      <if test="executed != null">
        executed,
      </if>
      <if test="pass != null">
        pass,
      </if>
      <if test="notPass != null">
        not_pass,
      </if>
      <if test="unfinished != null">
        unfinished,
      </if>
      <if test="blockedExec != null">
        blocked_exec,
      </if>
      <if test="caseExecRate != null">
        case_exec_rate,
      </if>
      <if test="casePassRate != null">
        case_pass_rate,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="invalid != null">
        invalid,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=BIGINT},
      </if>
      <if test="dirName != null">
          #{dirName, jdbcType=VARCHAR},
      </if>
      <if test="planExec != null">
          #{planExec, jdbcType=INTEGER},
      </if>
      <if test="executed != null">
          #{executed, jdbcType=INTEGER},
      </if>
      <if test="pass != null">
          #{pass, jdbcType=INTEGER},
      </if>
      <if test="notPass != null">
          #{notPass, jdbcType=INTEGER},
      </if>
      <if test="unfinished != null">
          #{unfinished, jdbcType=INTEGER},
      </if>
      <if test="blockedExec != null">
          #{blockedExec, jdbcType=INTEGER},
      </if>
      <if test="caseExecRate != null">
          #{caseExecRate, jdbcType=VARCHAR},
      </if>
      <if test="casePassRate != null">
          #{casePassRate, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="invalid != null">
        #{invalid, jdbcType=INTEGER},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    dir_name,
    plan_exec,
    executed,
    pass,
    not_pass,
    unfinished,
    blocked_exec,
    case_exec_rate,
    case_pass_rate,
    project_id,
    tenant_id,
      invalid,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=BIGINT},
    #{item.dirName, jdbcType=VARCHAR},
    #{item.planExec, jdbcType=INTEGER},
    #{item.executed, jdbcType=INTEGER},
    #{item.pass, jdbcType=INTEGER},
    #{item.notPass, jdbcType=INTEGER},
    #{item.unfinished, jdbcType=INTEGER},
    #{item.blockedExec, jdbcType=INTEGER},
    #{item.caseExecRate, jdbcType=VARCHAR},
    #{item.casePassRate, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
        #{item.invalid, jdbcType=INTEGER},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.MtCaseExecOverall">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="dirName != null">
        dir_name = #{dirName, jdbcType=VARCHAR},
      </if>
      <if test="planExec != null">
        plan_exec = #{planExec, jdbcType=INTEGER},
      </if>
      <if test="executed != null">
        executed = #{executed, jdbcType=INTEGER},
      </if>
      <if test="pass != null">
        pass = #{pass, jdbcType=INTEGER},
      </if>
      <if test="notPass != null">
        not_pass = #{notPass, jdbcType=INTEGER},
      </if>
      <if test="unfinished != null">
        unfinished = #{unfinished, jdbcType=INTEGER},
      </if>
      <if test="blockedExec != null">
        blocked_exec = #{blockedExec, jdbcType=INTEGER},
      </if>
      <if test="caseExecRate != null">
        case_exec_rate = #{caseExecRate, jdbcType=VARCHAR},
      </if>
      <if test="casePassRate != null">
        case_pass_rate = #{casePassRate, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="invalid != null">
        invalid = #{invalid, 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.MtCaseExecOverall">
    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="dirName != null">
        AND dir_name = #{dirName,jdbcType=VARCHAR}
      </if>
      <if test="planExec != null">
        AND plan_exec = #{planExec,jdbcType=INTEGER}
      </if>
      <if test="executed != null">
        AND executed = #{executed,jdbcType=INTEGER}
      </if>
      <if test="pass != null">
        AND pass = #{pass,jdbcType=INTEGER}
      </if>
      <if test="notPass != null">
        AND not_pass = #{notPass,jdbcType=INTEGER}
      </if>
      <if test="unfinished != null">
        AND unfinished = #{unfinished,jdbcType=INTEGER}
      </if>
      <if test="blockedExec != null">
        AND blocked_exec = #{blockedExec,jdbcType=INTEGER}
      </if>
      <if test="caseExecRate != null">
        AND case_exec_rate = #{caseExecRate,jdbcType=VARCHAR}
      </if>
      <if test="casePassRate != null">
        AND case_pass_rate = #{casePassRate,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="invalid != null">
        AND invalid = #{invalid,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.MtCaseExecOverall">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="dirName != null">
        AND dir_name=#{dirName,jdbcType=VARCHAR}
      </if>
      <if test="planExec != null">
        AND plan_exec=#{planExec,jdbcType=INTEGER}
      </if>
      <if test="executed != null">
        AND executed=#{executed,jdbcType=INTEGER}
      </if>
      <if test="pass != null">
        AND pass=#{pass,jdbcType=INTEGER}
      </if>
      <if test="notPass != null">
        AND not_pass=#{notPass,jdbcType=INTEGER}
      </if>
      <if test="unfinished != null">
        AND unfinished=#{unfinished,jdbcType=INTEGER}
      </if>
      <if test="blockedExec != null">
        AND blocked_exec=#{blockedExec,jdbcType=INTEGER}
      </if>
      <if test="caseExecRate != null">
        AND case_exec_rate=#{caseExecRate,jdbcType=VARCHAR}
      </if>
      <if test="casePassRate != null">
        AND case_pass_rate=#{casePassRate,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="invalid != null">
        AND invalid=#{invalid,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

</mapper>