Commit 61aa370f authored by 38823's avatar 38823

报单和合同历史数据查询优化

parent 6d71e69d
...@@ -12,50 +12,37 @@ ...@@ -12,50 +12,37 @@
--代理店权限(自然人) --代理店权限(自然人)
select * select *
from con_contract_history_lv t from con_contract_history_lv t
where t.bp_class = 'NP' where t.Id_Card_No =
and t.Id_Card_No =
(select hbm.id_card_no from hls_bp_master hbm where hbm.bp_id = ${@bp_id}) (select hbm.id_card_no from hls_bp_master hbm where hbm.bp_id = ${@bp_id})
and t.unit_id in (select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id}) and t.unit_id in (select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id})
and exists( and exists(
select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id} and vv.POSITION_TYPE = 'SALES' select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id} and vv.POSITION_TYPE = 'SALES'
) )
union all union all
--非代理店(自然人)
select * select *
from con_contract_history_lv t from con_contract_history_lv t
where t.bp_class = 'NP' where t.Id_Card_No =
and t.Id_Card_No =
(select hbm.id_card_no from hls_bp_master hbm where hbm.bp_id = ${@bp_id}) (select hbm.id_card_no from hls_bp_master hbm where hbm.bp_id = ${@bp_id})
and not exists( and not exists(
select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id} and vv.POSITION_TYPE = 'SALES' select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id} and vv.POSITION_TYPE = 'SALES'
) )
union all union all
--非代理店(自然人)
select *
from con_contract_history_lv t
where t.bp_class = 'ORG'
and t.social_code = (select hbm.social_code
from hls_bp_master hbm
where hbm.bp_id = ${@bp_id})
and t.unit_id =
(select hbm.unit_id from hls_bp_master hbm where hbm.bp_id = ${@bp_id})
union all
--代理店(法人) --代理店(法人)
select * select *
from con_contract_history_lv t from con_contract_history_lv t
where t.bp_class = 'ORG' where t.social_code = (select hbm.social_code
and t.social_code = (select hbm.social_code
from hls_bp_master hbm from hls_bp_master hbm
where hbm.bp_id = ${@bp_id}) where hbm.bp_id = ${@bp_id})
and t.unit_id in (select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id}) and t.unit_id in (select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id})
and not exists( and exists(
select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id} and vv.POSITION_TYPE = 'SALES' select vv.unit_id from exp_emp_assign_e_v vv where vv.user_id = ${/session/@user_id} and vv.POSITION_TYPE = 'SALES'
) )
union all union all
--非代理店(法人) --非代理店(法人)
select * select *
from con_contract_history_lv t from con_contract_history_lv t
where t.bp_class = 'ORG' where t.social_code = (select hbm.social_code
and t.social_code = (select hbm.social_code
from hls_bp_master hbm from hls_bp_master hbm
where hbm.bp_id = ${@bp_id}) where hbm.bp_id = ${@bp_id})
and not exists( and not exists(
......
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