<?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">
    <sql id="Base_Column_List">
        JH, QKDM, DWDM, DWMC, YTDM, BGRQ, YCLX, SCCW, CS, YSDCYL, YSDCWD, YSBHYL, ZSJDDS, ZSJDDIS, YCZS,
        TGGG, JX, ZDCJYC, STHD, sb.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 web
        left join sys_blockinfo sb on web.qkdm = sb.blockcode
        where BGRQ = #{testdate,jdbcType=TIMESTAMP}
        <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>