<?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.cyyzs.dao.StaticDataDao">
    <resultMap id="BaseResultMap" type="cn.com.victorysoft.business.cyyzs.entity.StaticData">
        <id column="JH" jdbcType="VARCHAR" property="jh"/>
        <result column="QKDM" jdbcType="VARCHAR" property="qkdm"/>
        <result column="DWDM" jdbcType="VARCHAR" property="dwdm"/>
        <result column="DWMC" jdbcType="VARCHAR" property="dwmc"/>
        <result column="YTDM" jdbcType="VARCHAR" property="ytdm"/>
        <result column="BGRQ" jdbcType="TIMESTAMP" property="bgrq"/>
        <result column="YCLX" jdbcType="VARCHAR" property="yclx"/>
        <result column="SCCW" jdbcType="VARCHAR" property="sccw"/>
        <result column="CS" jdbcType="DECIMAL" property="cs"/>
        <result column="YSDCYL" jdbcType="DECIMAL" property="ysdcyl"/>
        <result column="YSDCWD" jdbcType="DECIMAL" property="ysdcwd"/>
        <result column="YSBHYL" jdbcType="DECIMAL" property="ysbhyl"/>
        <result column="ZSJDDS" jdbcType="DECIMAL" property="zsjdds"/>
        <result column="ZSJDDIS" jdbcType="DECIMAL" property="zsjddis"/>
        <result column="YCZS" jdbcType="DECIMAL" property="yczs"/>
        <result column="TGGG" jdbcType="DECIMAL" property="tggg"/>
        <result column="JX" jdbcType="DECIMAL" property="jx"/>
        <result column="ZDCJYC" jdbcType="DECIMAL" property="zdcjyc"/>
        <result column="STHD" jdbcType="DECIMAL" property="sthd"/>
    </resultMap>
    <sql id="Base_Column_List">
        JH, QKDM, DWDM, DWMC, YTDM, BGRQ, YCLX, SCCW, CS, YSDCYL, YSDCWD, YSBHYL, ZSJDDS, ZSJDDIS, YCZS,
        TGGG, JX, ZDCJYC, STHD, c.BLOCKNAME qkmc,
        (select flag_name from sys_flag where category_code = 'YCLX' and flag_code = yclx) yclxmc
    </sql>
    <select id="selectList" parameterType="cn.com.victorysoft.business.cyyzs.param.StaticDataParam"
            resultType="cn.com.victorysoft.business.cyyzs.entity.StaticData">
        select
        <include refid="Base_Column_List"/>
        from WATER_WELL_BASIC a
        left join sys_unitinfo b on a.dwdm = b.unitcode
        left join sys_blockinfo c on a.qkdm = c.blockcode
        where BGRQ = #{testdate,jdbcType=VARCHAR}
        <if test="unitcode != null and unitcode != ''">
            and DWDM in (select unitcode
            from SYS_UNITINFO
            start with UNITCODE = #{unitcode,jdbcType=VARCHAR}
            connect by prior UNITCODE = P_UNITCODE)
        </if>
        <if test="wellname != null and wellname != ''">
            and JH = #{wellname,jdbcType=VARCHAR}
        </if>
        <if test="blockcode != null and blockcode != ''">
            and QKDM = #{blockcode,jdbcType=VARCHAR}
        </if>
        <if test="oiltype != null and oiltype != ''">
            and YCLX = #{oiltype,jdbcType=VARCHAR}
        </if>
        order by jh
    </select>
    <update id="update" parameterType="cn.com.victorysoft.business.cyyzs.entity.StaticData">
        update WATER_WELL_BASIC
        <set>
            <if test="bgrq != null">
                BGRQ = #{bgrq,jdbcType=TIMESTAMP},
            </if>
            <if test="zdcjyc != null">
                ZDCJYC = #{zdcjyc,jdbcType=DECIMAL},
            </if>
        </set>
        where JH = #{jh,jdbcType=VARCHAR}
    </update>
</mapper>