diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml
index ca23ea7..2ae5611 100644
--- a/.idea/sqldialects.xml
+++ b/.idea/sqldialects.xml
@@ -27,12 +27,15 @@
+
+
+
diff --git a/finereport/tianbao/EARLY_WARNING/看板数据预警-项目维度.sql b/finereport/tianbao/EARLY_WARNING/看板数据预警-项目维度.sql
new file mode 100644
index 0000000..09b8c01
--- /dev/null
+++ b/finereport/tianbao/EARLY_WARNING/看板数据预警-项目维度.sql
@@ -0,0 +1,236 @@
+-- *****************************
+-- 创建人员: 杨坤安
+-- 创建时间: 2024-08-08
+-- 功能描述: 看板数据预警-项目维度
+-- *****************************
+
+
+-- -------------------------------
+-- 财务
+-- -------------------------------
+
+
+
+
+-- -------------------------------
+-- 运营
+-- -------------------------------
+
+SELECT
+'运营' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'接房率低于80%的项目' AS INDICATOR_TYPE -- 指标类型
+,accept_num / room_num AS ACCEPT_NUM_RATE -- 接房率
+FROM dw.dws_operation_room_park_info_d
+where accept_num / room_num < 0.8
+and comm_name not like '%案场%' and comm_name not like '%撤%'
+UNION ALL
+SELECT
+'运营' AS BUSINESS_TYPE -- 业务类型
+,c.organ_name AS ORGAN_NAME -- 片区名称
+,c.comm_name AS COMM_NAME -- 项目名称
+,'计划即将到期项目' AS INDICATOR_TYPE -- 指标类型
+,count(1) AS PLAN_NUM -- 计划即将到期数量
+FROM
+(
+ SELECT
+ a.plan_level,
+ jt.responsible_person1 ,
+ a.id,
+ a.plan_status,
+ a.input_date,
+ a.end_date
+ FROM dwd_operations_plan_info_d a,
+ JSON_TABLE
+ (
+ cast( CONCAT( '["', REPLACE ( responsible_person1, ',', '","' ), '"]' ) AS json ),
+ "$[*]" COLUMNS ( responsible_person1 INT PATH "$" )
+ ) AS jt
+ where a.end_date > date_format(CURDATE() - INTERVAL 3 day,'%Y-%m-%d')
+ and a.end_date <= date_format(CURDATE(),'%Y-%m-%d')
+) a
+left join dw.ods_oa_hrmresource_d b
+on a.responsible_person1 = b.id
+left join
+(
+ select
+ distinct organ_code
+ ,organ_name
+ ,comm_id
+ ,comm_name
+ ,oa_comm_id
+ from dim_organ_mapping where comm_id is not null
+)c
+on b.subcompanyid1 = c.oa_comm_id
+GROUP BY c.organ_name, c.comm_name
+UNION ALL
+select
+'运营' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'权责亏损项目-填报' AS INDICATOR_TYPE -- 指标类型
+,count(1) AS PROJECT_NUM -- 权责亏损项目数
+from ods_caiwu_feecollection
+where yr_month = '2024-06'
+and category = '物业'
+and index_profit_fact < 0
+GROUP BY organ_name, comm_name
+UNION ALL
+-- -------------------------------
+-- 物业
+-- -------------------------------
+select
+'物业' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'物业费实收总额(万元)' AS INDICATOR_TYPE -- 指标类型
+,sum(ifnull(pr_paid_cu_amt,0) + ifnull(cu_paid_cu_amt,0) - ifnull(pr_offset_cu_amt,0) - ifnull(cu_offset_cu_amt,0)- ifnull(cu_offset_pr_amt,0) - ifnull(cu_paid_pr_amt,0))/10000 paid_amt
+from dw.dwd_finance_fees_serial_d
+where ParentCostCode = '0001' and left(ym,7) = left(CURRENT_DATE(),7) -- 当前月
+and organ_name not in ('东湖商管','领悦总部','演示机构')
+GROUP BY organ_name, comm_name
+UNION ALL
+select
+'物业' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'物业费收缴率' AS INDICATOR_TYPE -- 指标类型
+,sum(ifnull(pr_paid_cu_amt,0) + ifnull(cu_paid_cu_amt,0) - ifnull(pr_offset_cu_amt,0) - ifnull(cu_offset_cu_amt,0)+(- ifnull(cu_paid_pr_amt,0) - ifnull(cu_offset_pr_amt,0))) / sum(ifnull(cu_receivable_amt,0) + ifnull(pr_exempt_cu_amt,0) + ifnull(cu_exempt_cu_amt,0)+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)) collection_rate
+from dwd_finance_fees_serial_d
+where ParentCostCode = '0001'
+AND left(ym,7) = left(CURRENT_DATE(),7) -- 当前月
+GROUP BY organ_name, comm_name
+UNION ALL
+-- TODO
+SELECT
+'物业' AS BUSINESS_TYPE -- 业务类型
+,'' AS ORGAN_NAME -- 片区名称
+,'' AS COMM_NAME -- 项目名称
+,'案场服务费当期收缴率' AS INDICATOR_TYPE -- 指标类型
+,0 AS VALUE
+FROM dual
+UNION ALL
+SELECT
+'物业' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'投诉关闭率' AS INDICATOR_TYPE -- 指标类型
+, sum(tousu_close_incident_num) / sum(tousu_incident_num) AS tousu_close_rate
+FROM dws_estate_incident_info_m
+where incident_ym = replace(left(CURRENT_DATE(),7),'-','')
+group BY organ_name, comm_name
+UNION ALL
+SELECT
+'物业' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'报事关闭率' AS INDICATOR_TYPE -- 指标类型
+, sum(completed_incident_num - completed_not_close_incident_num) / sum(incident_num) AS close_rate
+FROM dws_estate_incident_info_m
+where incident_ym = replace(left(CURRENT_DATE(),7),'-','')
+group BY organ_name, comm_name
+UNION ALL
+
+-- -------------------------------
+-- 工程
+-- -------------------------------
+
+SELECT
+'工程' AS BUSINESS_TYPE -- 业务类型
+ ,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'水电收缴率' AS INDICATOR_TYPE -- 指标类型
+,sum((ifnull(pr_paid_cu_amt,0) + ifnull(cu_paid_cu_amt,0) - ifnull(pr_offset_cu_amt,0) - ifnull(cu_offset_cu_amt,0))+(- ifnull(cu_paid_pr_amt,0) - ifnull(cu_offset_pr_amt,0))) / sum((ifnull(cu_receivable_amt,0) + ifnull(pr_exempt_cu_amt,0) + ifnull(cu_exempt_cu_amt,0))+(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))) collection_rate
+from dwd_finance_fees_serial_d
+where ParentCostCode = '0008' and MiddleCostCode in ('00080001','00080002','00080003','00080004','00080005','00080006','00080007','00080008','00080017','00080018','00080019','00080022','00080023','00080024','00080027','00080028','00080032','00080035')
+and ym = left(CURRENT_DATE(),7)
+GROUP BY organ_name, comm_name
+UNION ALL
+SELECT
+'工程' AS BUSINESS_TYPE -- 业务类型
+,a.organ_name AS ORGAN_NAME -- 片区名称
+,a.comm_name AS COMM_NAME -- 项目名称
+,'停车场启费率-无法计算项目收缴率' AS INDICATOR_TYPE -- 指标类型
+,SUM(case when qifei_cost_num > 0 then 1 else 0 end) / sum(CNT) AS qifei_rate
+from
+(
+ select
+ a.organ_name
+ ,a.comm_name
+ ,sum(case when (ifnull(pr_paid_cu_amt,0) + ifnull(cu_paid_cu_amt,0) + ifnull(pr_exempt_cu_amt,0) + ifnull(cu_exempt_cu_amt,0)) + (ifnull(cu_receivable_amt,0) + ifnull(pr_exempt_cu_amt,0) + ifnull(cu_exempt_cu_amt,0)) + (- ifnull(cu_paid_pr_amt,0) + ifnull(cu_offset_pr_amt,0)) + (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)) !=0 then 1 else 0 end) qifei_cost_num
+ ,count(1) over() AS CNT
+ from
+ (
+ select
+ distinct
+ organ_code
+ ,organ_name
+ ,comm_id
+ ,comm_name
+ from dim_organ_mapping
+ where comm_id is not null and comm_name not like '%撤场%' and comm_name not like '%案场%' and comm_name not like '%禁用%' and length(comm_id) != 0
+ )a
+ left join
+ (
+ select
+ *
+ from dwd_finance_fees_serial_d
+ where MiddleCostCode in ('00010003','00030001','00030002','00030003','00030004','00030005','00030006','00030007','00030008','00030009','00030010')
+ and ym = left(CURRENT_DATE(),7)
+ )b
+ on a.comm_id = b.commid
+ group by a.organ_name, a.comm_name
+)a
+GROUP BY a.organ_name, a.comm_name
+UNION ALL
+SELECT
+'工程' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'设备设施完好率' AS INDICATOR_TYPE -- 指标类型
+,CASE WHEN sum(equipment_num) = 0 THEN 0
+ else sum(good_equipment_num) / sum(equipment_num) END AS good_rate
+FROM dws_engine_equipment_in_good_d
+GROUP BY organ_name, comm_name
+UNION ALL
+SELECT
+'工程' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'设备空间巡查完成率' AS INDICATOR_TYPE -- 指标类型
+,CASE WHEN SUM(task_num) = 0 THEN 0 ELSE SUM(task_finish_num) / SUM(task_num) END AS FINISH_RATE
+FROM dws_engine_equipment_inspect_task_m
+where task_ym = replace(left(CURRENT_DATE(),7),'-','')
+GROUP BY organ_name, comm_name
+UNION ALL
+SELECT
+'工程' AS BUSINESS_TYPE -- 业务类型
+,organ_name AS ORGAN_NAME -- 片区名称
+,comm_name AS COMM_NAME -- 项目名称
+,'异常抬杆比例' AS INDICATOR_TYPE -- 指标类型
+,CASE WHEN SUM(carflow) = 0 THEN 0 ELSE SUM(manualOutNum) / SUM(carflow) END AS 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_name, comm_name
+
+-- -------------------------------
+-- 创新 => 没有项目
+-- -------------------------------
+
+
+
+
+UNION ALL
+-- -------------------------------
+-- 商业
+-- -------------------------------
+
+
+
+
+
+-- -------------------------------
+-- 法务
+-- -------------------------------
+
diff --git a/finereport/xiazuan/3_property/4_投诉明细.sql b/finereport/xiazuan/3_property/4_投诉明细.sql
index 54c13ec..374911f 100644
--- a/finereport/xiazuan/3_property/4_投诉明细.sql
+++ b/finereport/xiazuan/3_property/4_投诉明细.sql
@@ -16,6 +16,7 @@ FROM
,SUM(IFNULL(tousu_incident_num,0)) AS tousu_incident_num -- 投诉量
FROM dw.dws_estate_incident_info_m
where incident_ym = '${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)+"'","")}
GROUP BY
organ_code
diff --git a/finereport/xiazuan/6_innovation/7_空间运营出租率明细.sql b/finereport/xiazuan/6_innovation/7_空间运营出租率明细.sql
new file mode 100644
index 0000000..4197d10
--- /dev/null
+++ b/finereport/xiazuan/6_innovation/7_空间运营出租率明细.sql
@@ -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")}
\ No newline at end of file
diff --git a/finereport/xiazuan/6_innovation/9_多径回款情况.sql b/finereport/xiazuan/6_innovation/9_多径回款情况.sql
new file mode 100644
index 0000000..bbb8066
--- /dev/null
+++ b/finereport/xiazuan/6_innovation/9_多径回款情况.sql
@@ -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
+
+
+
+