hanfucheng преди 1 година
родител
ревизия
71fb12c193

+ 36 - 22
src/main/resources/mapper/digitalenvironment/EnvironmentViewMapper.xml

@@ -33,29 +33,43 @@
 
 	<select id="getEnvironmentLeader" parameterType="EnvironmentLeaderVO" resultType="EnvironmentLeaderBO">
 		SELECT
-		a.name as nickName,
-		u.user_id as userId,
-		a.phone phone,
-		d.dept_name deptName,
-		a.environment_job environmentJob,
-		b.dict_label environmentLabel
+			t.nickName,
+			t.userId,
+			t.phone,
+			t.environmentJob,
+			t.environmentLabel,
+			REPLACE ( group_concat( dept_name ORDER BY find_in_set( d.dept_id, t.ancestors ) ), ',', '' ) deptName
 		FROM
-		centerdata_t_environment_person a
-		LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
-		LEFT JOIN ${database_system}.sys_user u ON a.user_id = u.user_id
-		left join ${database_system}.sys_dict_data b on a.environment_job = b.dict_value
-		WHERE
-		1 = 1
-		<if test="environmentJob != null and environmentJob != ''">
-			and a.environment_job=#{environmentJob}
-		</if>
-		<if test="name != null and name != ''">
-			and a.name like concat('%', #{name}, '%')
-		</if>
-		<choose>
-			<when test="deptId != null and deptId != ''">and FIND_IN_SET( #{deptId}, CONCAT(d.ancestors,',',d.dept_id) )</when>
-			<otherwise>${params.dataScope}</otherwise>
-		</choose>
+		(
+			SELECT
+				a.NAME AS nickName,
+				u.user_id AS userId,
+				a.phone phone,
+				d.dept_name deptName,
+				a.environment_job environmentJob,
+				b.dict_label environmentLabel,
+				SUBSTR( CONCAT( d.ancestors, ',', a.dept_id ), 7 ) ancestors
+			FROM
+			centerdata_t_environment_person a
+			LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
+			LEFT JOIN ${database_system}.sys_user u ON a.user_id = u.user_id
+			LEFT JOIN ${database_system}.sys_dict_data b ON a.environment_job = b.dict_value
+			WHERE
+			1 = 1
+			<if test="environmentJob != null and environmentJob != ''">
+				and a.environment_job=#{environmentJob}
+			</if>
+			<if test="name != null and name != ''">
+				and a.name like concat('%', #{name}, '%')
+			</if>
+			<choose>
+				<when test="deptId != null and deptId != ''">and FIND_IN_SET( #{deptId}, CONCAT(d.ancestors,',',d.dept_id) )</when>
+				<otherwise>${params.dataScope}</otherwise>
+			</choose>
+		) t
+		LEFT JOIN ${database_system}.sys_dept d ON find_in_set( d.dept_id, t.ancestors )
+		GROUP BY
+		t.nickName
 	</select>
 
 	<select id="selectEnvironmentUerId"

+ 33 - 20
src/main/resources/mapper/digitalfirecontrol/CenterdataTFirecontrolPersonMapper.xml

@@ -218,26 +218,39 @@
 
     <select id="getResourcesLeader" parameterMap="pm_VisuForestLeader" resultMap="rm_VisuForestLeader">
         SELECT
-        a.name as nickName,
-        u.user_id as userId,
-        a.firecontrol_job firecontrolJob,
-        b.dict_label firecontrolLabel
+            t.nickName,
+            t.userId,
+            t.firecontrolJob,
+            t.firecontrolLabel,
+            REPLACE ( group_concat( dept_name ORDER BY find_in_set( d.dept_id, t.ancestors ) ), ',', '' ) deptName
         FROM
-        ${database_data}.centerdata_t_firecontrol_person a
-        LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
-        LEFT JOIN ${database_system}.sys_user u ON a.user_id = u.user_id
-        left join ${database_system}.sys_dict_data b on a.firecontrol_job = b.dict_value
-        WHERE
-        1 = 1
-        <if test="linJob != null and linJob != ''">
-            and a.firecontrol_job=#{linJob}
-        </if>
-        <if test="name != null and name != ''">
-            and a.name LIKE CONCAT('%',#{name}, '%')
-        </if>
-        <choose>
-            <when test="deptId != null and deptId != ''">and FIND_IN_SET( #{deptId}, CONCAT(d.ancestors,',',d.dept_id) )</when>
-            <otherwise>${params.dataScope}</otherwise>
-        </choose>
+        (
+            SELECT
+                a.NAME AS nickName,
+                u.user_id AS userId,
+                a.firecontrol_job firecontrolJob,
+                b.dict_label firecontrolLabel,
+                SUBSTR( CONCAT( d.ancestors, ',', a.dept_id ), 7 ) ancestors
+            FROM
+            centerdata_t_firecontrol_person a
+            LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
+            LEFT JOIN ${database_system}.sys_user u ON a.user_id = u.user_id
+            LEFT JOIN ${database_system}.sys_dict_data b ON a.firecontrol_job = b.dict_value
+            WHERE
+            1 = 1
+            <if test="linJob != null and linJob != ''">
+                and a.firecontrol_job=#{linJob}
+            </if>
+            <if test="name != null and name != ''">
+                and a.name LIKE CONCAT('%',#{name}, '%')
+            </if>
+            <choose>
+                <when test="deptId != null and deptId != ''">and FIND_IN_SET( #{deptId}, CONCAT(d.ancestors,',',d.dept_id) )</when>
+                <otherwise>${params.dataScope}</otherwise>
+            </choose>
+        ) t
+        LEFT JOIN ${database_system}.sys_dept d ON find_in_set( d.dept_id, t.ancestors )
+        GROUP BY
+        t.nickName
     </select>
 </mapper>

+ 43 - 27
src/main/resources/mapper/digitalforest/ForestViewMapper.xml

@@ -80,33 +80,49 @@
 
     <select id="getForestLeader" parameterType="ForestLeaderVO" resultType="ForestLeaderBO">
         SELECT
-        a.lin_name as nickName,
-        u.user_id as userId,
-        d.dept_name as deptName,
-        u.phonenumber as phonenumber,
-        a.lin_phone as linPhone,
-        a.lin_job linJob,
-        b.dict_label linLabel
+            t.nickName,
+            t.userId,
+            t.phonenumber,
+            t.linPhone,
+            t.linJob,
+            t.linLabel,
+            REPLACE(group_concat( dept_name ORDER BY find_in_set( d.dept_id, t.ancestors ) ),',','') deptName
         FROM
-        centerdata_t_forest_linleader a
-        LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
-        LEFT JOIN ${database_system}.sys_user u ON a.user_id = u.user_id
-        left join ${database_system}.sys_dict_data b on a.lin_job = b.dict_value
-        WHERE
-        1 = 1
-        <if test="linJob != null and linJob != ''">
-            and a.lin_job=#{linJob}
-        </if>
-        <if test="name != null and name != ''">
-            and a.lin_name like concat('%', #{name}, '%')
-        </if>
-        <choose>
-            <when test="deptId != null  and deptId != ''">
-                and FIND_IN_SET( #{deptId}, CONCAT(d.ancestors,',',d.dept_id) )
-            </when>
-            <otherwise>
-                ${params.dataScope}
-            </otherwise>
-        </choose>
+        (
+            SELECT
+                a.lin_name AS nickName,
+                u.user_id AS userId,
+                d.dept_name AS deptName,
+                u.phonenumber AS phonenumber,
+                a.lin_phone AS linPhone,
+                a.lin_job linJob,
+                b.dict_label linLabel,
+                SUBSTR(CONCAT( d.ancestors, ',', a.dept_id ),7) ancestors,
+                a.dept_id deptId
+            FROM
+            centerdata_t_forest_linleader a
+            LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
+            LEFT JOIN ${database_system}.sys_user u ON a.user_id = u.user_id
+            LEFT JOIN ${database_system}.sys_dict_data b ON a.lin_job = b.dict_value
+            WHERE
+            1 = 1
+            <if test="linJob != null and linJob != ''">
+                and a.lin_job=#{linJob}
+            </if>
+            <if test="name != null and name != ''">
+                and a.lin_name like concat('%', #{name}, '%')
+            </if>
+            <choose>
+                <when test="deptId != null  and deptId != ''">
+                    and FIND_IN_SET( #{deptId}, CONCAT(d.ancestors,',',d.dept_id) )
+                </when>
+                <otherwise>
+                    ${params.dataScope}
+                </otherwise>
+            </choose>
+        ) t
+        LEFT JOIN ${database_system}.sys_dept d ON find_in_set( d.dept_id, t.ancestors )
+        GROUP BY
+        t.nickName
     </select>
 </mapper>

+ 29 - 15
src/main/resources/mapper/digitalwater/WaterConservancyViewMapper.xml

@@ -94,24 +94,38 @@
 
     <select id="getRyListByJob" parameterType="WaterConservancyViewBO" resultType="map">
         SELECT
-            DISTINCT a.user_id userId,
-            a.`name` AS name,
-            d.dept_name AS deptName,
-            a.phone AS phone,
-            a.post post,
-            b.dict_label postName
+            t.userId,
+            t.NAME,
+            t.phone,
+            t.post,
+            t.postName,
+            REPLACE ( group_concat( dept_name ORDER BY find_in_set( d.dept_id, t.ancestors ) ), ',', '' ) deptName
         FROM
+        (
+            SELECT
+                DISTINCT a.user_id userId,
+                a.`name` AS NAME,
+                d.dept_name AS deptName,
+                a.phone AS phone,
+                a.post post,
+                b.dict_label postName,
+                SUBSTR( CONCAT( d.ancestors, ',', a.dept_id ), 7 ) ancestors
+            FROM
             centerdata_t_hydraulic_river_length a
             LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
-            left join ${database_system}.sys_dict_data b on a.post = b.dict_value
-        WHERE
-            a.type = #{leadType}
-        <if test="dictType != null  and dictType != ''">AND a.post = #{dictType}</if>
-        <if test="name != null  and name != ''">AND a.name like concat('%', #{name}, '%')</if>
-        <choose>
-            <when test="deptId != null and deptId != ''">and FIND_IN_SET( #{deptId}, CONCAT(d.ancestors,',',d.dept_id) )</when>
-            <otherwise>${params.dataScope}</otherwise>
-        </choose>
+            LEFT JOIN ${database_system}.sys_dict_data b ON a.post = b.dict_value
+            WHERE
+                a.type = #{leadType}
+                <if test="dictType != null  and dictType != ''">AND a.post = #{dictType}</if>
+                <if test="name != null  and name != ''">AND a.name like concat('%', #{name}, '%')</if>
+                <choose>
+                    <when test="deptId != null and deptId != ''">and FIND_IN_SET( #{deptId}, CONCAT(d.ancestors,',',d.dept_id) )</when>
+                    <otherwise>${params.dataScope}</otherwise>
+                </choose>
+        ) t
+        LEFT JOIN ${database_system}.sys_dept d ON find_in_set( d.dept_id, t.ancestors )
+        GROUP BY
+        t.NAME
     </select>
 
     <select id="getTianList" parameterType="WaterConservancyViewBO" resultType="map">