From 20d271a1678c7bee469dd86699727ac65d20bcf1 Mon Sep 17 00:00:00 2001 From: yangkunan Date: Tue, 6 Aug 2024 17:45:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E6=96=B0=E7=94=9F=E6=80=81=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E7=9C=8B=E6=9D=BF=E6=95=B0=E6=8D=AE=E5=AF=B9?= =?UTF-8?q?=E9=BD=90+=E5=BE=A1=E5=92=8C=E6=B3=B0=E9=94=80=E5=94=AE?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E6=98=8E=E7=BB=86=E3=80=81=E6=96=B0=E9=9B=B6?= =?UTF-8?q?=E5=94=AE=E8=AE=A2=E5=8D=95=E6=98=8E=E7=BB=86=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/sqldialects.xml | 2 + finereport/kanban/mobile/创新生态_mobile.sql | 267 +++++++++++++++++- .../6_innovation/御和泰销售预警明细.sql | 63 +++++ .../xiazuan/6_innovation/新零售订单明细.sql | 65 +++++ 4 files changed, 396 insertions(+), 1 deletion(-) create mode 100644 finereport/xiazuan/6_innovation/御和泰销售预警明细.sql create mode 100644 finereport/xiazuan/6_innovation/新零售订单明细.sql diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml index f5426ad..ca23ea7 100644 --- a/.idea/sqldialects.xml +++ b/.idea/sqldialects.xml @@ -12,6 +12,7 @@ + @@ -32,6 +33,7 @@ + \ No newline at end of file diff --git a/finereport/kanban/mobile/创新生态_mobile.sql b/finereport/kanban/mobile/创新生态_mobile.sql index 27c1191..6c5c79e 100644 --- a/finereport/kanban/mobile/创新生态_mobile.sql +++ b/finereport/kanban/mobile/创新生态_mobile.sql @@ -188,4 +188,269 @@ FROM T1 SELECT CONCAT(assessment_occupany_rate,'%') AS 完成率 FROM dws_point_occupancy_rate_summary_all -WHERE ym = '${REPLACE(p_ym,"-","")}' \ No newline at end of file +WHERE ym = '${REPLACE(p_ym,"-","")}' + + + + +-- ====================================== +-- report_1_空间运营_new +-- ====================================== + +SELECT + organ_name + ,assessment_occupany_rate AS 出租率 + ,total_occupany_rate + ,ROW_NUMBER() OVER (ORDER BY assessment_occupany_rate ${IF(p_kj = "低于50%","ASC","DESC")}) AS 序号 + +FROM + ( + SELECT + + ${IF(LEN(p_area)>0,"comm_name", "organ_name")} AS organ_name + ,assessment_occupany_rate AS assessment_occupany_rate + ,total_occupany_rate as total_occupany_rate + FROM dw.dws_point_occupancy_rate_summary_project + WHERE 1=1 + AND assessment_occupany_rate IS NOT NULL + AND ym = DATE_FORMAT(CURDATE(),'%Y%m') + ${IF(LEN(p_area)>0," AND organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} + ${if(left(fine_role,2)=="项目","and comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")} + )T +ORDER BY assessment_occupany_rate ${IF(p_kj = "低于50%","ASC","DESC")} +LIMIT 5 + + + +-- ====================================== +-- 新零售 +-- ====================================== + +SELECT + T1.organ_comm_name AS organ_name + ,T1.FINISH_RATE AS 销售完成率 + ,T1.sale_target / 10000 AS sale_target + ,T1.sale_amt / 10000 AS sale_amt + ,ROW_NUMBER() OVER (ORDER BY T1.FINISH_RATE ${IF(p_xls = "低于50%","ASC","DESC")}) AS 序号 +FROM + ( + SELECT +-- B.organ_code +-- ,B.organ_name +-- ,B.comm_id +-- ,B.comm_name + ${IF(LEN(p_area)>0,"B.comm_name", "B.organ_name")} AS organ_comm_name +-- ,SUM(B.sale_target) AS sale_target + ,SUM(IFNULL(A.sale_amt,0)) + SUM(IFNULL(B.sale_fact,0)) AS sale_amt + ,SUM(IFNULL(B.sale_target,0)) AS sale_target + ,CASE WHEN SUM(IFNULL(B.sale_target,0)) = 0 THEN 0 + ELSE SUM(IFNULL(A.sale_amt,0)) + SUM(IFNULL(B.sale_fact,0)) / SUM(IFNULL + (B.sale_target,0)) + END AS FINISH_RATE -- 销售完成率 + FROM + ( + select + organ_code + ,organ_name + ,comm_id + ,comm_name + ,sum(case when create_ym = '202406' then 0 else sale_amt end) sale_amt -- 202406填报数据为线下+线下,所以不取线上数据 + from dw.dws_innoveco_new_retail_m + where create_ym = '${REPLACE(p_ym,"-","")}' + group by + organ_code + ,organ_name + ,comm_id + ,comm_name + )A + RIGHT JOIN + ( + SELECT + organ_code + ,organ_name + ,comm_id + ,comm_name + ,SUM(IFNULL(index_retail_target,0))*10000 AS sale_target + ,SUM(index_retail_fact)*10000 AS sale_fact + FROM dw.ods_innoveco_offlinesales + WHERE `year_month` = '${REPLACE(p_ym,"-","")}' + GROUP BY + organ_code + ,organ_name + ,comm_id + ,comm_name + )B + ON A.organ_code = B.organ_code + AND A.comm_id = B.comm_id + WHERE 1=1 + ${IF(LEN(p_area)>0," AND B.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} + ${if(left(fine_role,2)=="项目","and B.comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")} + GROUP BY + ${IF(LEN(p_area)>0,"B.comm_name", "B.organ_name")} + )T1 +ORDER BY T1.FINISH_RATE ${IF(p_xls = "低于50%","ASC","DESC")} +LIMIT 5 + + +-- ====================================== +-- 小悦到家 +-- ====================================== +SELECT + T1.organ_comm_name AS organ_name + ,T1.FINISH_RATE AS 销售完成率 + ,T1.sale_target AS sale_target + ,T1.sale_amt AS sale_amt + ,ROW_NUMBER() OVER (ORDER BY T1.FINISH_RATE ${IF(p_xydj = "低于50%","ASC","DESC")}) AS 序号 +FROM + ( + SELECT + ${IF(LEN(p_area)>0,"A.comm_name", "A.organ_name")} AS organ_comm_name + ,SUM(B.sale_target) AS sale_target + ,SUM(A.sale_amt) + SUM(B.sale_fact) AS sale_amt + ,CASE WHEN SUM(B.sale_target) = 0 THEN 0 + ELSE IFNULL((SUM(A.sale_amt) + SUM(B.sale_fact)) / SUM(B.sale_target),0) END AS FINISH_RATE + FROM + ( + select + organ_code + ,organ_name + ,comm_id + ,comm_name + ,sum(case when create_ym = '202406' then 0 else xydj_amt end) sale_amt -- 202406填报数据为线下+线下,所以不取线上数据 + from dws_innoveco_new_retail_m + where create_ym = '${REPLACE(p_ym,"-","")}' + group by + organ_code + ,organ_name + ,comm_id + ,comm_name + )A + LEFT JOIN + ( + SELECT + organ_code + ,organ_name + ,comm_id + ,comm_name + ,SUM(IFNULL(index_xiaoyuedj_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 + ,comm_id + ,comm_name + )B + ON A.organ_code = B.organ_code + AND A.comm_id = B.comm_id + WHERE 1=1 + ${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} + ${if(left(fine_role,2)=="项目","and B.comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")} + GROUP BY + ${IF(LEN(p_area)>0,"A.comm_name", "A.organ_name")} + )T1 +ORDER BY T1.FINISH_RATE ${IF(p_xydj = "低于50%","ASC","DESC")} +LIMIT 5 +; + +-- ====================================== +-- 御和泰 +-- ====================================== +SELECT + T1.organ_comm_name AS organ_name + ,T1.FINISH_RATE AS 销售完成率 + ,T1.sale_target / 10000 AS sale_target + ,T1.sale_amt / 10000 AS sale_amt + ,ROW_NUMBER() OVER (ORDER BY T1.FINISH_RATE ${IF(p_yht = "低于50%","ASC","DESC")}) AS 序号 +FROM + ( + SELECT + + ${IF(LEN(p_area)>0,"A.comm_name", "A.organ_name")} AS organ_comm_name + ,SUM(B.sale_target) AS sale_target + ,IFNULL(SUM(A.sale_amt) + SUM(B.sale_fact),0) AS sale_amt + ,CASE WHEN SUM(B.sale_target) = 0 THEN 0 + ELSE IFNULL(SUM(A.sale_amt) + SUM(B.sale_fact),0) / SUM(B.sale_target) END AS FINISH_RATE + FROM + ( + select + organ_code + ,organ_name + ,comm_id + ,comm_name + ,sum(case when create_ym = '202406' then 0 else yht_amt end) sale_amt -- 202406填报数据为线下+线下,所以不取线上数据 + from dws_innoveco_new_retail_m + where create_ym = '${REPLACE(p_ym,"-","")}' + group by + organ_code + ,organ_name + ,comm_id + ,comm_name + )A + LEFT JOIN + ( + SELECT + organ_code + ,organ_name + ,comm_id + ,comm_name + ,SUM(IFNULL(index_yuhetai_target,0))*10000 AS sale_target + ,SUM(index_yuhetai_fact)*10000 AS sale_fact + FROM ods_innoveco_offlinesales + WHERE `year_month` = '${REPLACE(p_ym,"-","")}' + GROUP BY + organ_code + ,organ_name + ,comm_id + ,comm_name + )B + ON A.organ_code = B.organ_code + AND A.comm_id = B.comm_id + WHERE 1=1 + ${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} + ${if(left(fine_role,2)=="项目","and B.comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")} + GROUP BY + ${IF(LEN(p_area)>0,"A.comm_name", "A.organ_name")} + )T1 +ORDER BY T1.FINISH_RATE ${IF(p_yht = "低于50%","ASC","DESC")} +LIMIT 5 + + + +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 销售完成率 ${IF(p_yht = "低于50%","ASC","DESC")}) 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")} \ No newline at end of file diff --git a/finereport/xiazuan/6_innovation/御和泰销售预警明细.sql b/finereport/xiazuan/6_innovation/御和泰销售预警明细.sql new file mode 100644 index 0000000..8e0c5ea --- /dev/null +++ b/finereport/xiazuan/6_innovation/御和泰销售预警明细.sql @@ -0,0 +1,63 @@ +-- 【1_report_御和泰销售情况】 + + +SELECT + T1.organ_name AS ORGAN_NAME + ,T1.comm_name AS COMM_NAME + ,T1.FINISH_RATE AS FINISH_RATE + ,T1.sale_target AS SALE_TARGET + ,T1.sale_amt AS SALE_AMT + ,ROW_NUMBER() OVER (ORDER BY T1.FINISH_RATE DESC) AS RK +FROM + ( + SELECT + + A.comm_name + ,A.organ_name + ,SUM(B.sale_target) AS sale_target + ,IFNULL(SUM(A.sale_amt) + SUM(B.sale_fact),0) AS sale_amt + ,CASE WHEN SUM(B.sale_target) = 0 THEN 0 + ELSE IFNULL(SUM(A.sale_amt) + SUM(B.sale_fact),0) / SUM(B.sale_target) END AS FINISH_RATE + FROM + ( + select + organ_code + ,organ_name + ,comm_id + ,comm_name + ,sum(case when create_ym = '202406' then 0 else yht_amt end) sale_amt -- 202406填报数据为线下+线下,所以不取线上数据 + from dw.dws_innoveco_new_retail_m -- 新零售月汇总 + where create_ym = '${REPLACE(p_ym,"-","")}' + group by + organ_code + ,organ_name + ,comm_id + ,comm_name + )A + LEFT JOIN + ( + SELECT + organ_code + ,organ_name + ,comm_id + ,comm_name + ,SUM(IFNULL(index_yuhetai_target,0))*10000 AS sale_target + ,SUM(index_yuhetai_fact)*10000 AS sale_fact + FROM dw.ods_innoveco_offlinesales + WHERE `year_month` = '${REPLACE(p_ym,"-","")}' + GROUP BY + organ_code + ,organ_name + ,comm_id + ,comm_name + )B + ON A.organ_code = B.organ_code + AND A.comm_id = B.comm_id + WHERE 1=1 + ${IF(LEN(p_area)>0," AND A.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} + ${if(left(fine_role,2)=="项目","and B.comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")} + GROUP BY + A.comm_name + ,A.organ_name + )T1 + diff --git a/finereport/xiazuan/6_innovation/新零售订单明细.sql b/finereport/xiazuan/6_innovation/新零售订单明细.sql new file mode 100644 index 0000000..c3d5fcd --- /dev/null +++ b/finereport/xiazuan/6_innovation/新零售订单明细.sql @@ -0,0 +1,65 @@ +-- ====================================== +-- 1_report_新零售订单明细 +-- ====================================== + +SELECT + T3.organ_code AS organ_code + ,T3.organ_name AS organ_name + ,T3.comm_id AS comm_id + ,T3.comm_name AS comm_name + ,T2.categoryLevel1 AS categoryLevel1-- 品类名称 + ,T2.goodsTitle AS goodsTitle -- 商品名称 + ,substr(T1.createTime,1,10) AS createTime -- 创建时间 + ,COUNT(T1.orderNo) AS orderNum -- 订单数量 + ,SUM(IFNULL(T1.salePrice,0)) - SUM(IFNULL(T1.refundCash,0)) AS AMOUNT-- 金额 + ,ROW_NUMBER() over (ORDER BY COUNT(T1.orderNo)) AS RK +FROM +( + SELECT + orderNo -- 订单号 + ,vid + ,vidName -- 项目名称 + ,salePrice -- 销售价格 + ,refundCash -- 退款金额 + ,createTime -- 创建时间 + FROM dw.dwd_innoveco_order_info_d -- 订单信息 + WHERE 1=1 + ${IF(LEN(p_startdate)>0,"AND createTime LIKE '"+FORMAT(p_startdate,"yyyy-MM")+"%'","")} + +)T1 +LEFT JOIN +( + SELECT + categoryLevel1 -- 品类名称 + ,skuNum -- 商品数量 + ,orderNo -- 订单号 + ,goodsTitle -- 商品名称 + FROM dw.dwd_innoveco_order_item_d -- 订单项信息 +)T2 +ON T1.orderNo = T2.orderNo +RIGHT JOIN +( + SELECT + -- DISTINCT + organ_code + , organ_name + , comm_id + , comm_name + , weim_comm_id + FROM dw.dim_organ_mapping +)T3 +ON T1.vid = T3.weim_comm_id +WHERE T3.comm_id IS NOT NULL +AND T1.createTime is not null +${IF(LEN(p_cate)>0," AND T2.categoryLevel1 IN ('"+JOINARRAY(p_cate,"','")+"')", "")} +${IF(LEN(p_good)>0," AND T2.goodsTitle IN ('"+JOINARRAY(p_good,"','")+"')", "")} +${IF(LEN(p_area)>0," AND T3.organ_code IN ('"+JOINARRAY(p_area,"','")+"')", "")} +${if(left(fine_role,2)=="项目","and T3.comm_name = '"+GETUSERDEPARTMENTS(3)+"'","")} +GROUP BY +T3.organ_code +,T3.organ_name +,T3.comm_id +,T3.comm_name +,T2.categoryLevel1 +,T2.goodsTitle +,substr(T1.createTime,1,10)