<?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">
<mapper namespace="com.chinaitop.depot.intelligent.grainsituation.mapper.TTestdataPointsMapper">
  <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPoints">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="org_id" jdbcType="VARCHAR" property="orgId" />
    <result column="cfbh" jdbcType="VARCHAR" property="cfbh" />
    <result column="points_time" jdbcType="TIMESTAMP" property="pointsTime" />
    <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPoints">
    <result column="str_points" jdbcType="LONGVARCHAR" property="strPoints" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, org_id, cfbh, points_time, updatetime
  </sql>
  <sql id="Blob_Column_List">
    str_points
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPointsExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from t_testdata_points
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPointsExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from t_testdata_points
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from t_testdata_points
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from t_testdata_points
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPointsExample">
    delete from t_testdata_points
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPoints">
    insert into t_testdata_points (id, org_id, cfbh, 
      points_time, updatetime, str_points
      )
    values (#{id,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, #{cfbh,jdbcType=VARCHAR}, 
      #{pointsTime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP}, #{strPoints,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPoints">
    insert into t_testdata_points
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="orgId != null">
        org_id,
      </if>
      <if test="cfbh != null">
        cfbh,
      </if>
      <if test="pointsTime != null">
        points_time,
      </if>
      <if test="updatetime != null">
        updatetime,
      </if>
      <if test="strPoints != null">
        str_points,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="orgId != null">
        #{orgId,jdbcType=VARCHAR},
      </if>
      <if test="cfbh != null">
        #{cfbh,jdbcType=VARCHAR},
      </if>
      <if test="pointsTime != null">
        #{pointsTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updatetime != null">
        #{updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="strPoints != null">
        #{strPoints,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPointsExample" resultType="java.lang.Integer">
    select count(*) from t_testdata_points
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update t_testdata_points
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.orgId != null">
        org_id = #{record.orgId,jdbcType=VARCHAR},
      </if>
      <if test="record.cfbh != null">
        cfbh = #{record.cfbh,jdbcType=VARCHAR},
      </if>
      <if test="record.pointsTime != null">
        points_time = #{record.pointsTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updatetime != null">
        updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.strPoints != null">
        str_points = #{record.strPoints,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update t_testdata_points
    set id = #{record.id,jdbcType=VARCHAR},
      org_id = #{record.orgId,jdbcType=VARCHAR},
      cfbh = #{record.cfbh,jdbcType=VARCHAR},
      points_time = #{record.pointsTime,jdbcType=TIMESTAMP},
      updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
      str_points = #{record.strPoints,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update t_testdata_points
    set id = #{record.id,jdbcType=VARCHAR},
      org_id = #{record.orgId,jdbcType=VARCHAR},
      cfbh = #{record.cfbh,jdbcType=VARCHAR},
      points_time = #{record.pointsTime,jdbcType=TIMESTAMP},
      updatetime = #{record.updatetime,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPoints">
    update t_testdata_points
    <set>
      <if test="orgId != null">
        org_id = #{orgId,jdbcType=VARCHAR},
      </if>
      <if test="cfbh != null">
        cfbh = #{cfbh,jdbcType=VARCHAR},
      </if>
      <if test="pointsTime != null">
        points_time = #{pointsTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updatetime != null">
        updatetime = #{updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="strPoints != null">
        str_points = #{strPoints,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPoints">
    update t_testdata_points
    set org_id = #{orgId,jdbcType=VARCHAR},
      cfbh = #{cfbh,jdbcType=VARCHAR},
      points_time = #{pointsTime,jdbcType=TIMESTAMP},
      updatetime = #{updatetime,jdbcType=TIMESTAMP},
      str_points = #{strPoints,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataPoints">
    update t_testdata_points
    set org_id = #{orgId,jdbcType=VARCHAR},
      cfbh = #{cfbh,jdbcType=VARCHAR},
      points_time = #{pointsTime,jdbcType=TIMESTAMP},
      updatetime = #{updatetime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <insert id="insertBatch" parameterType="java.util.List">
    <foreach collection="list" item="th" index="index" separator=";">
      insert into t_testdata_points (id, org_id, cfbh, points_time, str_points) values
      (#{th.id,jdbcType=VARCHAR}, #{th.orgId,jdbcType=VARCHAR}, #{th.cfbh,jdbcType=VARCHAR},
      #{th.pointsTime,jdbcType=TIMESTAMP}, #{th.strPoints,jdbcType=LONGVARCHAR})
    </foreach>
  </insert>
  <select id="test" resultType="java.util.Map" parameterType="java.util.Map">
    select a.id, a.org_id, a.storehouse, a.t_time, a.t_points from t_testdata a
    left join t_testdata_points b on a.id=b.id
    where 1=1
    and a.org_id is not null
    and b.id is null
    <if test="orgId != null">
      and a.org_id=#{orgId, jdbcType=VARCHAR}
    </if>
    order by a.t_time desc
  </select>
</mapper>