Browse Source

客户查询优化修改

anderx 1 week ago
parent
commit
567969bfa9

+ 31 - 29
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -329,7 +329,7 @@
 	</select>
 
 	<select id="selectOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
-	 	select DISTINCT
+	 	select
 		a.id as uid,
 			a.nickname as name,
 			date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
@@ -344,29 +344,30 @@
 	 		a.new_channel as newChannel,
 	 		a.level,
 			b.org_code orgCode
-
 		from  `user` a
-		left join user_names un on a.id=un.uid
+		inner join (SELECT DISTINCT uid FROM user_names
+		<if test="role == 0">
+			<if test="names !=null">
+				WHERE name in
+				<foreach close=")" collection="names" item="name" open="(" separator=",">
+					#{name}
+				</foreach>
+			</if>
+			<if test="names ==null and orgCode==null">
+				is null
+			</if>
+		</if>
+		<if test="role == 1 and name != null">
+			WHERE name like concat('%', #{name},'%')
+		</if>
+		                                               ) un on a.id=un.uid
 		left join organization_identity b on a.id = b.uid
 		left join district_glossory dg1 on b.location_province = dg1.id
 		left join district_glossory dg2 on b.location_city = dg2.id
 		left join district_glossory dg3 on b.location_area = dg3.id
 		left join admin d on a.aid = d.id
 		where a.type = 1 and a.status =0 and a.source in (1,2,3)
-	<if test="role == 0">
-		<if test="names !=null">
-			and un.name in
-		<foreach close=")" collection="names" item="name" open="(" separator=",">
-			#{name}
-		</foreach>
-		</if>
-		<if test="names ==null and orgCode==null">
-			is null
-		</if>
-	</if>
-	<if test="role == 1 and name != null">
-		and un.name like concat('%', #{name},'%')
-	</if>
+
 	<if test="aid != null and aid !=''">
 		and a.aid = #{aid,jdbcType=VARCHAR}
 	</if>
@@ -400,17 +401,10 @@
 		select
 		count(0)
 		from(select a.id from `user` a
-		left join user_names un on a.id=un.uid
-		left join organization_identity b on a.id = b.uid
-		<if test="departmentId != null and departmentId !=''">
-		INNER join (select id
-		from admin
-		where department_id=#{departmentId,jdbcType=VARCHAR}) d on a.aid = d.id
-		</if>
-		where a.type = 1 and a.status =0 and a.source in (1,2,3)
+		inner join (SELECT DISTINCT uid FROM user_names
 		<if test="role == 0">
 			<if test="names !=null">
-				and un.name in
+				WHERE name in
 				<foreach close=")" collection="names" item="name" open="(" separator=",">
 					#{name}
 				</foreach>
@@ -419,9 +413,17 @@
 				is null
 			</if>
 		</if>
-	<if test="role == 1 and name != null">
-		and un.name like concat('%', #{name},'%')
-	</if>
+		<if test="role == 1 and name != null">
+			WHERE name like concat('%', #{name},'%')
+		</if>
+		) un on a.id=un.uid
+		left join organization_identity b on a.id = b.uid
+		<if test="departmentId != null and departmentId !=''">
+		INNER join (select id
+		from admin
+		where department_id=#{departmentId,jdbcType=VARCHAR}) d on a.aid = d.id
+		</if>
+		where a.type = 1 and a.status =0 and a.source in (1,2,3)
 		<if test="aid != null and aid !=''">
 			and a.aid = #{aid,jdbcType=VARCHAR}
 		</if>

+ 5 - 5
src/main/resources/props/config_local.properties

@@ -7,13 +7,13 @@ static.host=//static.jishutao.com/${kede.version}
 #static.host=//172.16.1.187/${kede.version}
 #avatar.host=//172.16.1.199:3000
 
-#jdbc.url=jdbc\:mysql://localhost:3306/aft20250313?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc\:mysql://localhost:3306/aft20250613?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-#jdbc.username=root
-#jdbc.password=123456
-jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 jdbc.username=root
-jdbc.password=aftdev
+jdbc.password=123456
+#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.username=root
+#jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20