<?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.fumigation.mapper.TFumigationPlanMapper" >
  <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlan" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="house_id" property="houseId" jdbcType="INTEGER" />
    <result column="keeper" property="keeper" jdbcType="INTEGER" />
    <result column="grain_kind" property="grainKind" jdbcType="INTEGER" />
    <result column="grain_count" property="grainCount" jdbcType="DECIMAL" />
    <result column="grain_storage_time" property="grainStorageTime" jdbcType="TIMESTAMP" />
    <result column="fumigation_type" property="fumigationType" jdbcType="INTEGER" />
    <result column="fumigation_number" property="fumigationNumber" jdbcType="INTEGER" />
    <result column="fumigation_command" property="fumigationCommand" jdbcType="VARCHAR" />
    <result column="fumigation_operation" property="fumigationOperation" jdbcType="VARCHAR" />
    <result column="fumiagtion_protective" property="fumiagtionProtective" jdbcType="VARCHAR" />
    <result column="expected" property="expected" jdbcType="VARCHAR" />
    <result column="points_work" property="pointsWork" jdbcType="VARCHAR" />
    <result column="note" property="note" jdbcType="VARCHAR" />
    <result column="state" property="state" jdbcType="INTEGER" />
    <result column="creater" property="creater" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="approve_people" property="approvePeople" jdbcType="VARCHAR" />
    <result column="approve_department" property="approveDepartment" jdbcType="VARCHAR" />
    <result column="approve_note" property="approveNote" jdbcType="VARCHAR" />
    <result column="approve_time" property="approveTime" jdbcType="TIMESTAMP" />
    <result column="delete_state" property="deleteState" jdbcType="VARCHAR" />
    <result column="org_id" property="orgId" jdbcType="VARCHAR" />
    <result column="fumigation_frequency" property="fumigationFrequency" jdbcType="INTEGER" />
    <result column="cgxzfs" property="cgxzfs" jdbcType="VARCHAR" />
    <result column="hlxzfs" property="hlxzfs" jdbcType="VARCHAR" />
    <result column="hlxzynhljsjh" property="hlxzynhljsjh" jdbcType="VARCHAR" />
    <result column="xzfazd" property="xzfazd" jdbcType="VARCHAR" />
    <result column="xzfaqcr" property="xzfaqcr" jdbcType="VARCHAR" />
    <result column="xzfapzr" property="xzfapzr" jdbcType="VARCHAR" />
    <result column="xzfabbqk" property="xzfabbqk" jdbcType="VARCHAR" />
    <result column="xzfzr" property="xzfzr" jdbcType="VARCHAR" />
    <result column="hcjcdh" property="hcjcdh" jdbcType="VARCHAR" />
    <result column="updatetime" property="updatetime" 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, house_id, keeper, grain_kind, grain_count, grain_storage_time, fumigation_type, 
    fumigation_number, fumigation_command, fumigation_operation, fumiagtion_protective, 
    expected, points_work, note, state, creater, create_time, approve_people, approve_department, 
    approve_note, approve_time, delete_state, org_id, fumigation_frequency, cgxzfs, hlxzfs, 
    hlxzynhljsjh, xzfazd, xzfaqcr, xzfapzr, xzfabbqk, xzfzr, hcjcdh, updatetime
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlanExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from t_fumigation_plan
    <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_fumigation_plan
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from t_fumigation_plan
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlanExample" >
    delete from t_fumigation_plan
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlan" >
    insert into t_fumigation_plan (id, house_id, keeper, 
      grain_kind, grain_count, grain_storage_time, 
      fumigation_type, fumigation_number, fumigation_command, 
      fumigation_operation, fumiagtion_protective, 
      expected, points_work, note, 
      state, creater, create_time, 
      approve_people, approve_department, approve_note, 
      approve_time, delete_state, org_id, 
      fumigation_frequency, cgxzfs, hlxzfs, 
      hlxzynhljsjh, xzfazd, xzfaqcr, 
      xzfapzr, xzfabbqk, xzfzr, 
      hcjcdh, updatetime)
    values (#{id,jdbcType=VARCHAR}, #{houseId,jdbcType=INTEGER}, #{keeper,jdbcType=INTEGER}, 
      #{grainKind,jdbcType=INTEGER}, #{grainCount,jdbcType=DECIMAL}, #{grainStorageTime,jdbcType=TIMESTAMP},
      #{fumigationType,jdbcType=INTEGER}, #{fumigationNumber,jdbcType=INTEGER}, #{fumigationCommand,jdbcType=VARCHAR}, 
      #{fumigationOperation,jdbcType=VARCHAR}, #{fumiagtionProtective,jdbcType=VARCHAR}, 
      #{expected,jdbcType=VARCHAR}, #{pointsWork,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, 
      #{state,jdbcType=INTEGER}, #{creater,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{approvePeople,jdbcType=VARCHAR}, #{approveDepartment,jdbcType=VARCHAR}, #{approveNote,jdbcType=VARCHAR}, 
      #{approveTime,jdbcType=TIMESTAMP}, #{deleteState,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, 
      #{fumigationFrequency,jdbcType=INTEGER}, #{cgxzfs,jdbcType=VARCHAR}, #{hlxzfs,jdbcType=VARCHAR}, 
      #{hlxzynhljsjh,jdbcType=VARCHAR}, #{xzfazd,jdbcType=VARCHAR}, #{xzfaqcr,jdbcType=VARCHAR}, 
      #{xzfapzr,jdbcType=VARCHAR}, #{xzfabbqk,jdbcType=VARCHAR}, #{xzfzr,jdbcType=VARCHAR}, 
      #{hcjcdh,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlan" >
    insert into t_fumigation_plan
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="houseId != null" >
        house_id,
      </if>
      <if test="keeper != null" >
        keeper,
      </if>
      <if test="grainKind != null" >
        grain_kind,
      </if>
      <if test="grainCount != null" >
        grain_count,
      </if>
      <if test="grainStorageTime != null" >
        grain_storage_time,
      </if>
      <if test="fumigationType != null" >
        fumigation_type,
      </if>
      <if test="fumigationNumber != null" >
        fumigation_number,
      </if>
      <if test="fumigationCommand != null" >
        fumigation_command,
      </if>
      <if test="fumigationOperation != null" >
        fumigation_operation,
      </if>
      <if test="fumiagtionProtective != null" >
        fumiagtion_protective,
      </if>
      <if test="expected != null" >
        expected,
      </if>
      <if test="pointsWork != null" >
        points_work,
      </if>
      <if test="note != null" >
        note,
      </if>
      <if test="state != null" >
        state,
      </if>
      <if test="creater != null" >
        creater,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="approvePeople != null" >
        approve_people,
      </if>
      <if test="approveDepartment != null" >
        approve_department,
      </if>
      <if test="approveNote != null" >
        approve_note,
      </if>
      <if test="approveTime != null" >
        approve_time,
      </if>
      <if test="deleteState != null" >
        delete_state,
      </if>
      <if test="orgId != null" >
        org_id,
      </if>
      <if test="fumigationFrequency != null" >
        fumigation_frequency,
      </if>
      <if test="cgxzfs != null" >
        cgxzfs,
      </if>
      <if test="hlxzfs != null" >
        hlxzfs,
      </if>
      <if test="hlxzynhljsjh != null" >
        hlxzynhljsjh,
      </if>
      <if test="xzfazd != null" >
        xzfazd,
      </if>
      <if test="xzfaqcr != null" >
        xzfaqcr,
      </if>
      <if test="xzfapzr != null" >
        xzfapzr,
      </if>
      <if test="xzfabbqk != null" >
        xzfabbqk,
      </if>
      <if test="xzfzr != null" >
        xzfzr,
      </if>
      <if test="hcjcdh != null" >
        hcjcdh,
      </if>
      <if test="updatetime != null" >
        updatetime,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="houseId != null" >
        #{houseId,jdbcType=INTEGER},
      </if>
      <if test="keeper != null" >
        #{keeper,jdbcType=INTEGER},
      </if>
      <if test="grainKind != null" >
        #{grainKind,jdbcType=INTEGER},
      </if>
      <if test="grainCount != null" >
        #{grainCount,jdbcType=DECIMAL},
      </if>
      <if test="grainStorageTime != null" >
        #{grainStorageTime,jdbcType=TIMESTAMP},
      </if>
      <if test="fumigationType != null" >
        #{fumigationType,jdbcType=INTEGER},
      </if>
      <if test="fumigationNumber != null" >
        #{fumigationNumber,jdbcType=INTEGER},
      </if>
      <if test="fumigationCommand != null" >
        #{fumigationCommand,jdbcType=VARCHAR},
      </if>
      <if test="fumigationOperation != null" >
        #{fumigationOperation,jdbcType=VARCHAR},
      </if>
      <if test="fumiagtionProtective != null" >
        #{fumiagtionProtective,jdbcType=VARCHAR},
      </if>
      <if test="expected != null" >
        #{expected,jdbcType=VARCHAR},
      </if>
      <if test="pointsWork != null" >
        #{pointsWork,jdbcType=VARCHAR},
      </if>
      <if test="note != null" >
        #{note,jdbcType=VARCHAR},
      </if>
      <if test="state != null" >
        #{state,jdbcType=INTEGER},
      </if>
      <if test="creater != null" >
        #{creater,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="approvePeople != null" >
        #{approvePeople,jdbcType=VARCHAR},
      </if>
      <if test="approveDepartment != null" >
        #{approveDepartment,jdbcType=VARCHAR},
      </if>
      <if test="approveNote != null" >
        #{approveNote,jdbcType=VARCHAR},
      </if>
      <if test="approveTime != null" >
        #{approveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deleteState != null" >
        #{deleteState,jdbcType=VARCHAR},
      </if>
      <if test="orgId != null" >
        #{orgId,jdbcType=VARCHAR},
      </if>
      <if test="fumigationFrequency != null" >
        #{fumigationFrequency,jdbcType=INTEGER},
      </if>
      <if test="cgxzfs != null" >
        #{cgxzfs,jdbcType=VARCHAR},
      </if>
      <if test="hlxzfs != null" >
        #{hlxzfs,jdbcType=VARCHAR},
      </if>
      <if test="hlxzynhljsjh != null" >
        #{hlxzynhljsjh,jdbcType=VARCHAR},
      </if>
      <if test="xzfazd != null" >
        #{xzfazd,jdbcType=VARCHAR},
      </if>
      <if test="xzfaqcr != null" >
        #{xzfaqcr,jdbcType=VARCHAR},
      </if>
      <if test="xzfapzr != null" >
        #{xzfapzr,jdbcType=VARCHAR},
      </if>
      <if test="xzfabbqk != null" >
        #{xzfabbqk,jdbcType=VARCHAR},
      </if>
      <if test="xzfzr != null" >
        #{xzfzr,jdbcType=VARCHAR},
      </if>
      <if test="hcjcdh != null" >
        #{hcjcdh,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null" >
        #{updatetime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlanExample" resultType="java.lang.Integer" >
    select count(*) from t_fumigation_plan
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update t_fumigation_plan
    <set >
      <if test="record.id != null" >
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.houseId != null" >
        house_id = #{record.houseId,jdbcType=INTEGER},
      </if>
      <if test="record.keeper != null" >
        keeper = #{record.keeper,jdbcType=INTEGER},
      </if>
      <if test="record.grainKind != null" >
        grain_kind = #{record.grainKind,jdbcType=INTEGER},
      </if>
      <if test="record.grainCount != null" >
        grain_count = #{record.grainCount,jdbcType=DECIMAL},
      </if>
      <if test="record.grainStorageTime != null" >
        grain_storage_time = #{record.grainStorageTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.fumigationType != null" >
        fumigation_type = #{record.fumigationType,jdbcType=INTEGER},
      </if>
      <if test="record.fumigationNumber != null" >
        fumigation_number = #{record.fumigationNumber,jdbcType=INTEGER},
      </if>
      <if test="record.fumigationCommand != null" >
        fumigation_command = #{record.fumigationCommand,jdbcType=VARCHAR},
      </if>
      <if test="record.fumigationOperation != null" >
        fumigation_operation = #{record.fumigationOperation,jdbcType=VARCHAR},
      </if>
      <if test="record.fumiagtionProtective != null" >
        fumiagtion_protective = #{record.fumiagtionProtective,jdbcType=VARCHAR},
      </if>
      <if test="record.expected != null" >
        expected = #{record.expected,jdbcType=VARCHAR},
      </if>
      <if test="record.pointsWork != null" >
        points_work = #{record.pointsWork,jdbcType=VARCHAR},
      </if>
      <if test="record.note != null" >
        note = #{record.note,jdbcType=VARCHAR},
      </if>
      <if test="record.state != null" >
        state = #{record.state,jdbcType=INTEGER},
      </if>
      <if test="record.creater != null" >
        creater = #{record.creater,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null" >
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.approvePeople != null" >
        approve_people = #{record.approvePeople,jdbcType=VARCHAR},
      </if>
      <if test="record.approveDepartment != null" >
        approve_department = #{record.approveDepartment,jdbcType=VARCHAR},
      </if>
      <if test="record.approveNote != null" >
        approve_note = #{record.approveNote,jdbcType=VARCHAR},
      </if>
      <if test="record.approveTime != null" >
        approve_time = #{record.approveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deleteState != null" >
        delete_state = #{record.deleteState,jdbcType=VARCHAR},
      </if>
      <if test="record.orgId != null" >
        org_id = #{record.orgId,jdbcType=VARCHAR},
      </if>
      <if test="record.fumigationFrequency != null" >
        fumigation_frequency = #{record.fumigationFrequency,jdbcType=INTEGER},
      </if>
      <if test="record.cgxzfs != null" >
        cgxzfs = #{record.cgxzfs,jdbcType=VARCHAR},
      </if>
      <if test="record.hlxzfs != null" >
        hlxzfs = #{record.hlxzfs,jdbcType=VARCHAR},
      </if>
      <if test="record.hlxzynhljsjh != null" >
        hlxzynhljsjh = #{record.hlxzynhljsjh,jdbcType=VARCHAR},
      </if>
      <if test="record.xzfazd != null" >
        xzfazd = #{record.xzfazd,jdbcType=VARCHAR},
      </if>
      <if test="record.xzfaqcr != null" >
        xzfaqcr = #{record.xzfaqcr,jdbcType=VARCHAR},
      </if>
      <if test="record.xzfapzr != null" >
        xzfapzr = #{record.xzfapzr,jdbcType=VARCHAR},
      </if>
      <if test="record.xzfabbqk != null" >
        xzfabbqk = #{record.xzfabbqk,jdbcType=VARCHAR},
      </if>
      <if test="record.xzfzr != null" >
        xzfzr = #{record.xzfzr,jdbcType=VARCHAR},
      </if>
      <if test="record.hcjcdh != null" >
        hcjcdh = #{record.hcjcdh,jdbcType=VARCHAR},
      </if>
      <if test="record.updatetime != null" >
        updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update t_fumigation_plan
    set id = #{record.id,jdbcType=VARCHAR},
      house_id = #{record.houseId,jdbcType=INTEGER},
      keeper = #{record.keeper,jdbcType=INTEGER},
      grain_kind = #{record.grainKind,jdbcType=INTEGER},
      grain_count = #{record.grainCount,jdbcType=DECIMAL},
      grain_storage_time = #{record.grainStorageTime,jdbcType=TIMESTAMP},
      fumigation_type = #{record.fumigationType,jdbcType=INTEGER},
      fumigation_number = #{record.fumigationNumber,jdbcType=INTEGER},
      fumigation_command = #{record.fumigationCommand,jdbcType=VARCHAR},
      fumigation_operation = #{record.fumigationOperation,jdbcType=VARCHAR},
      fumiagtion_protective = #{record.fumiagtionProtective,jdbcType=VARCHAR},
      expected = #{record.expected,jdbcType=VARCHAR},
      points_work = #{record.pointsWork,jdbcType=VARCHAR},
      note = #{record.note,jdbcType=VARCHAR},
      state = #{record.state,jdbcType=INTEGER},
      creater = #{record.creater,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      approve_people = #{record.approvePeople,jdbcType=VARCHAR},
      approve_department = #{record.approveDepartment,jdbcType=VARCHAR},
      approve_note = #{record.approveNote,jdbcType=VARCHAR},
      approve_time = #{record.approveTime,jdbcType=TIMESTAMP},
      delete_state = #{record.deleteState,jdbcType=VARCHAR},
      org_id = #{record.orgId,jdbcType=VARCHAR},
      fumigation_frequency = #{record.fumigationFrequency,jdbcType=INTEGER},
      cgxzfs = #{record.cgxzfs,jdbcType=VARCHAR},
      hlxzfs = #{record.hlxzfs,jdbcType=VARCHAR},
      hlxzynhljsjh = #{record.hlxzynhljsjh,jdbcType=VARCHAR},
      xzfazd = #{record.xzfazd,jdbcType=VARCHAR},
      xzfaqcr = #{record.xzfaqcr,jdbcType=VARCHAR},
      xzfapzr = #{record.xzfapzr,jdbcType=VARCHAR},
      xzfabbqk = #{record.xzfabbqk,jdbcType=VARCHAR},
      xzfzr = #{record.xzfzr,jdbcType=VARCHAR},
      hcjcdh = #{record.hcjcdh,jdbcType=VARCHAR},
      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.fumigation.model.TFumigationPlan" >
    update t_fumigation_plan
    <set >
      <if test="houseId != null" >
        house_id = #{houseId,jdbcType=INTEGER},
      </if>
      <if test="keeper != null" >
        keeper = #{keeper,jdbcType=INTEGER},
      </if>
      <if test="grainKind != null" >
        grain_kind = #{grainKind,jdbcType=INTEGER},
      </if>
      <if test="grainCount != null" >
        grain_count = #{grainCount,jdbcType=DECIMAL},
      </if>
      <if test="grainStorageTime != null" >
        grain_storage_time = #{grainStorageTime,jdbcType=TIMESTAMP},
      </if>
      <if test="fumigationType != null" >
        fumigation_type = #{fumigationType,jdbcType=INTEGER},
      </if>
      <if test="fumigationNumber != null" >
        fumigation_number = #{fumigationNumber,jdbcType=INTEGER},
      </if>
      <if test="fumigationCommand != null" >
        fumigation_command = #{fumigationCommand,jdbcType=VARCHAR},
      </if>
      <if test="fumigationOperation != null" >
        fumigation_operation = #{fumigationOperation,jdbcType=VARCHAR},
      </if>
      <if test="fumiagtionProtective != null" >
        fumiagtion_protective = #{fumiagtionProtective,jdbcType=VARCHAR},
      </if>
      <if test="expected != null" >
        expected = #{expected,jdbcType=VARCHAR},
      </if>
      <if test="pointsWork != null" >
        points_work = #{pointsWork,jdbcType=VARCHAR},
      </if>
      <if test="note != null" >
        note = #{note,jdbcType=VARCHAR},
      </if>
      <if test="state != null" >
        state = #{state,jdbcType=INTEGER},
      </if>
      <if test="creater != null" >
        creater = #{creater,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="approvePeople != null" >
        approve_people = #{approvePeople,jdbcType=VARCHAR},
      </if>
      <if test="approveDepartment != null" >
        approve_department = #{approveDepartment,jdbcType=VARCHAR},
      </if>
      <if test="approveNote != null" >
        approve_note = #{approveNote,jdbcType=VARCHAR},
      </if>
      <if test="approveTime != null" >
        approve_time = #{approveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deleteState != null" >
        delete_state = #{deleteState,jdbcType=VARCHAR},
      </if>
      <if test="orgId != null" >
        org_id = #{orgId,jdbcType=VARCHAR},
      </if>
      <if test="fumigationFrequency != null" >
        fumigation_frequency = #{fumigationFrequency,jdbcType=INTEGER},
      </if>
      <if test="cgxzfs != null" >
        cgxzfs = #{cgxzfs,jdbcType=VARCHAR},
      </if>
      <if test="hlxzfs != null" >
        hlxzfs = #{hlxzfs,jdbcType=VARCHAR},
      </if>
      <if test="hlxzynhljsjh != null" >
        hlxzynhljsjh = #{hlxzynhljsjh,jdbcType=VARCHAR},
      </if>
      <if test="xzfazd != null" >
        xzfazd = #{xzfazd,jdbcType=VARCHAR},
      </if>
      <if test="xzfaqcr != null" >
        xzfaqcr = #{xzfaqcr,jdbcType=VARCHAR},
      </if>
      <if test="xzfapzr != null" >
        xzfapzr = #{xzfapzr,jdbcType=VARCHAR},
      </if>
      <if test="xzfabbqk != null" >
        xzfabbqk = #{xzfabbqk,jdbcType=VARCHAR},
      </if>
      <if test="xzfzr != null" >
        xzfzr = #{xzfzr,jdbcType=VARCHAR},
      </if>
      <if test="hcjcdh != null" >
        hcjcdh = #{hcjcdh,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null" >
        updatetime = #{updatetime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlan" >
    update t_fumigation_plan
    set house_id = #{houseId,jdbcType=INTEGER},
      keeper = #{keeper,jdbcType=INTEGER},
      grain_kind = #{grainKind,jdbcType=INTEGER},
      grain_count = #{grainCount,jdbcType=DECIMAL},
      grain_storage_time = #{grainStorageTime,jdbcType=TIMESTAMP},
      fumigation_type = #{fumigationType,jdbcType=INTEGER},
      fumigation_number = #{fumigationNumber,jdbcType=INTEGER},
      fumigation_command = #{fumigationCommand,jdbcType=VARCHAR},
      fumigation_operation = #{fumigationOperation,jdbcType=VARCHAR},
      fumiagtion_protective = #{fumiagtionProtective,jdbcType=VARCHAR},
      expected = #{expected,jdbcType=VARCHAR},
      points_work = #{pointsWork,jdbcType=VARCHAR},
      note = #{note,jdbcType=VARCHAR},
      state = #{state,jdbcType=INTEGER},
      creater = #{creater,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      approve_people = #{approvePeople,jdbcType=VARCHAR},
      approve_department = #{approveDepartment,jdbcType=VARCHAR},
      approve_note = #{approveNote,jdbcType=VARCHAR},
      approve_time = #{approveTime,jdbcType=TIMESTAMP},
      delete_state = #{deleteState,jdbcType=VARCHAR},
      org_id = #{orgId,jdbcType=VARCHAR},
      fumigation_frequency = #{fumigationFrequency,jdbcType=INTEGER},
      cgxzfs = #{cgxzfs,jdbcType=VARCHAR},
      hlxzfs = #{hlxzfs,jdbcType=VARCHAR},
      hlxzynhljsjh = #{hlxzynhljsjh,jdbcType=VARCHAR},
      xzfazd = #{xzfazd,jdbcType=VARCHAR},
      xzfaqcr = #{xzfaqcr,jdbcType=VARCHAR},
      xzfapzr = #{xzfapzr,jdbcType=VARCHAR},
      xzfabbqk = #{xzfabbqk,jdbcType=VARCHAR},
      xzfzr = #{xzfzr,jdbcType=VARCHAR},
      hcjcdh = #{hcjcdh,jdbcType=VARCHAR},
      updatetime = #{updatetime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectPlanQueryList" parameterType="java.util.Map" resultType="java.util.HashMap">
    SELECT
    1 AS planType,
    plan.id,
    plan.house_id AS houseId,
    keeper. NAME AS keeperName,
    plan.create_time AS createTime,
    plan.approve_time AS approveTime,
    plan.fumigation_type AS way,
    plan.fumigation_operation AS operation,
    (
    CASE plan.state
    WHEN '0' THEN
    '待提交'
    WHEN '1' THEN
    '待审批'
    WHEN '2' THEN
    '审批驳回'
    WHEN '3' THEN
    '审批拒绝'
    ELSE
    '审批通过'
    END
    ) AS state,
    plan.state stateType
    FROM
    t_fumigation_plan plan
    LEFT JOIN basic_keeper keeper ON keeper.id = plan.keeper
    WHERE plan.delete_state = 1 AND plan.org_id = #{orgId,jdbcType=INTEGER}
    <if test="houseId != null" >
      AND plan.house_id = #{houseId,jdbcType=INTEGER}
    </if>
    UNION ALL
    SELECT
    2 AS planType,
    pesticide.id,
    plan.house_id AS houseId,
    keeper. NAME AS keeperName,
    pesticide.create_time AS createTime,
    pesticide.approve_time AS approveTime,
    pesticide.use_drug_type AS way,
    pesticide.pesticide_operator AS operator,
    (
    CASE pesticide.state
    WHEN '0' THEN
    '施药待提交'
    WHEN '1' THEN
    '施药待审批'
    WHEN '2' THEN
    '施药审批驳回'
    WHEN '3' THEN
    '施药审批拒绝'
    ELSE
    '施药审批通过'
    END
    ) AS state,
    pesticide.state stateType
    FROM
    t_fumigation_pesticide pesticide
    LEFT JOIN t_fumigation_plan plan ON plan.id = pesticide.fumigation_id
    LEFT JOIN basic_keeper keeper ON keeper.id = plan.keeper
    WHERE pesticide.delete_state = 1 AND pesticide.org_id = #{orgId,jdbcType=INTEGER}
    <if test="houseId != null" >
      AND plan.house_id = #{houseId,jdbcType=INTEGER}
    </if>
  </select>

  <select id="getAllQueryList" parameterType="java.util.Map" resultType="java.util.HashMap">
    SELECT
    plan.id,
    plan.house_id AS houseId,
    plan.create_time AS createTime,
    plan.approve_time AS approveTime,
    plan.fumigation_type AS way,
    plan.grain_kind,
    plan.org_id,
    pesticide.drug_name,
    (
    CASE plan.state
    WHEN '0' THEN
    '待提交'
    WHEN '1' THEN
    '待审批'
    WHEN '2' THEN
    '审批驳回'
    WHEN '3' THEN
    '审批拒绝'
    ELSE
    '审批通过'
    END
    ) AS state
    FROM
    t_fumigation_plan plan
    LEFT JOIN basic_keeper keeper ON keeper.id = plan.keeper
    LEFT JOIN t_fumigation_pesticide pesticide ON pesticide.fumigation_id = plan.id
    WHERE plan.org_id = #{orgId,jdbcType=INTEGER}
  </select>

  <select id="getFumigationApproveList" parameterType="java.util.Map" resultType="java.util.HashMap">
    SELECT
    plan.id,
    plan.house_id houseId,
    plan.grain_kind grainKind,
    pes.drug_name drugName,
    plan.fumigation_type fumigationType,
    plan.fumigation_command fumigationCommand,
    approval.create_time createTime,
    plan.state, approval.id auditId,
    approval.result result,
    approval.task_id taskId,
    approval.task_name taskName,
    approval.operator operator
    FROM
    t_fumigation_plan plan
    LEFT JOIN t_fumigation_pesticide pes ON pes.fumigation_id = plan.id
    LEFT JOIN business_approval approval ON plan.id = approval.task_id
    WHERE plan.org_id = #{orgId,jdbcType=INTEGER}
    AND (plan.state = 2 OR plan.state = 3)
    AND approval.operator = #{userId}
    <if test="houseId != null" >
      AND plan.house_id = #{houseId,jdbcType=INTEGER}
    </if>
  </select>
  <select id="getProcessList" resultMap="BaseResultMap" parameterType="java.util.Map" >
    select
          plan.*
    FROM t_fumigation_plan plan
    LEFT JOIN t_fumigation_process pro ON pro.fumigation_id = plan.id
    WHERE 1=1
    <if test="houseId != null" >
      AND plan.house_id = #{houseId,jdbcType=INTEGER}
    </if>
    <if test="orgId != null" >
      AND plan.org_id = #{orgId,jdbcType=INTEGER}
    </if>
    <if test="state != null" >
      AND plan.state = #{state,jdbcType=INTEGER}
    </if>
    <if test="deleteState != null" >
      AND plan.delete_state = #{deleteState,jdbcType=INTEGER}
    </if>
    AND pro.id IS NULL
    ORDER BY create_time DESC
  </select>
  <select id="getJcd" parameterType="java.util.Map" resultType="java.util.Map">
    SELECT
		tc.hcjcdh
	FROM
		basic_storehouse sh
	INNER JOIN t_ccvalue tc ON tc.org_id = sh.org_id AND tc.v_cf_code = sh.storehouse_code
    where not exists (SELECT hcjcdh FROM t_fumigation_plan tp 
    	WHERE  tp.id != #{fumigationId,jdbcType=VARCHAR} AND tp.hcjcdh = tc.hcjcdh) 
      <if test="houseId != null">
        AND sh.storehouse_id = #{houseId,jdbcType=INTEGER}
      </if>
      AND tc.hcjcdh is not null
    GROUP BY tc.hcjcdh
  </select>
</mapper>