103 lines
3.7 KiB
MySQL
103 lines
3.7 KiB
MySQL
|
-- dic_门店
|
||
|
|
||
|
|
||
|
SELECT DISTINCT
|
||
|
comm_id AS 项目id,/*门店*/
|
||
|
comm_name AS 项目名称
|
||
|
FROM dim_organ_mapping
|
||
|
WHERE 1=1
|
||
|
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
|
||
|
|
||
|
|
||
|
-- dic_片区
|
||
|
|
||
|
|
||
|
SELECT DISTINCT
|
||
|
organ_code AS 片区id,
|
||
|
organ_name AS 片区名称
|
||
|
FROM dim_organ_mapping
|
||
|
|
||
|
|
||
|
-- dict_费用类型
|
||
|
|
||
|
select distinct ParentCostCode, ParentCostName
|
||
|
from dws_finance_fees_serial_m
|
||
|
order by ParentCostCode asc
|
||
|
|
||
|
|
||
|
-- report_收缴率
|
||
|
|
||
|
|
||
|
select
|
||
|
${if(len(p_area) == 0,"a.organ_code code, a.organ_name name,","a.comm_id code, a.comm_name name,")}
|
||
|
a.ym, ParentCostCode, ParentCostName
|
||
|
, (pr_paid_cu_amt + cu_paid_cu_amt + pr_exempt_cu_amt + cu_exempt_cu_amt)/10000 cu_paid_amt
|
||
|
, (cu_receivable_amt + pr_exempt_cu_amt + cu_exempt_cu_amt)/10000 cu_receivable_amt
|
||
|
, (- cu_paid_pr_amt + cu_offset_pr_amt)/10000 pr_paid_amt
|
||
|
, (pr_total_receivable_amt + pr_total_received_amt + cu_early_exempt_pr_amt + cu_exempt_pr_amt)/10000 pr_receivable_amt
|
||
|
, case when a.ParentCostCode = '0001' then b.index_dq_target else 0 end cu_coll_rate_target
|
||
|
, case when a.ParentCostCode = '0001' then b.index_wq_target else 0 end pr_coll_rate_target
|
||
|
, case when a.ParentCostCode = '0008' then b.index_sd_target
|
||
|
when a.ParentCostCode = '0007' then b.index_dj_target else 0 end total_coll_rate_target
|
||
|
from dws_finance_fees_serial_m a
|
||
|
left join ods_finance_collection_target_area b
|
||
|
on a.organ_code = b.organ_code and a.ym = b.ym
|
||
|
left join ods_finance_collection_target_project c
|
||
|
on a.comm_id = c.comm_id and a.ym = c.ym
|
||
|
where 1=1
|
||
|
${if(len(p_startdate) == 0,"","and a.ym = '" + p_startdate + "'")}
|
||
|
${if(len(p_feestype) == 0,"","and a.ParentCostCode = '" + p_feestype+ "'")}
|
||
|
${if(len(p_area) == 0,"","and a.organ_code = '" + p_area+ "'")}
|
||
|
;
|
||
|
|
||
|
|
||
|
-- report_收缴率目标
|
||
|
|
||
|
|
||
|
select
|
||
|
organ_code code
|
||
|
, organ_name name
|
||
|
, ym
|
||
|
, index_dq_target
|
||
|
, index_wq_target
|
||
|
, index_sd_target
|
||
|
, index_dj_target
|
||
|
, index_ac_target_dq
|
||
|
, index_ac_target_wq
|
||
|
, index_ac_target_zh
|
||
|
from ods_finance_collection_target_area
|
||
|
where 1=1
|
||
|
${if(len(p_startdate) == 0,"","and ym = '" + p_startdate + "'")}
|
||
|
union all
|
||
|
select
|
||
|
comm_id code
|
||
|
, comm_name name
|
||
|
, ym
|
||
|
, index_dq_target
|
||
|
, index_wq_target
|
||
|
, index_sd_target
|
||
|
, index_dj_target
|
||
|
, index_ac_target_dq
|
||
|
, index_ac_target_wq
|
||
|
, index_ac_target_zh
|
||
|
from ods_finance_collection_target_project
|
||
|
where 1=1
|
||
|
${if(len(p_startdate) == 0,"","and ym = '" + p_startdate + "'")}
|
||
|
|
||
|
|
||
|
-- report_中科目收缴率
|
||
|
|
||
|
select
|
||
|
b.organ_code, b.organ_name, b.comm_id, b.comm_name, ym
|
||
|
${if(len(p_feestype) == 0,", ParentCostCode CostCode, ParentCostName CostName",", MiddleCostCode CostCode, MiddleCostName CostName")}
|
||
|
, (pr_paid_cu_amt + cu_paid_cu_amt + pr_exempt_cu_amt + cu_exempt_cu_amt)/10000 cu_paid_amt
|
||
|
, (cu_receivable_amt + pr_exempt_cu_amt + cu_exempt_cu_amt)/10000 cu_receivable_amt
|
||
|
, (- cu_paid_pr_amt + cu_offset_pr_amt)/10000 pr_paid_amt
|
||
|
, (pr_total_receivable_amt + pr_total_received_amt + cu_early_exempt_pr_amt + cu_exempt_pr_amt)/10000 pr_receivable_amt
|
||
|
from dwd_finance_fees_serial_d a
|
||
|
inner join (select distinct organ_code, organ_name, comm_id, comm_name from dim_organ_mapping where comm_id is not null) b
|
||
|
on a.commid = b.comm_id
|
||
|
where 1=1
|
||
|
${if(len(p_startdate) == 0,"","and ym = '" + p_startdate + "'")}
|
||
|
${if(len(p_feestype) == 0,"","and ParentCostCode = '" + p_feestype+ "'")}
|
||
|
${if(len(p_area) == 0,"","and b.organ_code = '" + p_area+ "'")}
|