<?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.MtTestChartDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.MtTestChart">
      <!-- 主键id -->
    <id column="id" jdbcType="BIGINT" property="id"/>
                            <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 日期 -->
    <result column="record_date" jdbcType="DATE" property="recordDate"/>
        <!-- 累计计划数量 -->
    <result column="total_plan" jdbcType="INTEGER" property="totalPlan"/>
        <!-- 实际数量 -->
    <result column="total_actual" jdbcType="INTEGER" property="totalActual"/>
        <!-- 计划进度 -->
    <result column="percent_plan" jdbcType="DOUBLE" property="percentPlan"/>
        <!-- 实际进度 -->
    <result column="percent_actual" jdbcType="DOUBLE" property="percentActual"/>
        <!-- 系统进度：1、用例设计进度；2、需求分析进度；3、用例执行进度；4、总体测试进度 -->
    <result column="test_type" jdbcType="INTEGER" property="testType"/>
        <!--  -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,tenant_id
    ,record_date
    ,total_plan
    ,total_actual
    ,percent_plan
    ,percent_actual
    ,test_type
    ,project_id
  </sql>

  <sql id="Table_Name">
    mt_test_chart
  </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.MtTestChart">
    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="recordDate != null">
          AND record_date=#{recordDate,jdbcType=DATE}
      </if>
      <if test="totalPlan != null">
          AND total_plan=#{totalPlan,jdbcType=INTEGER}
      </if>
      <if test="totalActual != null">
          AND total_actual=#{totalActual,jdbcType=INTEGER}
      </if>
      <if test="percentPlan != null">
          AND percent_plan=#{percentPlan,jdbcType=DOUBLE}
      </if>
      <if test="percentActual != null">
          AND percent_actual=#{percentActual,jdbcType=DOUBLE}
      </if>
      <if test="testType != null">
          AND test_type=#{testType,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.MtTestChart">
    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="recordDate != null">
        record_date,
      </if>
      <if test="totalPlan != null">
        total_plan,
      </if>
      <if test="totalActual != null">
        total_actual,
      </if>
      <if test="percentPlan != null">
        percent_plan,
      </if>
      <if test="percentActual != null">
        percent_actual,
      </if>
      <if test="testType != null">
        test_type,
      </if>
      <if test="projectId != null">
        project_id,
      </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="recordDate != null">
          #{recordDate, jdbcType=DATE},
      </if>
      <if test="totalPlan != null">
          #{totalPlan, jdbcType=INTEGER},
      </if>
      <if test="totalActual != null">
          #{totalActual, jdbcType=INTEGER},
      </if>
      <if test="percentPlan != null">
          #{percentPlan, jdbcType=DOUBLE},
      </if>
      <if test="percentActual != null">
          #{percentActual, jdbcType=DOUBLE},
      </if>
      <if test="testType != null">
          #{testType, jdbcType=INTEGER},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    tenant_id,
    record_date,
    total_plan,
    total_actual,
    percent_plan,
    percent_actual,
    test_type,
    project_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=BIGINT},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.recordDate, jdbcType=DATE},
    #{item.totalPlan, jdbcType=INTEGER},
    #{item.totalActual, jdbcType=INTEGER},
    #{item.percentPlan, jdbcType=DOUBLE},
    #{item.percentActual, jdbcType=DOUBLE},
    #{item.testType, jdbcType=INTEGER},
    #{item.projectId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.MtTestChart">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="recordDate != null">
        record_date = #{recordDate, jdbcType=DATE},
      </if>
      <if test="totalPlan != null">
        total_plan = #{totalPlan, jdbcType=INTEGER},
      </if>
      <if test="totalActual != null">
        total_actual = #{totalActual, jdbcType=INTEGER},
      </if>
      <if test="percentPlan != null">
        percent_plan = #{percentPlan, jdbcType=DOUBLE},
      </if>
      <if test="percentActual != null">
        percent_actual = #{percentActual, jdbcType=DOUBLE},
      </if>
      <if test="testType != null">
        test_type = #{testType, jdbcType=INTEGER},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </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.MtTestChart">
    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="recordDate != null">
        AND record_date = #{recordDate,jdbcType=DATE}
      </if>
      <if test="totalPlan != null">
        AND total_plan = #{totalPlan,jdbcType=INTEGER}
      </if>
      <if test="totalActual != null">
        AND total_actual = #{totalActual,jdbcType=INTEGER}
      </if>
      <if test="percentPlan != null">
        AND percent_plan = #{percentPlan,jdbcType=DOUBLE}
      </if>
      <if test="percentActual != null">
        AND percent_actual = #{percentActual,jdbcType=DOUBLE}
      </if>
      <if test="testType != null">
        AND test_type = #{testType,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.MtTestChart">
    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="recordDate != null">
        AND record_date=#{recordDate,jdbcType=DATE}
      </if>
      <if test="totalPlan != null">
        AND total_plan=#{totalPlan,jdbcType=INTEGER}
      </if>
      <if test="totalActual != null">
        AND total_actual=#{totalActual,jdbcType=INTEGER}
      </if>
      <if test="percentPlan != null">
        AND percent_plan=#{percentPlan,jdbcType=DOUBLE}
      </if>
      <if test="percentActual != null">
        AND percent_actual=#{percentActual,jdbcType=DOUBLE}
      </if>
      <if test="testType != null">
        AND test_type=#{testType,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>