From c1f3a64b358649a0d3df6fc7d7d82a8134354279 Mon Sep 17 00:00:00 2001 From: yangkunan Date: Sun, 21 Sep 2025 22:00:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B5=84=E9=87=91=E4=BD=99?= =?UTF-8?q?=E9=A2=9D=E7=9B=B8=E5=85=B3=E5=8F=96=E6=95=B0+=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=94=B6=E5=85=A5=E6=94=AF=E5=87=BA=E6=9D=A1=E5=BD=A2?= =?UTF-8?q?=E5=9B=BE=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FineReport/财务主题/看板/资金管理驾驶舱.sql | 75 ++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/FineReport/财务主题/看板/资金管理驾驶舱.sql b/FineReport/财务主题/看板/资金管理驾驶舱.sql index a3c7458..b032164 100644 --- a/FineReport/财务主题/看板/资金管理驾驶舱.sql +++ b/FineReport/财务主题/看板/资金管理驾驶舱.sql @@ -2264,6 +2264,7 @@ FROM tmp2 T WHERE 1=1 ${if(sIncome_ly=0,"","and A.stat_type = '收入'")} ${if(isnull(sIncome_detail),"","and A.plan_item_class = '"+sIncome_detail+"'")} +ORDER BY A.stat_type,A.收入执行 ; @@ -2533,7 +2534,7 @@ FROM WHERE 1=1 ${if(sIncome_ly1=0,"","and A.stat_type = '支出'")} ${if(isnull(sIncome_detail1),"","and A.plan_item_class = '"+sIncome_detail1+"'")} - +ORDER BY A.支出执行 desc ; @@ -2779,7 +2780,7 @@ SELECT ,SUM(CASE WHEN A.subject_type in('受限资金') THEN A.yb_balance ELSE 0 END) AS limt_amt -- 受限资金 FROM base_calc A --- 同比 +-- 同期 with dba as ( select decode(length(accountnumber), '17', substring(accountnumber, 3), @@ -3033,6 +3034,71 @@ SELECT FROM base_calc A ; +-- 本年累计期初余额 +with dba as ( + select decode(length(accountnumber), '17', + substring(accountnumber, 3), + accountnumber) as accountnumber, + max(category_name) as category_name + + from dwr.dim_bank_account + where account_owner_class='langjiu' + group by decode(length(accountnumber), '17', + substring(accountnumber, 3), + accountnumber) +), + base_calc AS( + SELECT CASE + WHEN decode(a.is_usable,1,0,1)= 0 AND a.amt_type = '现金' AND a.corp_code <> '0223' + THEN '其中:可用存款' + WHEN a.amt_type = '票据' + THEN '银行承兑汇票' + WHEN a.amt_type = '现金' AND a.corp_code = '0223' + THEN '香港公司账户资金' + WHEN decode(a.is_usable,1,0,1) = 1 AND a.amt_type = '现金' AND a.corp_code <> '0223' + THEN '受限资金' + END AS subject_type + ,sum(a.amt)/10000 as yb_balance + + -- decode(a.is_usable,1,0,1) as is_limit--受限资金金额 +from dm.dm_fim_fud_balance a + inner join dwr.dim_corp c on a.corp_code=c.corp_code and c.corp_group='股份' +/*left join dba on decode(length(a.owner_bank_account), 17, + substring(a.owner_bank_account, 3), + a.owner_bank_account)=dba.accountnumber*/ +where a.stat_date=date'${CONCATENATE(year(sStart_date)-1,"-12-01")}' + and a.amt!=0 + ${IF(LEN(sCorp)!=0," AND a.corp_code IN ('"+ sCorp +"')", "")} + ${if(year(sStart_date)>=2025,"and a.owner_bank_account!='其他货币资金微信'","")} +and exists ( + select + 1 + from + dm.dm_bi_user_permisson + where + bi_user = '${fine_username}' + and per_model IN ('all','fim') + and ( + is_all = 1 + ) +) +group by CASE + WHEN decode(a.is_usable,1,0,1)= 0 AND a.amt_type = '现金' AND a.corp_code <> '0223' + THEN '其中:可用存款' + WHEN a.amt_type = '票据' + THEN '银行承兑汇票' + WHEN a.amt_type = '现金' AND a.corp_code = '0223' + THEN '香港公司账户资金' + WHEN decode(a.is_usable,1,0,1) = 1 AND a.amt_type = '现金' AND a.corp_code <> '0223' + THEN '受限资金' + END + ) +SELECT + SUM(CASE WHEN A.subject_type in('其中:可用存款','香港公司账户资金') THEN A.yb_balance ELSE 0 END) AS bank_amt -- 银行存款 + ,SUM(CASE WHEN A.subject_type in('银行承兑汇票') THEN A.yb_balance ELSE 0 END) AS bill_amt -- 票据 + ,SUM(CASE WHEN A.subject_type in('受限资金') THEN A.yb_balance ELSE 0 END) AS limt_amt -- 受限资金 +FROM base_calc A +; -- 资金分析-银行明细 @@ -3584,4 +3650,9 @@ FROM where dk.this_amt is not null GROUP BY occupy_credit_quota_type +ORDER BY CASE WHEN dk.occupy_credit_quota_type = '1年期贷款' THEN 2 + WHEN dk.occupy_credit_quota_type = '1-3年期贷款' THEN 3 + WHEN dk.occupy_credit_quota_type = '3-5年期贷款' THEN 4 + WHEN dk.occupy_credit_quota_type = '技改项目贷款(2030年到期)' THEN 1 + ELSE 99 END ; \ No newline at end of file