<?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="cn.com.victorysoft.business.technology.dao.WellTubeDao">
  <sql id="Base_Column_List">
    JH, NY, ZSCW, KGZT, TZYY, GZLX, YGLX, YGCJ, YGCD, YGXRRQ, FGQLX, FGQJS, FGQCJ, PSQLX,
    PSQJS, PSQCJ, DSDLX, DSDCJ,
    (select unitname from sys_unitinfo where unitcode = wb.unitcode_area) areaname,
    (select blockname from sys_blockinfo where blockcode = wb.blockcode) blockname
  </sql>
  <select id="selectList" parameterType="cn.com.victorysoft.business.sys.param.UnitWellMonthPageParam" resultType="cn.com.victorysoft.business.technology.entity.WellTube">
    select
    <include refid="Base_Column_List" />
    from TECH_WELL_TUBE t, water_well_basic wb
    where t.jh = wb.wellname
    and t.ny = #{month}
    <if test="unitcode != null and unitcode != ''">
      and wb.unitcode in (select unitcode from sys_unitinfo start with unitcode = #{unitcode} connect by prior unitcode = p_unitcode)
    </if>
    <if test="wellname != null and wellname != ''">
      and wb.wellname = #{wellname}
    </if>
    order by wb.wellname
  </select>
  <select id="selectByPrimaryKey" parameterType="cn.com.victorysoft.business.technology.entity.WellTube" resultType="cn.com.victorysoft.business.technology.entity.WellTube">
    select 
    <include refid="Base_Column_List" />
    from TECH_WELL_TUBE t, water_well_basic wb
    where t.jh = wb.wellname
    and JH = #{jh,jdbcType=VARCHAR}
    and NY = #{ny,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="cn.com.victorysoft.business.technology.entity.WellTube">
    delete from TECH_WELL_TUBE
    where JH = #{jh,jdbcType=VARCHAR}
    and NY = #{ny,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByMonth" parameterType="String">
    delete from TECH_WELL_TUBE
    where NY = #{month,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="cn.com.victorysoft.business.technology.entity.WellTube">
    insert into TECH_WELL_TUBE (JH, NY, ZSCW, KGZT, TZYY,
      GZLX, YGLX, YGCJ, YGCD, 
      YGXRRQ, FGQLX, FGQJS, 
      FGQCJ, PSQLX, PSQJS, 
      PSQCJ, DSDLX, DSDCJ
      )
    values (#{jh,jdbcType=VARCHAR}, #{ny,jdbcType=VARCHAR}, #{zscw,jdbcType=VARCHAR},
      #{kgzt,jdbcType=CHAR}, #{tzyy,jdbcType=VARCHAR},
      #{gzlx,jdbcType=VARCHAR}, #{yglx,jdbcType=VARCHAR}, #{ygcj,jdbcType=VARCHAR}, #{ygcd,jdbcType=DECIMAL}, 
      #{ygxrrq,jdbcType=TIMESTAMP}, #{fgqlx,jdbcType=VARCHAR}, #{fgqjs,jdbcType=VARCHAR},
      #{fgqcj,jdbcType=VARCHAR}, #{psqlx,jdbcType=VARCHAR}, #{psqjs,jdbcType=DECIMAL}, 
      #{psqcj,jdbcType=VARCHAR}, #{dsdlx,jdbcType=VARCHAR}, #{dsdcj,jdbcType=VARCHAR}
      )
  </insert>

  <insert id="insertBatch" parameterType="java.util.List">
    insert into TECH_WELL_TUBE (JH, NY, ZSCW, KGZT, TZYY,
    GZLX, YGLX, YGCJ, YGCD,
    YGXRRQ, FGQLX, FGQJS,
    FGQCJ, PSQLX, PSQJS,
    PSQCJ, DSDLX, DSDCJ
    )
    <foreach collection="list" item="item" separator="UNION ALL">
      SELECT
      #{item.jh,jdbcType=VARCHAR}, #{item.ny,jdbcType=VARCHAR}, #{item.zscw,jdbcType=VARCHAR},
      #{item.kgzt,jdbcType=CHAR}, #{item.tzyy,jdbcType=VARCHAR},
      #{item.gzlx,jdbcType=VARCHAR}, #{item.yglx,jdbcType=VARCHAR}, #{item.ygcj,jdbcType=VARCHAR}, #{item.ygcd,jdbcType=DECIMAL},
      #{item.ygxrrq,jdbcType=TIMESTAMP}, #{item.fgqlx,jdbcType=VARCHAR}, #{item.fgqjs,jdbcType=VARCHAR},
      #{item.fgqcj,jdbcType=VARCHAR}, #{item.psqlx,jdbcType=VARCHAR}, #{item.psqjs,jdbcType=DECIMAL},
      #{item.psqcj,jdbcType=VARCHAR}, #{item.dsdlx,jdbcType=VARCHAR}, #{item.dsdcj,jdbcType=VARCHAR}
      FROM dual
    </foreach>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="cn.com.victorysoft.business.technology.entity.WellTube">
    update TECH_WELL_TUBE
    <set>
      <if test="zscw != null">
        ZSCW = #{zscw,jdbcType=VARCHAR},
      </if>
      <if test="kgzt != null">
        KGZT = #{kgzt,jdbcType=CHAR},
      </if>
      <if test="tzyy != null">
        TZYY = #{tzyy,jdbcType=VARCHAR},
      </if>
      <if test="gzlx != null">
        GZLX = #{gzlx,jdbcType=VARCHAR},
      </if>
      <if test="yglx != null">
        YGLX = #{yglx,jdbcType=VARCHAR},
      </if>
      <if test="ygcj != null">
        YGCJ = #{ygcj,jdbcType=VARCHAR},
      </if>
      <if test="ygcd != null">
        YGCD = #{ygcd,jdbcType=DECIMAL},
      </if>
      <if test="ygxrrq != null">
        YGXRRQ = #{ygxrrq,jdbcType=TIMESTAMP},
      </if>
      <if test="fgqlx != null">
        FGQLX = #{fgqlx,jdbcType=VARCHAR},
      </if>
      <if test="fgqjs != null">
        FGQJS = #{fgqjs,jdbcType=VARCHAR},
      </if>
      <if test="fgqcj != null">
        FGQCJ = #{fgqcj,jdbcType=VARCHAR},
      </if>
      <if test="psqlx != null">
        PSQLX = #{psqlx,jdbcType=VARCHAR},
      </if>
      <if test="psqjs != null">
        PSQJS = #{psqjs,jdbcType=DECIMAL},
      </if>
      <if test="psqcj != null">
        PSQCJ = #{psqcj,jdbcType=VARCHAR},
      </if>
      <if test="dsdlx != null">
        DSDLX = #{dsdlx,jdbcType=VARCHAR},
      </if>
      <if test="dsdcj != null">
        DSDCJ = #{dsdcj,jdbcType=VARCHAR},
      </if>
    </set>
    where JH = #{jh,jdbcType=VARCHAR}
    and NY = #{ny,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.com.victorysoft.business.technology.entity.WellTube">
    update TECH_WELL_TUBE
    set ZSCW = #{zscw,jdbcType=VARCHAR},
      KGZT = #{kgzt,jdbcType=CHAR},
      TZYY = #{tzyy,jdbcType=VARCHAR},
      GZLX = #{gzlx,jdbcType=VARCHAR},
      YGLX = #{yglx,jdbcType=VARCHAR},
      YGCJ = #{ygcj,jdbcType=VARCHAR},
      YGCD = #{ygcd,jdbcType=DECIMAL},
      YGXRRQ = #{ygxrrq,jdbcType=TIMESTAMP},
      FGQLX = #{fgqlx,jdbcType=VARCHAR},
      FGQJS = #{fgqjs,jdbcType=VARCHAR},
      FGQCJ = #{fgqcj,jdbcType=VARCHAR},
      PSQLX = #{psqlx,jdbcType=VARCHAR},
      PSQJS = #{psqjs,jdbcType=DECIMAL},
      PSQCJ = #{psqcj,jdbcType=VARCHAR},
      DSDLX = #{dsdlx,jdbcType=VARCHAR},
      DSDCJ = #{dsdcj,jdbcType=VARCHAR}
    where JH = #{jh,jdbcType=VARCHAR}
    and NY = #{ny,jdbcType=VARCHAR}
  </update>
</mapper>