select id,parent_id,parent_ids, CONCAT(parent_ids, ',', id) as px, sort, '3' as lev,
id as city_id, name as city_name, null as area_id, null as area_name, null as street_id, null as street_name, null as community_id, null as community_name
from sys_office city where city.id = '220100000000' and city.del_flag ='0' and city.is_manage_center =1
union all
select area.id,area.parent_id, area.parent_ids, CONCAT(area.parent_ids, ',', area.id) as px, area.sort, '4' as lev,
city.id as city_id, city.name as city_name, area.id as area_id, area.name as area_name, null as street_id, null as street_name, null as community_id, null as community_name
from sys_office city left join sys_office area on area.parent_id = city.id
where city.id = '220100000000' and city.del_flag ='0' and area.del_flag ='0' and city.is_manage_center =1 and area.is_manage_center =1
union all
select street.id,street.parent_id, street.parent_ids, CONCAT(street.parent_ids, ',', street.id) as px, street.sort, '5' as lev,
city.id as city_id, city.name as city_name, area.id as area_id, area.name as area_name, street.id as street_id, street.name as street_name, null as community_id, null as community_name
from sys_office city left join sys_office area on area.parent_id = city.id left join sys_office street on street.parent_id = area.id
where city.id = '220100000000' and city.del_flag ='0' and area.del_flag ='0' and street.del_flag ='0' and city.is_manage_center =1 and area.is_manage_center =1 and street.is_manage_center =1
<!-- union all-->
<!-- select community.id,community.parent_id, community.parent_ids, CONCAT(community.parent_ids, ',', community.id) as px, community.sort, '6' as lev,-->
<!-- city.id as city_id, city.name as city_name, area.id as area_id, area.name as area_name, street.id as street_id, street.name as street_name, community.id as community_id, community.name as community_name-->
<!-- from sys_office city left join sys_office area on area.parent_id = city.id left join sys_office street on street.parent_id = area.id left join sys_office community on community.parent_id = street.id-->
<!-- where city.id = '220100000000' and city.del_flag ='0' and area.del_flag ='0' and street.del_flag ='0' and community.del_flag ='0'-->
<!-- and city.is_manage_center =1 and area.is_manage_center =1 and street.is_manage_center =1-->
) a left join jl_key_person_rating_dual_phone b on b.office_id = a.id
<where>
AND 1 = 1
<iftest="params.city_id != null and params.city_id != ''">
AND a.city_id = #{params.city_id}
</if>
<iftest="params.area_id != null and params.area_id != ''">
AND a.area_id = #{params.area_id}
</if>
<iftest="params.street_id != null and params.street_id != ''">
AND a.street_id = #{params.street_id}
</if>
<iftest="params.community_id != null and params.community_id != ''">
AND ((city_id = #{scope_area_id} and city_id not in (select city_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person.id))
AND ((city_id = #{scope_area_id} and jl_key_person.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where city_id = #{scope_area_id} AND key_person_id=jl_key_person.id))
</when>
<whentest="scope_grade == '4'.toString()">
AND ((area_id = #{scope_area_id} and area_id not in (select area_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person.id))
AND ((area_id = #{scope_area_id} and jl_key_person.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where area_id = #{scope_area_id} AND key_person_id=jl_key_person.id))
</when>
<whentest="scope_grade == '5'.toString()">
AND ((street_id = #{scope_area_id} and street_id not in (select street_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person.id))
AND ((street_id = #{scope_area_id} and jl_key_person.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where street_id = #{scope_area_id} AND key_person_id=jl_key_person.id))
</when>
<whentest="scope_grade == '6'.toString()">
AND ((community_id = #{scope_area_id} and community_id not in (select community_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person.id))
AND ((community_id = #{scope_area_id} and jl_key_person.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where community_id = #{scope_area_id} AND key_person_id=jl_key_person.id))
</when>
</choose>
...
...
@@ -123,19 +123,19 @@
and sys_type = '6'
<choose>
<whentest="scope_grade == '3'.toString()">
AND ((city_id = #{scope_area_id} and city_id not in (select city_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person_minor.id))
AND ((city_id = #{scope_area_id} and jl_key_person_minor.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where city_id = #{scope_area_id} AND key_person_id=jl_key_person_minor.id))
</when>
<whentest="scope_grade == '4'.toString()">
AND ((area_id = #{scope_area_id} and area_id not in (select area_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person_minor.id))
AND ((area_id = #{scope_area_id} and jl_key_person_minor.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where area_id = #{scope_area_id} AND key_person_id=jl_key_person_minor.id))
</when>
<whentest="scope_grade == '5'.toString()">
AND ((street_id = #{scope_area_id} and street_id not in (select street_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person_minor.id))
AND ((street_id = #{scope_area_id} and jl_key_person_minor.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where street_id = #{scope_area_id} AND key_person_id=jl_key_person_minor.id))
</when>
<whentest="scope_grade == '6'.toString()">
AND ((community_id = #{scope_area_id} and community_id not in (select community_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person_minor.id))
AND ((community_id = #{scope_area_id} and jl_key_person_minor.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where community_id = #{scope_area_id} AND key_person_id=jl_key_person_minor.id))
</when>
</choose>
...
...
@@ -147,19 +147,19 @@
and sys_type = '2'
<choose>
<whentest="scope_grade == '3'.toString()">
AND ((city_id = #{scope_area_id} and city_id not in (select city_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person.id))
AND ((city_id = #{scope_area_id} and jl_key_person.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where city_id = #{scope_area_id} AND key_person_id=jl_key_person.id))
</when>
<whentest="scope_grade == '4'.toString()">
AND ((area_id = #{scope_area_id} and area_id not in (select area_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person.id))
AND ((area_id = #{scope_area_id} and jl_key_person.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where area_id = #{scope_area_id} AND key_person_id=jl_key_person.id))
</when>
<whentest="scope_grade == '5'.toString()">
AND ((street_id = #{scope_area_id} and street_id not in (select street_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person.id))
AND ((street_id = #{scope_area_id} and jl_key_person.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where street_id = #{scope_area_id} AND key_person_id=jl_key_person.id))
</when>
<whentest="scope_grade == '6'.toString()">
AND ((community_id = #{scope_area_id} and community_id not in (select community_id from jl_key_person_rating_dual_person where key_person_id=jl_key_person.id))
AND ((community_id = #{scope_area_id} and jl_key_person.id not in (select key_person_id from jl_key_person_rating_dual_person))
OR exists(select id from jl_key_person_rating_dual_person where community_id = #{scope_area_id} AND key_person_id=jl_key_person.id))