<?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.tofly.feesapi.bmgl.mapper.BmSjMapper">

    <select id="selectMaxId" resultType="int">
        SELECT NVL(MAX(to_number(CODE + 0)), 0)
        FROM BM_SJ
    </select>

    <sql id="querySql">
        SELECT a.ssgs, a.code, a.name, b.name AS yslxmc,
        a.jtbz, a.sj, a.jt1_zs, a.jt1_sj, a.jt2_zs, a.jt2_sj, a.jt3_zs, a.jt3_sj,
        a.jt4_zs, a.jt4_sj, a.wsfdj, a.ljfdj,a.szyfdj,a.jtrksl,a.jtrkjs , a.czsj, a.isdisabled
        FROM BM_SJ a
        LEFT JOIN bm_yslx b on a.yslx=b.code
        WHERE 1=1
        <!--模糊查询 -->
        <if test="filter.searchText!=null">
            AND (a.code like '%${filter.searchText}%'
            OR a.name like '%${filter.searchText}%')
        </if>
        <!--所属公司-->
        <if test="filter.ssgs!=null">
            AND a.ssgs=#{filter.ssgs}
        </if>
        <!--用水类型-->
        <if test="filter.yslx!=null">
            AND a.yslx=#{filter.yslx}
        </if>

        <if test="filter.isdisabled!=null">
            AND a.isdisabled = #{filter.isdisabled}
        </if>
        AND a.isshow='1'
        ORDER BY to_number(a.CODE) ASC
    </sql>

    <select id="getPage" resultType="com.tofly.feesapi.bmgl.entity.dto.BmSjSelectDto">
        <include refid="querySql"/>
    </select>

    <select id="getList" resultType="com.tofly.feesapi.bmgl.entity.dto.BmSjSelectDto">
        <include refid="querySql"></include>
    </select>

</mapper>
