finereport逻辑更新

This commit is contained in:
yangkunan 2024-07-23 21:40:49 +08:00
parent 9226e54f79
commit 319166b0ad
13 changed files with 662 additions and 4 deletions

View File

@ -3,9 +3,15 @@
<component name="SqlDialectMappings"> <component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/dw/dim/dim_building_info_d.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/dw/dim/dim_building_info_d.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/dw/dim/dim_business_contract_type_d.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/dw/dim/dim_business_contract_type_d.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/dw/dim/dim_engine_equipment_d.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/dw/dim/dim_project_base_info_d.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/dw/dim/dim_project_base_info_d.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/dw/dwd/dwd_engine_equipment_status_d.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/dw/dws/dws_engine_equipment_in_good_d.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/dw/dws/dws_engine_equipment_inspect_task_m.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/dw/dws/dws_finance_fees_serial_m.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/dw/dws/dws_finance_fees_serial_m.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/dw/ods/ods_cost_budget_data_d.sql" dialect="Oracle" /> <file url="file://$PROJECT_DIR$/dw/ods/ods_cost_budget_data_d.sql" dialect="Oracle" />
<file url="file://$PROJECT_DIR$/finereport/kanban/mobile/创新生态_mobile.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/kanban/pc/工程.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/xiazuan/2_operation/住服比异常项目.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/finereport/xiazuan/2_operation/住服比异常项目.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/xiazuan/2_operation/计划到期明细.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/finereport/xiazuan/2_operation/计划到期明细.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/xiazuan/2_operation/项目明细弹窗.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/finereport/xiazuan/2_operation/项目明细弹窗.sql" dialect="MySQL" />

View File

@ -19,3 +19,6 @@ from dim_engine_equipment_d a
on a.CommID = c.comm_id on a.CommID = c.comm_id
group by group by
c.organ_code, c.organ_name, c.comm_id, c.comm_name c.organ_code, c.organ_name, c.comm_id, c.comm_name
;
SELECT * FROM dim_engine_equipment_d where SystemId = '8ae5eea4-f0e0-4106-a022-ad2b370cad80'

View File

@ -1,10 +1,11 @@
select select
organ_code, organ_name, comm_id, comm_name organ_code, organ_name, comm_id, comm_name
, date_format(TaskEndTime, '%Y%m') task_ym , date_format(TaskEndTime, '%Y%m') task_ym
, sum(case when TaskStatue = 2 then 1 else 0 end) task_finish_num , sum(case when TaskStatue = 2 then 1 else 0 end) task_finish_num -- 完成数量
, count(*) task_num , count(*) task_num -- 任务数量
,sum(case when TaskStatue = 2 then 1 else 0 end) / count(*) * 100 as rate
from dwd_engine_equipment_inspection_task_d a from dwd_engine_equipment_inspection_task_d a
left join (select distinct organ_code, organ_name, comm_id, comm_name from dim_organ_mapping) b join (select distinct organ_code, organ_name, comm_id, comm_name from dim_organ_mapping) b
on a.CommId = b.comm_id on a.CommId = b.comm_id
group by group by
organ_code, organ_name, comm_id, comm_name organ_code, organ_name, comm_id, comm_name

View File

@ -0,0 +1,191 @@
-- dic_1_片区
SELECT DISTINCT
organ_code AS id,
organ_name AS
FROM dim_organ_mapping
;
-- report_1_空间运营
WITH T1 AS
(SELECT
organ_code,
organ_name,
assessment_occupany_rate AS
FROM dws_point_occupancy_rate_summary_pq
WHERE 1=1
AND ym = '${REPLACE(p_ym,"-","")}'
${IF(p_kj = "低于50%","AND assessment_occupany_rate <= 50","AND assessment_occupany_rate >= 50")}
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${IF(LEN(p_prgject)>0," AND comm_id IN ('"+JOINARRAY(p_prgject,"','")+"')", "")}
)
SELECT
ROW_NUMBER() OVER (ORDER BY ) AS ,
organ_code,
organ_name,
FROM T1
ORDER BY ${IF(p_kj = "低于50%","ASC","DESC")}
;
-- report_2_新零售
WITH T1 AS (
select
organ_code,
organ_name,
sum(sale_amt)/10000 sale_amt
from dws_innoveco_new_retail_m
where create_ym = '${REPLACE(p_ym,"-","")}'
group by organ_code,organ_name
),T2 AS (
SELECT
organ_code,organ_name,
SUM(IFNULL(index_retail_target,0)) AS sale_target,
SUM(index_retail_fact) AS sale_fact
FROM ods_innoveco_offlinesales
WHERE `year_month` = '${REPLACE(p_ym,"-","")}'
GROUP BY organ_code,organ_name
),T3 AS (
SELECT
T1.organ_code,
T1.organ_name,
T2.sale_target,
(T1.sale_amt + T2.sale_fact) AS sale_amt,
IFNULL((T1.sale_amt + T2.sale_fact) / T2.sale_target,0) AS
FROM T1 LEFT JOIN T2 ON T1.organ_code = T2.organ_code
)
SELECT
ROW_NUMBER() OVER (ORDER BY ) AS ,
organ_code,
organ_name,
sale_target,
sale_amt,
FROM T3
WHERE 1=1
${IF(p_xls = "低于50%","AND 销售完成率 <= 0.5","AND 销售完成率 >= 0.5")}
ORDER BY ${IF(p_xls = "低于50%","ASC","DESC")}
;
-- report_3_小悦到家
WITH T1 AS (
select
organ_code,
organ_name,
sum(xydj_amt) sale_amt
from dws_innoveco_new_retail_m
where create_ym = '${REPLACE(p_ym,"-","")}'
group by organ_code,organ_name
),T2 AS (
SELECT
organ_code,organ_name,
SUM(IFNULL(index_xiaoyuedj_target,0)) AS sale_target,
SUM(index_yuhetai_fact) AS sale_fact
FROM ods_innoveco_offlinesales
WHERE `year_month` = '${REPLACE(p_ym,"-","")}'
GROUP BY organ_code,organ_name
),T3 AS (
SELECT
T1.organ_code,
T1.organ_name,
T2.sale_target,
(T1.sale_amt + T2.sale_fact) AS sale_amt,
IFNULL((T1.sale_amt + T2.sale_fact) / T2.sale_target,0) AS
FROM T1 LEFT JOIN T2 ON T1.organ_code = T2.organ_code
)
SELECT
ROW_NUMBER() OVER (ORDER BY ) AS ,
organ_code,
organ_name,
sale_target,
sale_amt,
FROM T3
WHERE 1=1
${IF(p_xydj = "低于50%","AND 销售完成率 <= 0.5","AND 销售完成率 >= 0.5")}
ORDER BY ${IF(p_xydj = "低于50%","ASC","DESC")}
;
-- report_4_御和泰
WITH T1 AS (
select
organ_code,
organ_name,
sum(yht_amt)/10000 sale_amt
from dws_innoveco_new_retail_m
where create_ym = '${REPLACE(p_ym,"-","")}'
group by organ_code,organ_name
),T2 AS (
SELECT
organ_code,organ_name,
SUM(IFNULL(index_yuhetai_target,0)) AS sale_target,
SUM(index_xiaoyuedj_fact) AS sale_fact
FROM ods_innoveco_offlinesales
WHERE `year_month` = '${REPLACE(p_ym,"-","")}'
GROUP BY organ_code,organ_name
),T3 AS (
SELECT
T1.organ_code,
T1.organ_name,
T2.sale_target,
(T1.sale_amt + T2.sale_fact) AS sale_amt,
IFNULL((T1.sale_amt + T2.sale_fact) / T2.sale_target,0) AS
FROM T1 LEFT JOIN T2 ON T1.organ_code = T2.organ_code
)
SELECT
ROW_NUMBER() OVER (ORDER BY ) AS ,
organ_code,
organ_name,
sale_target,
sale_amt,
FROM T3
WHERE 1=1
${IF(p_yht = "低于50%","AND 销售完成率 <= 0.5","AND 销售完成率 >= 0.5")}
ORDER BY ${IF(p_yht = "低于50%","ASC","DESC")}
;
-- report_指标卡
WITH T1 AS (/*各类别应收与实收*/
SELECT
index_type,
SUM(IFNULL(index_receivable,0)) AS ,
SUM(IFNULL(index_receipts,0)) AS
FROM ods_caiwu_profit
WHERE 1=1
AND `year_month` = '${REPLACE(p_ym,"-","")}'
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${IF(LEN(p_prgject)>0," AND comm_id IN ('"+JOINARRAY(p_prgject,"','")+"')", "")}
GROUP BY index_type
)
SELECT
IFNULL(SUM(CASE WHEN index_type = '附属资源/空间运营' THEN ELSE 0 END),0) AS ,
IFNULL(SUM(CASE WHEN index_type = '附属资源/空间运营' THEN / ELSE 0 END),0) AS ,
IFNULL(SUM(CASE WHEN index_type = '美居' THEN ELSE 0 END),0) AS ,
IFNULL(SUM(CASE WHEN index_type = '美居' THEN / ELSE 0 END),0) AS ,
IFNULL(SUM(CASE WHEN index_type = '社商/新零售' THEN ELSE 0 END),0) AS ,
IFNULL(SUM(CASE WHEN index_type = '社商/新零售' THEN / ELSE 0 END),0) AS ,
IFNULL(SUM(CASE WHEN index_type = '资产运营/资产租售' THEN ELSE 0 END),0) AS ,
IFNULL(SUM(CASE WHEN index_type = '资产运营/资产租售' THEN / ELSE 0 END),0) AS ,
IFNULL(SUM(),0) AS ,
IFNULL(SUM() / SUM(),0) AS
FROM T1
;
-- 全国综合考核率
SELECT
CONCAT(assessment_occupany_rate,'%') AS
FROM dws_point_occupancy_rate_summary_all
WHERE ym = '${REPLACE(p_ym,"-","")}'

View File

@ -0,0 +1,61 @@
-- dict_1_片区
SELECT DISTINCT
organ_code AS id,
organ_name AS
FROM dim_organ_mapping
;
-- report_出租分析组合图
SELECT
`type`,
SUM(IFNULL(construction_area,0))/10000 AS ,
SUM(IFNULL(lease_area,0))/10000 AS ,
SUM(IFNULL(lease_area,0))/SUM(IFNULL(construction_area,0)) AS
FROM dws_business_rent_rate_d
${IF(LEN(p_project) > 0," AND project_id IN ('"+JOINARRAY(p_project,"','")+"')", "")}
GROUP BY `type`
;
-- 出租率
SELECT
`type`
, sum(lease_area)/sum(construction_area) rent_rate
FROM dws_business_rent_rate_d
WHERE 1=1
${IF(LEN(p_project) > 0," AND project_id IN ('"+JOINARRAY(p_project,"','")+"')", "")}
group by `type`
;
-- 出租面积
SELECT
project_id
, project_name
, `type`
, construction_area/10000 construction_area
, lease_area/10000 lease_area
, lease_area/construction_area rent_rate
FROM dws_business_rent_rate_d
${IF(LEN(p_project) > 0," AND project_id IN ('"+JOINARRAY(p_project,"','")+"')", "")}
;
-- 收款金额
SELECT
project_id
, project_name
, accrual_month
, current_sure_money/10000 current_sure_money
, received_money/10000 received_money
, areare_money/10000 areare_money
FROM dws_business_bill_m
where left(accrual_month,7) = '${p_ym}'
${IF(LEN(p_project) > 0," AND project_id IN ('"+JOINARRAY(p_project,"','")+"')", "")}

View File

@ -0,0 +1,121 @@
-- dict_erp片区
SELECT DISTINCT
organ_code AS id,
organ_name AS
FROM dim_organ_mapping
-- report_车场启费
select
a.ym, a.organ_code, a.organ_name, a.comm_id, a.comm_name, case when qifei_cost_num > 0 then 1 else 0 end qifei_comm_num
from (
select
ifnull(b.ym,${IF(LEN(p_ym)>0,"'" + p_ym+ "'","null")} ) ym, a.organ_code, a.organ_name, a.comm_id, a.comm_name
,sum(case when ifnull(case when ifnull(pr_total_receivable_amt, 0) = 0 then (case when ifnull(cu_receivable_amt,0) then ifnull(cu_paid_pr_amt,0) else cu_receivable_amt end) else pr_total_receivable_amt end,0) != 0 then 1 else 0 end) qifei_cost_num
from (select distinct organ_code, organ_name, comm_id, comm_name from dim_organ_mapping where comm_id is not null) a
left join (
select * from dwd_finance_fees_serial_d
where MiddleCostCode in ('00010003','00030002')
${IF(LEN(p_ym)>0," AND ym ='" + p_ym+ "'","")}
) b
on a.comm_id = b.commid
group by b.ym, a.organ_code, a.organ_name, a.comm_id, a.comm_name
) a
where 1=1
${IF(LEN(p_area)>0," AND a.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
-- report_设备完好率
SELECT ${if(len(p_area)>0, "comm_id code, comm_name name,","organ_code code, organ_name name,")}
comm_id, comm_name,
good_equipment_num, equipment_num
FROM dws_engine_equipment_in_good_d;
-- 基础指标
select '停车场数量' indicator_name, count(*) indicator_value from dim_carpark_info_d
union all
select '车位数量', count(*) from dim_parking_info_d
union all
select '巡查点位数', count(*) from dim_engine_point_d
union all
select '设施设备总数', count(*) from dim_engine_equipment_d
-- 能耗环比
select *
from dws_engine_meter_dosage_m
where left(list_ym,4) = ${left(p_ym,4)}
AND list_ym <> DATE_FORMAT(CURDATE(), '%Y%m')
and MeterType in ('水表','电表')
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
-- 能耗排名
select ${IF(LEN(p_area)>0,"comm_id code, comm_name name,","organ_code code, organ_name name,")} dosage
from dws_engine_meter_dosage_m
where MeterType = '电表'
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${IF(LEN(p_ym)>0," AND list_ym ='" + left(p_ym,4) + right(p_ym,2) + "'","")}
order by Dosage desc
limit 5
-- 能耗同比
SELECT
organ_code
, organ_name
, comm_id
, comm_name
, MeterType
, list_ym
, Dosage
, Amount
FROM dws_engine_meter_dosage_m
where 1=1
AND list_ym <> DATE_FORMAT(CURDATE(), '%Y%m')
AND list_ym >= '${FORMAT(MONTHDELTA(CONCATENATE(p_ym,"-01"),-60),"yyyyMM")}'
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${IF(LEN(p_ym)>0," AND right(list_ym,2) ='" +right(p_ym,2) + "'","")}
and MeterType in ('水表','电表')
order by list_ym asc
-- 设备巡查
select
${IF(LEN(p_area)>0,"organ_code, organ_name, comm_id code, comm_name name,","organ_code code, organ_name name,")}
comm_id, comm_name,
task_ym
, task_finish_num
, task_num
FROM dws_engine_equipment_inspect_task_m
where 1=1
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${IF(LEN(p_ym)>0," AND task_ym ='" + left(p_ym,4) + right(p_ym,2) + "'","")}
-- 水电收缴率
select
sum(pr_paid_cu_amt + cu_paid_cu_amt + pr_offset_cu_amt + cu_offset_cu_amt - cu_offset_pr_amt - cu_paid_pr_amt) / sum(cu_receivable_amt + pr_exempt_cu_amt + cu_exempt_cu_amt + pr_total_receivable_amt + pr_total_received_amt + cu_early_exempt_pr_amt + cu_exempt_pr_amt) collection_rate
from dwd_finance_fees_serial_d
where ParentCostCode = '0008'
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${IF(LEN(p_ym)>0," AND ym ='" + p_ym+ "'","")}
-- 异常抬杆
select
organ_code , organ_name
, sum(manualOutNum) manualOutNum
, sum(carflow) carflow
, sum(manualOutNum) / sum(carflow) exceptionRate
from dws_engine_stat_exception_rate_w
where yw = (select distinct yw from dws_engine_stat_exception_rate_w order by yw desc limit 1)
group by organ_code , organ_name

View File

@ -0,0 +1,17 @@
select
concat(right(ym,2) + 0 , '') ym
, sum(plan_num) plan_num
, sum(plan_complete_num) plan_complete_num
, sum(plan_incomplete_num) plan_incomplete_num
, sum(plan_complete_num) / sum(plan_num) plan_complete_rate
, sum(plan_adjust_num) plan_adjust_num
, sum(plan_adjust_num) / sum(plan_num) plan_adjust_rate
from dws_operation_plan_summary_m a
left join (select distinct organ_code, organ_name, comm_id, comm_name
, oa_organ_code, oa_organ_name, oa_comm_id, oa_comm_name from dim_organ_mapping where comm_id is not null) b
on a.subcompanyid = b.oa_comm_id
where 1=1
${if(len(organ)=0,"","and organ_code = '"+organ+"'")}
and left(ym,4) = '2024'
group by ym
order by ym asc

View File

@ -0,0 +1,103 @@
-- 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+ "'")}

View File

@ -0,0 +1,17 @@
-- dic_片区
SELECT DISTINCT
organ_code AS id,
organ_name AS
FROM dim_organ_mapping
-- report_今日收费
select * from dws_finance_today_fees_d
where 1=1
${if(len(p_area) == 0,"","and organ_code = '" + p_area+ "'")}
order by organ_code, comm_id

View File

@ -0,0 +1,20 @@
-- dic_片区
SELECT DISTINCT
organ_code AS id,
organ_name AS
FROM dim_organ_mapping
-- report_现金流
select
${if(len(p_area) == 0,"organ_name name","comm_name name")}
, sum(sum_cash) sum_cash
from ods_caiwu_fullaperture
where 1=1
${if(len(p_startdate) == 0,"","and yr_month = '" + left(p_startdate,4) + right(p_startdate,2) + "'")}
${if(len(p_area) == 0,"","and organ_code = '" + p_area+ "'")}
group by ${if(len(p_area) == 0,"organ_name","comm_name")}
order by sum(sum_cash) desc

View File

@ -0,0 +1,39 @@
-- 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
-- report_收入成本利润预算填报
select
${if(len(p_area) == 0,"organ_code code, organ_name name,","comm_id code, comm_name name,")}
yr_month, category, yslx, index_income_target, index_income_fact, income_completion_rate
from(
select organ_code, organ_name, comm_id, comm_name, yr_month, category, '收入' yslx, index_income_target, index_income_fact, income_completion_rate
from ods_caiwu_feecollection
union all
select organ_code, organ_name, comm_id, comm_name, yr_month, category, '成本' yslx, index_cost_target, index_cost_fact, cost_completion_rate
from ods_caiwu_feecollection
union all
select organ_code, organ_name, comm_id, comm_name, yr_month, category, '利润' yslx, index_profit_target, profit_completion_rate, income_completion_rate
from ods_caiwu_feecollection
union all
select organ_code, organ_name, comm_id, comm_name, yr_month, category, '市拓' yslx, index_market_target, index_market_fact, market_completion_rate
from ods_caiwu_feecollection
) a where yslx = ${"'" + p_yslx + "'"}
${if(len(p_startdate) == 0,"","and yr_month = '" + p_startdate + "'")}
${if(len(p_area) == 0,"","and organ_code = '" + p_area+ "'")}

View File

@ -0,0 +1 @@
-- todo

View File

@ -0,0 +1,78 @@
-- dict_分析视角
WITH T1 AS (
SELECT '片区' AS
UNION ALL
SELECT '业务条线' AS
/*UNION ALL
SELECT '生命周期' AS */
)
SELECT FROM T1
WHERE 1=1
-- report_1_按片区得分
SELECT
organ_name,
SUM(IFNULL(index_mydf,0)) AS
FROM ods_wuye_complaint_half_year
WHERE yr = '${p_yr}'
AND t_quarter = '${p_jd}'
GROUP BY organ_name
-- report_1_按业务条线得分
SELECT
business AS 线,
index_df AS
FROM ods_wuye_complaint_business
WHERE yr = '${p_yr}'
AND jd = '${p_jd}'
-- report_表格1
WITH T1 AS (/*各片区目标*/
SELECT DISTINCT
organ_name,
organ_target
FROM ods_wuye_satisfaction_target
WHERE yr = '${p_yr}'
),T2 AS (/*各片区得分*/
SELECT
organ_name,
index_wl_yxybl AS ,
index_wl_myl AS ,
index_mwl_yxybl AS ,
index_mwl_myl AS ,
index_mydf AS
FROM ods_wuye_complaint_half_year
WHERE yr = '${p_yr}'
AND t_quarter = '${p_jd}'
)
SELECT
T1.organ_name AS ,
'${p_jd}' AS ,
T2.,
T1.organ_target AS ,
T2.,
T2.
FROM T1 LEFT JOIN T2 ON T1.organ_name = T2.organ_name
-- report_表格2
SELECT
organ_name AS ,
SUM(CASE WHEN business = '安全秩序管理' THEN index_df ELSE 0 END ) AS ,
SUM(CASE WHEN business = '保洁服务' THEN index_df ELSE 0 END ) AS ,
SUM(CASE WHEN business = '绿化维护' THEN index_df ELSE 0 END ) AS 绿,
SUM(CASE WHEN business = '客服服务' THEN index_df ELSE 0 END ) AS ,
SUM(CASE WHEN business = '上门维修服务' THEN index_df ELSE 0 END ) AS
FROM ods_wuye_complaint_business
WHERE yr = '${p_yr}'
AND jd = '${p_jd}'
GROUP BY organ_name