数据权限控制+排序功能
This commit is contained in:
parent
cfde02b97e
commit
a24caf3443
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/BI/销售业绩/市场费用报销明细.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/BI/销售业绩/电商销售订单.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/BI/销售业绩/经销商出货.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/BI/销售业绩/电商销售订单-废弃.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/BI/销售业绩/经销商出货-废弃.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/BI/销售业绩/销售订单.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/tianbao/产品档案填报.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/tianbao/基础指标填报表.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/tianbao/财务预算填报.sql" dialect="PostgreSQL" />
|
||||
@ -12,7 +12,9 @@
|
||||
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/1_1_1OA表单下钻.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/1_1财务凭证下钻.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/财务主题/报表/费用/4-财务费用汇总表.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/终端奖励对账.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/城市单元业绩达成.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/市场费用使用情况.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/酱酒计划执行表.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/销售业绩组合统计表.sql" dialect="PostgreSQL" />
|
||||
<file url="file://$PROJECT_DIR$/FineReport/销售主题/报表/销售业绩/销售指标月度汇总.sql" dialect="PostgreSQL" />
|
||||
|
@ -1,34 +0,0 @@
|
||||
select
|
||||
bill_code -- 报销单号
|
||||
,bill_status -- 审核状态
|
||||
,ct_code -- 合同付款单号
|
||||
,budget_code -- 预算编号
|
||||
,credence_code -- 凭证号
|
||||
,plan_code -- 方案号
|
||||
,bill_date -- 报销时间
|
||||
,stat_year -- 年
|
||||
,stat_month -- 月
|
||||
,deal_code -- 经销商编码
|
||||
,deal_name -- 经销商名称
|
||||
,src_deal_code -- 子经销商编码
|
||||
,src_deal_name -- 子经销商名称
|
||||
,city_unit_code -- 城市单元编码
|
||||
,city_unit_name -- 城市单元名称
|
||||
,office_code -- 办事处编码
|
||||
,office_name -- 办事处
|
||||
,region_code -- 大区编码
|
||||
,region_name -- 大区
|
||||
,bu_name -- 事业部
|
||||
,prodline_name -- 产品线
|
||||
,fist_item -- 一级项目
|
||||
,cost_source -- 费用来源
|
||||
,cost_item -- 费用项目
|
||||
,activity_type -- 活动类型
|
||||
,pay_way -- 支付方式
|
||||
,pay_way_class -- 支付方式类别
|
||||
,is_valid
|
||||
,audit_name -- 终审人
|
||||
-- 单据状态
|
||||
,amt_fill -- 填报金额
|
||||
,amt_approval -- 审批金额
|
||||
from dm.v_ag_str_sale_use_budget
|
@ -1,9 +1,13 @@
|
||||
-- ======================================
|
||||
-- 2024-11-21:由李维调整完毕
|
||||
-- ======================================
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM dm.v_ag_sal_eorder
|
||||
FROM dm.v_ag_sal_eorder a
|
||||
-- 订单时间
|
||||
WHERE order_time >= '${sStart_date}'
|
||||
AND order_time <= '${sEnd_date}'
|
||||
WHERE order_time >= '${sOrder_start_date}'
|
||||
AND order_time <= '${sOrder_end_date}'
|
||||
-- 商品 eproduct_code 、eproduct_name
|
||||
${if(len(sEproduct_code) == 0,"","and eproduct_name in ('" + sEproduct_code + "')")}
|
||||
|
||||
@ -29,4 +33,25 @@ ${if(len(sOrder_status) == 0,"","and order_status in ('" + sOrder_status + "')")
|
||||
${if(len(sProd) == 0,"","and product_code in ('" + sProd + "')")}
|
||||
|
||||
-- 金额区间
|
||||
${if(len(sStart_amt) == 0,"","and ordered_amt >= " + sStart_amt + "")}
|
||||
${if(len(sEnd_amt) == 0,"","and ordered_amt <= " + sEnd_amt + "")}
|
||||
|
||||
|
||||
-- 权限控制
|
||||
AND exists (
|
||||
select
|
||||
1
|
||||
from
|
||||
dm.dm_bi_user_permisson
|
||||
where
|
||||
bi_user = '${fine_username}'
|
||||
and per_model IN ('all','sal')
|
||||
and (
|
||||
is_all = 1
|
||||
OR per_code = a.p_bu_code -- 事业部
|
||||
-- OR per_code = a.region_code -- 大区
|
||||
-- OR per_code = a.office_code -- 城市单元
|
||||
OR per_code = a.city_unit_code -- 城市单元
|
||||
)
|
||||
)
|
||||
|
@ -1,3 +1,6 @@
|
||||
-- ======================================
|
||||
-- 2024-11-21:由李维调整完毕
|
||||
-- ======================================
|
||||
SELECT
|
||||
*
|
||||
,CASE WHEN bu_code ='0202/0223'
|
||||
@ -9,23 +12,20 @@ SELECT
|
||||
THEN '成都市场'
|
||||
ELSE region_name
|
||||
END AS report_region_name -- 报表大区
|
||||
FROM dm.v_ag_sal_cust_flow
|
||||
FROM dm.v_ag_sal_cust_flow a
|
||||
-- 出货时间
|
||||
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 + "')")}
|
||||
|
||||
@ -44,12 +44,34 @@ ${if(len(sProd) == 0,"","and product_code in ('" + sProd + "')")}
|
||||
-- 产品线
|
||||
${if(len(sPl_name) == 0,"","and pl_name in ('" + sPl_name + "')")}
|
||||
|
||||
-- 金额区间
|
||||
${if(len(sStart_amt) == 0,"","and ordered_amt >= " + sStart_amt + "")}
|
||||
${if(len(sEnd_amt) == 0,"","and ordered_amt <= " + sEnd_amt + "")}
|
||||
|
||||
-- 子主经销商筛选
|
||||
${if(sIs_srcdeal== "主经销商",if(len(sDeal)==0,"","and deal_code in ('" + sDeal + "')"),if(len(sDeal)==0,"","and src_deal_code in ('" +sDeal + "')"))}
|
||||
${if(sSub_main== "主经销商",if(len(sDeal)==0,"","and deal_code in ('" + sDeal + "')"),if(len(sDeal)==0,"","and src_deal_code in ('" +sDeal + "')"))}
|
||||
|
||||
-- 收货方
|
||||
${if(len(sOpposite) == 0,"","and opposite_name in ('" + sOpposite + "')")}
|
||||
${if(len(sOpposite_name) == 0,"","and opposite_name in ('" + sOpposite_name + "')")}
|
||||
|
||||
-- 单据号 bill_code
|
||||
${if(len(sBill) == 0,"","and bill_code in ('" + sBill + "')")}
|
||||
|
||||
|
||||
-- 权限控制
|
||||
AND exists (
|
||||
select
|
||||
1
|
||||
from
|
||||
dm.dm_bi_user_permisson
|
||||
where
|
||||
bi_user = '${fine_username}'
|
||||
and per_model IN ('all','sal')
|
||||
and (
|
||||
is_all = 1
|
||||
OR per_code = a.bu_code -- 事业部
|
||||
OR per_code = a.region_code -- 大区
|
||||
OR per_code = a.office_code -- 城市单元
|
||||
OR per_code = a.city_unit_code -- 城市单元
|
||||
)
|
||||
)
|
@ -1,4 +1,6 @@
|
||||
|
||||
-- ======================================
|
||||
-- 2024-11-21:由李维调整完毕
|
||||
-- ======================================
|
||||
select
|
||||
*
|
||||
,CASE
|
@ -1,3 +1,6 @@
|
||||
-- ======================================
|
||||
-- 2024-11-21:由李维调整完毕
|
||||
-- ======================================
|
||||
select * from dm.v_ag_sal_collection
|
||||
where 1=1
|
||||
${if(len(p_bill_code) == 0,"","and bill_code in ('" + p_bill_code + "')")}
|
92
BI/销售业绩/销售订单.sql
Normal file
92
BI/销售业绩/销售订单.sql
Normal file
@ -0,0 +1,92 @@
|
||||
SELECT
|
||||
pk
|
||||
,order_code -- 订单号
|
||||
,src_order_code -- 来源订单号
|
||||
,order_time -- 订单时间
|
||||
,order_type -- 订单类型
|
||||
,city_unit_code -- 城市单元编码
|
||||
,city_unit_name -- 城市单元
|
||||
,office_code -- 办事处编码
|
||||
,office_name -- 办事处
|
||||
,region_code -- 大区编码
|
||||
,region_name -- 大区名称
|
||||
,bu_code -- 事业部编码
|
||||
,bu_name -- 事业部
|
||||
,province_name -- 省份
|
||||
,city_name -- 市区
|
||||
,deal_code -- 主经销商编码
|
||||
,deal_name -- 主经销商名称
|
||||
,src_deal_code -- 子经销商编码
|
||||
,src_deal_name -- 子经销商名称
|
||||
,deal_type -- 经销商类型
|
||||
,yys_code -- 运营商编码
|
||||
,yys_name -- 运营商名称
|
||||
,product_code -- 产品编码
|
||||
,product_name -- 产品名称
|
||||
,aroma_type -- 香型
|
||||
,pi_name -- 品项
|
||||
,pr_name -- 产品系列
|
||||
,report_pi_name -- 报表品项
|
||||
,plan_pi_name -- 计划品项
|
||||
,plan_type -- 计划类型
|
||||
,pl_name -- 产品线
|
||||
,p_bu_code -- 产品所属事业部编码
|
||||
,p_bu_name -- 产品所属事业部名称
|
||||
,price_item -- 价格项
|
||||
,spec -- 规格
|
||||
,is_jxzx -- 酱酒执行
|
||||
,price -- 单价
|
||||
,discount_price -- 折后价
|
||||
,order_num -- 订单数量
|
||||
,pack_base_num -- 转换率
|
||||
,ton_num -- 订单吨数
|
||||
,x_amt -- x类金额
|
||||
,adj_amt -- 调整金额
|
||||
,e_amt -- E类费用
|
||||
,f_amt -- F类费用
|
||||
,q_amt -- Q类费用
|
||||
,d_amt -- D类金额
|
||||
,fz_amt -- FZ类金额
|
||||
,other_amt -- 其他费用
|
||||
,amt_bu -- 计事业部金额
|
||||
,amt_region -- 计大区金额
|
||||
,amt_office -- 计办事处金额
|
||||
,amt_city_unit -- 计城市单元金额
|
||||
,amt_dealer -- 计经销商金额
|
||||
FROM dm.v_ag_sal_order a
|
||||
-- 订单时间
|
||||
WHERE order_time >= '${CONCATENATE(sOrder_start_date," 00:00:00")}'
|
||||
AND order_time <= '${CONCATENATE(sOrder_end_date," 00:00:00")}'
|
||||
-- 事业部
|
||||
${if(len(sBu) == 0,"","and a.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(sProduct) == 0,"","and product_code IN ('"+ sProduct +"')")}
|
||||
-- 子主经销商
|
||||
${if(sSub_main == '主经销商',if(len(sDeal) == 0,"","and deal_code IN ('"+ sDeal+"')"),if(len(sDeal) == 0,"","and src_deal_code IN ('"+ sDeal +"')"))}
|
||||
-- 单据号
|
||||
${if(len(sBill) == 0,"","and order_code in ('" + sBill + "')")}
|
||||
-- 酱酒执行计划
|
||||
${if(len(sBill) == 0,"","and order_code in ('" + sBill + "')")}
|
||||
-- 权限控制
|
||||
AND exists (
|
||||
select
|
||||
1
|
||||
from
|
||||
dm.dm_bi_user_permisson
|
||||
where
|
||||
bi_user = '${fine_username}'
|
||||
and per_model IN ('all','sal')
|
||||
and (
|
||||
is_all = 1
|
||||
OR per_code = a.bu_code -- 事业部
|
||||
OR per_code = a.region_code -- 大区
|
||||
OR per_code = a.office_code -- 城市单元
|
||||
OR per_code = a.city_unit_code -- 城市单元
|
||||
)
|
||||
)
|
@ -129,9 +129,22 @@ where
|
||||
from dwi.dwi_fim_tax_payed t1
|
||||
JOIN corp t2 ON t1.corp_code = t2.corp_code
|
||||
WHERE bill_status='已匹配'
|
||||
AND tax_name <> '企业所得税'
|
||||
AND stat_date <= '${CONCATENATE(sEnd_mon,"-01 00:00:00")}'
|
||||
AND stat_date >= '${CONCATENATE(sStart_mon,"-01 00:00:00")}'
|
||||
GROUP By tax_name
|
||||
-- 增加企业所得特殊处理规则
|
||||
UNION ALL
|
||||
select
|
||||
'企业所得税' AS "税种" -- 税种
|
||||
,SUM(actual_amt) AS "实际入库"
|
||||
,SUM(refund_amt) AS "退税金额"
|
||||
from dwi.dwi_fim_tax_payed t1
|
||||
JOIN corp t2 ON t1.corp_code = t2.corp_code
|
||||
WHERE bill_status='已匹配'
|
||||
AND tax_name like '企业所得税%'
|
||||
AND stat_date <= '${CONCATENATE(sEnd_mon,"-01 00:00:00")}'
|
||||
AND stat_date >= '${CONCATENATE(sStart_mon,"-01 00:00:00")}'
|
||||
)fin3
|
||||
on fin0.税种 = fin3.税种
|
||||
ORDER BY
|
||||
|
200
FineReport/销售主题/报表/终端奖励对账.sql
Normal file
200
FineReport/销售主题/报表/终端奖励对账.sql
Normal file
@ -0,0 +1,200 @@
|
||||
with base_data as (
|
||||
select
|
||||
to_char(a.stat_date,'yyyy') as stat_year,
|
||||
to_char(a.stat_date,'mm') as stat_mon,
|
||||
a.stat_date,
|
||||
case when a.indi_type='现金分润'
|
||||
then (case when dmp.pl_name='兼香龙马' and dmp.product_name like '%郎牌·%马特%'
|
||||
then '郎牌·马特2.0版终端月度奖励'
|
||||
when dmp.pl_name='兼香龙马'
|
||||
then '兼香龙马终端月度奖励'
|
||||
when dmp.pl_name='兼香顺品'
|
||||
then '兼香顺品终端分润活动奖励'
|
||||
end
|
||||
)
|
||||
when a.indi_type='消费者红包'
|
||||
then (case when dmp.pl_name='兼香龙马' and dmp.product_name like '%郎牌·%马特%'
|
||||
then '郎牌·马特2.0版消费者红包奖励'
|
||||
when dmp.pl_name='红花郎'
|
||||
then '红花郎消费者红包奖励'
|
||||
else dmp.pl_name||'消费者红包月度奖励'
|
||||
end
|
||||
)
|
||||
else '终端销售奖月度销售奖励' end as indi_type,
|
||||
d.fist_dept_code as bu_code,
|
||||
max(d.fist_dept_name) as bu_name,
|
||||
d.secd_dept_code as region_code,
|
||||
max(d.secd_dept_name) as region_name,
|
||||
d.thrd_dept_code as office_code,
|
||||
max(d.thrd_dept_name) as office_name,
|
||||
cust.deal_code,
|
||||
cust.deal_name,
|
||||
dmp.pl_name,
|
||||
nvl(p.pi_name,dmp.pi_name) as pi_name,
|
||||
a.product_code,
|
||||
dmp.product_name,
|
||||
sum(a.bottle_num) as bottle_num,
|
||||
sum(a.amt) as amt
|
||||
from dm.dm_mak_indicator_day a
|
||||
left join dwr.dim_product dmp on a.product_code = dmp.product_code
|
||||
left join sdi_oth.product_pi_special p on a.product_code=p.product_code
|
||||
left join dwr.dim_department d on d.dept_code = nvl(a.city_unit_code,dmp.bu_code)
|
||||
left join dwr.dim_dealer cust on a.src_deal_code = cust.deal_code
|
||||
where indi_type in ('终端销售奖','现金分润','消费者红包')
|
||||
and a.stat_date >= timestamp'${CONCATENATE(sStart_date," 00:00:00.000")}'
|
||||
AND a.stat_date < timestamp '${CONCATENATE(sEnd_date," 00:00:00.000")}'
|
||||
|
||||
group by
|
||||
to_char(a.stat_date,'yyyy'),
|
||||
to_char(a.stat_date,'mm'),
|
||||
a.stat_date,
|
||||
case when a.indi_type='现金分润'
|
||||
then (case when dmp.pl_name='兼香龙马' and dmp.product_name like '%郎牌·%马特%'
|
||||
then '郎牌·马特2.0版终端月度奖励'
|
||||
when dmp.pl_name='兼香龙马'
|
||||
then '兼香龙马终端月度奖励'
|
||||
when dmp.pl_name='兼香顺品'
|
||||
then '兼香顺品终端分润活动奖励'
|
||||
end
|
||||
)
|
||||
when a.indi_type='消费者红包'
|
||||
then (case when dmp.pl_name='兼香龙马' and dmp.product_name like '%郎牌·%马特%'
|
||||
then '郎牌·马特2.0版消费者红包奖励'
|
||||
when dmp.pl_name='红花郎'
|
||||
then '红花郎消费者红包奖励'
|
||||
else dmp.pl_name||'消费者红包月度奖励'
|
||||
end
|
||||
)
|
||||
else '终端销售奖月度销售奖励' end,
|
||||
d.fist_dept_code,
|
||||
d.secd_dept_code,
|
||||
d.thrd_dept_code,
|
||||
cust.deal_code,
|
||||
cust.deal_name,
|
||||
dmp.pl_name,
|
||||
nvl(p.pi_name,dmp.pi_name),
|
||||
a.product_code,
|
||||
dmp.product_name
|
||||
union all
|
||||
select
|
||||
to_char(a.rebate_time,'yyyy') as stat_year,
|
||||
to_char(a.rebate_time,'mm') as stat_mon,
|
||||
date_trunc('day',a.rebate_time) as stat_date,
|
||||
'终端销售奖月度销售奖励' as indi_type,
|
||||
d.fist_dept_code as bu_code,
|
||||
max(d.fist_dept_name) as bu_name,
|
||||
d.secd_dept_code as region_code,
|
||||
max(d.secd_dept_name) as region_name,
|
||||
d.thrd_dept_code as office_code,
|
||||
max(d.thrd_dept_name) as office_name,
|
||||
cust.deal_code,
|
||||
cust.deal_name,
|
||||
dmp.pl_name,
|
||||
nvl(p.pi_name,dmp.pi_name) as pi_name,
|
||||
a.product_code,
|
||||
dmp.product_name,
|
||||
count(a.bottle_code) as bottle_num,
|
||||
sum(a.amt) as amt
|
||||
from dwi.dwi_mak_rebate_person a
|
||||
left join dwr.dim_product dmp on a.product_code=dmp.product_code
|
||||
left join sdi_oth.product_pi_special p on a.product_code=p.product_code
|
||||
left join (select
|
||||
deal_code,
|
||||
pl_name,
|
||||
max(city_unit_code) as city_unit_code
|
||||
from dwr.dim_dealer_administer
|
||||
where enabled_status=1
|
||||
group by deal_code,pl_name) dda on a.deal_code=dda.deal_code and dmp.pl_name=dda.pl_name
|
||||
left join dwr.dim_department d on d.dept_code = nvl(dda.city_unit_code,a.bu_code)
|
||||
left join dwr.dim_dealer cust on a.deal_code = cust.deal_code
|
||||
where a.trade_direction='收入'
|
||||
and a.bill_type='分润'
|
||||
and rebate_time >= timestamp '${CONCATENATE(sStart_date," 00:00:00.000")}'
|
||||
AND rebate_time < timestamp '${CONCATENATE(sEnd_date," 00:00:00.000")}'
|
||||
group by
|
||||
to_char(a.rebate_time,'yyyy'),
|
||||
to_char(a.rebate_time,'mm'),
|
||||
date_trunc('day',a.rebate_time),
|
||||
d.fist_dept_code,
|
||||
d.secd_dept_code,
|
||||
d.thrd_dept_code,
|
||||
cust.deal_code,
|
||||
cust.deal_name,
|
||||
dmp.pl_name,
|
||||
nvl(p.pi_name,dmp.pi_name) ,
|
||||
a.product_code,
|
||||
dmp.product_name
|
||||
)
|
||||
SELECT
|
||||
stat_year -- 统计年
|
||||
,stat_mon -- 统计月
|
||||
,stat_date -- 统计日期
|
||||
,indi_type -- 账单类型
|
||||
,bu_code -- 事业部编码
|
||||
,bu_name -- 事业部
|
||||
,region_code -- 大区编码
|
||||
,region_name -- 大区名称
|
||||
,office_code -- 办事处编码
|
||||
,office_name -- 办事处名称
|
||||
,deal_code -- 经销商编码
|
||||
,deal_name -- 经销商名称
|
||||
,pl_name -- 产品线名称
|
||||
,pi_name -- 品项
|
||||
,product_code -- 产品编码
|
||||
,product_name -- 产品名称
|
||||
,bottle_num -- 瓶数
|
||||
,amt -- 金额
|
||||
FROM base_data a
|
||||
-- 排序
|
||||
left join sdi_xdata.mdm_dim_sorted st
|
||||
on a.region_code=st.sorted_value
|
||||
and st.sorted_type='大区'
|
||||
-- 权限控制
|
||||
where exists (
|
||||
select
|
||||
1
|
||||
from
|
||||
dm.dm_bi_user_permisson
|
||||
where
|
||||
bi_user = '${fine_username}'
|
||||
and per_model IN ('all','sal')
|
||||
and (
|
||||
is_all = 1
|
||||
OR per_code = a.bu_code -- 事业部
|
||||
OR per_code = a.region_code -- 大区
|
||||
OR per_code = a.office_code -- 办事处
|
||||
-- OR per_code = a.city_unit_code -- 城市单元
|
||||
)
|
||||
)
|
||||
|
||||
-- 事业部
|
||||
${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(sPl_name) == 0,"","and pl_name IN ('"+ sPl_name+"')")}
|
||||
-- 经销商
|
||||
${if(len(sDeal) == 0,"",if(REGEXP(sDeal,"^[0-9]+$"),"and deal_code = '"+sDeal+"'","and deal_name like '%"+sDeal+"%'"))}
|
||||
-- 账单类型
|
||||
${if(len(sIndi_type) == 0,"","and indi_type IN ('"+ sIndi_type +"')")}
|
||||
ORDER BY nvl(st.sorted_no,99)
|
||||
|
||||
limit ${pPage_rows} offset (${pJump_page}-1)*${pPage_rows}
|
||||
|
||||
|
||||
|
||||
|
||||
-- 数据更新时间:
|
||||
--
|
||||
|
||||
SELECT
|
||||
CONCAT('数据更新时间:',LEFT(MAX(T.update_time),19)) AS update_time
|
||||
FROM
|
||||
(
|
||||
SELECT MAX(update_time) AS update_time FROM dm.dm_mak_indicator_day
|
||||
UNION ALL
|
||||
SELECT MAX(update_time) AS update_time FROM dwi.dwi_mak_rebate_person
|
||||
)T
|
||||
;
|
@ -1,90 +0,0 @@
|
||||
-- *****************************
|
||||
-- 创建人员: 杨坤安
|
||||
-- 创建时间: 202401120
|
||||
-- 功能描述: 原报表名称: 04城市单元主要指标达成
|
||||
-- *****************************
|
||||
|
||||
|
||||
-- ======================================
|
||||
-- 08销售指标达成(看板)
|
||||
-- ======================================
|
||||
|
||||
select a.pk,
|
||||
a.stat_date,
|
||||
a.indi_type,
|
||||
a.bu_code,
|
||||
o.dept_name as bu_name,
|
||||
a.region_code,
|
||||
d.secd_dept_name as region_name,
|
||||
a.office_code,
|
||||
d.thrd_dept_name as office_name,
|
||||
a.city_unit_code,
|
||||
d.dept_name as city_unit_name,
|
||||
pv.town_name as province_name,
|
||||
cit.town_name as city_name,
|
||||
a.deal_code,
|
||||
deal.deal_name,
|
||||
a.src_deal_code,
|
||||
a.deal_type,
|
||||
a.product_code,
|
||||
a.num_bu,
|
||||
a.num_region,
|
||||
a.num_office,
|
||||
a.num_city_unit,
|
||||
a.num_dealer,
|
||||
a.amt_bu,
|
||||
a.amt_region,
|
||||
a.amt_office,
|
||||
a.amt_city_unit,
|
||||
a.amt_dealer,
|
||||
a.update_time,
|
||||
a.is_new_dealer
|
||||
from dm.dm_sal_indicator_day a
|
||||
left join dwr.dim_department d on d.dept_code=a.city_unit_code
|
||||
left join dwr.dim_dealer deal on a.deal_code=deal.deal_code
|
||||
left join dwr.dim_department o on o.dept_code=a.bu_code
|
||||
left join dwr.dim_product po on a.product_code=po.product_code
|
||||
left join (select city_unit_code,
|
||||
max(province_code) as province_code,
|
||||
max(city_code) as city_code
|
||||
from dwr.dim_dealer_administer
|
||||
where enabled_status=1
|
||||
group by city_unit_code) are on a.city_unit_code=are.city_unit_code
|
||||
left join dwr.dim_area pv on nvl(a.province_code,are.province_code)=pv.town_code
|
||||
left join dwr.dim_area cit on nvl(a.city_code,are.city_code)=cit.town_code
|
||||
left join dwr.dim_department dd on (case when
|
||||
a.indi_type in ('融资未填仓','已填仓未下单','未下单往来余额','费用余额')
|
||||
then a.bu_code else po.bu_code end)=dd.dept_code
|
||||
where stat_date>=date'2020-01-01'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- ======================================
|
||||
-- 05城市单元销售指标达成
|
||||
-- ======================================
|
||||
|
||||
|
||||
select
|
||||
stat_date
|
||||
,indi_type
|
||||
,cp_region_code
|
||||
,cp_region_name
|
||||
,bu_code
|
||||
,bu_name
|
||||
,region_code
|
||||
,region_name
|
||||
,office_code
|
||||
,office_name
|
||||
,city_unit_code
|
||||
,city_unit_name
|
||||
,deal_type
|
||||
,province
|
||||
,city
|
||||
-- 年度
|
||||
-- 月度
|
||||
-- 季度
|
||||
,amt_cityunit -- 金额
|
||||
from dm.v_sal_indicator_cityunit
|
24
FineReport/销售主题/报表/销售业绩/市场费用使用情况.sql
Normal file
24
FineReport/销售主题/报表/销售业绩/市场费用使用情况.sql
Normal file
@ -0,0 +1,24 @@
|
||||
select
|
||||
stat_date -- 统计时间
|
||||
,indi_type -- 指标类型
|
||||
,bu_code -- 事业部编码
|
||||
,bu_name -- 事业部
|
||||
,region_code -- 大区
|
||||
,region_name -- 大区名称
|
||||
,office_code -- 办事处编码
|
||||
,office_name -- 办事处
|
||||
,city_unit_code -- 城市单元编码
|
||||
,city_unit_name -- 城市单元名称
|
||||
,deal_code -- 经销商编码
|
||||
,deal_name -- 经销商
|
||||
,fist_item -- 一级项目
|
||||
,fist_item_kh --
|
||||
,cost_source -- 费用来源
|
||||
,cost_source_kh
|
||||
,cost_item -- 费用项目
|
||||
,activity_type -- 活动类别
|
||||
,pay_way -- 支付方式
|
||||
,pl_name -- 产品线
|
||||
,amt -- 金额
|
||||
,create_time -- 创建时间
|
||||
from dm.v_sal_market_indi_month a
|
@ -1,67 +1,3 @@
|
||||
-- ======================================
|
||||
-- 主语句
|
||||
-- ======================================
|
||||
select a.period_id, -- 时间ID
|
||||
a.year, -- 年度
|
||||
a.month, -- 月度
|
||||
a.deal_code, -- 主经销商编码
|
||||
a.deal_name, -- 主经销商名称
|
||||
a.src_deal_code, -- 子经销商编码
|
||||
a.src_deal_name, -- 子经销商名称
|
||||
d.fist_dept_code as bu_code, --
|
||||
d.secd_dept_code as region_code, -- 大区编码
|
||||
d.secd_dept_name as region_name, -- 大区名称
|
||||
a.plan_type, -- 计划类型
|
||||
a.plan_item, -- 计划项目
|
||||
a.plan_pi_name, -- 计划品项
|
||||
a.plan_in_num, -- 计划内瓶数
|
||||
a.plan_in_pack, -- 计划内件数
|
||||
a.plan_in_ton, -- 计划内吨数
|
||||
a.plan_in_amt, -- 计划内金额
|
||||
a.plan_out_num, -- 计划外瓶数
|
||||
a.plan_out_pack, -- 计划外件数
|
||||
a.plan_out_ton, -- 计划外吨数
|
||||
a.plan_out_amt, -- 计划外金额
|
||||
a.create_by, -- 创建人
|
||||
a.create_time, -- 创建时间
|
||||
a.update_by, -- 更新人
|
||||
a.update_time, -- 更新时间
|
||||
a.plan_pi_code, -- 计划品相编码
|
||||
nvl(stp.is_suspend,'0') as is_suspend
|
||||
from
|
||||
(
|
||||
SELECT
|
||||
*
|
||||
FROM dm.dm_cus_flavour_plan_executed
|
||||
WHERE year = '${SYear}'
|
||||
-- 计划类型
|
||||
${if(len(sPlantype) == 0,"","and plan_type IN ('"+sPlantype+"')")}
|
||||
-- 计划品项
|
||||
${if(len(sPlanpi) == 0,"","and plan_pi_name IN ('"+sPlanpi+"')")}
|
||||
-- 子主经销商
|
||||
${if(sDeal == 1,if(len(sDealName) == 0,"","and deal_code IN ('"+ sDealName+"')"),if(len(sDealName) == 0,"","and src_deal_code IN ('"+ sDealName +"')"))}
|
||||
)a
|
||||
left join dwr.dim_department d on a.city_unit_code=d.dept_code
|
||||
left join
|
||||
(
|
||||
select
|
||||
bu_code -- 事业部编码
|
||||
,deal_code -- 经销商编码
|
||||
,'1' as is_suspend
|
||||
from dwi.dwi_mdm_customers_lifecycle -- 经销商生命周期
|
||||
where bill_type='终止' -- 单据类型
|
||||
group by bu_code,deal_code
|
||||
having max(bill_date)<=sysdate -- 单据时间
|
||||
) stp
|
||||
on a.src_deal_code=stp.deal_code
|
||||
and d.fist_dept_code=stp.bu_code
|
||||
WHERE 1=1
|
||||
-- 事业部
|
||||
${if(len(sBu) == 0,"","and stp.bu_code IN ('"+sBu+"')")}
|
||||
-- 经销商是否终止
|
||||
${if(len(SIsstop) == 0,"","and nvl(stp.is_suspend,'0') = '"+SIsstop+"'")}
|
||||
ORDER BY a.month
|
||||
;
|
||||
|
||||
-- ======================================
|
||||
-- 语句处理
|
||||
@ -186,9 +122,9 @@ from
|
||||
-- 计划类型
|
||||
${if(len(sPlan_type) == 0,"","and plan_type IN ('"+sPlan_type+"')")}
|
||||
-- 计划品项
|
||||
${if(len(sPlan_Pi) == 0,"","and plan_pi_name IN ('"+sPlan_Pi+"')")}
|
||||
${if(len(sPlan_pi_name) == 0,"","and plan_pi_name IN ('"+sPlan_pi_name+"')")}
|
||||
-- 经销商
|
||||
${if(sIs_srcdeal == '2',if(len(sDeal) == 0,"","and deal_code IN ('"+ sDeal+"')"),if(len(sDeal) == 0,"","and src_deal_code IN ('"+ sDeal +"')"))}
|
||||
${if(sSub_main == '2',if(len(sDeal) == 0,"","and deal_code IN ('"+ sDeal+"')"),if(len(sDeal) == 0,"","and src_deal_code IN ('"+ sDeal +"')"))}
|
||||
)a
|
||||
left join dwr.dim_department d on a.city_unit_code=d.dept_code
|
||||
left join
|
||||
@ -204,25 +140,30 @@ left join
|
||||
) stp
|
||||
on a.src_deal_code=stp.deal_code
|
||||
and d.fist_dept_code=stp.bu_code
|
||||
WHERE 1=1
|
||||
-- 排序
|
||||
left join sdi_xdata.mdm_dim_sorted st on d.secd_dept_code=st.sorted_value and st.sorted_type='大区'
|
||||
-- 权限控制
|
||||
where exists (
|
||||
select
|
||||
1
|
||||
from
|
||||
dm.dm_bi_user_permisson
|
||||
where
|
||||
bi_user = '${fine_username}'
|
||||
and per_model IN ('all','sal')
|
||||
and (
|
||||
is_all = 1
|
||||
OR per_code = d.fist_dept_code -- 事业部
|
||||
OR per_code = d.secd_dept_code -- 大区
|
||||
-- OR per_code = a.office_code
|
||||
OR per_code = a.city_unit_code -- 城市单元
|
||||
)
|
||||
)
|
||||
-- 事业部
|
||||
${if(len(sBu) == 0,"","and stp.bu_code IN ('"+sBu+"')")}
|
||||
-- 经销商是否终止
|
||||
${if(len(sIs_stop_deal) == 0,"","and nvl(stp.is_suspend,'0') = '"+sIs_stop_deal+"'")}
|
||||
ORDER BY
|
||||
a.year -- 年度
|
||||
,a.month -- 月度
|
||||
,a.deal_code -- 主经销商编码
|
||||
,a.deal_name -- 主经销商名称
|
||||
,a.src_deal_code -- 子经销商编码
|
||||
,a.src_deal_name -- 子经销商名称
|
||||
,d.fist_dept_code -- 事业部编码
|
||||
,d.secd_dept_code -- 大区编码
|
||||
,d.secd_dept_name -- 大区名称
|
||||
,a.plan_type -- 计划类型
|
||||
,a.plan_item -- 计划项目
|
||||
,a.plan_pi_name -- 计划品项
|
||||
|
||||
ORDER BY nvl(st.sorted_no,99)
|
||||
;
|
||||
|
||||
|
||||
@ -249,4 +190,4 @@ ${if(sDeal == 1,if(len(sDealName) == 0,"","and deal_code IN ('"+ sDealName+"')")
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('数据更新日期:',LEFT(MAX(update_time),19)) AS update_time FROM dm.dm_cus_flavour_plan_executed
|
||||
SELECT CONCAT('数据更新时间:',LEFT(MAX(update_time),19)) AS update_time FROM dm.dm_cus_flavour_plan_executed
|
||||
|
@ -1,3 +1,9 @@
|
||||
-- ======================================
|
||||
-- 2024-11-21: 需求调整,暂缓维护
|
||||
-- ======================================
|
||||
|
||||
|
||||
|
||||
SELECT
|
||||
${if(len(sDim)>0,sDim + ","," ")}
|
||||
${if(FIND('合同金额', sIndex)>0," ROUND(SUM(T1.ct_amt ) / 10000,2) AS 合同金额,","")}
|
||||
@ -317,5 +323,138 @@ SELECT MAX(update_time) AS update_time FROM dwr.fact_sal_deliver -- dm.v_ag_sal_
|
||||
UNION ALL
|
||||
SELECT MAX(update_time) AS update_time FROM dwr.fact_sal_dealer_stock -- dm.v_ag_sal_deal_stock -- 实物库存
|
||||
)T
|
||||
;
|
||||
|
||||
-- 使用 : dm.dm_sal_indicator_day 去掉目标
|
||||
-- ======================================
|
||||
-- 销售业绩组合表
|
||||
-- ======================================
|
||||
-- 使用 : dm.dm_sal_indicator_day -- 销售种子指标按日汇总表
|
||||
-- 20241121更新: 与销售业绩月度汇总功能相似,待确认最终报表方案
|
||||
|
||||
select
|
||||
|
||||
|
||||
bu.dept_name as bu_name -- 事业部名称
|
||||
-- ,d.dept_name as p_bu_name -- 产品所属事业部名称
|
||||
,dmd.secd_dept_name as region_name -- 大区名称
|
||||
,dmd.thrd_dept_name as office_name -- 办事处名称
|
||||
,dmd.dept_name as city_unit_name -- 城市单元名称
|
||||
,max(pv.town_name) as province_name -- 省
|
||||
,max(cit.town_name) as city_name -- 市
|
||||
,p.pl_name -- 产品线名称
|
||||
,p.pi_name -- 品项名称
|
||||
-- ,p.report_pi_name -- 报表品项
|
||||
,p.product_name -- 产品名称
|
||||
,deal.deal_name -- 主经销商名称
|
||||
,sd.deal_name as src_deal_name -- 子经销商名称
|
||||
|
||||
-- p.spec, -- 规格
|
||||
|
||||
-- 合同金额
|
||||
-- 订单金额
|
||||
-- 回款金额
|
||||
-- 发货金额
|
||||
-- 发货件数
|
||||
-- 发货瓶数
|
||||
-- 实物库存
|
||||
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
bu_code
|
||||
,region_code
|
||||
,office_code
|
||||
,city_unit_code
|
||||
,deal_code
|
||||
,src_deal_code
|
||||
,product_code
|
||||
,province_code
|
||||
,city_code
|
||||
,CASE WHEN indi_type IN ('合同','合同计划')
|
||||
THEN (amt_bu + amt_region + amt_office + amt_city_unit + amt_dealer)
|
||||
ELSE 0 END AS ct_amt -- 合同金额
|
||||
,CASE WHEN indi_type IN ('订单','电商订单')
|
||||
THEN (amt_bu + amt_region + amt_office + amt_city_unit + amt_dealer)
|
||||
ELSE 0 END AS total_amt -- 订单金额
|
||||
,CASE WHEN indi_type IN ('回款','电商订单')
|
||||
THEN (amt_bu + amt_region + amt_office + amt_city_unit + amt_dealer)
|
||||
ELSE 0 END AS clc_amt -- 回款金额
|
||||
,CASE WHEN indi_type IN ('发货','费用发货','电商订单')
|
||||
THEN (amt_bu + amt_region + amt_office + amt_city_unit + amt_dealer)
|
||||
ELSE 0 END AS deli_amt --发货金额
|
||||
,CASE WHEN indi_type IN ('发货','费用发货','电商订单')
|
||||
THEN (num_bu + num_region + num_office + num_city_unit + num_dealer)
|
||||
ELSE 0 END AS total_num -- 发货瓶数
|
||||
-- 发货件数=瓶数/pack_base_num
|
||||
-- 发货瓶数?
|
||||
,CASE WHEN indi_type IN ('实物库存') -- 使用金额
|
||||
THEN (num_bu + num_region + num_office + num_city_unit + num_dealer)
|
||||
ELSE 0 END AS real_amt -- 实物库存
|
||||
-- 在途库存
|
||||
-- 实物库存
|
||||
-- 已填仓未下单
|
||||
-- 未下单往来余额
|
||||
-- 未发货
|
||||
-- 融资未填仓
|
||||
-- 费用余额
|
||||
|
||||
-- 其他库存
|
||||
FROM dm.dm_sal_indicator_day -- 销售种子指标按日汇总表
|
||||
WHERE indi_type NOT LIKE '%目标%'
|
||||
-- 统计日期
|
||||
AND stat_date >= '${CONCATENATE(sStart_date," 00:00:00")}'
|
||||
AND stat_date <= '${CONCATENATE(sEnd_date," 00:00:00")}'
|
||||
${if(len(sIndex) == 0,"","and indi_type IN ('"+sIndex+"')")}
|
||||
-- 事业部
|
||||
${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(sProduct) == 0,"","and product_code IN ('"+ sProduct +"')")}
|
||||
-- 产品线
|
||||
${if(len(sPl_name) == 0,"","and p.pl_name IN ('"+ sPl_name +"')")}
|
||||
-- 子主经销商
|
||||
${if(sSub_main == '2',if(len(sDeal) == 0,"","and deal_code IN ('"+ sDeal+"')"),if(len(sDeal) == 0,"","and src_deal_code IN ('"+ sDeal +"')"))}
|
||||
|
||||
)a
|
||||
left join dwr.dim_product p on a.product_code=p.product_code
|
||||
left join dwr.dim_department dmd on a.city_unit_code=dmd.dept_code
|
||||
left join dwr.dim_department bu on a.bu_code=bu.dept_code
|
||||
left join dwr.dim_department d on p.bu_code=d.dept_code
|
||||
left join dwr.dim_dealer deal on a.deal_code=deal.deal_code
|
||||
left join dwr.dim_dealer sd on a.src_deal_code=sd.deal_code
|
||||
left join dwr.dim_area pv on a.province_code=pv.town_code
|
||||
left join dwr.dim_area cit on a.city_code=cit.town_code
|
||||
left join sdi_xdata.mdm_dim_sorted st on a.region_code=st.sorted_value and st.sorted_type='大区'
|
||||
where exists (
|
||||
select
|
||||
1
|
||||
from
|
||||
dm.dm_bi_user_permisson
|
||||
where
|
||||
bi_user = '${fine_username}'
|
||||
and per_model IN ('all','sal')
|
||||
and (
|
||||
is_all = 1
|
||||
OR per_code = a.bu_code
|
||||
OR per_code = a.region_code
|
||||
OR per_code = a.office_code
|
||||
OR per_code = a.city_unit_code
|
||||
)
|
||||
)
|
||||
|
||||
-- 品项
|
||||
${if(len(sPi_name) == 0,"","and p.pi_name IN ('"+ sPi_name+"')")}
|
||||
-- 省
|
||||
${if(len(sProvince) == 0,"","and pv.province_name IN ('"+ sProvince+"')")}
|
||||
-- 市
|
||||
${if(len(sCity) == 0,"","and cit.city_name IN ('"+ sCity+"')")}
|
||||
|
||||
order by nvl(st.sorted_no,99)
|
||||
|
||||
-- SQL分页:
|
||||
-- limit ${pPage_rows} offset (${pJump_page}-1)*${pPage_rows}
|
||||
|
@ -1,5 +1,6 @@
|
||||
-- ======================================
|
||||
-- 销售指标月度汇总
|
||||
-- 2024-11-21: 需求调整,暂缓维护
|
||||
-- ======================================
|
||||
|
||||
|
||||
@ -78,7 +79,7 @@ from
|
||||
-- 产品
|
||||
${if(len(sProduct) == 0,"","and product_code IN ('"+ sProduct +"')")}
|
||||
-- 子主经销商
|
||||
${if(sIs_srcdeal == '2',if(len(sDeal) == 0,"","and deal_code IN ('"+ sDeal+"')"),if(len(sDeal) == 0,"","and src_deal_code IN ('"+ sDeal +"')"))}
|
||||
${if(sSub_main == '2',if(len(sDeal) == 0,"","and deal_code IN ('"+ sDeal+"')"),if(len(sDeal) == 0,"","and src_deal_code IN ('"+ sDeal +"')"))}
|
||||
)a
|
||||
left join dwr.dim_product p on a.product_code=p.product_code
|
||||
left join dwr.dim_department dmd on a.city_unit_code=dmd.dept_code
|
||||
@ -88,7 +89,23 @@ left join dwr.dim_dealer deal on a.deal_code=deal.deal_code
|
||||
left join dwr.dim_dealer sd on a.src_deal_code=sd.deal_code
|
||||
left join dwr.dim_area pv on a.province_code=pv.town_code
|
||||
left join dwr.dim_area cit on a.city_code=cit.town_code
|
||||
where 1 = 1
|
||||
left join sdi_xdata.mdm_dim_sorted st on a.region_code=st.sorted_value and st.sorted_type='大区'
|
||||
where exists (
|
||||
select
|
||||
1
|
||||
from
|
||||
dm.dm_bi_user_permisson
|
||||
where
|
||||
bi_user = '${fine_username}'
|
||||
and per_model IN ('all','sal')
|
||||
and (
|
||||
is_all = 1
|
||||
OR per_code = a.bu_code
|
||||
OR per_code = a.region_code
|
||||
OR per_code = a.office_code
|
||||
OR per_code = a.city_unit_code
|
||||
)
|
||||
)
|
||||
|
||||
-- 产品线
|
||||
${if(len(sPl_name) == 0,"","and p.pl_name IN ('"+ sPl_name +"')")}
|
||||
@ -126,8 +143,9 @@ group by to_char(a.stat_date,'yyyy'),
|
||||
p.bu_code,
|
||||
d.dept_name,
|
||||
p.spec,
|
||||
p.aroma_type
|
||||
p.aroma_type,st.sorted_no
|
||||
order by nvl(st.sorted_no,99)
|
||||
limit ${pPage_rows} offset (${pJump_page}-1)*${pPage_rows}
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('数据更新日期:',LEFT(MAX(update_time),19)) AS update_time FROM dm.dm_sal_indicator_day
|
||||
SELECT CONCAT('数据更新时间:',LEFT(MAX(update_time),19)) AS update_time FROM dm.dm_sal_indicator_day
|
||||
|
70
FineReport/销售主题/报表/首页.sql
Normal file
70
FineReport/销售主题/报表/首页.sql
Normal file
@ -0,0 +1,70 @@
|
||||
-- ======================================
|
||||
-- 报表上新
|
||||
-- ======================================
|
||||
|
||||
SELECT
|
||||
op1.entry_id AS "报表id",
|
||||
op2.displayname AS "报表名称",
|
||||
TO_CHAR(op1.create_time,'YYYY-MM-DD') AS "上新时间"
|
||||
FROM
|
||||
sdi_fine.input_fr_report_list op1
|
||||
LEFT JOIN sdi_fine.fine_authority_object op2 ON op1.entry_id = op2.id
|
||||
WHERE
|
||||
report_status = '0'
|
||||
-- AND STRING_TO_ARRAY(op1.role_list,',') && STRING_TO_ARRAY('${fine_role}',',')
|
||||
AND op1.create_time >= CURRENT_TIMESTAMP - INTERVAL '7 days'
|
||||
ORDER BY
|
||||
op1.create_time DESC
|
||||
|
||||
|
||||
-- ======================================
|
||||
-- 收藏目录表
|
||||
-- ======================================
|
||||
|
||||
-- 收藏目录表
|
||||
SELECT
|
||||
IF(LENGTH(LEFT(op3.path,POSITION('/' IN op3.path) - 1)) > 0,LEFT(op3.path,POSITION('/' IN op3.path) - 1),"其他") AS `所属根目录名称`,
|
||||
op3.path AS `报表全路径`,
|
||||
op1.id,
|
||||
op1.entryId AS `报表ID`,
|
||||
op1.userId AS `用户ID`,
|
||||
op2.realName AS `姓名`,
|
||||
op2.userName AS `用户名`,
|
||||
op3.displayName AS `报表名称`
|
||||
|
||||
FROM
|
||||
fine_favorite_entry op1
|
||||
JOIN fine_user op2 ON op1.userId = op2.id
|
||||
JOIN fine_authority_object op3 ON op1.entryId = op3.id
|
||||
WHERE
|
||||
op2.userName = '${fine_username}'
|
||||
-- 展示终端类型:此处需要再讨论一下PC及移动端定义
|
||||
AND op3.deviceType = 1
|
||||
-- 平台类型:此处只展示链接/FR报表/BI报表
|
||||
AND op3.expandType IN (5,102,201)
|
||||
-- AND IFNULL(LEFT(op3.path,POSITION('/' IN op3.path) - 1),"其他") = '${sDefaultFile}'
|
||||
|
||||
|
||||
-- ======================================
|
||||
-- 最近浏览
|
||||
-- ======================================
|
||||
|
||||
-- 近10天近30个目录
|
||||
SELECT
|
||||
op1.tname AS `报表全路径`,
|
||||
op2.id AS `报表ID`,
|
||||
SUBSTRING_INDEX(op2.displayName, '/', -1) AS `模版名称`,
|
||||
-- FROM_UNIXTIME(MAX(op1.time) / 1000,'%Y-%m-%d %H:%i:%s') AS `访问时间`
|
||||
FROM_UNIXTIME(MAX(op1.time) / 1000,'%Y-%m-%d') AS `访问时间`
|
||||
FROM
|
||||
logdb.fine_record_execute op1
|
||||
LEFT JOIN finedb.fine_authority_object op2 ON op1.tname = op2.path
|
||||
WHERE
|
||||
op1.username = (SELECT CONCAT(realName,'(',userName,')') AS username FROM finedb.fine_user WHERE userName = '${fine_username}')
|
||||
AND op1.time >= UNIX_TIMESTAMP(DATE_SUB(CURDATE(),INTERVAL 10 DAY)) * 1000
|
||||
GROUP BY
|
||||
op2.displayName,
|
||||
op2.id
|
||||
ORDER BY
|
||||
op1.time DESC
|
||||
LIMIT 30
|
Loading…
Reference in New Issue
Block a user