From abf3a061b99999ba3cfcf3268396a77e015a2bbd Mon Sep 17 00:00:00 2001 From: yangkunan Date: Sun, 17 Nov 2024 22:55:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A2=E5=8A=A1=E8=B4=B9=E7=94=A8=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E5=8F=82=E6=95=B0=E5=90=8D=E7=A7=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?+BI=E6=8A=A5=E8=A1=A8=E6=95=B0=E6=8D=AE=E9=9B=86=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BI/销售业绩/电商销售订单.sql | 32 ++++++++++-- BI/销售业绩/经销商出货.sql | 50 ++++++++++++++---- BI/销售业绩/销售发货明细.sql | 29 +++++++++-- .../财务主题/报表/费用/1_1_1OA表单下钻.sql | 16 ++++-- .../财务主题/报表/费用/1_1财务凭证下钻.sql | 52 ++++++++++++++++--- 5 files changed, 147 insertions(+), 32 deletions(-) diff --git a/BI/销售业绩/电商销售订单.sql b/BI/销售业绩/电商销售订单.sql index b6ea840..2e8a469 100644 --- a/BI/销售业绩/电商销售订单.sql +++ b/BI/销售业绩/电商销售订单.sql @@ -1,10 +1,32 @@ SELECT * FROM dm.v_ag_sal_eorder -WHERE 1=1 -${if(len(p_order) == 0,"","and order_code in ('" + p_order + "')")} +-- 订单时间 +WHERE order_time >= '${sStart_date}' +AND order_time <= '${sEnd_date}' +-- 商品 eproduct_code 、eproduct_name +${if(len(sEproduct_code) == 0,"","and eproduct_name in ('" + sEproduct_code + "')")} --- order_status -- 订单状态 --- ,order_code -- 订单号 --- group by order_status +-- 单据号 +${if(len(sBill) == 0,"","and order_code in ('" + sBill + "')")} + +-- 是否有对照关系 is_refer +${if(len(sIs_refer) == 0,"","and is_refer in ('" + sIs_refer + "')")} + +-- 城市单元 sCu +${if(len(sCu) == 0,"","and city_unit_code in ('" + sCu + "')")} + +-- 退款标识 is_refund "0","无退款","含退款" +${if(len(sIs_refund) == 0,"","and is_refund in ('" + sIs_refund + "')")} + +-- 订单状态 Order_status +${if(len(sOrder_status) == 0,"","and order_status in ('" + sOrder_status + "')")} + +-- 品项 sPi + ${if(len(sPi_name) == 0,"","and pi_name in ('" + sPi_name + "')")} + +-- 产品 sProd +${if(len(sProd) == 0,"","and product_code in ('" + sProd + "')")} + +-- 金额区间 diff --git a/BI/销售业绩/经销商出货.sql b/BI/销售业绩/经销商出货.sql index fd870b5..bf83f3e 100644 --- a/BI/销售业绩/经销商出货.sql +++ b/BI/销售业绩/经销商出货.sql @@ -10,14 +10,46 @@ SELECT ELSE region_name END AS report_region_name -- 报表大区 FROM dm.v_ag_sal_cust_flow -where 1=1 +-- 出货时间 +WHERE bill_time >= '${sStart_date}' +AND bill_time <= '${sEnd_date}' + + +-- 事业部 +${if(len(sBu) == 0,"","and bu_code in ('" + sBu + "')")} + +-- 大区 +${if(len(sRegion) == 0,"","and region_code in ('" + sRegion + "')")} + + +-- 办事处 +${if(len(sOffice) == 0,"","and office_code in ('" + sOffice + "')")} + + +-- 城市单元 +${if(len(sCu) == 0,"","and city_unit_code in ('" + sCu + "')")} + +-- 省份 +${if(len(sProvince) == 0,"","and province_name in ('" + sProvince + "')")} + +-- 地市 +${if(len(sCity) == 0,"","and city_name in ('" + sCity + "')")} + +-- 经销商类型 +${if(len(sDeal_type) == 0,"","and deal_type in ('" + sDeal_type + "')")} + +-- 产品 +${if(len(sProd) == 0,"","and product_code in ('" + sProd + "')")} + +-- 产品线 +${if(len(sPl_name) == 0,"","and pl_name in ('" + sPl_name + "')")} + -- 子主经销商筛选 -${if(p_is_src_deal== "主经销商",if(len(p_deal_name)==0,"","and deal_name in ('" + p_deal_name + "')"),if(len(p_deal_name)==0,"","and src_deal_name in ('" + p_deal_name + "')"))} --- 单据号 bill_code -${if(len(p_bill_code) == 0,"","and bill_code in ('" + p_bill_code + "')")} --- 省 -${if(len(p_province) == 0,"","and province_name in ('" + p_province + "')")} --- 市 -${if(len(p_city) == 0,"","and city_name in ('" + p_city + "')")} +${if(sIs_srcdeal== "主经销商",if(len(sDeal)==0,"","and deal_code in ('" + sDeal + "')"),if(len(sDeal)==0,"","and src_deal_code in ('" +sDeal + "')"))} + -- 收货方 -${if(len(p_opposite) == 0,"","and opposite_name in ('" + p_opposite + "')")} +${if(len(sOpposite) == 0,"","and opposite_name in ('" + sOpposite + "')")} + +-- 单据号 bill_code +${if(len(sBill) == 0,"","and bill_code in ('" + sBill + "')")} + diff --git a/BI/销售业绩/销售发货明细.sql b/BI/销售业绩/销售发货明细.sql index aded5ef..3c9730c 100644 --- a/BI/销售业绩/销售发货明细.sql +++ b/BI/销售业绩/销售发货明细.sql @@ -22,10 +22,29 @@ select ELSE region_name END AS report_region_name -- 报表大区 from dm.v_ag_sal_deliver -WHERE 1 = 1 +-- 发货时间 +WHERE deli_time >= '${sStart_date}' + AND deli_time <= '${sEnd_date}' +-- 事业部 +${if(len(sBu) == 0,"","and bu_code in ('" + sBu + "')")} + +-- 大区 +${if(len(sRegion) == 0,"","and region_code in ('" + sRegion + "')")} + +-- 办事处 +${if(len(sOffice) == 0,"","and office_code in ('" + sOffice + "')")} + +-- 城市单元 +${if(len(sCu) == 0,"","and city_unit_code in ('" + sCu + "')")} + +-- 子主经销商筛选 +${if(sIs_srcdeal== "主经销商",if(len(sDeal)==0,"","and deal_code in ('" + sDeal + "')"),if(len(sDeal)==0,"","and src_deal_code in ('" +sDeal + "')"))} + +-- 产品 +${if(len(sProd) == 0,"","and product_code in ('" + sProd + "')")} + -- 发货单号 - ${if(len(p_deli_code) == 0,"","and deli_code = '" + p_deli_code + "'")} +${if(len(sDeli_code) == 0,"","and deli_code = '" + sDeli_code + "'")} + -- 订单号 - ${if(len(p_order_code) == 0,"","and order_code = '" + p_order_code + "'")} --- - ${if(p_is_src_deal== "主经销商",if(len(p_deal_name)==0,"","and deal_name in ('" + p_deal_name + "')"),if(len(p_deal_name)==0,"","and src_deal_name in ('" + p_deal_name + "')"))} +${if(len(sOrder) == 0,"","and order_code = '" + sOrder + "'")} diff --git a/FineReport/财务主题/报表/费用/1_1_1OA表单下钻.sql b/FineReport/财务主题/报表/费用/1_1_1OA表单下钻.sql index 911c07c..82908db 100644 --- a/FineReport/财务主题/报表/费用/1_1_1OA表单下钻.sql +++ b/FineReport/财务主题/报表/费用/1_1_1OA表单下钻.sql @@ -5,7 +5,7 @@ WITH corp AS ( FROM dwr.dim_corp WHERE corp_type = '实体' AND (parent_corp_code LIKE '02%' OR corp_code = '0301') - ${IF(LEN(sCorpCode)!=0," AND corp_code IN ('"+JOINARRAY(sCorpCode,"','")+"')", "")} + ${IF(LEN(sCorp)!=0," AND corp_code IN ('"+ sCorp +"')", "")} ) SELECT bill_date -- 制单日期 @@ -27,12 +27,18 @@ SELECT ,opp_account_name -- 对方户名 ,opp_bank_account -- 对方帐号 ,opp_name -- 对方名称 - ,amt -- 金额 + ,amt / 10000 AS amt -- 金额 ,remark -- 备注 ,budget_type -- 预算类型 ,fund_content -- 支出内容 FROM dwi.dwi_fim_oa_payment WHERE corp_code in(SELECT corp_code FROM corp) - AND bill_date >= CONCAT('${sQueryStartDate}','-01') - AND bill_date <= CONCAT('${sQueryDate}','-01') - ${if(len(sBillcode)=0,"","AND bill_code = '" + sBillcode +"'")} \ No newline at end of file +AND bill_date >= CONCAT('${sStart_mon}','-01') +AND bill_date <= CONCAT('${sEnd_mon}','-01') +${if(len(sBill)=0,"","AND bill_code = '" + sBill +"'")} + + + +SELECT + CONCAT('数据更新日期:',LEFT(MAX(update_time),19)) AS update_time +FROM dwi.dwi_fim_oa_payment diff --git a/FineReport/财务主题/报表/费用/1_1财务凭证下钻.sql b/FineReport/财务主题/报表/费用/1_1财务凭证下钻.sql index fc3ce66..8560550 100644 --- a/FineReport/财务主题/报表/费用/1_1财务凭证下钻.sql +++ b/FineReport/财务主题/报表/费用/1_1财务凭证下钻.sql @@ -24,24 +24,26 @@ SELECT ,subject_full_name -- 科目全称 ,aux_content -- 辅助核算 ,debit_amt / 10000 AS debit_amt -- 借方金额 - ,credit_amt / 10000 credit_amt -- 贷方金额 + ,credit_amt / 10000 AS credit_amt -- 贷方金额 ,src_bill_codes -- 来源单据号 ,acnt_date -- 记账日期 FROM dwi.dwi_fim_voucher where subject_code like '6601%' and corp_code in(SELECT corp_code FROM corp) - ${if(len(sBill)=0," ","AND src_bill_codes = '" + sBill +"'")} --- AND acnt_year = '${YEAR(sStart_mon)}' + ${if(len(sBill)=0," ","AND src_bill_codes = '" + sBill + "'")} +AND acnt_year = LEFT('${sStart_mon}',4) +AND acnt_mon >= RIGHT('${sStart_mon}',2) +AND acnt_mon <= RIGHT('${sEnd_mon}',2) -- AND acnt_mon <= '${FORMAT(sStart_mon,"MM")}' -- ${switch(sCalcType -- ,"m","AND concat(acnt_year,'-',acnt_mon) <= '" + sQueryDate + "' AND concat(acnt_year,'-',acnt_mon) >= '" + sQueryStartDate + "'" -- ,"y","AND concat(acnt_year,'-',acnt_mon) <= '" + sQueryDate + "' AND concat(acnt_year,'-',acnt_mon) >= '" + sQueryStartDate + "'" -- )} - ${switch(sCalcType -,"m","AND acnt_year = '" + YEAR(sStart_mon) + "' AND acnt_mon = '" + FORMAT(sStart_mon,"MM") + "'" -,"y","AND acnt_year = '" + YEAR(sStart_mon) + "' AND acnt_mon = '" + FORMAT(sStart_mon,"MM") + "'" -)} +-- ${switch(sCalcType +-- ,"m","AND acnt_year = '" + YEAR(sStart_mon) + "' AND acnt_mon = '" + FORMAT(sStart_mon,"MM") + "'" +-- ,"y","AND acnt_year = '" + YEAR(sStart_mon) + "' AND acnt_mon = '" + FORMAT(sStart_mon,"MM") + "'" +-- )} ${nvl(switch(sSubject ,"0000","AND subject_code like '6601%' AND (subject_code not like '660114%' @@ -57,4 +59,38 @@ and corp_code in(SELECT corp_code FROM corp) AND subject_code NOT like '660164%' )" ,"660114,660127","AND (subject_code like '660114%' or subject_code like '660127%')") - ,"and subject_code like '" + sSubject +"%'")} \ No newline at end of file + ,"and subject_code like '" + sSubject +"%'")} + + +-- ====================================== +-- 数据更新时间 +-- ====================================== + + + + +SELECT +CONCAT('数据更新日期:',LEFT(MAX(update_time),19)) AS update_time +FROM dwi.dwi_fim_voucher +where subject_code like '6601%' + + +-- ====================================== +-- 查询OA可下钻单据号 +-- ====================================== + + +SELECT + a.bill_code -- 单据号 + ,b.subject_name +FROM dwi.dwi_fim_oa_payment a + LEFT JOIN + ( + SELECT + * + FROM dwi.dwi_fim_voucher + )b + on a.bill_code = b.src_bill_codes +where b.src_bill_codes is not NULL + and a.bill_date >= '2024-01-01' + and b.subject_code LIKE '6601%'