财务费用报表参数名称修改+BI报表数据集参数化
This commit is contained in:
parent
da3348d85a
commit
abf3a061b9
@ -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 + "')")}
|
||||
|
||||
-- 金额区间
|
||||
|
||||
|
@ -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 + "')")}
|
||||
|
||||
|
@ -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 + "'")}
|
||||
|
@ -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 +"'")}
|
||||
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
|
||||
|
@ -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%'
|
||||
@ -58,3 +60,37 @@ and corp_code in(SELECT corp_code FROM corp)
|
||||
)"
|
||||
,"660114,660127","AND (subject_code like '660114%' or subject_code like '660127%')")
|
||||
,"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%'
|
||||
|
Loading…
Reference in New Issue
Block a user