<?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.WellToolDao">
  <sql id="Base_Column_List">
    JH, NY, ZSCW, KGZT, TZYY, ZYRQ, ZYMD, JTSXYS, JQDLSJ, YQYY, SZGD, CSQKMS, TGZK, WTJD,
    TDGLX, TDNTJ, TDJD, TDRQ, DLJD, DLSY, DLRQ, HJDNJ, HJDJD, HJDRQ, CZXGQSD, KCWZ, CZNJ, 
    CZRQ, YJYLX, YJYYL, JKXH, WGXS, MQRGJD,
    (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.WellTool">
    select
    <include refid="Base_Column_List" />
    from TECH_WELL_TOOL 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.WellTool" resultType="cn.com.victorysoft.business.technology.entity.WellTool">
    select 
    <include refid="Base_Column_List" />
    from TECH_WELL_TOOL 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.WellTool">
    delete from TECH_WELL_TOOL
    where JH = #{jh,jdbcType=VARCHAR}
    and NY = #{ny,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByMonth" parameterType="String">
    delete from TECH_WELL_TOOL
    where NY = #{month,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="cn.com.victorysoft.business.technology.entity.WellTool">
    insert into TECH_WELL_TOOL (JH, NY, ZSCW, KGZT, TZYY,
      ZYRQ, ZYMD, JTSXYS, 
      JQDLSJ, YQYY, SZGD, 
      CSQKMS, TGZK, WTJD,
      TDGLX, TDNTJ, TDJD, 
      TDRQ, DLJD, DLSY, 
      DLRQ, HJDNJ, HJDJD, 
      HJDRQ, CZXGQSD, KCWZ, 
      CZNJ, CZRQ, YJYLX, 
      YJYYL, JKXH, WGXS, MQRGJD)
    values (#{jh,jdbcType=VARCHAR}, #{ny,jdbcType=VARCHAR}, #{zscw,jdbcType=VARCHAR},
      #{kgzt,jdbcType=CHAR}, #{tzyy,jdbcType=VARCHAR},
      #{zyrq,jdbcType=TIMESTAMP}, #{zymd,jdbcType=VARCHAR}, #{jtsxys,jdbcType=VARCHAR}, 
      #{jqdlsj,jdbcType=TIMESTAMP}, #{yqyy,jdbcType=VARCHAR}, #{szgd,jdbcType=DECIMAL}, 
      #{csqkms,jdbcType=VARCHAR}, #{tgzk,jdbcType=VARCHAR}, #{wtjd,jdbcType=VARCHAR},
      #{tdglx,jdbcType=VARCHAR}, #{tdntj,jdbcType=DECIMAL}, #{tdjd,jdbcType=VARCHAR}, 
      #{tdrq,jdbcType=TIMESTAMP}, #{dljd,jdbcType=VARCHAR}, #{dlsy,jdbcType=VARCHAR}, 
      #{dlrq,jdbcType=TIMESTAMP}, #{hjdnj,jdbcType=DECIMAL}, #{hjdjd,jdbcType=VARCHAR}, 
      #{hjdrq,jdbcType=TIMESTAMP}, #{czxgqsd,jdbcType=DECIMAL}, #{kcwz,jdbcType=DECIMAL}, 
      #{cznj,jdbcType=DECIMAL}, #{czrq,jdbcType=TIMESTAMP}, #{yjylx,jdbcType=VARCHAR}, 
      #{yjyyl,jdbcType=DECIMAL}, #{jkxh,jdbcType=VARCHAR}, #{wgxs,jdbcType=DECIMAL},
      #{mqrgjd,jdbcType=DECIMAL})
  </insert>

  <insert id="insertBatch" parameterType="java.util.List">
    insert into TECH_WELL_TOOL (JH, NY, ZSCW, KGZT, TZYY,
    ZYRQ, ZYMD, JTSXYS,
    JQDLSJ, YQYY, SZGD,
    CSQKMS, TGZK, WTJD,
    TDGLX, TDNTJ, TDJD,
    TDRQ, DLJD, DLSY,
    DLRQ, HJDNJ, HJDJD,
    HJDRQ, CZXGQSD, KCWZ,
    CZNJ, CZRQ, YJYLX,
    YJYYL, JKXH, WGXS, MQRGJD)
    <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.zyrq,jdbcType=TIMESTAMP}, #{item.zymd,jdbcType=VARCHAR}, #{item.jtsxys,jdbcType=VARCHAR},
      #{item.jqdlsj,jdbcType=TIMESTAMP}, #{item.yqyy,jdbcType=VARCHAR}, #{item.szgd,jdbcType=DECIMAL},
      #{item.csqkms,jdbcType=VARCHAR}, #{item.tgzk,jdbcType=VARCHAR}, #{item.wtjd,jdbcType=VARCHAR},
      #{item.tdglx,jdbcType=VARCHAR}, #{item.tdntj,jdbcType=DECIMAL}, #{item.tdjd,jdbcType=VARCHAR},
      #{item.tdrq,jdbcType=TIMESTAMP}, #{item.dljd,jdbcType=VARCHAR}, #{item.dlsy,jdbcType=VARCHAR},
      #{item.dlrq,jdbcType=TIMESTAMP}, #{item.hjdnj,jdbcType=DECIMAL}, #{item.hjdjd,jdbcType=VARCHAR},
      #{item.hjdrq,jdbcType=TIMESTAMP}, #{item.czxgqsd,jdbcType=DECIMAL}, #{item.kcwz,jdbcType=DECIMAL},
      #{item.cznj,jdbcType=DECIMAL}, #{item.czrq,jdbcType=TIMESTAMP}, #{item.yjylx,jdbcType=VARCHAR},
      #{item.yjyyl,jdbcType=DECIMAL}, #{item.jkxh,jdbcType=VARCHAR}, #{item.wgxs,jdbcType=DECIMAL},
      #{item.mqrgjd,jdbcType=DECIMAL}
      FROM dual
    </foreach>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="cn.com.victorysoft.business.technology.entity.WellTool">
    update TECH_WELL_TOOL
    <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="zyrq != null">
        ZYRQ = #{zyrq,jdbcType=TIMESTAMP},
      </if>
      <if test="zymd != null">
        ZYMD = #{zymd,jdbcType=VARCHAR},
      </if>
      <if test="jtsxys != null">
        JTSXYS = #{jtsxys,jdbcType=VARCHAR},
      </if>
      <if test="jqdlsj != null">
        JQDLSJ = #{jqdlsj,jdbcType=TIMESTAMP},
      </if>
      <if test="yqyy != null">
        YQYY = #{yqyy,jdbcType=VARCHAR},
      </if>
      <if test="szgd != null">
        SZGD = #{szgd,jdbcType=DECIMAL},
      </if>
      <if test="csqkms != null">
        CSQKMS = #{csqkms,jdbcType=VARCHAR},
      </if>
      <if test="tgzk != null">
        TGZK = #{tgzk,jdbcType=VARCHAR},
      </if>
      <if test="wtjd != null">
        WTJD = #{wtjd,jdbcType=VARCHAR},
      </if>
      <if test="tdglx != null">
        TDGLX = #{tdglx,jdbcType=VARCHAR},
      </if>
      <if test="tdntj != null">
        TDNTJ = #{tdntj,jdbcType=DECIMAL},
      </if>
      <if test="tdjd != null">
        TDJD = #{tdjd,jdbcType=VARCHAR},
      </if>
      <if test="tdrq != null">
        TDRQ = #{tdrq,jdbcType=TIMESTAMP},
      </if>
      <if test="dljd != null">
        DLJD = #{dljd,jdbcType=VARCHAR},
      </if>
      <if test="dlsy != null">
        DLSY = #{dlsy,jdbcType=VARCHAR},
      </if>
      <if test="dlrq != null">
        DLRQ = #{dlrq,jdbcType=TIMESTAMP},
      </if>
      <if test="hjdnj != null">
        HJDNJ = #{hjdnj,jdbcType=DECIMAL},
      </if>
      <if test="hjdjd != null">
        HJDJD = #{hjdjd,jdbcType=VARCHAR},
      </if>
      <if test="hjdrq != null">
        HJDRQ = #{hjdrq,jdbcType=TIMESTAMP},
      </if>
      <if test="czxgqsd != null">
        CZXGQSD = #{czxgqsd,jdbcType=DECIMAL},
      </if>
      <if test="kcwz != null">
        KCWZ = #{kcwz,jdbcType=DECIMAL},
      </if>
      <if test="cznj != null">
        CZNJ = #{cznj,jdbcType=DECIMAL},
      </if>
      <if test="czrq != null">
        CZRQ = #{czrq,jdbcType=TIMESTAMP},
      </if>
      <if test="yjylx != null">
        YJYLX = #{yjylx,jdbcType=VARCHAR},
      </if>
      <if test="yjyyl != null">
        YJYYL = #{yjyyl,jdbcType=DECIMAL},
      </if>
      <if test="jkxh != null">
        JKXH = #{jkxh,jdbcType=VARCHAR},
      </if>
      <if test="wgxs != null">
        WGXS = #{wgxs,jdbcType=DECIMAL},
      </if>
      <if test="mqrgjd != null">
        MQRGJD = #{mqrgjd,jdbcType=DECIMAL},
      </if>
    </set>
    where JH = #{jh,jdbcType=VARCHAR}
    and NY = #{ny,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.com.victorysoft.business.technology.entity.WellTool">
    update TECH_WELL_TOOL
    set ZSCW = #{zscw,jdbcType=VARCHAR},
      KGZT = #{kgzt,jdbcType=CHAR},
      TZYY = #{tzyy,jdbcType=VARCHAR},
      ZYRQ = #{zyrq,jdbcType=TIMESTAMP},
      ZYMD = #{zymd,jdbcType=VARCHAR},
      JTSXYS = #{jtsxys,jdbcType=VARCHAR},
      JQDLSJ = #{jqdlsj,jdbcType=TIMESTAMP},
      YQYY = #{yqyy,jdbcType=VARCHAR},
      SZGD = #{szgd,jdbcType=DECIMAL},
      CSQKMS = #{csqkms,jdbcType=VARCHAR},
      TGZK = #{tgzk,jdbcType=VARCHAR},
      WTJD = #{wtjd,jdbcType=VARCHAR},
      TDGLX = #{tdglx,jdbcType=VARCHAR},
      TDNTJ = #{tdntj,jdbcType=DECIMAL},
      TDJD = #{tdjd,jdbcType=VARCHAR},
      TDRQ = #{tdrq,jdbcType=TIMESTAMP},
      DLJD = #{dljd,jdbcType=VARCHAR},
      DLSY = #{dlsy,jdbcType=VARCHAR},
      DLRQ = #{dlrq,jdbcType=TIMESTAMP},
      HJDNJ = #{hjdnj,jdbcType=DECIMAL},
      HJDJD = #{hjdjd,jdbcType=VARCHAR},
      HJDRQ = #{hjdrq,jdbcType=TIMESTAMP},
      CZXGQSD = #{czxgqsd,jdbcType=DECIMAL},
      KCWZ = #{kcwz,jdbcType=DECIMAL},
      CZNJ = #{cznj,jdbcType=DECIMAL},
      CZRQ = #{czrq,jdbcType=TIMESTAMP},
      YJYLX = #{yjylx,jdbcType=VARCHAR},
      YJYYL = #{yjyyl,jdbcType=DECIMAL},
      JKXH = #{jkxh,jdbcType=VARCHAR},
      WGXS = #{wgxs,jdbcType=DECIMAL},
      MQRGJD = #{mqrgjd,jdbcType=DECIMAL}
    where JH = #{jh,jdbcType=VARCHAR}
    and NY = #{ny,jdbcType=VARCHAR}
  </update>
</mapper>