Newer
Older
huludao / src / main / resources / mapper / RiverManage / RiverInfoBasisDao.xml
<?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.newfiber.api.pc.dao.RiverManage.RiverInfoBasisDao" >
  <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.RiverInfoBasis" >
    <id column="Serial" property="serial" jdbcType="BIGINT" />
    <result column="River_Name" property="riverName" jdbcType="NVARCHAR" />
    <result column="River_Grade" property="riverGrade" jdbcType="INTEGER" />
    <result column="River_Grade_Zn" property="riverGradeZn" jdbcType="NVARCHAR" />
    <result column="Parent_River_No" property="parentRiverNo" jdbcType="VARCHAR" />
    <result column="River_Length" property="riverLength" jdbcType="DECIMAL" />
    <result column="River_Start_Address" property="riverStartAddress" jdbcType="NVARCHAR" />
    <result column="River_End_Address" property="riverEndAddress" jdbcType="NVARCHAR" />
    <result column="Flow_Through_Region" property="flowThroughRegion" jdbcType="NVARCHAR" />
    <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="Create_User_No" property="createUserNo" jdbcType="VARCHAR" />
    <result column="River_No" property="riverNo" jdbcType="VARCHAR" />
    <result column="Division_No" property="divisionNo" jdbcType="VARCHAR" />
  </resultMap>

  <!-- 通用查询结果列 -->
  <sql id="Base_Column_List">
			r.Serial,
			r.River_Name,
			r.River_Grade,
			r.River_Grade_Zn,
			r.Parent_River_No,
			r.River_Length,
			r.River_Start_Address,
			r.River_End_Address,
			r.Flow_Through_Region,
			r.Create_Time,
			r.Create_User_No,
			r.River_No,
			r.Division_No,
			r.River_Information,
			r.River_Pics_No,
			r.Point_XY
		</sql>

  <select id="selectRiverInfoBasisList" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" >
    select
      r.Serial serial,r.River_Name riverName,r.River_Grade riverGrade,r.River_Grade_Zn riverGradeZn,r.Parent_River_No parentRiverNo,f.Chief_User_No chiefUserNo,
      r.River_Length riverLength,r.River_Start_Address riverStartAddress,r.River_End_Address riverEndAddress,r.Flow_Through_Region flowThroughRegion,
    DATE_FORMAT(r.Create_Time,'%Y-%m-%d %T') time,r.Create_User_No createUserNo,r.River_No riverNo,r.Division_No divisionNo,r.River_Information riverInformation,
      r.River_Pics_No riverPicsNo,f.Chief_Grade chiefGrade,f.Chief_Grade_Zn chiefGradeZn,a.Division_Name divisionName,r.Point_XY pointXY,
    o.user_name 'createUserName',
    o.phone_num 'phone',
    i.user_name 'chiefUserName'
    from river_info_basis r
    inner join huludao_main.sys_user_info o
    on o.User_No = r.Create_User_No
    inner join river_chief f
    on f.River_No = r.River_No
    inner join huludao_main.sys_user_info i
    on i.User_No = f.Chief_User_No
    inner join administrative_division a
    on a.Division_No = r.Division_No
    where 1=1
    <if test="riverNo != null and riverNo != ''">
      and r.River_No = #{riverNo,jdbcType=VARCHAR}
    </if>
    <if test="riverGrade != null and riverGrade != ''">
      and r.River_Grade = #{riverGrade,jdbcType=INTEGER}
    </if>
    <if test="riverName != null and riverName != ''">
      and r.River_Name like '%${riverName}%'
    </if>
    <if test="pageNo != null" >
      order by r.Serial limit #{pageNo} ,#{pageSize}
    </if>
  </select>

  <select id="selectRiverInfoBasisPoint" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select Point_XY pointXY
      from river_info_basis
      where River_No = #{riverNo,jdbcType=VARCHAR}
  </select>
  
  <select id="getRiverByUser" resultType="String" parameterType="String">
    select River_No
      from river_chief
      where Chief_User_No = #{userNo,jdbcType=VARCHAR}
      limit 0,1
  </select>

  <select id="getChildRiver" parameterType="String" resultType="String">
    select distinct River_No from river_info_basis where FIND_IN_SET(River_No,getChildrenRiver(#{riverNo}))
  </select>
  
  <select id="getChildRiverByUser" parameterType="String" resultType="String">
    <choose>
      <when test="userNo != null">
        select distinct River_No from river_info_basis
        where Parent_River_No in ( select a.River_No from river_info_basis a,river_chief b where a.River_No = b.River_No and  Chief_User_No = #{userNo})
        union all select DISTINCT a.River_No from river_info_basis a,river_chief b where a.River_No = b.River_No and  Chief_User_No = #{userNo}
      </when>
      <otherwise>
        select distinct River_No from river_info_basis where Parent_River_No in
        (select River_No from river_info_basis where Parent_River_No = '0')
        union all select DISTINCT River_No from river_info_basis where Parent_River_No = '0'
      </otherwise>
    </choose>
  </select>

  <select id="selectRiverInfoBasisByDivisionNo" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" >
    select
    r.Serial serial,r.River_Name riverName,r.River_Grade riverGrade,r.River_Grade_Zn riverGradeZn,r.Parent_River_No parentRiverNo,
    r.River_Length riverLength,r.River_Start_Address riverStartAddress,r.River_End_Address riverEndAddress,r.Flow_Through_Region flowThroughRegion,
    DATE_FORMAT(r.Create_Time,'%Y-%m-%d %T') time,r.Create_User_No createUserNo,r.River_No riverNo,r.Division_No divisionNo,r.River_Information riverInformation,
    r.River_Pics_No riverPicsNo,f.Chief_Grade chiefGrade,f.Chief_Grade_Zn chiefGradeZn,a.Division_Name divisionName,
    o.user_name 'createUserName',
    o.phone_num 'phone'
    from river_info_basis r
    inner join huludao_main.sys_user_info o
    on o.User_No = r.Create_User_No
    inner join river_chief f
    on f.River_No = r.River_No
    inner join administrative_division a
    on a.Division_No = r.Division_No
    where 1=1
    <if test="divisionNo != null and divisionNo != ''">
      and r.Division_No = #{divisionNo,jdbcType=VARCHAR}
    </if>
    <if test="riverNo != null and riverNo != ''">
      and r.River_No = #{riverNo,jdbcType=VARCHAR}
    </if>
    <if test="pageNo != null" >
      order by r.Serial limit #{pageNo},#{pageSize}
    </if>
  </select>

  <select id="selectRiverInfoBasisByDivisionNoo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" >
    select
    r.Serial serial,r.River_Name riverName,r.River_Grade riverGrade,r.River_Grade_Zn riverGradeZn,r.Parent_River_No parentRiverNo,
    r.River_Length riverLength,r.River_Start_Address riverStartAddress,r.River_End_Address riverEndAddress,r.Flow_Through_Region flowThroughRegion,
    DATE_FORMAT(r.Create_Time,'%Y-%m-%d %T') time,r.Create_User_No createUserNo,r.River_No riverNo,r.Division_No divisionNo,r.River_Information riverInformation,
    r.River_Pics_No riverPicsNo,a.Division_Name divisionName,f.Chief_Grade chiefGrade,f.Chief_Grade_Zn chiefGradeZn,
    o.user_name 'createUserName',
    d.user_name 'chiefUserName',
    d.phone_num 'phone'
    from river_info_basis r
    left join river_chief f
    on f.River_No = r.River_No
    left join huludao_main.sys_user_info o
    on o.User_No = r.Create_User_No
    left join administrative_division a
    on a.Division_No = r.Division_No
    left join huludao_main.sys_user_info d
    on f.Chief_User_No = d.User_No
    where 1=1
    <if test="divisionNo != null and divisionNo != ''">
      and r.Division_No = #{divisionNo,jdbcType=VARCHAR}
    </if>
    <if test="riverNo != null and riverNo != ''">
      and r.River_No = #{riverNo,jdbcType=VARCHAR}
    </if>
      order by r.Serial
  </select>

  <select id="selectByRiverGrade" parameterType="int" resultMap="BaseResultMap">
    SELECT * FROM  river_info_basis WHERE  River_Grade = #{grade}
  </select>

  <delete id="deleteRiverInfoBasis" parameterType="java.util.List" >
    delete from river_info_basis
    where River_No in
    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
      #{item}
    </foreach>
  </delete>

  <insert id="addRiverInfoBasis" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" >
    insert into river_info_basis
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="riverName != null" >
        River_Name,
      </if>
      <if test="riverGrade != null" >
        River_Grade,
      </if>
      <if test="riverGradeZn != null" >
        River_Grade_Zn,
      </if>
      <if test="parentRiverNo != null" >
        Parent_River_No,
      </if>
      <if test="riverLength != null" >
        River_Length,
      </if>
      <if test="riverStartAddress != null" >
        River_Start_Address,
      </if>
      <if test="riverEndAddress != null" >
        River_End_Address,
      </if>
      <if test="flowThroughRegion != null" >
        Flow_Through_Region,
      </if>
      <if test="createUserNo != null" >
        Create_User_No,
      </if>
      <if test="riverNo != null" >
        River_No,
      </if>
      <if test="divisionNo != null" >
        Division_No,
      </if>
      <if test="riverInformation != null" >
        River_Information,
      </if>
      <if test="riverPicsNo != null" >
        River_Pics_No,
      </if>
      <if test="pointXY != null" >
        Point_XY,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="riverName != null" >
        #{riverName,jdbcType=VARCHAR},
      </if>
      <if test="riverGrade != null" >
        #{riverGrade,jdbcType=INTEGER},
      </if>
      <if test="riverGradeZn != null" >
        #{riverGradeZn,jdbcType=NVARCHAR},
      </if>
      <if test="parentRiverNo != null" >
        #{parentRiverNo,jdbcType=VARCHAR},
      </if>
      <if test="riverLength != null" >
        #{riverLength,jdbcType=DECIMAL},
      </if>
      <if test="riverStartAddress != null" >
        #{riverStartAddress,jdbcType=NVARCHAR},
      </if>
      <if test="riverEndAddress != null" >
        #{riverEndAddress,jdbcType=NVARCHAR},
      </if>
      <if test="flowThroughRegion != null" >
        #{flowThroughRegion,jdbcType=NVARCHAR},
      </if>
      <if test="createUserNo != null" >
        #{createUserNo,jdbcType=VARCHAR},
      </if>
      <if test="riverNo != null" >
        #{riverNo,jdbcType=VARCHAR},
      </if>
      <if test="divisionNo != null" >
        #{divisionNo,jdbcType=VARCHAR},
      </if>
      <if test="riverInformation != null" >
        #{riverInformation,jdbcType=NVARCHAR},
      </if>
      <if test="riverPicsNo != null" >
        #{riverPicsNo,jdbcType=VARCHAR},
      </if>
      <if test="pointXY != null" >
        #{pointXY,jdbcType=NVARCHAR},
      </if>
    </trim>
  </insert>

  <select id="countRiverInfoBasisList" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" resultType="java.lang.Integer" >
    select count(distinct r.Serial)
      from river_info_basis r
      inner join huludao_main.sys_user_info o
      on o.User_No = r.Create_User_No
      where 1=1
      <if test="riverNo != null and riverNo != ''">
        and r.River_No = #{riverNo,jdbcType=VARCHAR}
      </if>
      <if test="riverGrade != null and riverGrade != ''">
        and r.River_Grade = #{riverGrade,jdbcType=INTEGER}
      </if>
      <if test="riverName != null and riverName != ''">
        and r.River_Name like '%${riverName}%'
      </if>
  </select>

  <update id="updateRiverInfoBasis" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" >
    update river_info_basis
    <set>
      <if test="riverName != null and riverName != ''" >
        River_Name = #{riverName,jdbcType=VARCHAR},
      </if>
      <if test="riverGrade != null" >
        River_Grade = #{riverGrade,jdbcType=INTEGER},
      </if>
      <if test="riverGradeZn != null  and riverGradeZn != ''" >
        River_Grade_Zn = #{riverGradeZn,jdbcType=VARCHAR},
      </if>
      <if test="parentRiverNo != null and parentRiverNo != ''" >
        Parent_River_No = #{parentRiverNo,jdbcType=VARCHAR},
      </if>
      <if test="riverLength != null" >
        River_Length = #{riverLength,jdbcType=DECIMAL},
      </if>
      <if test="riverStartAddress != null and riverStartAddress != ''" >
        River_Start_Address = #{riverStartAddress,jdbcType=VARCHAR},
      </if>
      <if test="riverEndAddress != null and riverEndAddress != ''" >
        River_End_Address = #{riverEndAddress,jdbcType=VARCHAR},
      </if>
      <if test="flowThroughRegion != null and flowThroughRegion != ''" >
        Flow_Through_Region = #{flowThroughRegion,jdbcType=VARCHAR},
      </if>
      <if test="divisionNo != null and divisionNo != ''" >
        Division_No = #{divisionNo,jdbcType=VARCHAR},
      </if>
      <if test="riverInformation != null and riverInformation != ''" >
        River_Information = #{riverInformation,jdbcType=VARCHAR},
      </if>
      <if test="riverPicsNo != null and riverPicsNo != ''" >
        River_Pics_No = #{riverPicsNo,jdbcType=VARCHAR},
      </if>
      <if test="pointXY != null and pointXY != ''" >
        Point_XY = #{pointXY,jdbcType=VARCHAR}
      </if>
    </set>
    where River_No = #{riverNo,jdbcType=VARCHAR}
  </update>
  
  <select id="selectRiverByRiverNo" parameterType="java.lang.String" resultMap="BaseResultMap">
    SELECT * FROM river_info_basis r WHERE r.River_No=#{riverNo}
  </select>

  <select id="selectRiverInfoBasisTotal" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" resultType="java.lang.Integer">
    select count(DISTINCT b.Serial)
      from river_info_basis b
      where River_Grade = #{riverGrade,jdbcType=INTEGER}
  </select>

  <select id="countRiverInfoTotalRiver" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" resultType="java.lang.Integer">
    select count(DISTINCT Serial) countSize
      from river_info_basis
         where Parent_River_No = #{riverNo,jdbcType=VARCHAR}
  </select>

  <select id="selectByParentNo" parameterType="string" resultMap="BaseResultMap">
    SELECT * FROM  river_info_basis WHERE  Parent_River_No = #{parentNo}
  </select>

  <select id="countRiverChiefTotalByDivisionNo" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" resultType="java.lang.Integer">
    select count(DISTINCT r.Serial)
      from division_org_manage m
      inner join huludao_main.sys_user_org g
      on g.Org_No = m.Org_No
      inner join river_info_basis r
      on r.Division_No = m.Division_No
      where m.Division_No = #{divisionNo,jdbcType=VARCHAR}
  </select>

  <select id="countRiverMessageTotal" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" resultType="java.lang.Integer">
    select count(DISTINCT Chief_User_No)
      from river_chief
  </select>

  <select id="countRiverInfoMessageTotal" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis" resultType="java.lang.Integer">
    select count(DISTINCT b.River_Name)
    from river_info_basis b
  </select>

  <select id="selectUserNoByRiverNo" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select River_No riverNo
      from river_info_basis r
      inner join river_chief c
      on c.River_No = r.River_No
      where c.Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
  </select>

  <select id="selectRiverNoRiverName" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select r.River_No riverNo,r.River_Name riverName
    from river_info_basis r
    inner join river_chief c
    on c.River_No = r.River_No
    where c.Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
  </select>

  <select id="selectRiverParentRiverNo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select r.River_No riverNo,r.River_Grade riverGrade,r.River_Name riverName
     from river_info_basis r
     where r.Division_No = #{divisionNo,jdbcType=VARCHAR}
  </select>

  <select id="selectRiverParentRiverNoo" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select a.Parent_Division_No parentDivisionNo
    from administrative_division a
    where a.Division_No = #{divisionNo,jdbcType=VARCHAR}
  </select>

  <select id="selectRiverUserName" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select r.chief_User_No chiefUserNo,
      z.user_name 'userName'
      from river_chief r
      inner join huludao_main.sys_user_info z
      on z.User_No = r.Chief_User_No
      where 1=1
      <if test="list != null and list.size > 0">
        and r.Chief_User_No in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
          #{item}
        </foreach>
      </if>
  </select>

  <select id="selectRiverUserNameo" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select r.chief_User_No chiefUserNo,
      z.user_name 'userName'
      from river_chief r
      inner join huludao_main.sys_user_info z
      on z.User_No = r.Chief_User_No
      where 1=1
      <if test="list != null and list.size > 0">
        and r.Chief_User_No in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
          #{item}
        </foreach>
      </if>
      and r.Chief_User_No not in (select r.Chief_User_No from patrol_days_config r)
  </select>

  <select id="selectRiverNoRiverNameByUserNo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select r.River_No riverNo,r.River_Name riverName
      from river_info_basis r
      inner join river_chief f
      on f.River_No = r.River_No
      where 1=1
      <if test="chiefUserNo != null and chiefUserNo != ''">
        and f.Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
      </if>
  </select>


  <select id="selectAddRiverNoRiverNameByUserNo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select a.River_Name riverName,a.River_No riverNo,i.user_name chiefUserName,i.User_No chiefUserNo from river_info_basis a
    inner join river_chief b
    on a.River_No = b.River_No
    inner join huludao_main.sys_user_info i
    on i.User_No = b.Chief_User_No
    where a.River_No not in (select c.River_No from patrol_days_config c)
  </select>

  <select id="selectRiverInfoWaterLevel" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select DISTINCT y.Standard_Level standardLevel,y.Standard_Level_Zn standardLevelZn,y.Data_No dataNo,y.ST siteNo
      from river_info_basis r
      left join river_fracture_manage m
      on m.River_No = r.River_No
      left join fracture_site_manage  s
      on s.Fracture_No = m.Fracture_No
      left join site_water_quality y
      on y.ST = s.Site_No
      where 1=1
      <if test="riverNo != null and riverNo != ''">
        and r.River_No = #{riverNo,jdbcType=VARCHAR}
      </if>
      order by y.Standard_Level asc
      limit 0 , 1
  </select>

  <select id="selectFractureNo" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select DISTINCT r.Fracture_No fractureNo,s.Fracture_Name groupName
      from river_fracture_manage r
      inner join fracture_info_basis s
      on s.Fracture_No = r.Fracture_No
      where r.River_No = #{riverNo,jdbcType=VARCHAR}
  </select>

  <select id="selectSiteNo" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select DISTINCT r.Site_No siteNo,m.Site_Name siteName
      from fracture_site_manage  r
      inner join site_site_manage m
      on m.Site_Serial = r.Site_No
      where r.Fracture_No = #{fractureNo,jdbcType=VARCHAR}
  </select>

  <select id="selectWaterQualityMessage" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.WaterQuality">
    select s.ST siteNo,s.Data_No dataNo,s.Field_Name_ZN fieldNameZn,s.Field_Name fieldName,s.Field_Value fieldValue,s.Unit unit
      from site_water_quality_Evaluate_Data s
      where s.Data_No = #{dataNo,jdbcType=VARCHAR}
      and s.ST = #{siteNo,jdbcType=VARCHAR}
  </select>

  <select id="selectWaterQualityMessageHistory" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.WaterQuality">
    select s.ST siteNo,s.Data_No dataNo,s.Field_Name_ZN fieldNameZn,s.Field_Name fieldName,s.Field_Value fieldValue,s.Unit unit
      from site_water_quality_Evaluate_Data s
      where s.ST = #{siteNo,jdbcType=VARCHAR}
      order by s.Create_Time DESC
  </select>

  <select id="selectWaterQualityMessageHistoryByFieldName" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.WaterQuality">
    select s.ST siteNo,s.Data_No dataNo,s.Field_Name_ZN fieldNameZn,s.Field_Name fieldName,s.Field_Value fieldValue,s.Unit unit,
      DATE_FORMAT(s.Create_Time,'%Y-%m-%d %T') time
      from site_water_quality_Evaluate_Data s
      where s.ST = #{siteNo,jdbcType=VARCHAR}
      and s.Field_Name = #{fieldName,jdbcType=VARCHAR}
      order by s.Create_Time ASC
      limit 0 , 10
</select>

  <select id="selectRiverInformationIsNull" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select r.Serial serial,b.River_Name riverName
      from river_chief r
      inner join river_info_basis b
      on r.River_No = b.River_No
      where r.River_No = #{riverNo,jdbcType=VARCHAR}
  </select>
  
  <select id="getHighestRiverChief" resultType="String">
    select DISTINCT b.Chief_User_No from river_info_basis a,river_chief b
    where a.River_No = b.River_No and  a.Parent_River_No = '0'
  </select>


  <!-- 获取河道基础信息表列表 -->
  <select id="queryList" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select <include refid="Base_Column_List" />
    from river_info_basis
    <choose>
      <when test="sidx != null and sidx.trim() != ''">
        order by ${sidx} ${order}
      </when>
      <otherwise>
        order by Serial desc
      </otherwise>
    </choose>
  </select>

  <!-- 获取河道基础信息表列表 -->
  <select id="queryRiverListByDivisionNo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select <include refid="Base_Column_List" />,
    f.Chief_Grade_Zn chiefGradeZn,
    i.user_name userName
    from river_info_basis r
    left join river_chief f
    on r.River_No = f.River_No
    left join huludao_main.sys_user_info i
    on i.User_No = f.Chief_User_No
    where 1=1
    <if test = "userNo != null and userNo != ''">
      and f.Chief_User_No = #{userNo}
    </if>
  </select>

  <!-- 获取河道基础信息表列表 -->
  <select id="queryRiverInfoByRivertNo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select <include refid="Base_Column_List" />,
    b.River_Name parentRiverName,
    f.Chief_Grade_Zn chiefGradeZn,
    f.Chief_Duty chiefDuty,
    i.user_name userName,
    i.phone_num phone_num,
    a.Division_Name divisionName
    from river_info_basis r
    left join river_info_basis b
    on r.Parent_River_No = b.River_No
    inner join administrative_division a
    on a.Division_No = r.Division_No
    left join river_chief f
    on r.River_No = f.River_No
    left join huludao_main.sys_user_info i
    on i.User_No = f.Chief_User_No
    where 1=1
    <if test = "riverNo != null and riverNo != ''">
      and r.River_No = #{riverNo}
    </if>
    <if test = "userNo != null and userNo != ''">
      and f.Chief_User_No = #{userNo}
    </if>
  </select>

  <!-- 获取河道基础信息表列表 -->
  <select id="queryRiverListByParentRivertNo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select <include refid="Base_Column_List" />,
    b.River_Name parentRiverName,
    f.Chief_Grade_Zn chiefGradeZn,
    f.Chief_Duty chiefDuty,
    i.user_name userName,
    i.phone_num phoneNum,
    a.Division_Name divisionName
    from river_info_basis r
    left join river_info_basis b
    on r.Parent_River_No = b.River_No
    inner join administrative_division a
    on a.Division_No = r.Division_No
    left join river_chief f
    on r.River_No = f.River_No
    left join huludao_main.sys_user_info i
    on i.User_No = f.Chief_User_No
    where 1=1
    <if test = "parentRiverNo != null and parentRiverNo != ''">
      and r.Parent_River_No = #{parentRiverNo}
    </if>
  </select>

  <select id="queryRiverListByDivision" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
		select  CONCAT(River_Name,'(',River_Start_Address,'-',River_End_Address,')') riverName,River_No riverNo
		from river_info_basis where Division_No = #{divisionNo}
	</select>

  <select id="batchSelect" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select a.River_Name riverName,a.River_No riverNo,i.user_name chiefUserName,i.User_No chiefUserNo from river_info_basis a
    inner join river_chief b
    on a.River_No = b.River_No
    inner join huludao_main.sys_user_info i
    on i.User_No = b.Chief_User_No
    where a.River_No not in (select c.River_No from patrol_days_config c)
    and a.River_No in
    <foreach collection="riverNos" index="index" item="item" open="(" separator="," close=")">
      #{item}
    </foreach>
	</select>


    <select id="selectByUserNo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
      select <include refid="Base_Column_List" />
      from river_info_basis r
      inner join river_chief b
      on r.River_No = b.River_No
      where b.Chief_User_No = #{userNo}
    </select>

  <select id="baseRiver" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
    select <include refid="Base_Column_List" />
    from river_info_basis r
    where r.River_Grade = 3 and r.Parent_River_No = 0
  </select>

  <select id="selectDivisionNoByUserNo" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis">
     SELECT DISTINCT r.Division_No divisionNo,r.River_No
    FROM river_info_basis r INNER JOIN river_chief rc ON rc.River_No = r.River_No
      where rc.Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
    limit 1
  </select>
</mapper>