空间运营出租率明细表+多径回款情况、欠费下钻明细表开发

This commit is contained in:
yangkunan 2024-08-07 18:28:53 +08:00
parent ff32b41897
commit d589dc4829
4 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@ -33,6 +33,8 @@
<file url="file://$PROJECT_DIR$/finereport/xiazuan/3_property/2_报事情况报表.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/finereport/xiazuan/3_property/2_报事情况报表.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/xiazuan/3_property/4_投诉明细.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/finereport/xiazuan/3_property/4_投诉明细.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/xiazuan/4_engine/1_异常抬杆下钻明细.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/finereport/xiazuan/4_engine/1_异常抬杆下钻明细.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/xiazuan/6_innovation/7_空间运营出租率明细.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/xiazuan/6_innovation/9_多径回款情况.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/finereport/xiazuan/6_innovation/新零售订单明细.sql" dialect="MySQL" /> <file url="file://$PROJECT_DIR$/finereport/xiazuan/6_innovation/新零售订单明细.sql" dialect="MySQL" />
<file url="PROJECT" dialect="MySQL" /> <file url="PROJECT" dialect="MySQL" />
</component> </component>

View File

@ -0,0 +1,83 @@
-- 【1_report_空间运营出租率明细】
SELECT
${IF(LEN(p_area)>0,"A.comm_name", "A.organ_name")} AS NAME
,SUM(A.POINT_NUM ) AS POINT_NUM -- 点位数量
,SUM(B.point_num_total ) AS point_num_total-- 总点位数
,SUM(A.IS_ADD ) AS add_point_num -- 新增点位数
,SUM(B.point_num_valid ) AS point_num_valid -- 有效点位数
,SUM(B.point_num_invalid ) AS point_num_invalid -- 无效点位数
,SUM(B.point_num_rent ) AS point_num_rent -- 出租点位数
,SUM(A.Price ) AS Price -- 单价
,CASE WHEN SUM(B.point_num_total ) = 0 THEN 0
ELSE SUM(B.point_num_valid ) / SUM(B.point_num_total ) END AS point_rent_rate -- 考核出租率
FROM
(
SELECT
A2.organ_code AS organ_code -- 片区ID
,A2.organ_name AS organ_name -- 片区名称
,A1.CommID AS CommID -- 项目id
,A2.comm_name AS comm_name -- 项目名称
,A1.IS_ADD AS IS_ADD
,A1.POINT_NUM AS POINT_NUM
,A1.New_Price AS New_Price
,A1.New_Price / A1.POINT_NUM AS Price
FROM
(
SELECT
CommID -- 项目id
,SUM(CASE WHEN PriceUnit like '%月%' THEN IFNULL(Price,0) * 12 ELSE IFNULL(Price,0) END) AS New_Price
,SUM(CASE WHEN AddTime >= DATE_ADD(LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)), INTERVAL 1 DAY) THEN 1
ELSE 0 END) AS IS_ADD
-- ,SUM(CASE WHEN AddTime >= CONCAT('${p_ym}','-01') THEN 1
-- ELSE 0 END) AS IS_ADD
,count(1) AS POINT_NUM -- 点位数量
FROM dw.dim_innoveco_space_point_d -- 创新生态空间点位
GROUP BY
CommID
)A1
LEFT JOIN
(
SELECT
comm_id
,comm_name
,organ_code
,organ_name
FROM dw.dim_organ_mapping
GROUP BY
comm_id
,comm_name
,organ_code
,organ_name
)A2
-- ON A1.OrganCode = A2.organ_code
ON A1.CommID = A2.comm_id
)A
LEFT JOIN
(
SELECT
organ_code -- 片区ID
,organ_name -- 片区名称
,comm_id -- 项目ID
,comm_name -- 项目名称
-- ,usestate -- 项目状态
-- ,point_type -- 点位类型
,SUM(IFNULL(point_num_total ,0)) AS point_num_total -- 总点位数
,SUM(IFNULL(point_num_ismustdo ,0)) AS point_num_ismustdo -- 必做点位数
,SUM(IFNULL(point_num_zengzhi ,0)) AS point_num_zengzhi -- 增值点位数
,SUM(IFNULL(point_num_valid ,0)) AS point_num_valid -- 有效点位数
,SUM(IFNULL(point_num_invalid ,0)) AS point_num_invalid -- 无效点位数
,SUM(IF(usestate='使用',IFNULL(point_num_total,0),0)) AS point_num_rent -- 出租点位数
FROM dw.dws_innoveco_point_summary -- 有效点位
GROUP BY
organ_code -- 片区ID
,organ_name -- 片区名称
,comm_id -- 项目ID
,comm_name -- 项目名称
)B
ON A.CommID = B.comm_id
AND A.organ_code = B.organ_code
WHERE B.comm_id IS NOT NULL
${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${if(left(fine_role,2)=="项目","and A.comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
GROUP BY
${IF(LEN(p_area)>0,"A.comm_name", "A.organ_name")}

View File

@ -0,0 +1,95 @@
-- 【1_report_多径回款情况】
SELECT
business_code -- 业务域code
,organ_code -- erp片区code
,organ_name -- erp片区名称
,comm_id -- 项目id
,comm_name -- 项目名称
,index_type -- 多经类别(社商/ 新零售、美居、附属资源/ 空间运营、资产运营/ 资产租售)
,index_receivable -- 应收值
,index_receipts -- 实收值
,index_not_receipts -- 未回款数
,collection_rate -- 回款率
FROM dw.ods_caiwu_profit
WHERE (index_receivable <> 0 OR index_receipts <> 0 OR index_not_receipts <> 0)
AND `year_month` = '${REPLACE(p_ym,"-","")}'
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${if(left(fine_role,2)=="项目","and comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
${IF(LEN(p_type)>0," AND index_type IN ('"+JOINARRAY(p_type,"','")+"')", "")}
-- 【2_业务条线】
SELECT
DISTINCT
index_type
FROM dw.ods_caiwu_profit
;
-- 【1_report_欠费下钻明细】
SELECT
A.OrganCode AS OrganCode -- 片区编码
,A.OrganName AS OrganName -- 片区名称
,A.CommID AS CommID -- 项目id
,A.CommName AS CommName -- 项目名称
,A.CustName AS CustName -- 客户姓名 商户
,SUM(A.recev_amount) AS recev_amount-- 应收金额
,A.AccountsDueDate AS AccountsDueDate -- 应收日期
,SUM(A.paid_amount) AS paid_amount -- 实收金额 回款金额
,SUM(A.recev_amount) - SUM(A.paid_amount) AS Arrears_amount -- 欠费金额
,IF(SUM(A.recev_amount) = 0,0,SUM(A.paid_amount) /SUM(A.recev_amount)) AS PAID_AMOUNT_RATE
FROM
(
SELECT
OrganCode -- 片区编码
,OrganName -- 片区名称
,CommID -- 项目id
,CommName -- 项目名称
,CustName -- 客户姓名 商户
,SUBSTR(AccountsDueDate,1,10) AS AccountsDueDate -- 应收日期
,CorpCostID
,CASE WHEN BussType IN('新增','删除') THEN DealAmount ELSE 0 END AS recev_amount -- 应收金额
,CASE WHEN BussType IN('实收','撤销实收') THEN DealAmount ELSE 0 END AS paid_amount -- 实收金额
FROM dw.ods_erp_tb_hspr_feesserial_${p_comm_id}_d
WHERE left(AccountsDueDate,7) = '${p_ym}'
${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")}
${if(left(fine_role,2)=="项目","and comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")}
)A
JOIN
(
SELECT
a.CorpCostID
,a.CostName
FROM
(
select
CorpCostID
,CostCode
,CostName
from dw.dim_corp_cost_item_d -- 总部费用科目
where length(CostCode) != 4
) a
left join
(
select
CorpCostID
,CostCode
from dim_corp_cost_item_d
where length(CostCode) = 4
) b
on left(a.CostCode,4) = b.CostCode
where b.CostCode = '0007'
)B
ON A.CorpCostID = B.CorpCostID
GROUP BY
A.OrganCode
,A.OrganName
,A.CommID
,A.CommName
,A.CustName
,A.AccountsDueDate