Commit 92e88e37 by 徐高华

sql优化

parent 3b9cdcb8
...@@ -369,27 +369,30 @@ ...@@ -369,27 +369,30 @@
</select> </select>
<select id="listMemberStaffRelNew" resultType="com.gic.haoban.manage.service.entity.ext.MemberStaffRelExtDO"> <select id="listMemberStaffRelNew" resultType="com.gic.haoban.manage.service.entity.ext.MemberStaffRelExtDO">
select ecr.member_id as memberId, select * from (
ecr.external_user_id as memberExternalUserId, select ecr.member_id as memberId,
scr.staff_id as staffId, ecr.external_user_id as memberExternalUserId,
scr.clerk_id as staffClerkId scr.staff_id as staffId,
from (select a.staff_id, scr.clerk_id as staffClerkId
a.clerk_id from tab_haoban_external_clerk_related as ecr
from tab_haoban_staff_clerk_relation a left join
left join tab_haoban_staff b on a.staff_id = b.staff_id (select a.staff_id,
where a.clerk_id in a.clerk_id
<foreach collection="clerkIdList" item="item" separator="," open="(" close=")"> from tab_haoban_staff_clerk_relation a
#{item} left join tab_haoban_staff b on a.staff_id = b.staff_id
</foreach> where a.clerk_id in
and a.status_flag = 1 <foreach collection="clerkIdList" item="item" separator="," open="(" close=")">
group by a.staff_id, b.wx_user_id, a.clerk_id) as scr #{item}
left join tab_haoban_external_clerk_related as ecr on scr.staff_id = ecr.staff_id </foreach>
where ecr.status_flag = 1 and a.status_flag = 1
and ecr.enterprise_id = #{enterpriseId,jdbcType=VARCHAR} group by a.staff_id, a.clerk_id) as scr on scr.staff_id = ecr.staff_id
and ecr.member_id in where ecr.status_flag = 1
<foreach collection="memberIdList" item="item" separator="," open="(" close=")"> and ecr.enterprise_id = #{enterpriseId,jdbcType=VARCHAR}
#{item} and ecr.member_id in
</foreach> <foreach collection="memberIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
) t where t.staffId is not null
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment