<?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.ventilation.mapper.TVentilationMapper" >
  <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.ventilation.model.TVentilation" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="org_id" property="orgId" jdbcType="VARCHAR" />
    <result column="v_cf_code" property="vCfCode" jdbcType="VARCHAR" />
    <result column="operation_id" property="operationId" jdbcType="VARCHAR" />
    <result column="v_dev_name" property="vDevName" jdbcType="VARCHAR" />
    <result column="v_device_code" property="vDeviceCode" jdbcType="VARCHAR" />
    <result column="v_pattern" property="vPattern" jdbcType="VARCHAR" />
    <result column="v_start_time" property="vStartTime" jdbcType="TIMESTAMP" />
    <result column="v_end_time" property="vEndTime" jdbcType="TIMESTAMP" />
    <result column="v_distinguish_state" property="vDistinguishState" jdbcType="INTEGER" />
    <result column="v_state" property="vState" jdbcType="INTEGER" />
    <result column="v_update_person" property="vUpdatePerson" jdbcType="VARCHAR" />
    <result column="data_source" property="dataSource" jdbcType="VARCHAR" />
    <result column="v_update_time" property="vUpdateTime" jdbcType="TIMESTAMP" />
  </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_cf_code, operation_id, v_dev_name, v_device_code, v_pattern, v_start_time, 
    v_end_time, v_distinguish_state, v_state, v_update_person, data_source, v_update_time
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.intelligent.ventilation.model.TVentilationExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from t_ventilation
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from t_ventilation
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from t_ventilation
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.ventilation.model.TVentilationExample" >
    delete from t_ventilation
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.chinaitop.depot.intelligent.ventilation.model.TVentilation" >
    insert into t_ventilation (id, org_id, v_cf_code, 
      operation_id, v_dev_name, v_device_code, 
      v_pattern, v_start_time, v_end_time, 
      v_distinguish_state, v_state, v_update_person, 
      data_source, v_update_time)
    values (#{id,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, #{vCfCode,jdbcType=VARCHAR}, 
      #{operationId,jdbcType=VARCHAR}, #{vDevName,jdbcType=VARCHAR}, #{vDeviceCode,jdbcType=VARCHAR}, 
      #{vPattern,jdbcType=VARCHAR}, #{vStartTime,jdbcType=TIMESTAMP}, #{vEndTime,jdbcType=TIMESTAMP}, 
      #{vDistinguishState,jdbcType=INTEGER}, #{vState,jdbcType=INTEGER}, #{vUpdatePerson,jdbcType=VARCHAR}, 
      #{dataSource,jdbcType=VARCHAR}, #{vUpdateTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.ventilation.model.TVentilation" >
    insert into t_ventilation
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="orgId != null" >
        org_id,
      </if>
      <if test="vCfCode != null" >
        v_cf_code,
      </if>
      <if test="operationId != null" >
        operation_id,
      </if>
      <if test="vDevName != null" >
        v_dev_name,
      </if>
      <if test="vDeviceCode != null" >
        v_device_code,
      </if>
      <if test="vPattern != null" >
        v_pattern,
      </if>
      <if test="vStartTime != null" >
        v_start_time,
      </if>
      <if test="vEndTime != null" >
        v_end_time,
      </if>
      <if test="vDistinguishState != null" >
        v_distinguish_state,
      </if>
      <if test="vState != null" >
        v_state,
      </if>
      <if test="vUpdatePerson != null" >
        v_update_person,
      </if>
      <if test="dataSource != null" >
        data_source,
      </if>
      <if test="vUpdateTime != null" >
        v_update_time,
      </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="vCfCode != null" >
        #{vCfCode,jdbcType=VARCHAR},
      </if>
      <if test="operationId != null" >
        #{operationId,jdbcType=VARCHAR},
      </if>
      <if test="vDevName != null" >
        #{vDevName,jdbcType=VARCHAR},
      </if>
      <if test="vDeviceCode != null" >
        #{vDeviceCode,jdbcType=VARCHAR},
      </if>
      <if test="vPattern != null" >
        #{vPattern,jdbcType=VARCHAR},
      </if>
      <if test="vStartTime != null" >
        #{vStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="vEndTime != null" >
        #{vEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="vDistinguishState != null" >
        #{vDistinguishState,jdbcType=INTEGER},
      </if>
      <if test="vState != null" >
        #{vState,jdbcType=INTEGER},
      </if>
      <if test="vUpdatePerson != null" >
        #{vUpdatePerson,jdbcType=VARCHAR},
      </if>
      <if test="dataSource != null" >
        #{dataSource,jdbcType=VARCHAR},
      </if>
      <if test="vUpdateTime != null" >
        #{vUpdateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.ventilation.model.TVentilationExample" resultType="java.lang.Integer" >
    select count(*) from t_ventilation
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update t_ventilation
    <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.vCfCode != null" >
        v_cf_code = #{record.vCfCode,jdbcType=VARCHAR},
      </if>
      <if test="record.operationId != null" >
        operation_id = #{record.operationId,jdbcType=VARCHAR},
      </if>
      <if test="record.vDevName != null" >
        v_dev_name = #{record.vDevName,jdbcType=VARCHAR},
      </if>
      <if test="record.vDeviceCode != null" >
        v_device_code = #{record.vDeviceCode,jdbcType=VARCHAR},
      </if>
      <if test="record.vPattern != null" >
        v_pattern = #{record.vPattern,jdbcType=VARCHAR},
      </if>
      <if test="record.vStartTime != null" >
        v_start_time = #{record.vStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.vEndTime != null" >
        v_end_time = #{record.vEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.vDistinguishState != null" >
        v_distinguish_state = #{record.vDistinguishState,jdbcType=INTEGER},
      </if>
      <if test="record.vState != null" >
        v_state = #{record.vState,jdbcType=INTEGER},
      </if>
      <if test="record.vUpdatePerson != null" >
        v_update_person = #{record.vUpdatePerson,jdbcType=VARCHAR},
      </if>
      <if test="record.dataSource != null" >
        data_source = #{record.dataSource,jdbcType=VARCHAR},
      </if>
      <if test="record.vUpdateTime != null" >
        v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update t_ventilation
    set id = #{record.id,jdbcType=VARCHAR},
      org_id = #{record.orgId,jdbcType=VARCHAR},
      v_cf_code = #{record.vCfCode,jdbcType=VARCHAR},
      operation_id = #{record.operationId,jdbcType=VARCHAR},
      v_dev_name = #{record.vDevName,jdbcType=VARCHAR},
      v_device_code = #{record.vDeviceCode,jdbcType=VARCHAR},
      v_pattern = #{record.vPattern,jdbcType=VARCHAR},
      v_start_time = #{record.vStartTime,jdbcType=TIMESTAMP},
      v_end_time = #{record.vEndTime,jdbcType=TIMESTAMP},
      v_distinguish_state = #{record.vDistinguishState,jdbcType=INTEGER},
      v_state = #{record.vState,jdbcType=INTEGER},
      v_update_person = #{record.vUpdatePerson,jdbcType=VARCHAR},
      data_source = #{record.dataSource,jdbcType=VARCHAR},
      v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.chinaitop.depot.intelligent.ventilation.model.TVentilation" >
    update t_ventilation
    <set >
      <if test="orgId != null" >
        org_id = #{orgId,jdbcType=VARCHAR},
      </if>
      <if test="vCfCode != null" >
        v_cf_code = #{vCfCode,jdbcType=VARCHAR},
      </if>
      <if test="operationId != null" >
        operation_id = #{operationId,jdbcType=VARCHAR},
      </if>
      <if test="vDevName != null" >
        v_dev_name = #{vDevName,jdbcType=VARCHAR},
      </if>
      <if test="vDeviceCode != null" >
        v_device_code = #{vDeviceCode,jdbcType=VARCHAR},
      </if>
      <if test="vPattern != null" >
        v_pattern = #{vPattern,jdbcType=VARCHAR},
      </if>
      <if test="vStartTime != null" >
        v_start_time = #{vStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="vEndTime != null" >
        v_end_time = #{vEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="vDistinguishState != null" >
        v_distinguish_state = #{vDistinguishState,jdbcType=INTEGER},
      </if>
      <if test="vState != null" >
        v_state = #{vState,jdbcType=INTEGER},
      </if>
      <if test="vUpdatePerson != null" >
        v_update_person = #{vUpdatePerson,jdbcType=VARCHAR},
      </if>
      <if test="dataSource != null" >
        data_source = #{dataSource,jdbcType=VARCHAR},
      </if>
      <if test="vUpdateTime != null" >
        v_update_time = #{vUpdateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.intelligent.ventilation.model.TVentilation" >
    update t_ventilation
    set org_id = #{orgId,jdbcType=VARCHAR},
      v_cf_code = #{vCfCode,jdbcType=VARCHAR},
      operation_id = #{operationId,jdbcType=VARCHAR},
      v_dev_name = #{vDevName,jdbcType=VARCHAR},
      v_device_code = #{vDeviceCode,jdbcType=VARCHAR},
      v_pattern = #{vPattern,jdbcType=VARCHAR},
      v_start_time = #{vStartTime,jdbcType=TIMESTAMP},
      v_end_time = #{vEndTime,jdbcType=TIMESTAMP},
      v_distinguish_state = #{vDistinguishState,jdbcType=INTEGER},
      v_state = #{vState,jdbcType=INTEGER},
      v_update_person = #{vUpdatePerson,jdbcType=VARCHAR},
      data_source = #{dataSource,jdbcType=VARCHAR},
      v_update_time = #{vUpdateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <insert id="insertBatch" parameterType="java.util.List">
    insert into t_ventilation (id, org_id, v_cf_code,
    operation_id, v_dev_name, v_device_code,
    v_pattern, v_start_time, v_end_time,
    v_distinguish_state, v_state, v_update_person,
    data_source, v_update_time)
    values
    <foreach collection="list" item="record" index="index" separator=",">
      (#{record.id,jdbcType=VARCHAR}, #{record.orgId,jdbcType=VARCHAR}, #{record.vCfCode,jdbcType=VARCHAR},
      #{record.operationId,jdbcType=VARCHAR}, #{record.vDevName,jdbcType=VARCHAR}, #{record.vDeviceCode,jdbcType=VARCHAR},
      #{record.vPattern,jdbcType=VARCHAR}, #{record.vStartTime,jdbcType=TIMESTAMP}, #{record.vEndTime,jdbcType=TIMESTAMP},
      #{record.vDistinguishState,jdbcType=INTEGER}, #{record.vState,jdbcType=INTEGER}, #{record.vUpdatePerson,jdbcType=VARCHAR},
      #{record.dataSource,jdbcType=VARCHAR}, #{record.vUpdateTime,jdbcType=TIMESTAMP})
    </foreach>
  </insert>

  <select id="getByCode" resultMap="BaseResultMap" parameterType="java.util.Map">
    select
    <include refid="Base_Column_List" />
    from t_ventilation
    where v_cf_code = #{vcfcode,jdbcType=VARCHAR} and v_dev_name = #{vdevname,jdbcType=VARCHAR}
  </select>
</mapper>