<?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.elephant.framework.galaxy.aroad.module.zhjg.mapper.ZhjgDckhRwMapper">

  <resultMap id="zhjgDckhRwMap" type="com.elephant.framework.galaxy.aroad.module.zhjg.entity.ZhjgDckhRw">
        <id property="id" column="id"/>
        <result property="rwmc" column="rwmc"/>
        <result property="rwzt" column="rwzt"/>
        <result property="cydw" column="cydw"/>
        <result property="cydwid" column="cydwid"/>
        <result property="cyr" column="cyr"/>
        <result property="dblx" column="dblx"/>
        <result property="zrdw" column="zrdw"/>
        <result property="zrdwid" column="zrdwid"/>
        <result property="zrr" column="zrr"/>
        <result property="ksrq" column="ksrq"/>
        <result property="blqx" column="blqx"/>
        <result property="xfsj" column="xfsj"/>
        <result property="dbnr" column="dbnr"/>
        <result property="dbfj" column="dbfj"/>
        <result property="fjname" column="fjname"/>
        <result property="dbr" column="dbr"/>
        <result property="dbrlxfs" column="dbrlxfs"/>
        <result property="creator" column="creator"/>
        <result property="createTime" column="create_time"/>
        <result property="updatePerson" column="update_person"/>
        <result property="updateTime" column="update_time"/>
        <result property="status" column="status"/>
        <result property="delFlag" column="del_flag"/>
        <result property="remarks" column="remarks"/>
  </resultMap>

    <select id="selectRwForPage" resultMap="zhjgDckhRwMap">
          SELECT distinct
          rw.*
          FROM
          t_zhjg_dckh_rw rw
          LEFT JOIN
          t_zhjg_dckh_rw_ff ff
          on
          ff.rwid=rw.id
          <where>
                <if test="khrw.rwmc!=null">
                      rw.rwmc like CONCAT('%',#{khrw.rwmc},'%')
                </if>
                <if test="khrw.zrdwid!=null">
                   and   rw.zrdwid =#{khrw.zrdwid}
                </if>
                <if test="khrw.cydw!=null">
                      and  dr.rwmc like CONCAT('%',#{rw.cydw},'%')
                </if>
                <if test="loginDeptId!=null">
                      and  ff.dwdm=#{loginDeptId}
                </if>
                <if test="khrw.rwzt!=null">
                      and  ff.zt=#{khrw.rwzt}
                </if>
                <if test="khrw.status!=null">
                      and  rw.rwzt=#{khrw.status}
                </if>
          </where>
          order by rw.create_time desc
    </select>
</mapper>
