2024-07-23 21:40:49 +08:00
|
|
|
-- 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 片区名称
|
2024-09-11 11:34:29 +08:00
|
|
|
FROM dws_finance_fees_serial_m
|
|
|
|
where 1=1 and organ_code is not null
|
|
|
|
and organ_name not in ('东湖商管','领悦总部','演示机构')
|
|
|
|
${if(GETUSERDEPARTMENTS(2)="领悦集团总部","","and organ_name = '"+GETUSERDEPARTMENTS(2)+"'")}
|
2024-07-23 21:40:49 +08:00
|
|
|
|
|
|
|
-- dict_费用类型
|
|
|
|
|
2024-09-11 11:34:29 +08:00
|
|
|
select distinct ParentCostCode, case when ParentCostCode = '0008' then '代收代缴水电费' else ParentCostName end ParentCostName
|
2024-07-23 21:40:49 +08:00
|
|
|
from dws_finance_fees_serial_m
|
2024-09-11 11:34:29 +08:00
|
|
|
where ParentCostCode in ('0001','0007','0008')
|
2024-07-23 21:40:49 +08:00
|
|
|
order by ParentCostCode asc
|
|
|
|
|
|
|
|
|
2024-09-11 11:36:32 +08:00
|
|
|
|
|
|
|
-- report_多经收缴情况
|
|
|
|
SELECT
|
|
|
|
${if(len(p_area) == 0,"organ_code code, organ_name name,","comm_id code, comm_name name,")}
|
|
|
|
`year_month`, index_type, index_receivable, index_receipts, index_not_receipts, collection_rate, update_user, update_time
|
|
|
|
FROM ods_caiwu_profit
|
|
|
|
where 1=1
|
|
|
|
-- ${if(len(p_area) == 0,"","and organ_code = '" + p_area+ "'")}
|
|
|
|
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
|
|
|
|
${if(len(p_startdate) == 0,"","and `year_month` = '" + replace(p_startdate,"-","") + "'")}
|
|
|
|
${if(left(fine_role,2)=="项目","and comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-23 21:40:49 +08:00
|
|
|
-- report_收缴率
|
|
|
|
|
|
|
|
|
2024-09-11 11:34:29 +08:00
|
|
|
select * from (
|
|
|
|
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
|
|
|
|
, (ifnull(pr_paid_cu_amt,0) + ifnull(cu_paid_cu_amt,0) - ifnull(pr_offset_cu_amt,0) - ifnull(cu_offset_cu_amt,0))/10000 cu_paid_amt
|
|
|
|
, (ifnull(cu_receivable_amt,0) + ifnull(pr_exempt_cu_amt,0) + ifnull(cu_exempt_cu_amt,0))/10000 cu_receivable_amt
|
|
|
|
, (- ifnull(cu_paid_pr_amt,0) - ifnull(cu_offset_pr_amt,0))/10000 pr_paid_amt
|
|
|
|
, (ifnull(pr_total_receivable_amt,0) + ifnull(pr_total_received_amt,0) + ifnull(cu_early_exempt_pr_amt,0) + ifnull(cu_exempt_pr_amt,0))/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 and a.organ_code is not null
|
|
|
|
and a.organ_name not in ('东湖商管','领悦总部','演示机构') and a.comm_name not like '%天富%'
|
|
|
|
${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+ "'")}
|
|
|
|
${IF(LEN(p_area)>0," AND a.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
|
|
|
|
${if(left(fine_role,2)=="项目","and a.comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
|
|
|
|
) a where not (cu_paid_amt=0 and cu_receivable_amt=0 and pr_paid_amt=0 and pr_receivable_amt = 0)
|
2024-07-23 21:40:49 +08:00
|
|
|
|
|
|
|
-- report_收缴率目标
|
|
|
|
|
|
|
|
select
|
|
|
|
organ_code code
|
|
|
|
, organ_name name
|
|
|
|
, ym
|
2024-09-11 11:36:32 +08:00
|
|
|
, ${IF(p_feestype = '0001',"index_dq_target",IF(p_feestype = "0007","''","''"))} AS index_dq_target
|
|
|
|
, ${IF(p_feestype = '0001',"index_wq_target",IF(p_feestype = "0007","''","''"))} AS index_wq_target
|
2024-07-23 21:40:49 +08:00
|
|
|
, 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
|
2024-09-11 11:36:32 +08:00
|
|
|
, ${IF(p_feestype = '0001',"index_dq_target",IF(p_feestype = "0007","''","''"))} AS index_dq_target
|
|
|
|
, ${IF(p_feestype = '0001',"index_wq_target",IF(p_feestype = "0007","''","''"))} AS index_wq_target
|
2024-07-23 21:40:49 +08:00
|
|
|
, 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 + "'")}
|
2024-09-11 11:36:32 +08:00
|
|
|
${if(left(fine_role,2)=="项目","and comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
|
|
|
|
|
|
|
|
-- report_物业费收缴总目标
|
|
|
|
|
|
|
|
select organ_code, ym, index_dq_target, index_wq_target from ods_finance_collection_target_area where organ_code = '5501'
|
|
|
|
${if(left(fine_role,2)=="项目","and comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
|
2024-07-23 21:40:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
-- report_中科目收缴率
|
|
|
|
|
|
|
|
select
|
2024-09-11 11:36:32 +08:00
|
|
|
CostName
|
|
|
|
, sum((ifnull(cu_receivable_amt,0) - ifnull(cu_paid_amt,0)) + (ifnull(pr_receivable_amt,0) - ifnull(pr_paid_amt,0))) owed_amt
|
|
|
|
from (
|
|
|
|
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")}
|
|
|
|
, (ifnull(pr_paid_cu_amt,0) + ifnull(cu_paid_cu_amt,0) - ifnull(pr_offset_cu_amt,0) - ifnull(cu_offset_cu_amt,0))/10000 cu_paid_amt
|
|
|
|
, (ifnull(cu_receivable_amt,0) + ifnull(pr_exempt_cu_amt,0) + ifnull(cu_exempt_cu_amt,0))/10000 cu_receivable_amt
|
|
|
|
, (- ifnull(cu_paid_pr_amt,0) - ifnull(cu_offset_pr_amt,0))/10000 pr_paid_amt
|
|
|
|
, (ifnull(pr_total_receivable_amt,0) + ifnull(pr_total_received_amt,0) + ifnull(cu_early_exempt_pr_amt,0) + ifnull(cu_exempt_pr_amt,0))/10000 pr_receivable_amt
|
|
|
|
from dwd_finance_fees_serial_d a
|
|
|
|
left join(
|
|
|
|
select a.CommID comm_id, a.CommName comm_name, b.OrganCode organ_code, b.OrganName organ_name from ods_erp_tb_hspr_community_d a
|
|
|
|
left join (
|
|
|
|
select * from ods_erp_tb_sys_organ_d
|
|
|
|
where length(OrganCode) = 4
|
|
|
|
) b
|
|
|
|
on left(a.OrganCode,4) = b.OrganCode
|
|
|
|
) b
|
|
|
|
on a.commid = b.comm_id
|
|
|
|
where 1=1
|
|
|
|
and ((a.ParentCostCode = '0008' and a.MiddleCostCode in ('00080001','00080002','00080003','00080004','00080005','00080006','00080007','00080008','00080017','00080018','00080019','00080022','00080023','00080024','00080027','00080028','00080032','00080035')) or a.ParentCostCode = '0001')
|
|
|
|
and a.organ_name not in ('东湖商管','领悦总部','演示机构') and a.comm_name not like '%天富%'
|
|
|
|
${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+ "'")}
|
|
|
|
${IF(LEN(p_area)>0," AND b.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
|
|
|
|
${if(left(fine_role,2)=="项目","and a.comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
|
|
|
|
) a
|
|
|
|
where not (cu_paid_amt=0 and cu_receivable_amt=0 and pr_paid_amt=0 and pr_receivable_amt = 0)
|
|
|
|
group by CostName
|
|
|
|
union all
|
|
|
|
SELECT
|
|
|
|
index_type, sum(index_not_receipts)
|
|
|
|
FROM ods_caiwu_profit
|
2024-07-23 21:40:49 +08:00
|
|
|
where 1=1
|
2024-09-11 11:36:32 +08:00
|
|
|
-- ${if(len(p_area) == 0,"","and organ_code = '" + p_area+ "'")}
|
|
|
|
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
|
|
|
|
${if(len(p_startdate) == 0,"","and `year_month` = '" + replace(p_startdate,"-","") + "'")}
|
|
|
|
${if(left(fine_role,2)=="项目","and comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
|
|
|
|
group by index_type
|
|
|
|
order by owed_amt desc
|