人力成本取值优化+商写片区归类优化

This commit is contained in:
yangkunan 2024-12-14 17:18:06 +08:00
parent fb6a2b6da6
commit 611d346127
3 changed files with 41 additions and 44 deletions

View File

@ -247,8 +247,7 @@ FROM
SELECT SELECT
* *
FROM dw.ods_cost_collection_lc_ac FROM dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
)A )A
LEFT JOIN LEFT JOIN
( (
@ -808,8 +807,7 @@ coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END)
,0 AS lc_fee_rate_target -- 人力成本费率 ,0 AS lc_fee_rate_target -- 人力成本费率
,0 AS ac_fee_rate_target -- 行政成本费率 ,0 AS ac_fee_rate_target -- 行政成本费率
from dw.ods_cost_collection_lc_ac from dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
UNION ALL UNION ALL
SELECT SELECT
0 AS lc_fee_rate 0 AS lc_fee_rate
@ -847,8 +845,7 @@ SELECT
,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用 ,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用
,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用 ,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用
from dw.ods_cost_collection_lc_ac from dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
GROUP BY organ_code GROUP BY organ_code
)A )A
LEFT JOIN LEFT JOIN
@ -2036,8 +2033,7 @@ SELECT
,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用 ,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用
,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用 ,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用
from dw.ods_cost_collection_lc_ac from dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} ${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
GROUP BY organ_code,organ_name GROUP BY organ_code,organ_name
)A )A
@ -2085,8 +2081,7 @@ SELECT
,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用 ,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用
,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用 ,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用
from dw.ods_cost_collection_lc_ac from dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} ${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
GROUP BY organ_code,organ_name GROUP BY organ_code,organ_name
)A )A
@ -2153,8 +2148,7 @@ FROM
, COALESCE(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END), , COALESCE(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),
0) AS ac_total_fee -- 行政成本费用 0) AS ac_total_fee -- 行政成本费用
FROM dw.ods_cost_collection_lc_ac FROM dw.ods_cost_collection_lc_ac
WHERE LEFT(ym, 4) = LEFT('${p_ym}', 4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
GROUP BY organ_code, comm_id, comm_name GROUP BY organ_code, comm_id, comm_name
)A1 )A1
LEFT JOIN LEFT JOIN
@ -2266,8 +2260,7 @@ FROM
, COALESCE(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END), , COALESCE(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),
0) AS ac_total_fee -- 行政成本费用 0) AS ac_total_fee -- 行政成本费用
FROM dw.ods_cost_collection_lc_ac FROM dw.ods_cost_collection_lc_ac
WHERE LEFT(ym, 4) = LEFT('${p_ym}', 4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
GROUP BY organ_code, comm_id, comm_name GROUP BY organ_code, comm_id, comm_name
)A1 )A1
LEFT JOIN LEFT JOIN

View File

@ -338,8 +338,8 @@ FROM
SELECT SELECT
* *
FROM dw.ods_cost_collection_lc_ac FROM dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
)A )A
LEFT JOIN LEFT JOIN
( (
@ -1184,8 +1184,7 @@ SELECT
,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用 ,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用
,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用 ,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用
from dw.ods_cost_collection_lc_ac from dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} ${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
GROUP BY organ_code,organ_name GROUP BY organ_code,organ_name
)A )A
@ -1241,8 +1240,7 @@ SELECT
,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用 ,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用
,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用 ,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用
from dw.ods_cost_collection_lc_ac from dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} ${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
GROUP BY organ_code,organ_name GROUP BY organ_code,organ_name
)A )A
@ -1318,8 +1316,7 @@ FROM
, COALESCE(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END), , COALESCE(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),
0) AS ac_total_fee -- 行政成本费用 0) AS ac_total_fee -- 行政成本费用
FROM dw.ods_cost_collection_lc_ac FROM dw.ods_cost_collection_lc_ac
WHERE LEFT(ym, 4) = LEFT('${p_ym}', 4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
GROUP BY organ_code, comm_id, comm_name GROUP BY organ_code, comm_id, comm_name
)A1 )A1
LEFT JOIN LEFT JOIN
@ -1441,8 +1438,7 @@ FROM
, COALESCE(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END), , COALESCE(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),
0) AS ac_total_fee -- 行政成本费用 0) AS ac_total_fee -- 行政成本费用
FROM dw.ods_cost_collection_lc_ac FROM dw.ods_cost_collection_lc_ac
WHERE LEFT(ym, 4) = LEFT('${p_ym}', 4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
GROUP BY organ_code, comm_id, comm_name GROUP BY organ_code, comm_id, comm_name
)A1 )A1
LEFT JOIN LEFT JOIN
@ -1992,8 +1988,7 @@ coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END)
,0 AS lc_fee_rate_target -- 人力成本费率 ,0 AS lc_fee_rate_target -- 人力成本费率
,0 AS ac_fee_rate_target -- 行政成本费率 ,0 AS ac_fee_rate_target -- 行政成本费率
from dw.ods_cost_collection_lc_ac from dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
UNION ALL UNION ALL
SELECT SELECT
0 AS lc_fee_rate 0 AS lc_fee_rate
@ -2031,8 +2026,7 @@ SELECT
,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用 ,coalesce(SUM(CASE WHEN cost_type = '人力成本' THEN actual_amount ELSE 0 END),0) AS lc_total_fee -- 人力成本费用
,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用 ,coalesce(SUM(CASE WHEN cost_type = '行政成本' THEN actual_amount ELSE 0 END),0) AS ac_total_fee -- 行政成本费用
from dw.ods_cost_collection_lc_ac from dw.ods_cost_collection_lc_ac
WHERE left(ym,4) = left('${p_ym}',4) WHERE ym = '${p_ym}'
AND ym <= '${p_ym}'
GROUP BY organ_code GROUP BY organ_code
)A )A
LEFT JOIN LEFT JOIN

View File

@ -205,16 +205,18 @@ SELECT
FROM FROM
( (
SELECT SELECT
organ_code CASE WHEN organ_code = '5501' THEN '0000' ELSE organ_code end AS organ_code
,SUM(index_market_target) AS index_market_target -- 收入目标值 ,SUM(index_market_target) AS index_market_target -- 收入目标值
,SUM(index_income_fact) AS index_income_fact -- 实际收入 ,SUM(index_income_fact) AS index_income_fact -- 实际收入
FROM ods_caiwu_feecollection FROM ods_caiwu_feecollection
WHERE category = '物业' WHERE category = '物业'
AND organ_code not in('5503','5501') AND organ_name <> '佳美物业'
AND organ_code not in('5503')
AND yr_month >= '${p_ym}' AND yr_month >= '${p_ym}'
AND yr_month <= '${p_startym}' AND yr_month <= '${p_startym}'
GROUP BY GROUP BY
organ_code CASE WHEN organ_code = '5501' THEN '0000' ELSE organ_code end
UNION ALL UNION ALL
SELECT SELECT
'0108' AS organ_code '0108' AS organ_code
@ -222,9 +224,10 @@ SELECT
,SUM(index_income_fact) AS index_income_fact -- 实际收入 ,SUM(index_income_fact) AS index_income_fact -- 实际收入
FROM ods_caiwu_feecollection FROM ods_caiwu_feecollection
WHERE category = '物业' WHERE category = '物业'
AND organ_name <> '佳美物业'
AND yr_month >= '${p_ym}' AND yr_month >= '${p_ym}'
AND yr_month <= '${p_startym}' AND yr_month <= '${p_startym}'
AND organ_code in('5503','5501') -- 集团办公区、集团总部片区归到商写片区 AND organ_code in('5503') -- 集团办公区、集团总部片区归到商写片区
)t )t
group by organ_code group by organ_code
)B )B
@ -302,6 +305,7 @@ SELECT
,'' AS organ_name -- erp片区名称 ,'' AS organ_name -- erp片区名称
,'153' AS hr_organ_id -- hr片区编码 ,'153' AS hr_organ_id -- hr片区编码
,'领悦集团总部' AS hr_organ_name -- hr片区名称 ,'领悦集团总部' AS hr_organ_name -- hr片区名称
UNION ALL
)A1 )A1
ON A.organ_code = A1.organ_code ON A.organ_code = A1.organ_code
LEFT JOIN LEFT JOIN
@ -313,16 +317,17 @@ SELECT
FROM FROM
( (
SELECT SELECT
organ_code CASE WHEN organ_code = '5501' THEN '0000' ELSE organ_code end AS organ_code
,SUM(index_market_target) AS index_market_target -- 收入目标值 ,SUM(index_market_target) AS index_market_target -- 收入目标值
,SUM(index_income_fact) AS index_income_fact -- 实际收入 ,SUM(index_income_fact) AS index_income_fact -- 实际收入
FROM ods_caiwu_feecollection FROM ods_caiwu_feecollection
WHERE category = '物业' WHERE category = '物业'
AND organ_code not in('5503','5501') AND organ_name <> '佳美物业'
AND organ_code not in('5503')
AND yr_month >= '${p_ym}' AND yr_month >= '${p_ym}'
AND yr_month <= '${p_startym}' AND yr_month <= '${p_startym}'
GROUP BY GROUP BY
organ_code CASE WHEN organ_code = '5501' THEN '0000' ELSE organ_code end
UNION ALL UNION ALL
SELECT SELECT
'0108' AS organ_code '0108' AS organ_code
@ -330,9 +335,10 @@ SELECT
,SUM(index_income_fact) AS index_income_fact -- 实际收入 ,SUM(index_income_fact) AS index_income_fact -- 实际收入
FROM ods_caiwu_feecollection FROM ods_caiwu_feecollection
WHERE category = '物业' WHERE category = '物业'
AND organ_name <> '佳美物业'
AND yr_month >= '${p_ym}' AND yr_month >= '${p_ym}'
AND yr_month <= '${p_startym}' AND yr_month <= '${p_startym}'
AND organ_code in('5503','5501') -- 集团办公区、集团总部片区归到商写片区 AND organ_code in('5503') -- 集团办公区归到商写片区
)t )t
group by organ_code group by organ_code
)B )B
@ -444,17 +450,18 @@ SELECT
FROM FROM
( (
SELECT SELECT
organ_code CASE WHEN organ_code = '5501' THEN '0000' ELSE organ_code end AS organ_code
,comm_id ,comm_id
,SUM(index_market_target) AS index_market_target -- 收入目标值 ,SUM(index_market_target) AS index_market_target -- 收入目标值
,SUM(index_income_fact) AS index_income_fact -- 实际收入 ,SUM(index_income_fact) AS index_income_fact -- 实际收入
FROM ods_caiwu_feecollection FROM ods_caiwu_feecollection
WHERE category = '物业' WHERE category = '物业'
AND organ_code not in('5503','5501') AND organ_name <> '佳美物业'
AND organ_code not in('5503')
AND yr_month >= '${p_ym}' AND yr_month >= '${p_ym}'
AND yr_month <= '${p_startym}' AND yr_month <= '${p_startym}'
GROUP BY GROUP BY
organ_code,comm_id CASE WHEN organ_code = '5501' THEN '0000' ELSE organ_code end,comm_id
UNION ALL UNION ALL
SELECT SELECT
'0108' AS organ_code -- 商写片区 '0108' AS organ_code -- 商写片区
@ -463,9 +470,10 @@ SELECT
,SUM(index_income_fact) AS index_income_fact -- 实际收入 ,SUM(index_income_fact) AS index_income_fact -- 实际收入
FROM ods_caiwu_feecollection FROM ods_caiwu_feecollection
WHERE category = '物业' WHERE category = '物业'
AND organ_name <> '佳美物业'
AND yr_month >= '${p_ym}' AND yr_month >= '${p_ym}'
AND yr_month <= '${p_startym}' AND yr_month <= '${p_startym}'
AND organ_code in('5503','5501') -- 集团办公区、集团总部片区归到商写片区 AND organ_code in('5503') -- 集团办公区、集团总部片区归到商写片区
)t )t
group by organ_code ,comm_id group by organ_code ,comm_id
)B )B
@ -589,17 +597,18 @@ SELECT
FROM FROM
( (
SELECT SELECT
organ_code CASE WHEN organ_code = '5501' THEN '0000' ELSE organ_code end AS organ_code
,comm_id ,comm_id
,SUM(index_market_target) AS index_market_target -- 收入目标值 ,SUM(index_market_target) AS index_market_target -- 收入目标值
,SUM(index_income_fact) AS index_income_fact -- 实际收入 ,SUM(index_income_fact) AS index_income_fact -- 实际收入
FROM ods_caiwu_feecollection FROM ods_caiwu_feecollection
WHERE category = '物业' WHERE category = '物业'
AND organ_name <> '佳美物业'
AND yr_month >= '${p_ym}' AND yr_month >= '${p_ym}'
AND yr_month <= '${p_startym}' AND yr_month <= '${p_startym}'
AND organ_code not in('5503','5501') AND organ_code not in('5503')
GROUP BY GROUP BY
organ_code,comm_id CASE WHEN organ_code = '5501' THEN '0000' ELSE organ_code end,comm_id
UNION ALL UNION ALL
SELECT SELECT
'0108' AS organ_code -- 商写片区 '0108' AS organ_code -- 商写片区
@ -608,9 +617,10 @@ SELECT
,SUM(index_income_fact) AS index_income_fact -- 实际收入 ,SUM(index_income_fact) AS index_income_fact -- 实际收入
FROM ods_caiwu_feecollection FROM ods_caiwu_feecollection
WHERE category = '物业' WHERE category = '物业'
AND organ_name <> '佳美物业'
AND yr_month >= '${p_ym}' AND yr_month >= '${p_ym}'
AND yr_month <= '${p_startym}' AND yr_month <= '${p_startym}'
AND organ_code in('5503','5501') -- 集团办公区、集团总部片区归到商写片区 AND organ_code in('5503') -- 集团办公区、集团总部片区归到商写片区
)t )t
group by organ_code ,comm_id group by organ_code ,comm_id
)B )B