<?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.mobile.dao.PatrolProblemDao"> <!-- 可根据自己的需求,是否要使用 --> <resultMap type="com.newfiber.api.mobile.model.domain.PatrolProblem" id="patrolProblemMap"> <result property="patrolProblemNo" column="Patrol_Problem_No"/> <result property="problemType" column="Problem_Type"/> <result property="problemState" column="Problem_State"/> <result property="problemStateStr" column="Problem_State_Str"/> <result property="problemAddress" column="Problem_Address"/> <result property="problemTime" column="Problem_Time"/> <result property="problemDescription" column="Problem_Description"/> <result property="problemPicsNo" column="Problem_Pics_No"/> <result property="problemProcessNo" column="Problem_Process_No"/> <result property="patrolNo" column="Patrol_No"/> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> p.Patrol_Problem_No, p.Problem_Type, p.Problem_State, p.Problem_State_Str, p.Problem_Address, p.Problem_Time, p.Problem_Description, p.Problem_Pics_No, p.Problem_Process_No, p.Patrol_No, p.Coordinate, </sql> <!-- 获取列表 --> <select id="queryList" resultType="com.newfiber.api.mobile.model.domain.PatrolProblem"> select <include refid="Base_Column_List" /> from patrol_problem <choose> <when test="sidx != null and sidx.trim() != ''"> order by ${sidx} ${order} </when> <otherwise> order by Patrol_Problem_No desc </otherwise> </choose> </select> <select id="selectAllProblemList" resultType="com.newfiber.api.mobile.model.domain.PatrolProblem"> select p.Patrol_Problem_No, p.Coordinate, b.Complain_Type_Name complainTypeName from patrol_problem p inner join complain_type_basis b on p.Problem_Type = b.Complain_Type_No </select> <select id="queryListByPatrolNo" resultType="com.newfiber.api.mobile.model.domain.PatrolProblem"> select <include refid="Base_Column_List" /> b.Complain_Type_Name complainTypeName, s.River_Name riverName, o.user_name userName, o.phone_num phone_num from patrol_problem p inner join complain_type_basis b on p.Problem_Type = b.Complain_Type_No inner join river_patrol t on t.Patrol_No = p.Patrol_No inner join river_info_basis s on s.River_No = t.River_No inner join huludao_main.sys_user_info o on o.User_No = t.River_Chief_No where 1=1 <if test="patrolNo != null and patrolNo != ''"> and p.Patrol_No = #{patrolNo,jdbcType=VARCHAR} </if> <if test="patrolProblemNo != null and patrolProblemNo != ''"> and p.Patrol_Problem_No = #{patrolProblemNo,jdbcType=VARCHAR} </if> </select> <select id="queryProblemByPatrolNo" resultType="java.lang.Integer" parameterType="java.lang.String"> select count(p.Patrol_Problem_No) from patrol_problem p inner join river_patrol r on p.Patrol_No = r.Patrol_No where r.Patrol_No = #{patrolNo,jdbcType=VARCHAR} </select> <select id="queryFinishedByPatrolNo" resultType="java.lang.Integer" parameterType="java.lang.String"> select count(p.Problem_State) from patrol_problem p inner join river_patrol r on p.Patrol_No = r.Patrol_No where r.Patrol_No = #{patrolNo,jdbcType=VARCHAR} and p.Problem_State = 2 </select> <!--获取巡查问题列表(分类统计)--> <select id="queryProblemListByUserNo" resultType="com.newfiber.api.mobile.model.domain.PatrolProblem"> select <include refid="Base_Column_List" /> b.Complain_Type_Name complainTypeName, s.River_Name riverName from patrol_problem p inner join complain_type_basis b on p.Problem_Type = b.Complain_Type_No inner join river_patrol t on t.Patrol_No = p.Patrol_No inner join river_info_basis s on s.River_No = t.River_No inner join process_problem e on e.Process_No = p.Problem_Process_No where 1=1 <if test="problemState != null"> and p.Problem_State = #{problemState,jdbcType=INTEGER} </if> <if test="processNextUserNo != null and processNextUserNo != ''"> and e.Process_Next_Org in (select Org_No from huludao_main.sys_user_org where User_No = '${processNextUserNo}') </if> limit 1 </select> <!--获取巡查问题列表(分类统计待处理)--> <select id="queryProblemListByUserNoToBeProcessed" resultType="com.newfiber.api.mobile.model.domain.PatrolProblem" parameterType="java.util.List"> select distinct <include refid="Base_Column_List" /> b.Complain_Type_Name complainTypeName, s.River_Name riverName, e.Process_Next_Org processNextOrg, e.User_Org userOrg, s.River_No riverNo from patrol_problem p inner join complain_type_basis b on p.Problem_Type = b.Complain_Type_No inner join river_patrol t on t.Patrol_No = p.Patrol_No inner join river_info_basis s on s.River_No = t.River_No inner join process_problem e on e.Process_No = p.Problem_Process_No where 1=1 and p.Problem_State != 2 and p.Problem_Process_No in <foreach collection="processPicsList" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </select> <!--获取巡查问题列表(分类统计已处理)--> <select id="queryProblemListByUserNoProcessed" resultType="com.newfiber.api.mobile.model.domain.PatrolProblem"> select distinct <include refid="Base_Column_List" /> b.Complain_Type_Name complainTypeName, s.River_Name riverName, e.Process_Next_Org processNextOrg, e.User_Org userOrg, s.River_No riverNo from patrol_problem p inner join complain_type_basis b on p.Problem_Type = b.Complain_Type_No inner join river_patrol t on t.Patrol_No = p.Patrol_No inner join river_info_basis s on s.River_No = t.River_No inner join process_problem e on e.Process_No = p.Problem_Process_No where 1=1 and e.User_No = '${userNo}' and p.Problem_State = 1 Group by p.Problem_Process_No, p.Patrol_Problem_No, p.Problem_Type, p.Problem_State, p.Problem_State_Str, p.Problem_Address, p.Problem_Time, p.Problem_Description, p.Problem_Pics_No, p.Patrol_No, p.Coordinate, b.Complain_Type_Name, s.River_Name, e.Process_Next_Org, e.User_Org, s.River_No </select> <!--获取巡查问题列表(分类统计已结案)--> <select id="queryProblemListByUserNoClosed" resultType="com.newfiber.api.mobile.model.domain.PatrolProblem"> select distinct <include refid="Base_Column_List" /> b.Complain_Type_Name complainTypeName, s.River_Name riverName, e.Process_Next_Org processNextOrg, e.User_Org userOrg, s.River_No riverNo, e.Process_Time from patrol_problem p inner join complain_type_basis b on p.Problem_Type = b.Complain_Type_No inner join river_patrol t on t.Patrol_No = p.Patrol_No inner join river_info_basis s on s.River_No = t.River_No inner join process_problem e on e.Process_No = p.Problem_Process_No where 1=1 and p.Problem_State = 2 <if test="userNo != null and userNo != ''"> and e.Process_Next_Org in (select Org_No from huludao_main.sys_user_org where User_No = '${userNo}') </if> order by e.Process_Time desc </select> <!--获取某时间段登录用户同级别河流问题数量--> <select id="problemStatisticalInfo" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.ProblemStatistical"> select a.Complain_Type_No code,a.Complain_Type_Name name ,count(b.Problem_Type) num from complain_type_basis a LEFT JOIN patrol_problem b on a.Complain_Type_No = b.Problem_Type where ( exists (select rb.River_No from river_info_basis rb, administrative_division ad where rb.Division_No = ad.Division_No and rb.River_No = b.River_No and exists ( select f.Division_No from login_info c,river_chief d, river_info_basis e ,administrative_division f where c.userNo = d.Chief_User_No and d.River_No = e.River_No and e.Division_No = f.Division_No and f.Parent_Division_No = ad.Parent_Division_No and c.sId = #{sid} ) ) or b.River_No is null) AND (b.Problem_Time BETWEEN #{st} and #{et} OR b.River_No is null) GROUP BY a.Complain_Type_No,a.Complain_Type_Name </select> <!--获取某时间段当前用户同级别河流所有问题总数量--> <select id="problemTotal" parameterType="Map" resultType="int"> select count(b.Problem_Type) from complain_type_basis a LEFT JOIN patrol_problem b on a.Complain_Type_No = b.Problem_Type where ( exists (select rb.River_No from river_info_basis rb, administrative_division ad where rb.Division_No = ad.Division_No and rb.River_No = b.River_No and exists ( select f.Division_No from login_info c,river_chief d, river_info_basis e ,administrative_division f where c.userNo = d.Chief_User_No and d.River_No = e.River_No and e.Division_No = f.Division_No and f.Parent_Division_No = ad.Parent_Division_No and c.sId = #{sid} ) ) or b.River_No is null) AND b.Problem_Time BETWEEN #{st} and #{et} </select> <!--获取某时间段当前用户同下级河流各类问题总数量--> <select id="problemStatisticalSubordinate" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.ProblemStatistical"> select a.Complain_Type_No code,a.Complain_Type_Name name ,count(b.Problem_Type) num from complain_type_basis a LEFT JOIN patrol_problem b on a.Complain_Type_No = b.Problem_Type where ( exists (select rb.River_No from river_info_basis rb, administrative_division ad where rb.Division_No = ad.Division_No and rb.River_No = b.River_No and exists ( select f.Division_No from login_info c,river_chief d, river_info_basis e ,administrative_division f where c.userNo = d.Chief_User_No and d.River_No = e.River_No and e.Division_No = f.Division_No and f.Division_No = ad.Parent_Division_No and c.sId = #{sid} ) ) or b.River_No is null ) AND (b.Problem_Time BETWEEN #{st} and #{et} or b.River_No is null) GROUP BY a.Complain_Type_No,a.Complain_Type_Name </select> <!--获取某时间段当前用户同下级河流所有问题总数量--> <select id="problemTotalSubordinate" parameterType="Map" resultType="int"> select count(b.Problem_Type) from complain_type_basis a LEFT JOIN patrol_problem b on a.Complain_Type_No = b.Problem_Type where ( exists (select rb.River_No from river_info_basis rb, administrative_division ad where rb.Division_No = ad.Division_No and rb.River_No = b.River_No and exists ( select f.Division_No from login_info c,river_chief d, river_info_basis e ,administrative_division f where c.userNo = d.Chief_User_No and d.River_No = e.River_No and e.Division_No = f.Division_No and f.Division_No = ad.Parent_Division_No and c.sId = #{sid} ) ) or b.River_No is null ) AND (b.Problem_Time BETWEEN #{st} and #{et} or b.River_No is null) </select> <!--获取当前用户某时间段同本级河流巡查事件数量--> <select id="InspectEvent" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.ProblemStatistical"> select a.River_No code,a.River_Name name,count(b.Patrol_Problem_No) num from river_info_basis a inner JOIN administrative_division ad on a.Division_No = ad.Division_No LEFT JOIN patrol_problem b on a.River_No = b.River_No <if test="problemState != null"> AND b.Problem_State =#{problemState} </if> where exists (select d.Chief_Grade from login_info c,river_chief d,river_info_basis e,administrative_division f where c.userNo = d.Chief_User_No and d.River_No = e.River_No and e.Division_No = f.Division_No and f.Parent_Division_No = ad.Parent_Division_No and c.sId = #{sid}) and (b.Problem_Time BETWEEN #{st} and #{et} or b.River_No is null) GROUP BY a.River_No ,a.River_Name ORDER BY a.River_No <if test="startPage != null and pageSize != null"> limit #{startPage},#{pageSize} </if> </select> <!--获取当前用户某时间段下级区域巡查事件数量--> <select id="InspectEventSubordinate" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.ProblemStatistical"> select ad.Division_No code,ad.Division_Name name,count(b.Patrol_Problem_No) num from river_info_basis a inner JOIN administrative_division ad on a.Division_No = ad.Division_No LEFT JOIN patrol_problem b on a.River_No = b.River_No <if test="problemState != null"> AND b.Problem_State =#{problemState} </if> where exists (select d.Chief_Grade from login_info c,river_chief d,river_info_basis e,administrative_division f where c.userNo = d.Chief_User_No and d.River_No = e.River_No and e.Division_No = f.Division_No and f.Division_No = ad.Parent_Division_No and c.sId = #{sid}) and (b.Problem_Time BETWEEN #{st} and #{et} or b.River_No is null) GROUP BY ad.Division_No,ad.Division_Name ORDER BY ad.Division_No <if test="startPage != null and pageSize != null"> limit #{startPage},#{pageSize} </if> </select> <!--查询河流的巡查事件--> <select id="queryListByRiver" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.PatrolProblem"> SELECT a.Patrol_Problem_No patrolProblemNo,a.Problem_Process_No problemProcessNo,a.Problem_Time problemTime,a.Problem_Address problemAddress,a.Problem_State problemState,a.Problem_State_Str problemStateStr,b.Complain_Type_Name complainTypeName FROM patrol_problem a,complain_type_basis b WHERE a.Problem_Type = b.Complain_Type_No <if test="st != null and et != null"> and a.Problem_Time BETWEEN #{st} and #{et} </if> AND a.River_No = #{riverNo} </select> <!--查询区域的问题数量--> <select id="problemTotalOfArea" parameterType="Map" resultType="com.newfiber.api.mobile.model.domain.ProblemStatistical"> select b.River_No code,b.River_Name name,d.user_name userName,count(e.Patrol_Problem_No) num from administrative_division a inner 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 huludao_main.sys_user_info d on c.Chief_User_No = d.User_no left join patrol_problem e on b.River_No = e.River_No <if test="problemState != null"> AND e.Problem_State =#{problemState} </if> where (e.Problem_Time BETWEEN #{st} and #{et} or e.River_No is null) AND a.Division_No = #{divisionNo} GROUP BY b.River_No,b.River_Name,d.user_name ORDER by b.River_No </select> </mapper>