<?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.EventsManage.AdministrativeDivisionDao" > <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision" > <id column="Serial" property="serial" jdbcType="BIGINT" /> <result column="Division_No" property="divisionNo" jdbcType="VARCHAR" /> <result column="Division_Name" property="divisionName" jdbcType="NVARCHAR" /> <result column="Parent_Division_No" property="parentDivisionNo" jdbcType="VARCHAR" /> <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP" /> <result column="Division_Description" property="divisionDescription" jdbcType="NVARCHAR" /> <result column="Pic_No" property="picNo" jdbcType="VARCHAR" /> </resultMap> <resultMap id="treeMap" type="com.newfiber.api.pc.model.EventsManage.Tree"> <result column="id" property="id" jdbcType="VARCHAR"/> <result column="text" property="text" jdbcType="VARCHAR"/> <collection property="children" select="children" column="{divisionNo=id}"></collection> </resultMap> <sql id="Example_Where_Clause" > <where > <foreach collection="oredCriteria" item="criteria" separator="or" > <if test="criteria.valid" > <trim prefix="(" suffix=")" prefixOverrides="and" > <foreach collection="criteria.criteria" item="criterion" > <choose > <when test="criterion.noValue" > and ${criterion.condition} </when> <when test="criterion.singleValue" > and ${criterion.condition} #{criterion.value} </when> <when test="criterion.betweenValue" > and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} </when> <when test="criterion.listValue" > and ${criterion.condition} <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > #{listItem} </foreach> </when> </choose> </foreach> </trim> </if> </foreach> </where> </sql> <sql id="Update_By_Example_Where_Clause" > <where > <foreach collection="example.oredCriteria" item="criteria" separator="or" > <if test="criteria.valid" > <trim prefix="(" suffix=")" prefixOverrides="and" > <foreach collection="criteria.criteria" item="criterion" > <choose > <when test="criterion.noValue" > and ${criterion.condition} </when> <when test="criterion.singleValue" > and ${criterion.condition} #{criterion.value} </when> <when test="criterion.betweenValue" > and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} </when> <when test="criterion.listValue" > and ${criterion.condition} <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > #{listItem} </foreach> </when> </choose> </foreach> </trim> </if> </foreach> </where> </sql> <sql id="Base_Column_List" > <if test="fields == null" > Serial, Division_No, Division_Name, Parent_Division_No, Create_Time </if> <if test="fields != null" > ${fields} </if> </sql> <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivisionQuery" > select a.Serial, a.Division_No, a.Division_Name, a.Parent_Division_No, DATE_FORMAT(a.Create_Time,'%Y-%m-%d %T') formatTime, d.Division_Name parentDivisionName, a.Division_Description, a.Pic_No from administrative_division a LEFT JOIN administrative_division d ON a.Parent_Division_No = d.Division_No <choose> <when test="_parameter != null"> <include refid="Example_Where_Clause" /> </when> <otherwise> WHERE 1=1 </otherwise> </choose> <if test="startRow != null" > ORDER BY a.Serial limit #{startRow},#{pageSize} </if> </select> <select id="selectParentDivisionNo" resultType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision"> select a.Parent_Division_No parentDivisionNo,a.Division_Name divisionName from administrative_division a <where> <if test="divisionNo != null"> a.Division_No = #{divisionNo,jdbcType=VARCHAR} </if> </where> </select> <select id="selectParentDivisionNoList" resultType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision"> select a.Parent_Division_No parentDivisionNo,a.Division_Name divisionName,a.Division_No divisionNo from administrative_division a where a.Parent_Division_No = #{divisionNo,jdbcType=VARCHAR} </select> <select id="selectuserNoListByDivisionNo" resultType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision"> select c.Chief_User_No userNo from administrative_division a inner join river_info_basis b on a.Division_No = b.Division_No inner join river_chief c on c.River_No = b.River_No where a.Parent_Division_No = #{divisionNo,jdbcType=VARCHAR} </select> <select id="selectCountRiverListByDivisionNo" resultType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision"> select a.division_No divisionNo,a.Division_Name divisionName,count(c.Chief_User_No) countRiver from administrative_division a left join river_info_basis b on a.Division_No = b.Division_No left join river_chief c on c.River_No = b.River_No where a.Parent_Division_No = #{divisionNo,jdbcType=VARCHAR} group by a.division_No,a.Division_Name </select> <select id="selectCountRiverByDivisionNo" resultType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision"> select count(c.Chief_User_No) countRiver from administrative_division a left join river_info_basis b on a.Division_No = b.Division_No left join river_chief c on c.River_No = b.River_No where 1=1 <if test="list != null and list.size > 0"> and a.Parent_Division_No in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> group by a.Parent_Division_No </select> <select id="selectDivisionNo" resultType="java.lang.String" parameterType="java.lang.String"> select a.Division_No divisionNo from administrative_division a inner join river_info_basis b on a.Division_No = b.Division_No inner join river_chief c on c.River_No = b.River_No where c.Chief_User_No = #{userNo,jdbcType=VARCHAR} </select> <select id="selectParentDivisionNoListByRiver" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision"> select a.Parent_Division_No,a.Division_Name,a.Division_No from administrative_division a inner join river_info_basis f on f.Division_No = a.Division_No where a.Parent_Division_No = #{divisionNo,jdbcType=VARCHAR} </select> <delete id="deleteByExample" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivisionQuery" > delete from administrative_division <if test="_parameter != null" > <include refid="Example_Where_Clause" /> </if> </delete> <insert id="insertSelective" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision" > insert into administrative_division <trim prefix="(" suffix=")" suffixOverrides="," > <if test="serial != null" > Serial, </if> <if test="divisionNo != null" > Division_No, </if> <if test="divisionName != null" > Division_Name, </if> <if test="parentDivisionNo != null" > Parent_Division_No, </if> <if test="createTime != null" > Create_Time, </if> <if test="divisionDescription != null" > Division_Description, </if> <if test="picNo != null" > Pic_No, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="serial != null" > #{serial,jdbcType=BIGINT}, </if> <if test="divisionNo != null" > #{divisionNo,jdbcType=VARCHAR}, </if> <if test="divisionName != null" > #{divisionName,jdbcType=NVARCHAR}, </if> <if test="parentDivisionNo != null" > #{parentDivisionNo,jdbcType=VARCHAR}, </if> <if test="createTime != null" > #{createTime,jdbcType=TIMESTAMP}, </if> <if test="divisionDescription != null" > #{divisionDescription,jdbcType=NVARCHAR}, </if> <if test="picNo != null" > #{picNo,jdbcType=VARCHAR}, </if> </trim> </insert> <select id="countByExample" parameterType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivisionQuery" resultType="java.lang.Integer" > select count(*) from administrative_division <if test="_parameter != null" > <include refid="Example_Where_Clause" /> </if> </select> <update id="updateByExampleSelective" parameterType="map" > update administrative_division <set > <if test="record.serial != null" > Serial = #{record.serial,jdbcType=BIGINT}, </if> <if test="record.divisionNo != null" > Division_No = #{record.divisionNo,jdbcType=VARCHAR}, </if> <if test="record.divisionName != null" > Division_Name = #{record.divisionName,jdbcType=NVARCHAR}, </if> <if test="record.parentDivisionNo != null" > Parent_Division_No = #{record.parentDivisionNo,jdbcType=VARCHAR}, </if> <if test="record.createTime != null" > Create_Time = #{record.createTime,jdbcType=TIMESTAMP}, </if> </set> <if test="_parameter != null" > <include refid="Update_By_Example_Where_Clause" /> </if> </update> <select id="selectRiverByDivisionNo" parameterType="String" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis"> SELECT r.River_Name riverName, r.River_No riverNo FROM river_info_basis r WHERE 1=1 <if test="divisionNo != null and divisionNo !=''"> AND r.Division_No =#{divisionNo} </if> </select> <select id="getUserNoByDivisionNo" parameterType="String" resultType="com.newfiber.api.pc.model.Users"> SELECT o.User_No loginname FROM division_org_manage M INNER JOIN huludao_main.sys_user_org O ON m.Org_No=o.Org_No WHERE m.Division_No=#{divisionNo} </select> <select id="getUserODivision" parameterType="String" resultType="com.newfiber.api.pc.model.Users"> SELECT s.User_No loginname,s.user_name name FROM division_org_manage M INNER JOIN huludao_main.sys_user_org O ON m.Org_No=o.Org_No INNER JOIN huludao_main.sys_user_info s ON O.User_No = s.User_No WHERE m.Division_No=#{divisionNo} and not exists (select r.Chief_User_No from river_chief r where r.Chief_User_No = s.User_No) </select> <select id="selectRiverEventCountOrder" parameterType="map" resultMap="BaseResultMap"> SELECT r.River_Name riverName, r.River_No riverNo, count(c.Serial) count FROM complaint c INNER JOIN river_info_basis r ON c.River_No=r.River_No WHERE 1=1 <if test="list != null and list.size() > 0"> c.River_No in <foreach collection="list" open="(" close=")" item="item" index="index" separator=","> '${item}' </foreach> </if> <if test="startTime != null and endTime != null"> AND c.Complain_Time BETWEEN #{startTime,jdbcType=TIMESTAMP} AND #{endTime,jdbcType=TIMESTAMP} </if> GROUP BY r.River_Name,r.River_No ORDER BY count DESC </select> <select id="selectDivisionEventCountOrder" parameterType="map" resultMap="BaseResultMap"> SELECT a.Division_Name, count(c.Serial) count FROM complaint c INNER JOIN administrative_division a ON c.Division_No =a.Division_No WHERE 1=1 <if test="startTime != null and endTime != null"> AND c.Complain_Time BETWEEN #{startTime,jdbcType=TIMESTAMP} AND #{endTime,jdbcType=TIMESTAMP} </if> <if test="typeList != null"> AND <foreach collection="typeList" index="index" item="item" open="(" close=")" separator="or"> c.Complain_Type='${item}' </foreach> </if> <if test="divisionList != null"> AND <foreach collection="divisionList" separator="or" close=")" open="(" item="item" index="index"> c.Division_No='${item}' </foreach> </if> GROUP BY a.Division_Name ORDER BY count DESC </select> <delete id="deleteByDivisionNo" parameterType="String"> DELETE FROM administrative_division WHERE Division_No = #{divisionNo} </delete> <select id="selectByDivisionNo" parameterType="string" resultMap="BaseResultMap"> SELECT * FROM administrative_division WHERE Division_No = #{divisionNo} </select> <select id="selectRiveAndLowerRiver" parameterType="String" resultType="com.newfiber.api.pc.model.River.RiverInfoBasis"> SELECT r.River_No riverNo, r.River_Name riverName, r.River_Grade_Zn riverGradeZn, d.Division_Name divisionName, d.Division_No divisionNo FROM river_info_basis r INNER JOIN administrative_division d ON r.Division_No = d.Division_No WHERE 1=1 <if test="str != null and str !=''"> AND r.River_Name LIKE '%${str}%' </if> <if test="list != null and list.size() !=0"> AND <foreach collection="list" item="item" index="index" open="(" close=")" separator="or"> r.Division_No ='${item}' </foreach> </if> </select> <select id="getCurrentDivision" parameterType="String" resultMap="BaseResultMap"> SELECT a.Serial, a.Division_No, a.Division_Name, a.Parent_Division_No, DATE_FORMAT(a.Create_Time,'%Y-%m-%d %T') formatTime, a.Division_Description, a.Pic_No FROM huludao_main.sys_user_org b,division_org_manage c, administrative_division a where b.Org_No = c.Org_No and c.Division_No = a.Division_No and b.User_No = #{userNo} </select> <select id="getSubordinateDivision" parameterType="java.util.List" resultMap="BaseResultMap"> select DISTINCT a.Division_No from administrative_division a where 1=1 <if test="parentNo != null and parentNo.size() > 0"> and a.Parent_Division_No in <foreach collection="list" item="division" open="(" close=")" separator=","> #{division} </foreach> </if> </select> <select id="getDivisionTree" resultMap="treeMap" parameterType="String"> select DISTINCT a.Division_No id,a.Division_Name text FROM administrative_division a WHERE a.Parent_Division_No = #{paraDivisionNo} and EXISTS (select b.Division_No FROM administrative_division b where b.Parent_Division_No = a.Division_No) </select> <select id="children" resultMap="treeMap" parameterType="java.util.Map"> select DISTINCT Division_No id,Division_Name text FROM administrative_division WHERE Parent_Division_No = #{divisionNo} </select> <select id="getDivisionTreeNew" parameterType="String" resultType="com.newfiber.api.pc.model.EventsManage.Tree"> select DISTINCT a.Division_No id,a.Division_Name text FROM administrative_division a WHERE a.Parent_Division_No = #{paraDivisionNo} </select> <select id="getChildDivision" parameterType="string" resultMap="BaseResultMap"> SELECT Division_No,Division_Name FROM administrative_division WHERE Parent_Division_No = (SELECT Division_No FROM administrative_division WHERE Parent_Division_No = '0' limit 1) </select> <!-- 获取下级行政区划表列表 --> <select id="queryListByDivisionNo" resultType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision"> select Division_No divisionNo,Division_Name divisionName from administrative_division where Parent_Division_No = #{divisionNo,jdbcType=VARCHAR} </select> <!-- 根据sid获取本级行政区划 --> <select id="queryDivisionNoByUserNo" resultType="com.newfiber.api.pc.model.EventsManage.AdministrativeDivision" parameterType="java.lang.String"> select a.Division_No divisionNo,a.Division_Name divisionName from administrative_division a inner join division_org_manage e on a.Division_No = e.Division_No inner join huludao_main.sys_user_org s on s.Org_No = e.Org_No inner join huludao_main.sys_user_info i on i.User_No = s.User_No inner join login_info l on l.userNo = i.User_No where 1=1 <if test="sid != null and sid != ''"> and l.sId = #{sid,jdbcType=VARCHAR} </if> <if test="userNo != null and userNo != ''"> and i.User_No = #{userNo,jdbcType=VARCHAR} </if> </select> <select id="queryDivisionsubordinate" parameterType="String" resultMap="BaseResultMap"> SELECT Division_No,Division_Name FROM administrative_division a WHERE EXISTS (SELECT d.Division_No FROM login_info b,river_chief c,river_info_basis d WHERE b.userNo = c.Chief_User_No and c.River_No = d.River_No and d.Division_No = a.Parent_Division_No and b.sId = #{sid} ) or EXISTS (select d2.Division_No from login_info b1,huludao_main.sys_user_org c2,division_org_manage d2 where b1.userNo = c2.User_No and c2.Org_No = d2.Org_No and d2.Division_No = a.Parent_Division_No and b1.sId = #{sid} ) </select> <select id="listParent" resultMap="BaseResultMap"> SELECT Serial, Division_No, Division_Name, Parent_Division_No, Create_Time FROM administrative_division where 1=1 <if test="parentNo != null and parentNo.size() > 0"> and Parent_Division_No in <foreach collection="parentNo" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </select> <select id="listAll" resultMap="BaseResultMap"> SELECT Serial, Division_No, Division_Name, Parent_Division_No, Create_Time FROM administrative_division </select> <select id="queryListByDivisionNos" resultMap="BaseResultMap"> SELECT Serial, Division_No, Division_Name, Parent_Division_No, Create_Time FROM administrative_division <if test="parentNo != null and parentNo.size() > 0"> where Division_No in <foreach collection="parentNo" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </select> <select id="listByDivisions" resultMap="BaseResultMap"> select c.Chief_User_No userNo,b.River_No riverNo from administrative_division a inner join river_info_basis b on a.Division_No = b.Division_No inner join river_chief c on c.River_No = b.River_No <if test="parentNo != null and parentNo.size() > 0"> where a.Parent_Division_No in <foreach collection="parentNo" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </select> <select id="nextDivision" resultMap="BaseResultMap"> select Division_No,Division_Name from administrative_division <if test="divisionNos != null and divisionNos.size() > 0"> where Division_No in <foreach collection="divisionNos" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </select> <select id="selectAll" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from administrative_division a </select> <select id="selectOne" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from administrative_division a where Parent_Division_No = 0 </select> </mapper>