Newer
Older
huludao / src / main / resources / mapper / RiverManage / RiverPatrolDao.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.RiverPatrolDao" >
  <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.RiverPatrol" >
    <id column="Serial" property="serial" jdbcType="BIGINT" />
    <result column="Chief_User_No" property="chiefUserNo" jdbcType="VARCHAR" />
    <result column="Patrol_0Time" property="patrolTime" jdbcType="TIMESTAMP" />
    <result column="Patrol_No" property="patrolNo" jdbcType="VARCHAR" />
  </resultMap>

  <!-- 通用查询结果列 -->
  <sql id="Base_Column_List">
			r.Serial serial,
			r.River_Chief_No riverChiefNo,
			r.Patrol_Start_Time patrolStartTime,
			r.Patrol_No patrolNo,
			r.Patrol_Summary patrolSummary,
			r.Patrol_End_Time patrolEndTime,
			r.Patrol_Pics_No patrolPicsNo,
			r.River_No riverNo,
			r.Patrol_Distance patrolDistance,
			r.Patrol_Coordinates patrolCoordinates,
			r.Patrol_Name patrolName,
		</sql>

    <sql id="Base_Column_ListExt">
        Serial, River_Chief_No, Patrol_Start_Time, Patrol_No, Patrol_End_Time, Patrol_Pics_No,
        River_No, Patrol_Distance, Patrol_Name
    </sql>
    <sql id="Blob_Column_List">
        Patrol_Summary, Patrol_Coordinates
    </sql>

  <select id="selectRiverPatrolList" resultType="com.newfiber.api.pc.model.River.RiverPatrol" parameterType="com.newfiber.api.pc.model.River.RiverPatrol" >
    select
        r.Serial serial,r.River_Chief_No riverChiefNo,r.Patrol_Name patrolName,DATE_FORMAT(r.Patrol_Start_Time,'%Y-%m-%d %T') time,r.Patrol_No patrolNo,
        o.user_name chiefUserName, b.River_Name riverName
        from river_patrol r
        inner join river_chief f
        on f.Chief_User_No = r.River_Chief_No
        inner join river_info_basis b
        on f.River_No = b.River_No
        inner join huludao_main.sys_user_info o
        on o.User_No = r.River_Chief_No
        where 1=1
        <if test="patrolNo != null and patrolNo != ''">
            and r.Patrol_No = #{patrolNo,jdbcType=VARCHAR}
        </if>
        <if test="riverChiefNo != null and riverChiefNo != ''">
            and r.River_Chief_No = #{riverChiefNo,jdbcType=VARCHAR}
        </if>
        <if test="riverName != null and riverName != ''">
            and b.River_Name like '%${riverName}%'
        </if>
        order by r.Patrol_Start_Time DESC
        <if test="pageNo != null" >
            limit #{pageNo} ,#{pageSize}
        </if>
  </select>

    <select id="selectRiverPatrolListByWeiXin" resultMap="BaseResultMap" parameterType="Map" >
        select
        r.Serial serial,r.River_Chief_No riverChiefNo,r.Patrol_Summary patrolSummary,DATE_FORMAT(r.Patrol_Start_Time,'%Y-%m-%d %T') time,r.Patrol_No patrolNo,
        b.River_Name riverName,f.Chief_Grade_Zn chiefGradeZn,
        o.user_name 'chiefUserName'
        from river_patrol r
        inner join river_chief f
        on f.Chief_User_No = r.River_Chief_No
        inner join river_info_basis b
        on f.River_No = b.River_No
        inner join huludao_main.sys_user_info o
        on o.User_No = r.River_Chief_No
        where 1=1
        <if test="riverNo != null and riverNo != ''">
          and b.River_No = #{riverNo,jdbcType=VARCHAR}
        </if>
        <if test="createTime != null">
            and r.Patrol_Start_Time between #{createTime} and #{endTime}
        </if>
        <if test="page != null and rows != null">
            limit #{page},#{rows}
        </if>
    </select>

  <delete id="deleteRiverPatrol" parameterType="com.newfiber.api.pc.model.River.RiverPatrol" >
    delete from river_patrol
    where Patrol_No = #{patrolNo,jdbcType=VARCHAR}
  </delete>

  <insert id="addRiverPatrol" parameterType="com.newfiber.api.pc.model.River.RiverPatrol" >
    insert into river_patrol
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="patrolNo != null" >
        Patrol_No,
      </if>
      <if test="chiefUserNo != null" >
        River_Chief_No,
      </if>
      <if test="patrolTime != null" >
        Patrol_Start_Time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="patrolNo != null" >
        #{patrolNo,jdbcType=VARCHAR},
      </if>
      <if test="chiefUserNo != null" >
        #{chiefUserNo,jdbcType=VARCHAR},
      </if>
      <if test="patrolTime != null" >
        #{patrolTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

  <select id="countRiverPatrolList" parameterType="com.newfiber.api.pc.model.River.RiverPatrol" resultType="java.lang.Integer" >
    select count(0)
      from river_patrol r
      inner join river_chief f
      on f.Chief_User_No = r.River_Chief_No
      inner join river_info_basis b
      on f.River_No = b.River_No
      inner join huludao_main.sys_user_info o
      on o.User_No = r.River_Chief_No
      where 1=1
      <if test="patrolNo != null and patrolNo != ''">
        and r.Patrol_No = #{patrolNo,jdbcType=VARCHAR}
      </if>
      <if test="riverChiefNo != null and riverChiefNo != ''">
          and r.River_Chief_No = #{riverChiefNo,jdbcType=VARCHAR}
      </if>
      <if test="riverName != null and riverName != ''">
          and b.River_Name like '%${riverName}%'
      </if>
  </select>

  <update id="updateRiverPatrol" parameterType="com.newfiber.api.pc.model.River.RiverPatrol" >
    update river_patrol
    <set >
      <if test="chiefGrade != null" >
        Chief_Grade = #{chiefGrade,jdbcType=VARCHAR},
      </if>
      <if test="chiefGradeZn != null" >
        Chief_Grade_Zn = #{chiefGradeZn,jdbcType=NVARCHAR},
      </if>
      <if test="chiefDuty != null" >
        Chief_Duty = #{chiefDuty,jdbcType=NVARCHAR},
      </if>
      <if test="riverNo != null" >
        River_No = #{riverNo,jdbcType=VARCHAR},
      </if>
    </set>
    where Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
  </update>

  <select id="countRiverPatrolTotal" resultType="com.newfiber.api.pc.model.River.RiverPatrol" parameterType="com.newfiber.api.pc.model.River.RiverPatrol">
    SELECT COUNT(DISTINCT r.Serial) countSize,
      o.user_name chiefUserName
        FROM river_patrol r
        inner join huludao_main.sys_user_info o
        on o.User_No = r.River_Chief_No
        where 1=1
        <if test="createTime != null">
          and r.Patrol_Start_Time between #{createTime,jdbcType=DATE} and #{endTime,jdbcType=DATE}
        </if>
      GROUP BY o.user_name
        order by countSize desc
        limit 0,5
  </select>

  <select id="selectPatrolUserTotal" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverPatrol">
    select DISTINCT s.User_No riverChiefNo
      from administrative_division a
      inner join division_org_manage m
      on a.Division_No = m.Division_No
      inner join huludao_main.sys_user_org s
      on s.Org_No = m.Org_No
      where a.Division_No = #{divisionNo,jdbcType=VARCHAR}
  </select>
  
  <select id="selectPatrolByUserNo" resultMap="BaseResultMap" >
	 SELECT
		r.Serial serial,
		s.user_name chiefUserName,
		r.Patrol_No patrolNo,
		r.River_Chief_No riverChiefNo,
      DATE_FORMAT(r.Patrol_Start_Time,'%Y-%m-%d %T') time,
		i.River_Name divisionNo
	FROM
		river_patrol r
	INNER JOIN huludao_main.sys_user_info s ON r.River_Chief_No = s.User_No
	INNER JOIN river_chief c ON r.River_Chief_No = c.Chief_User_No
	INNER JOIN river_info_basis i ON i.River_No = c.River_No
	WHERE
		1=1
      <if test="list != null">
          AND s.User_No in
          <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
              #{item}
          </foreach>
      </if>
    <if test="sort != null">
     ORDER BY ${sort}
     	<if test="order != null">
     	${order}
     	</if>
    </if>
    <if test="sort == null">
    ORDER BY r.Patrol_Start_Time DESC
    </if>
    <if test="pageSize != 0">
    	limit #{pageNo} ,#{pageSize}
    </if>
  </select>
  
  <select id="getPatrolCountByUserNo" resultType="int" parameterType="java.util.List">
	 SELECT
		count(r.Serial)
	FROM
		river_patrol r
	INNER JOIN huludao_main.sys_user_info s ON r.River_Chief_No = s.User_No
	WHERE
		1=1
      <if test="list != null">
          AND s.User_No in
          <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
              #{item}
          </foreach>
      </if>
  </select>
  
  <select id="getSubUserNo" resultType="java.lang.String" parameterType="java.lang.String">
	SELECT
		uo.User_No
	FROM
		huludao_main.sys_user_org uo
	INNER JOIN division_org_manage dom ON uo.Org_No = dom.Org_No
	INNER JOIN administrative_division ad ON ad.Division_No = dom.Division_No
	WHERE
		ad.Division_No IN (
			SELECT
				ad1.Division_No
			FROM
				administrative_division ad1
			INNER JOIN division_org_manage dom1 ON ad1.Parent_Division_No = dom1.Division_No
			INNER JOIN huludao_main.sys_user_org uo1 ON uo1.Org_No = dom1.Org_No
			WHERE
				uo1.User_No = #{userNo}
		)
  </select>

    <select id="selectRiverPatrolByRiverNo" parameterType="com.newfiber.api.pc.model.River.RiverPatrol" resultType="java.lang.Integer">
        select count(r.Serial)
          from river_patrol r
          inner join river_chief f
          on r.River_Chief_No = f.Chief_User_No
          inner join river_info_basis i
          on i.River_No = f.River_No
          where f.River_No = #{riverNo,jdbcType=VARCHAR}
          <if test="createTime != null">
            and r.Patrol_Start_Time between #{createTime} and #{endTime}
          </if>
    </select>
    
    <select id="getTourInfoByChiefNo" resultType="com.newfiber.api.pc.model.River.RiverPatrol">
        SELECT <include refid="Base_Column_ListExt" />,<include refid="Blob_Column_List" />
        FROM river_patrol r
        WHERE r.River_Chief_No = #{riverChiefNo,jdbcType=VARCHAR}
        <if test="startTime != null">
            and r.Patrol_Start_Time &gt;= #{startTime}
        </if>
        <if test="endTime != null">
            and r.Patrol_Start_Time &lt;= #{endTime}
        </if>
        order by r.Patrol_Start_Time desc
    </select>

  <!-- 根据行政区划编号获取河长巡查列表 -->
  <select id="queryListByDivisionNo" resultType="com.newfiber.api.pc.model.River.RiverPatrol" parameterType="Map">
    select <include refid="Base_Column_List" />
    b.River_Name riverName,
    o.user_name userName,
    b.Division_No divisionNo
    from river_patrol r
    inner join river_info_basis b
    on b.River_No = r.River_No
    inner join huludao_main.sys_user_info o
    on r.River_Chief_No = o.user_No
    where b.Division_No = '${divisionNo}'
    <choose>
      <when test="sidx != null and sidx.trim() != ''">
        order by ${sidx} ${order}
      </when>
      <otherwise>
        order by r.Patrol_End_Time desc
      </otherwise>
    </choose>
    <if test="startRow != null and pageSize != null">
      limit #{startRow},#{pageSize}
    </if>
  </select>

  <!-- 根据巡查编号获取每次巡河的问题数量和问题解决数量 -->
  <select id="queryCountByPatrolNo" resultType="com.newfiber.api.pc.model.River.RiverPatrol">
		select a.problemNum from (
			select count(p.Patrol_Problem_No) as problemNum from patrol_problem as p
			where p.Patrol_No = '${patrolNo}'
		union
			select count(r.Patrol_Problem_No) as finishedNum from patrol_problem as r
			where r.Problem_State = 7 and r.Patrol_No = '${patrolNo}') as a
	</select>

  <!-- 根据巡查编号获取河长巡查具体信息 -->
  <select id="queryInfoByPatrolNo" resultType="com.newfiber.api.pc.model.River.RiverPatrol">
    select <include refid="Base_Column_List" />
    b.River_Name riverName,
    o.user_name userName,
    b.Division_No divisionNo
    from river_patrol r
  <choose>
      <when test='userNo !=null and userNo == "Admin"'>
          left join river_info_basis b
          on b.River_No = r.River_No
          left join huludao_main.sys_user_info o
          on r.River_Chief_No = o.user_No
          where r.Patrol_No = #{patrolNo,jdbcType=VARCHAR}
      </when>
      <otherwise>
          inner join river_info_basis b
          on b.River_No = r.River_No
          inner join huludao_main.sys_user_info o
          on r.River_Chief_No = o.user_No
          where r.Patrol_No = #{patrolNo,jdbcType=VARCHAR}
      </otherwise>
  </choose>

  </select>
  <!--本级河长巡查次数统计-->
  <select id="pollingTimesCurrnt" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.ProblemStatistical">
		select d.User_No code,d.user_name name,count(e.River_Chief_No) num from
		administrative_division a INNER JOIN river_info_basis b on a.Division_No = b.Division_No
		INNER JOIN river_chief c on b.River_No = c.River_No
		INNER JOIN huludao_main.sys_user_info d on c.Chief_User_No = d.User_No
		left join river_patrol e on d.User_No = e.River_Chief_No
		where exists
		( select ad.Parent_Division_No from login_info li,river_chief rc,river_info_basis rib,administrative_division ad
		  where ad.Parent_Division_No = a.Parent_Division_No and  li.userNo = rc.Chief_User_No and rc.River_No = rib.River_No
		  and rib.Division_No = ad.Division_No and li.sId = #{sid}
		 )
		AND (e.Patrol_End_Time BETWEEN #{st} and #{et} or e.Patrol_End_Time is null)
		GROUP BY d.User_No,d.user_name
		order by d.User_No
	</select>
  <!--根据条件获取河长巡查表列表(分页)-->
  <select id="queryListByUserNo" parameterType="Map" resultType="com.newfiber.api.pc.model.River.RiverPatrol">
    SELECT a.Serial,
    a.River_Chief_No,
    a.Patrol_Start_Time,
    a.Patrol_No,
    a.Patrol_Summary,
    a.Patrol_End_Time,
    a.Patrol_Pics_No,
    a.River_No,
    a.Patrol_Distance,
    a.Patrol_Coordinates,a.Patrol_Name,b.user_name,c.River_Name
    FROM river_patrol a,huludao_main.sys_user_info b,river_info_basis c
    WHERE a.River_Chief_No = b.User_No
    AND a.River_No = c.River_No
    AND a.River_Chief_No = #{userNo}
    AND a.Patrol_Start_Time BETWEEN #{st} and #{et}
    ORDER BY a.Patrol_Start_Time
    <if test="startPage != null and pageSize != null">
      limit #{startPage},#{pageSize}
    </if>
  </select>
  <!--查询当前用户下级区域所有用户巡查总距离-->
  <select id="queryDistance" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.InspectTheDistance">
    select a.Division_No divisionNo,a.Division_Name divisionName,c.Chief_Duty position,d.User_No userNo,d.user_name userName,sum(e.Patrol_Distance) mileage from
    administrative_division a INNER JOIN river_info_basis b on a.Division_No = b.Division_No
    INNER JOIN river_chief c on b.River_No = c.River_No
    INNER JOIN huludao_main.sys_user_info d on c.Chief_User_No = d.User_No
    left join river_patrol e on d.User_No = e.River_Chief_No
    where exists
    (select ad.Parent_Division_No from login_info li,river_chief rc,river_info_basis rib,administrative_division ad
    where ad.Division_No = a.Parent_Division_No and  li.userNo = rc.Chief_User_No and rc.River_No = rib.River_No and rib.Division_No = ad.Division_No and li.sId = #{sid})
    AND (e.Patrol_Start_Time BETWEEN #{st} AND #{et} OR e.Patrol_No is null)
    group by a.Division_No,a.Division_Name,c.Chief_Duty,d.User_No,d.user_name
    ORDER BY mileage
    <if test="startPage != null and pageSize != null">
      limit #{startPage},#{pageSize}
    </if>
  </select>
  <!--下级区域河长巡查次数统计-->
  <select id="pollingTimesSubordinate" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.InspectTheDistance">
    select a.Division_No divisionNo,a.Division_Name divisionName ,c.Chief_Duty position,d.User_No userNo,d.user_name userName,count(e.Patrol_No) num from
    administrative_division a INNER JOIN river_info_basis b on a.Division_No = b.Division_No
    INNER JOIN river_chief c on b.River_No = c.River_No
    INNER JOIN huludao_main.sys_user_info d on c.Chief_User_No = d.User_No
    left join river_patrol e on d.User_No = e.River_Chief_No
    where exists
    ( select ad.Parent_Division_No from login_info li,river_chief rc,river_info_basis rib,administrative_division ad
    where ad.Division_No = a.Parent_Division_No and  li.userNo = rc.Chief_User_No and rc.River_No = rib.River_No and rib.Division_No = ad.Division_No and li.sId = #{sid})
    AND (e.Patrol_Start_Time BETWEEN #{st} AND #{et} OR e.Patrol_No is null)
    group by a.Division_No,a.Division_Name,c.Chief_Duty,d.User_No,d.user_name
    ORDER BY num desc
    <if test="startPage != null and pageSize != null">
      limit #{startPage},#{pageSize}
    </if>
  </select>
  <!--获取指定区划每个河长的巡查次数-->
  <select id="pollingTimesByDivisionNo" parameterType="String" resultType="com.newfiber.api.mobile.model.domain.InspectTheDistance">
    select c.Chief_Duty position,d.User_No userNo,d.user_name userName,count(e.Patrol_No) num from
    administrative_division a INNER JOIN river_info_basis b on a.Division_No = b.Division_No
    INNER JOIN river_chief c on b.River_No = c.River_No
    INNER JOIN huludao_main.sys_user_info d on c.Chief_User_No = d.User_No
    left join river_patrol e on d.User_No = e.River_Chief_No
    where
    a.Division_No = #{divisionNo}
    AND (e.Patrol_Start_Time BETWEEN #{st} AND #{et} OR e.Patrol_No is null)
    group by c.Chief_Duty,d.User_No,d.user_name
    ORDER BY num desc
    <if test="startPage != null and pageSize != null">
      limit #{startPage},#{pageSize}
    </if>
  </select>
  <!--下级区域应巡人数-->
  <select id="poollingUserNumSubordinate" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.ProblemStatistical">
		select a.Division_No code,a.Division_Name name,count(pdc.Chief_User_No) total from
		administrative_division a left JOIN river_info_basis b on a.Division_No = b.Division_No
		left JOIN river_chief c on b.River_No = c.River_No
	  	left join patrol_days_config pdc on pdc.River_No = c.River_No and pdc.Chief_User_No = c.Chief_User_No
		left JOIN huludao_main.sys_user_info d on c.Chief_User_No = d.User_No
		where exists
		( select ad.Parent_Division_No from login_info li,river_chief rc,river_info_basis rib,administrative_division ad
		  where ad.Division_No = a.Parent_Division_No and  li.userNo = rc.Chief_User_No and rc.River_No = rib.River_No and rib.Division_No = ad.Division_No and li.sId = #{sid})
		GROUP BY a.Division_No,a.Division_Name
	</select>
  <!--个区域已巡检人数-->
  <select id="inspected" parameterType="Map" resultType="int">
	    select count(pdc.Chief_User_No) from
	    administrative_division a left JOIN river_info_basis b on a.Division_No = b.Division_No
		left JOIN river_chief c on b.River_No = c.River_No
	    left join patrol_days_config pdc on pdc.River_No = c.River_No and pdc.Chief_User_No = c.Chief_User_No
		where EXISTS
		(select rp.River_No from river_patrol rp where rp.River_No = c.River_No
		 and rp.River_Chief_No = c.Chief_User_No AND rp.Patrol_Start_Time BETWEEN #{st} and #{et})
		AND a.Division_No = #{divisionNo}
	</select>


  <!-- 按照当前河长河长编号和河道编号查询其所属组织 -->
  <select id="queryOrgNoByRiverAndChiefNo" resultType="java.lang.String" parameterType="com.newfiber.api.pc.model.UserManager.SysOrganization">
		select m.Org_No from
		administrative_division i
		inner join division_org_manage m
		on i.Division_No = m.Division_No
		inner join huludao_main.sys_organization o
		on o.Org_No = m.Org_No
		inner join river_info_basis s
		on i.Division_No = s.Division_No
		inner join river_chief r
		on r.River_No = s.River_No
		where r.Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
		and r.River_No = #{riverNo,jdbcType=VARCHAR}

	</select>

    <select id="queryList" resultType="com.newfiber.api.pc.model.River.RiverPatrol" parameterType="Map">
        select <include refid="Base_Column_List" />
        b.River_Name riverName,
        o.user_name userName,
        b.Division_No divisionNo
        from river_patrol r
        <choose>
            <when test='userNo !=null and userNo == "Admin"'>
                left join river_info_basis b
                on b.River_No = r.River_No
                left join huludao_main.sys_user_info o
                on r.River_Chief_No = o.user_No
            </when>
            <otherwise>
                inner join river_info_basis b
                on b.River_No = r.River_No
                inner join huludao_main.sys_user_info o
                on r.River_Chief_No = o.user_No
                where o.user_no = #{userNo}
                <if test="divisionNo != null and divisionNo != ''">
                    and b.Division_No = #{divisionNo}
                </if>
            </otherwise>
        </choose>
        order by r.Patrol_Start_Time desc
        <if test="startRow != null and pageSize != null">
            limit #{startRow},#{pageSize}
        </if>
    </select>

    <select id="getAllChiefNo" resultType="com.newfiber.api.pc.model.River.RiverPatrol">
        SELECT <include refid="Base_Column_ListExt" />,<include refid="Blob_Column_List" />
        FROM river_patrol r where 1=1
        <if test="startTime != null">
            and r.Patrol_Start_Time &gt;= #{startTime}
        </if>
        <if test="endTime != null">
            and r.Patrol_Start_Time &lt;= #{endTime}
        </if>
        order by Patrol_Start_Time desc
    </select>

    <select id="selectAll" resultType="com.newfiber.api.pc.model.River.RiverPatrol" parameterType="com.newfiber.api.pc.model.River.RiverPatrol" >
        select
        r.Serial serial,r.River_Chief_No riverChiefNo,r.Patrol_Name patrolName,DATE_FORMAT(r.Patrol_Start_Time,'%Y-%m-%d %T') time,r.Patrol_No patrolNo,
        o.user_name chiefUserName, b.River_Name riverName
        from river_patrol r
        inner join river_chief f
        on f.Chief_User_No = r.River_Chief_No
        inner join river_info_basis b
        on f.River_No = b.River_No
        inner join huludao_main.sys_user_info o
        on o.User_No = r.River_Chief_No
        where 1=1
        <if test="riverName != null and riverName != ''">
            and b.River_Name like '%${riverName}%'
        </if>
        order by r.Patrol_Start_Time desc
    </select>


    <select id="queryOrgNoByUserNo" resultType="java.lang.String" parameterType="com.newfiber.api.pc.model.UserManager.SysOrganization">
		select org_no from
		huludao_main.sys_user_org o
		where o.user_no = #{chiefUserNo,jdbcType=VARCHAR}
		limit 1
	</select>

    <select id="selectByRiverAndName" resultType="com.newfiber.api.pc.model.River.RiverPatrol">
        select
        r.Serial serial,r.River_Chief_No riverChiefNo,r.Patrol_Name patrolName,DATE_FORMAT(r.Patrol_Start_Time,'%Y-%m-%d %T') time,r.Patrol_No patrolNo,
        o.user_name chiefUserName,rib.River_No, rib.River_Name riverName
        from
        river_patrol r
        inner join river_info_basis rib
        on r.River_No = rib.River_No
        inner join huludao_main.sys_user_info o
        on o.User_No = r.River_Chief_No
		where 1=1
        <if test="riverName != null and riverName != ''">
            and rib.River_Name like '%${riverName}%'
        </if>
        <if test="collect != null and collect.size > 0">
            and r.River_No in
            <foreach collection="collect" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
	</select>
</mapper>