<?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.TCcdataMapper" >
  <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.grainsituation.model.TCcdata" >
    <result column="id" property="id" jdbcType="VARCHAR" />
    <result column="org_id" property="orgId" jdbcType="VARCHAR" />
    <result column="v_cc_code" property="vCcCode" jdbcType="VARCHAR" />
    <result column="v_hw_code" property="vHwCode" jdbcType="VARCHAR" />
    <result column="stand_or" property="standOr" jdbcType="VARCHAR" />
    <result column="stand_time" property="standTime" jdbcType="TIMESTAMP" />
    <result column="i_tdh" property="iTdh" jdbcType="INTEGER" />
    <result column="i_value" property="iValue" jdbcType="INTEGER" />
    <result column="v_update_time" property="vUpdateTime" jdbcType="TIMESTAMP" />
    <result column="v_update_people" property="vUpdatePeople" jdbcType="VARCHAR" />
    <result column="data_source" property="dataSource" jdbcType="VARCHAR" />
    <result column="v_remark" property="vRemark" jdbcType="VARCHAR" />
    <result column="updatetime" property="updatetime" jdbcType="TIMESTAMP" />
    <result column="jchcff" property="jchcff" jdbcType="VARCHAR" />
    <result column="hczl" property="hczl" jdbcType="VARCHAR" />
    <result column="cldjpd" property="cldjpd" jdbcType="VARCHAR" />
    <result column="hckyxfx" property="hckyxfx" jdbcType="VARCHAR" />
    <result column="fsbw" property="fsbw" jdbcType="VARCHAR" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.chinaitop.depot.intelligent.grainsituation.model.TCcdata" extends="BaseResultMap" >
    <result column="c_image" property="cImage" jdbcType="LONGVARBINARY" />
    <result column="ckmdzjh" property="ckmdzjh" jdbcType="LONGVARBINARY" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" 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="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    id, org_id, v_cc_code, v_hw_code, stand_or, stand_time, i_tdh, i_value, v_update_time, 
    v_update_people, data_source, v_remark, updatetime, jchcff, hczl, cldjpd, hckyxfx, fsbw
  </sql>
  <sql id="Blob_Column_List" >
    c_image, ckmdzjh
  </sql>
  <select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcdataExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from t_ccdata
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcdataExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from t_ccdata
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcdataExample" >
    delete from t_ccdata
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcdata" >
    insert into t_ccdata (id, org_id, v_cc_code, 
      v_hw_code, stand_or, stand_time, 
      i_tdh, i_value, v_update_time, 
      v_update_people, data_source, v_remark, 
      updatetime, jchcff, hczl, 
      cldjpd, hckyxfx, c_image, ckmdzjh,fsbw
      )
    values (#{id,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, #{vCcCode,jdbcType=VARCHAR}, 
      #{vHwCode,jdbcType=VARCHAR}, #{standOr,jdbcType=VARCHAR}, #{standTime,jdbcType=TIMESTAMP}, 
      #{iTdh,jdbcType=INTEGER}, #{iValue,jdbcType=INTEGER}, #{vUpdateTime,jdbcType=TIMESTAMP}, 
      #{vUpdatePeople,jdbcType=VARCHAR}, #{dataSource,jdbcType=VARCHAR}, #{vRemark,jdbcType=VARCHAR}, 
      #{updatetime,jdbcType=TIMESTAMP}, #{jchcff,jdbcType=VARCHAR}, #{hczl,jdbcType=VARCHAR}, 
      #{cldjpd,jdbcType=VARCHAR}, #{hckyxfx,jdbcType=VARCHAR}, #{cImage,jdbcType=LONGVARBINARY},
      #{ckmdzjh,jdbcType=LONGVARBINARY},#{fsbw,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcdata" >
    insert into t_ccdata
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="orgId != null" >
        org_id,
      </if>
      <if test="vCcCode != null" >
        v_cc_code,
      </if>
      <if test="vHwCode != null" >
        v_hw_code,
      </if>
      <if test="standOr != null" >
        stand_or,
      </if>
      <if test="standTime != null" >
        stand_time,
      </if>
      <if test="iTdh != null" >
        i_tdh,
      </if>
      <if test="iValue != null" >
        i_value,
      </if>
      <if test="vUpdateTime != null" >
        v_update_time,
      </if>
      <if test="vUpdatePeople != null" >
        v_update_people,
      </if>
      <if test="dataSource != null" >
        data_source,
      </if>
      <if test="vRemark != null" >
        v_remark,
      </if>
      <if test="updatetime != null" >
        updatetime,
      </if>
      <if test="jchcff != null" >
        jchcff,
      </if>
      <if test="hczl != null" >
        hczl,
      </if>
      <if test="cldjpd != null" >
        cldjpd,
      </if>
      <if test="hckyxfx != null" >
        hckyxfx,
      </if>
      <if test="cImage != null" >
        c_image,
      </if>
      <if test="ckmdzjh != null" >
        ckmdzjh,
      </if>
      <if test="fsbw != null">
        fsbw,
      </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="vCcCode != null" >
        #{vCcCode,jdbcType=VARCHAR},
      </if>
      <if test="vHwCode != null" >
        #{vHwCode,jdbcType=VARCHAR},
      </if>
      <if test="standOr != null" >
        #{standOr,jdbcType=VARCHAR},
      </if>
      <if test="standTime != null" >
        #{standTime,jdbcType=TIMESTAMP},
      </if>
      <if test="iTdh != null" >
        #{iTdh,jdbcType=INTEGER},
      </if>
      <if test="iValue != null" >
        #{iValue,jdbcType=INTEGER},
      </if>
      <if test="vUpdateTime != null" >
        #{vUpdateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="vUpdatePeople != null" >
        #{vUpdatePeople,jdbcType=VARCHAR},
      </if>
      <if test="dataSource != null" >
        #{dataSource,jdbcType=VARCHAR},
      </if>
      <if test="vRemark != null" >
        #{vRemark,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null" >
        #{updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="jchcff != null" >
        #{jchcff,jdbcType=VARCHAR},
      </if>
      <if test="hczl != null" >
        #{hczl,jdbcType=VARCHAR},
      </if>
      <if test="cldjpd != null" >
        #{cldjpd,jdbcType=VARCHAR},
      </if>
      <if test="hckyxfx != null" >
        #{hckyxfx,jdbcType=VARCHAR},
      </if>
      <if test="cImage != null" >
        #{cImage,jdbcType=LONGVARBINARY},
      </if>
      <if test="ckmdzjh != null" >
        #{ckmdzjh,jdbcType=LONGVARBINARY},
      </if>
      <if test="fsbw != null">
        #{fsbw,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcdataExample" resultType="java.lang.Integer" >
    select count(*) from t_ccdata
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update t_ccdata
    <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.vCcCode != null" >
        v_cc_code = #{record.vCcCode,jdbcType=VARCHAR},
      </if>
      <if test="record.vHwCode != null" >
        v_hw_code = #{record.vHwCode,jdbcType=VARCHAR},
      </if>
      <if test="record.standOr != null" >
        stand_or = #{record.standOr,jdbcType=VARCHAR},
      </if>
      <if test="record.standTime != null" >
        stand_time = #{record.standTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.iTdh != null" >
        i_tdh = #{record.iTdh,jdbcType=INTEGER},
      </if>
      <if test="record.iValue != null" >
        i_value = #{record.iValue,jdbcType=INTEGER},
      </if>
      <if test="record.vUpdateTime != null" >
        v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.vUpdatePeople != null" >
        v_update_people = #{record.vUpdatePeople,jdbcType=VARCHAR},
      </if>
      <if test="record.dataSource != null" >
        data_source = #{record.dataSource,jdbcType=VARCHAR},
      </if>
      <if test="record.vRemark != null" >
        v_remark = #{record.vRemark,jdbcType=VARCHAR},
      </if>
      <if test="record.updatetime != null" >
        updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.jchcff != null" >
        jchcff = #{record.jchcff,jdbcType=VARCHAR},
      </if>
      <if test="record.hczl != null" >
        hczl = #{record.hczl,jdbcType=VARCHAR},
      </if>
      <if test="record.cldjpd != null" >
        cldjpd = #{record.cldjpd,jdbcType=VARCHAR},
      </if>
      <if test="record.hckyxfx != null" >
        hckyxfx = #{record.hckyxfx,jdbcType=VARCHAR},
      </if>
      <if test="record.cImage != null" >
        c_image = #{record.cImage,jdbcType=LONGVARBINARY},
      </if>
      <if test="record.ckmdzjh != null" >
        ckmdzjh = #{record.ckmdzjh,jdbcType=LONGVARBINARY},
      </if>
      <if test="record.fsbw != null">
        fsbw = #{record.fsbw,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map" >
    update t_ccdata
    set id = #{record.id,jdbcType=VARCHAR},
      org_id = #{record.orgId,jdbcType=VARCHAR},
      v_cc_code = #{record.vCcCode,jdbcType=VARCHAR},
      v_hw_code = #{record.vHwCode,jdbcType=VARCHAR},
      stand_or = #{record.standOr,jdbcType=VARCHAR},
      stand_time = #{record.standTime,jdbcType=TIMESTAMP},
      i_tdh = #{record.iTdh,jdbcType=INTEGER},
      i_value = #{record.iValue,jdbcType=INTEGER},
      v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP},
      v_update_people = #{record.vUpdatePeople,jdbcType=VARCHAR},
      data_source = #{record.dataSource,jdbcType=VARCHAR},
      v_remark = #{record.vRemark,jdbcType=VARCHAR},
      updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
      jchcff = #{record.jchcff,jdbcType=VARCHAR},
      hczl = #{record.hczl,jdbcType=VARCHAR},
      cldjpd = #{record.cldjpd,jdbcType=VARCHAR},
      hckyxfx = #{record.hckyxfx,jdbcType=VARCHAR},
      c_image = #{record.cImage,jdbcType=LONGVARBINARY},
      ckmdzjh = #{record.ckmdzjh,jdbcType=LONGVARBINARY},
      fsbw = #{record.fsbw,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update t_ccdata
    set id = #{record.id,jdbcType=VARCHAR},
      org_id = #{record.orgId,jdbcType=VARCHAR},
      v_cc_code = #{record.vCcCode,jdbcType=VARCHAR},
      v_hw_code = #{record.vHwCode,jdbcType=VARCHAR},
      stand_or = #{record.standOr,jdbcType=VARCHAR},
      stand_time = #{record.standTime,jdbcType=TIMESTAMP},
      i_tdh = #{record.iTdh,jdbcType=INTEGER},
      i_value = #{record.iValue,jdbcType=INTEGER},
      v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP},
      v_update_people = #{record.vUpdatePeople,jdbcType=VARCHAR},
      data_source = #{record.dataSource,jdbcType=VARCHAR},
      v_remark = #{record.vRemark,jdbcType=VARCHAR},
      updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
      jchcff = #{record.jchcff,jdbcType=VARCHAR},
      hczl = #{record.hczl,jdbcType=VARCHAR},
      cldjpd = #{record.cldjpd,jdbcType=VARCHAR},
      hckyxfx = #{record.hckyxfx,jdbcType=VARCHAR},
      fsbw = #{record.fsbw,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>

  <insert id="insertBatch" parameterType="java.util.List">
    insert into t_ccdata (id, org_id, v_cc_code,
    i_tdh, i_value, v_update_time,
    data_source, v_remark, c_image
    )
    values
    <foreach collection="list" item="cc" index="index" separator=",">
      (#{cc.id,jdbcType=VARCHAR}, #{cc.orgId,jdbcType=VARCHAR}, #{cc.vCcCode,jdbcType=VARCHAR},
      #{cc.iTdh,jdbcType=INTEGER}, #{cc.iValue,jdbcType=INTEGER}, #{cc.vUpdateTime,jdbcType=TIMESTAMP},
      #{cc.dataSource,jdbcType=VARCHAR}, #{cc.vRemark,jdbcType=VARCHAR}, #{cc.cImage,jdbcType=LONGVARBINARY}
      )
    </foreach>
  </insert>

  <select id="getList" resultType="java.util.Map" parameterType="java.util.Map">
    SELECT
    td.id AS id,
    tv.v_cf_code AS vcfcode,
    td.v_hw_code AS vhwid,
    td.stand_or AS standor,
    td.stand_time AS standtime,
    td.i_tdh AS itdh,
    td.hczl AS hczl,
    td.i_value AS ivalue,
    td.v_update_people AS vupdatepeople,
    td.v_update_time AS vupdatetime,
    tv.hcjcdh AS hcjcdh,
    td.ckmdzjh as ckmdzjh,
    td.fsbw as fsbw
    FROM
    t_ccdata td
    LEFT JOIN t_ccvalue tv ON td.v_update_time = tv.v_update_time
    WHERE td.org_id = #{orgId} and td.v_cc_code = tv.v_cc_code
    <if test="iBeginTdh != null and test=iEndTdh != null">
      and td.i_tdh BETWEEN #{iBeginTdh, jdbcType=INTEGER} AND #{iEndTdh, jdbcType=INTEGER}
    </if>
    <if test="vCfCode != null">
      and tv.v_cf_code = #{vCfCode}
    </if>
    <if test="createTime != null">
      AND td.v_update_time &lt; #{createTime}
    </if>
    ORDER BY td.v_update_time DESC
  </select>
</mapper>