20230215_数据库过程_渠道业务清算过程
----2023-0131-清算过程
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_sja’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_sja as
select * from shzc.xc_qdcn_pgtx_qdtype a
where a.in_time = (
select max(a.in_time) from shzc.xc_qdcn_pgtx_qdtype a where a.in_time<to_date(’‘’||v_monsrh||‘’‘,’‘yyyymm’')) ';
EXECUTE IMMEDIATE (SQL_STRING);
----放号
SQL_STRING:=‘delete shzc.xc_qdcn_pgtx_qsqdtype_fhb a where a.cycle=’‘’||v_monsrq||‘’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_fhb
select a.servnumber,a.subsid,a.registerorgid,b.大类,a.createdate,to_char(createdate,’‘yyyymm’‘) cycle,a.status,a.statusdate,
a.prodid,a.prodname,a.jiazhi,a.五大渠道,a.是否活跃,a.是否拉新,
a.是否折后48,a.最后一次活跃时间,a.停机锁,a.是否新入网信用购,a.是否融合, a.是否业务融合, a.是否宽带融合,
a.关怀打折,a.折后价值,a.是否参与终端合约,a.话费合约_12月竞赛 话费合约竞赛,a.预存合约,a.是否开通宽带,
a.是否搭载收费权益产品,a.权益10元_12月竞赛 权益10元竞赛,a.直销员电话,a.recopid,a.oid,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from zhyw.shc_fanghao_’||v_monsrq||’ a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.registerorgid=b.渠道编码
and a.recopid=t.operid(+)
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_fhb d where d.subsid=a.subsid and d.oid=a.oid)
and to_char(a.createdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_fhc’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_fhc as
select a.*,nvl(b.status,’‘US20’') status_n
from shzc.xc_qdcn_pgtx_qsqdtype_fhb a,
(select b.subsid,b.status from zhyw.subscriber b ) b
where a.subsid=b.subsid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_fhs’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_fhs as
select ‘‘新入网’’ item,a.subsid,a.servnumber,a.createdate recdate,a.createdate startdate,a.registerorgid recorgid,a.recopid,prodname,a.大类,a.直销员电话,’‘新入网’’ type,
nvl(case when nvl(a.是否拉新,‘‘否’’)=‘‘是’’ and nvl(a.prodname,‘‘0’’) not like ‘’%副卡%‘’ then 2 end,1) 结算数,a.限定渠道,a.限定工号,a.oid,a.status_n
from shzc.xc_qdcn_pgtx_qsqdtype_fhc a
where a.status in (‘‘US10’’,‘‘US30’’)
and a.停机锁 in (‘‘正常在用’’,‘‘强制半停’’)
and a.是否活跃=1
and a.status_n<>‘‘US10’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_zh48s’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_zh48s as
select ‘‘折后48’’ item,a.subsid,a.servnumber,a.createdate recdate,a.createdate startdate,a.registerorgid recorgid,a.recopid,prodname,a.大类,a.直销员电话,’‘折后48’’ type,
nvl(case when nvl(a.是否折后48,0)=1 then round(a.折后价值/48,1) end,0)*
nvl(case when nvl(a.是否宽带融合,‘‘0’’)=‘‘1’’ or nvl(a.是否新入网信用购,‘‘0’’)=‘‘1’’ then 1.2 end,1)*
nvl(case when a.预存合约 is not null or nvl(a.话费合约竞赛,‘‘0’’)=‘‘1’’ or nvl(a.是否开通宽带,‘‘0’’)=‘‘1’’ or nvl(a.是否搭载收费权益产品,‘‘0’’)=‘‘1’’
or nvl(a.权益10元竞赛,‘‘0’’)=‘‘1’’ or nvl(a.是否参与终端合约,‘‘0’’)=‘‘1’’ then 1 end,0 ) 结算数,a.限定渠道,a.限定工号,a.oid,a.status_n
from shzc.xc_qdcn_pgtx_qsqdtype_fhc a
where a.status in (‘‘US10’’,‘‘US30’’)
and a.停机锁 in (‘‘正常在用’’,‘‘强制半停’’)
and a.status_n<>‘‘US10’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_xhb
select distinct a.所属区县名称,a1.unit_id,a1.unit_name,a.PRODID_FW,
a.grid_name, a.subsid,a.servnumber,zhyw.getprodname(a.prodid_fw) prodid_fwm, a.leixing, a.prodnamezt,
a.startdate,a.enddate,a.所属乡镇_街道名称, a.所属小区_学校_自然村,
a.代理商,a.带宽限制,a.网络设备情况,replace(a.联系人姓名,’‘1’‘,’‘I’') 联系人姓名,
a.lx_priv, a.PRIVNAME_PRIV, a.PRIV_START, a.PRIV_END,
a.lx_rh, a.PRIVNAME_RH, a.RH_START, a.RH_END,
a.PRIVNAME_YC, a.YC_START, a.YC_END,
a.applyoperidfw, a.recorgid, k12.orgname,a.代理商a, a.recdate , a.canceloperidfw,
c.privname, c.privname_startdate, c.privname_enddate,
a.FEE FEEa, a.RECEIVEDATE RECEIVEDATEa, a.dictname dictnamea, a.statusdate statusdatea,
c.FEE FEEc, c.RECEIVEDATE RECEIVEDATEc, c.dictname dictnamec, c.statusdate statusdatec,
a.ont类型,
a.ont_privname, f1.dictname, g.反馈营销片区, a.客户经理,
case when k1.f_servnumber is not null then ‘‘搭载副卡’’ end 搭载副卡,k1.f_subsid,k1.recdate recdatek1,k1.recopid,
k6.privname privnamek6,k6.jiazhi,
k7.privname privnamek7, k7.xf_privname,k7.xf_start xf_start,k7.xf_end xf_end,k7.xf_operid ,
case when k8.subsid is not null then ‘‘可开副卡’’ end 可开副卡,
k9.item,k9.dc,
k10.flow_m,
case when k11.status=‘‘stcmNml’’ then ‘‘开通家庭网’’ end flag_fam,
k13.cancel_reason,
k14.privname 宽带资费,
k15.privname 宽带优惠,
case when c.subsid is not null and nvl(c.enddate,sysdate+10000)>sysdate then ‘‘1’’ end flag_htv,
case when k16.in_subsid is not null then ‘‘同址换号’’ end flag_huanhao ,
case when k17.user_id is not null then ‘‘c类宽带’’ end c类 ,
k12.unit_name unit_namek12,
case when k18.AFFECTTYPE=2 then ‘‘当月生效’’ when k18.AFFECTTYPE=3 then ‘‘次月生效’’ else to_char(k18.affecttype,0) end 生效月份,
zhixiao_hm ,k19.zhixiao_name ,a.APPLYOID
from zhyw.zhai_yxkd_priv_subs_‘||v_monsrq||’ a,
zhyw.qcy_tmp_unit_grid a1,
zhyw.zb_yxkd_county b ,
zhyw.zhai_htv_subsxin c ,
ZHYW.zhht_kd_om_order1 F, (select * from zhyw.dict_item m where groupid=‘‘US’’) f1, ZHYW.ZHAI_PQ_KD_DIM g,
zhyw.zb_wnfk_subs k1,
zhyw.zb_subs_tc_jiazhi k6,
zhyw.zb_yxkd_xufei_subs k7,
zhyw.wanneng_fk_mb_mx k8 ,
zhyw.zb_kd_aijia_qunzu_subs k9,
zhyw.zb_yxkd_flow_‘||v_monsrq||’ k10,
zhyw.ZB_FAM_SUBS_‘||v_last_day||’ k11,
zhyw.shc_organization k12,
zhyw.zb_yxkd_cancel_reason_subs k13,
(select item,subsid,privid,privname,a.startdate,a.enddate
from zhyw.qcy_tmp_kd_prv_2 a
where item=‘‘产品资费’’ and
nvl(enddate,sysdate+10000)>sysdate-1
) k14,
(select subsid,privid,privname,startdate,enddate
from zhyw.qcy_tmp_kd_photo_2
where nvl(enddate,sysdate+10000)>sysdate-1
) k15, —宽带优惠到期
zhyw.ZB_YXKD_HUANHAO_SUBS k16,
zibo.d_notbroadband_user_ds k17,
zhyw.SHC_SUBS_PRODUCT k18,
zhyw.cs_order_contact k19
where a.所属区县=b.所属区县(+) and
a.grid_id=a1.grid_id(+) and
a.subsid=c.subsid(+) and a.servnumber=F.acc_num(+) AND
a.status=f1.dictid(+) and nvl(a.订单状态,‘‘0’’)<>‘‘已撤单’’ and nvl(a.lx_priv,‘‘0’’)<>‘‘铁通天’’
and a.所属小区_学校_自然村=g.boss小区编码(+)
and a.subsid=k1.main_subsid(+) and
a.subsid=k6.subsid(+) and
a.subsid=k7.subsid(+) and
a.subsid=k8.subsid(+) and
a.subsid=k9.subsid(+) and
a.subsid=k10.user_id(+) and
a.subsid=k11.subsid(+) and
a.recorgid=k12.orgid(+) and
a.subsid=k13.subsid(+) and
a.subsid=k14.subsid(+) and
a.subsid=k15.subsid(+) and
a.subsid=k16.in_subsid(+) and
a.subsid=k17.user_id(+) and
a.subsid=k18.subsid(+) and
a.prodid_fw=k18.prodid(+) and
a.applyoid=k19.oid(+)
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_xhb d where d.subsid=a.subsid and d.applyoid=a.APPLYOID)
and (to_char(a.recdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’
or to_char(a.startdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’) ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_xhc’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_xhc as
select a.subsid,a.servnumber,a.prodid_fw,a.startdate,a.enddate,a.带宽限制,a.recorgid,b.大类,
a.recdate,a.dictname,a.jiazhi,a.可开副卡,a.item,a.dc,a.flag_htv,’‘宽带’’ type,a.zhixiao_hm,a.applyoperidfw,a.APPLYOID,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from shzc.xc_qdcn_pgtx_qsqdtype_xhb a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.recorgid=b.渠道编码
and a.applyoperidfw=t.operid(+)';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_xhd
select A.所属区县名称, a.servnumber,a.subsid, a.startdate,a.enddate,a.STARTDATE_FW, a.ENDDATE_FW, a.ORGNAME, a.APPLYOPERID, d.UNIT_NAME, a.CANCELOPERID, a.RECDATE,
a.所属小区_学校_自然村, a.recorgid, a.代理商, a.联系电话, a.联系人姓名, a.PRIVNAME, a.PRIVNAME_STARTDATE, a.PRIVNAME_ENDDATE,a.applyoid,
a.接入费, a.赠送2个月, a.赠送2个月STARTDATE, a.赠送2个月ENDDATE, a.预存, a.预存STARTDATE, a.预存ENDDATE, a.FEE, a.RECEIVEDATE, a.dictname, a.statusdate,
a.所属区县名称宽带, a.宽带开通时间, a.宽带结束时间, a.代理商宽带, a.机顶盒厂家, a.是否4k, a.resid, settleday,a.notes,
c.canceldate,c.canceloperid canceloperidc,
b1.zhixiao_hm,b1.zhixiao_name ,a.oid
from zhyw.zhai_htv_subsxin a,
zhyw.zb_yxkd_county b,
zhyw.zb_htv_service_cancel c,
zibo.dw_grid_zone_ds_old d ,
zhyw.cs_order_contact b1
where a.所属区县名称=b.所属区县名称(+)
and a.subsid=c.subsid (+)
and a.applyoid=b1.oid(+)
and a.所属小区_学校_自然村=d.zone_id(+)
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_xhd d where d.subsid=a.subsid and d.oid=a.oid)
and (to_char(a.recdate,’‘yyyymm’‘)=’‘’||v_monsrq||‘’’
or to_char(a.startdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’)';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_xhe’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_xhe as
select a.subsid,a.servnumber,a.privname,a.startdate,a.enddate,’‘0’’ 带宽限制,a.recorgid,b.大类,
a.recdate,a.dictname,0 jiazhi,‘‘0’’ 可开副卡,‘‘0’’ item,‘‘0’’ dc,‘‘0’‘flag_htv,’‘高清’’ type,a.zhixiao_hm,a.applyoperid,a.oid,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from shzc.xc_qdcn_pgtx_qsqdtype_xhd a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.recorgid=b.渠道编码
and a.applyoperid=t.operid(+)';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_xhce’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_xhce as
select distinct a.,nvl(case when to_char(a.startdate,‘‘yyyymm’’)<‘’‘||v_monsr||’‘’ then ‘‘生效’’ end,‘‘受理’’) 生效 from shzc.xc_qdcn_pgtx_qsqdtype_xhc a
union all
select distinct a.,nvl(case when to_char(a.startdate,’‘yyyymm’‘)<’‘’||v_monsr||‘’’ then ‘‘生效’’ end,‘‘受理’’) 生效 from shzc.xc_qdcn_pgtx_qsqdtype_xhe a ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_xhcf’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_xhcf as
select a.*,nvl(nvl(b.status,d.status),’‘US20’‘) status_n
from shzc.xc_qdcn_pgtx_qsqdtype_xhce a,
(select b.subsid,b.status from zhyw.subscriber b) b,
zhyw.subscriber d
where a.subsid=b.subsid(+)
and a.subsid=d.subsid(+)’;
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_xhs’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_xhs as
select a.type item,a.subsid,a.servnumber,a.recdate,a.startdate,a.recorgid,a.applyoperidfw recopid,prodid_fw,a.大类,a.zhixiao_hm 直销员电话,’‘线盒新增’‘type,
1 结算数,a.限定渠道,a.限定工号,a.APPLYOID,a.状态 from
(select a.,‘‘受理未生效’’ 状态 from shzc.xc_qdcn_pgtx_qsqdtype_xhcf a where a.生效=‘‘受理’’ and a.startdate>to_date(‘’‘||v_monsrh||’‘’,‘‘yyyymm’’)
union all
select a.,’‘生效后停机’’ from shzc.xc_qdcn_pgtx_qsqdtype_xhcf a where a.生效=‘‘生效’’ and a.status_n<>‘‘US10’’) a’;
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_stb
select distinct a.qx,a.item,a.subsid,a.servnumber,a.recdate,a.recopid,a.recorgid,a.orgname,
case when substr( a.notes,instr(a.notes,’‘1’‘,1),11) in (select servnumber from zhyw.subscriber ) then ‘’***’’ else a.notes end notes,
case when a.recdefid=‘‘WiredDevup’’ then ‘‘家庭业务设备升级’’ else a.recdefid end 家庭业务设备升级, case when b.user_id is not null then ‘‘目标客户’’ end 目标客户,
a.privname ,a.rec_type,b.user_flag,a.zone_id,a.grid_name ,a.oid
From zhyw.zb_chg_equ_subs a,
zhyw.zb_chg_equ_photo b
where a.subsid=b.user_id(+)
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_stb d where d.subsid=a.subsid and d.oid=a.oid)
and to_char(a.recdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_stc’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_stc as
select a.*,b.大类,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from shzc.xc_qdcn_pgtx_qsqdtype_stb a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.recorgid=b.渠道编码
and a.recopid=t.operid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_std
select distinct a.rec_qx,a.item,b.grid_id,b.grid_name,a.subsid, a.servnumber, a.unit_name,a.pkg_prod,a.pkg_name, a.privid,a.privname,
b3.attrvalue,b3.res_type_name, b3.flag,a.recorgid,
a.recdate,a.startdate,a.enddate,c.orgname,a.applyoperid, b1.notes,
a.是否自办渠道,a.渠道经理,
a.kd_start,a.kd_end,
a.createdate ,a.statusname, a.statusdate,a.tc_privname,a.jiazhi,
a.zone_id,a.zone_name,
b4.item 权益,c.unit_name unit_namec,a.flag_midhigh,
zhixiao_hm,b5.zhixiao_name ,a.applyoid
from zhyw.zb_yxkd_sanjiantao_subs a,
zhyw.zb_yyy_unit b,
zhyw.shc_organization c,
zhyw.shc_reception b1,
zhyw.zb_yxkd_anfang_mac b3,
(select * from zhyw.zb_yxkd_sanjiantao_subs
where nvl(enddate,sysdate+10000)>startdate and
nvl(enddate,sysdate+10000)>sysdate-1 and item like upper(’‘%宽带权益%’‘) )b4,
zhyw.cs_order_contact b5
where a.applyoperid=b.operid(+) and
a.recorgid=c.orgid(+) and
a.applyoid=b1.oid(+) and
a.applyoid=b3.applyoid(+) and
a.privid=b3.privid(+) and
a.subsid=b4.subsid(+) and
a.applyoid=b5.oid(+) and
a.item like ‘’%安防%’’
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_std d where d.subsid=a.subsid and d.applyoid=a.applyoid)
and to_char(a.startdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_ste’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_ste as
select a.*,b.大类,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from shzc.xc_qdcn_pgtx_qsqdtype_std a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.recorgid=b.渠道编码
and a.applyoperid=t.operid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_stf
select distinct a.rec_qx,a.item,b.grid_id,b.grid_name,a.servnumber,a.subsid, a.unit_name,a.pkg_prod,a.pkg_name, a.privid,a.privname,
a1.note , a.recdate,a.startdate,a.enddate,c.orgname,a.applyoperid, b1.notes,
a.是否自办渠道,a.渠道经理,a.recorgid,
a.kd_start,a.kd_end,
a.createdate ,a.statusname, a.statusdate,a.tc_privname,a.jiazhi,
a.zone_id,a.zone_name,
case when b2.recoid is not null then ‘‘上门收费’’ end 上门收费,
to_char(b2.fee/100) fee,
to_char(b2.paydate,’‘yyyymmdd’') paydate,
c.unit_name unit_namec,
b3.res_type_name, b3.attrvalue ,
b4. lastonline,
to_char(a1.dc) dc,a1.售价,
case when b5.AFFECTTYPE=2 then ‘‘当月生效’’ when b5.AFFECTTYPE=3 then ‘‘次月生效’’ else to_char(b5.affecttype,0) end 生效月份,
a.flag_midhigh ,zhixiao_hm,b6.zhixiao_name ,a.applyoid
from zhyw.zb_yxkd_sanjiantao_subs a,(select *from qcy.qcy_yxkd_sanjiantao_priv where item like ''%路由器%'' and note like ''%W%'') a1,zhyw.zb_yyy_unit b,zhyw.shc_organization c,zhyw.shc_reception b1,zhyw.zb_door_fee_rec B2,(select * from zhyw.zb_yxkd_anfang_mac where item=''路由器'') b3,(select product_no, to_char(lastonline_date,''yyyymmdd'') lastonlineFrom zibo.d_luyou_equipment_naguan_dt@zibo) b4,zhyw.SHC_SUBS_PRODUCT b5,zhyw.cs_order_contact b6 where a.applyoperid=b.operid(+) anda.recorgid=c.orgid(+) anda.applyoid=b1.oid(+) anda.privid=a1.privid(+) anda.applyoid=b2.recoid(+) anda.applyoid=b3.applyoid(+) anda.servnumber=b4.product_no(+) anda.subsid=b5.subsid(+) anda.pkg_prod=b5.prodid(+) anda.applyoid=b6.oid(+) and a.item=''路由器'' and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_stf d where d.subsid=a.subsid and d.applyoid=a.applyoid)and to_char(a.startdate,''yyyymm'')='''||v_monsrq||''' ';EXECUTE IMMEDIATE (SQL_STRING);commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_stg’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_stg as
select a.*,b.大类 ,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from shzc.xc_qdcn_pgtx_qsqdtype_stf a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.recorgid=b.渠道编码
and a.applyoperid=t.operid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_sth
select distinct rec_qx,a.item,b.grid_id,b.grid_name, a.servnumber,a.subsid, a.unit_name,
a.pkg_prod,a.pkg_name, a.privid,a.privname, b3.dc,b3.note, a.recdate,
a.startdate,a.enddate,c.orgname,a.applyoperid, b1.notes,
a.是否自办渠道,a.渠道经理,a.recorgid,
tsbxy_priv,tsbxy_start,tsbxy_end,
kd_start,kd_end,
a.createdate ,a.statusname, a.statusdate,a.tc_privname,a.jiazhi,
a.zone_id,a.zone_name,
case when b2.subsid is not null then ‘‘有优惠’’ end flag,
c.unit_name unit_namec,a.flag_midhigh,zhixiao_hm,b4.zhixiao_name ,a.applyoid
from zhyw.zb_yxkd_sanjiantao_subs a,
zhyw.zb_yyy_unit b,
zhyw.shc_organization c,
zhyw.shc_reception b1,
( select *from zhyw.zb_yxkd_priv_monitor_subs
where send_priv=’‘PRIV20210608985.999’’ and
nvl(send_end,sysdate+36)>send_start and
nvl(send_end,sysdate+36)>sysdate-1) b2,
qcy.qcy_yxkd_sanjiantao_priv b3,
zhyw.cs_order_contact b4
where a.applyoperid=b.operid(+) and
a.recorgid=c.orgid(+) and
a.applyoid=b1.oid(+) and
a.subsid=b2.subsid(+) and
a.privid=b3.privid(+) and
a.applyoid=b4.oid(+)
and a.item=‘‘提速包’’
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_sth d where d.subsid=a.subsid and d.applyoid=a.applyoid)
and to_char(a.recdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_sti’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_sti as
select a.*,b.大类,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from shzc.xc_qdcn_pgtx_qsqdtype_sth a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.recorgid=b.渠道编码
and a.applyoperid=t.operid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_stj
select distinct a.rec_qx,a.item,b.grid_id,b.grid_name, a.servnumber,a.subsid, a.unit_name,a.pkg_prod,a.pkg_name,
a.privid,a.privname, a.recdate,a.startdate,a.enddate,c.orgname,a.applyoperid, b1.notes,
a.是否自办渠道,a.渠道经理,a.recorgid,
a.kd_start,a.kd_end,
a.createdate ,a.statusname, a.statusdate,a.tc_privname,a.jiazhi,
a.zone_id,a.zone_name,
b2.item item2,c.unit_name unit_namec,a.flag_midhigh,zhixiao_hm,b3.zhixiao_name,a.applyoid
from zhyw.zb_yxkd_sanjiantao_subs a,
zhyw.zb_yyy_unit b,
zhyw.shc_organization c,
zhyw.shc_reception b1,
(select * from zhyw.zb_yxkd_sanjiantao_subs where nvl(enddate,sysdate+10000)>startdate
and nvl(enddate,sysdate+10000)>sysdate-1 and item like upper(’‘%家庭安防%’’ ) )b2,
zhyw.cs_order_contact b3
where a.applyoperid=b.operid(+) and
a.recorgid=c.orgid(+) and
a.applyoid=b1.oid(+) and
a.subsid=b2.subsid(+) and
a.applyoid=b3.oid(+)
and a.item=‘‘宽带权益包’’
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_stj d where d.subsid=a.subsid and d.applyoid=a.applyoid)
and to_char(a.startdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_stk’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_stk as
select a.*,b.大类,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from shzc.xc_qdcn_pgtx_qsqdtype_stj a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.recorgid=b.渠道编码
and a.applyoperid=t.operid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_stl
select a.prod_type,a.orgid,b.大类,a.RECOPID,a.servnumber,a.subsid,a.recdate,a.prodid,a.prodname,
a.privid,a.privname,a.oid,a.受理方式,a.鉴权,a.业务类型,
to_date(a.startdate,’‘yyyymmdd hh24:mi:ss’‘) startdate,
to_date(a.enddate,’‘yyyymmdd hh24:mi:ss’‘) enddate,
当前最新状态,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from zhyw.report_mx_month_’||v_monsrq||‘_new a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.orgid=b.渠道编码
and a.RECOPID=t.operid(+)
and a.prod_type =’‘千兆宽带’’
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_stl d where d.subsid=a.subsid and d.oid=a.oid)
and to_char(a.recdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_stm’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_stm as
select a.*, nvl(b.num,0) 结算数
from shzc.xc_qdcn_pgtx_qsqdtype_stl a,
shzc.xc_qdcn_pgtx_qdtype_privnum b
where a.privid=b.privid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=’ insert into shzc.xc_qdcn_pgtx_qsqdtype_stn
select distinct a.county_id,b2.unit_name,rec_qx,k.grid_name, a.servnumber,a.subsid,bizcode,vc_bizname,applyoperid,dictname,
a.recdate,b1.orgname,flag_nb,price,a.recorgid,a.orgname orgnamea,
startdate,enddate ,hm_status,所属区县名称,flag_red,flag_app, case when JF>=1600 then ‘‘可兑换’’ else ‘‘否’’ end 可兑换,
sp_name,sp_start,sp_end,sp_canceloperid ,
htv_start ,htv_end,
kd_start ,kd_end,
KD_QX, FLAG_XF, XF_START, XF_END, XF_PRIV ,xf_price,XF_OPERID, XF_QX, XF_ORG,
db_time 点播播放时长,
tz_time 赛特斯探针原始收视时长,
zmdj_cs 桌面点击次数,
hy_flag 用户当月是否活跃,
b3.playtime_xd_m 有效播放时长_分钟,
b4.note,a.tc_priv,a.jiazhi,FLAG_MIDHIGH ,
b5.zhixiao_hm,b5.zhixiao_name ,a.applyoid
from zhyw.zb_htv_spservice_subs a,
zhyw.zb_yyy_unit k,
zibo.DW_MBH_USER_HY_FLAG_‘||v_monsrq||’ a1 ,
( select b.orgname,a.oid from zhyw.shc_reception a, zhyw.organization b
where a.recorgid=b.orgid(+)
) b1,
zhyw.zb_grid_subs b2 ,
( select product_no,sum(playtime_xd_m ) playtime_xd_m
from zibo.DW_MBH_USER_ANDTV_SPLX_DM
where playtime_xd_m>0.05 and to_char(op_time,‘‘yyyymmdd’’)=(select to_char(max(op_time),‘‘yyyymmdd’’) from zibo.DW_MBH_USER_ANDTV_SPLX_DM a )
group by product_no ) b3,
(select *From qcy.qcy_htv_nb_priv where note=‘‘接盘优惠’’)b4,
zhyw.cs_order_contact b5
where a.applyoperid=k.operid(+) and
a.subsid=a1.user_id(+) and
a.applyoid=b1.oid(+) and
a.subsid=b2.subsid(+) and
a.servnumber=b3.product_No(+) and
a.bizcode=b4.privid(+) and
a.applyoid=b5.oid(+)
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_stn d where d.subsid=a.subsid and d.applyoid=a.applyoid)
and to_char(a.startdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_sto’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_sto as
select a.*,b.大类,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from shzc.xc_qdcn_pgtx_qsqdtype_stn a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.recorgid=b.渠道编码
and a.applyoperid=t.operid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_stp’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_stp as
select a.item,a.subsid,a.servnumber,a.recdate,a.recdate startdate,a.recorgid,a.recopid,a.家庭业务设备升级,a.大类,’‘0’’ 直销员电话,
‘‘光猫升级’’ type,1 预结算数,1 考核停机,a.限定渠道,a.限定工号,a.oid
from shzc.xc_qdcn_pgtx_qsqdtype_stc a where a.限定渠道+a.限定工号>0
union all
select a.item,a.subsid,a.servnumber,a.recdate,a.startdate,a.recorgid,a.applyoperid,a.pkg_name,a.大类,a.zhixiao_hm,
‘‘家庭安防’’ type,2 预结算数,1 考核停机,a.限定渠道,a.限定工号,a.applyoid
from shzc.xc_qdcn_pgtx_qsqdtype_ste a where a.限定渠道+a.限定工号>0
union all
–宽带权益包
select a.item,a.subsid,a.servnumber,a.recdate,a.startdate,a.recorgid,a.applyoperid,a.pkg_name,a.大类,a.zhixiao_hm,
‘‘宽带权益包’’ type,1 预结算数,1 考核停机,a.限定渠道,a.限定工号,a.applyoid
from shzc.xc_qdcn_pgtx_qsqdtype_stk a where a.限定渠道+a.限定工号>0
union all
–路由器
select a.item,a.subsid,a.servnumber,a.recdate,a.startdate,a.recorgid,a.applyoperid,a.note||‘’‘’||a.售价,a.大类,a.zhixiao_hm,‘‘路由器’’ type,
round(nvl(case when upper(a.note) like ‘’%WIFI5%‘’ then 199/120 end,269/120),1) 预结算数,1 考核停机,a.限定渠道,a.限定工号,a.applyoid
from shzc.xc_qdcn_pgtx_qsqdtype_stg a where a.限定渠道+a.限定工号>0 and (upper(a.note) like ‘’%WIFI6%‘’ or upper(a.note) like ‘’%WIFI5%‘’)
union all
–提速包
select a.item,a.subsid,a.servnumber,a.recdate,a.recdate startdate,a.recorgid,a.APPLYOPERID,a.privname||‘’‘’||to_char(nvl(b.num,0)) pkg_name,
a.大类,a.zhixiao_hm,‘‘提速包’’ type,round(nvl(b.num,0)/10,1) 预结算数 ,1 考核停机,a.限定渠道,a.限定工号,a.applyoid
from shzc.xc_qdcn_pgtx_qsqdtype_sti a,
shzc.xc_qdcn_pgtx_qdtype_tsbnum b
where a.限定渠道+a.限定工号>0 and a.privid=b.privid(+)
union all
–千兆宽带
select a.prod_type,a.subsid,a.servnumber,a.recdate,a.recdate,a.orgid,a.recopid,a.prodname,a.大类,‘‘0’’,
‘‘千兆宽带’’ type,a.结算数 预结算数,0 考核停机,a.限定渠道,a.限定工号,a.oid
from shzc.xc_qdcn_pgtx_qsqdtype_stm a where a.限定渠道+a.限定工号>0
union all
–魔百和点播明细 表头价格取10、20、19.9、-5,-5统一替换为-7。渠道量求和/10
select ‘‘魔百和点播’’ prod_type,a.subsid,a.servnumber,a.recdate,a.startdate,a.recorgid,a.applyoperid,a.vc_bizname,a.大类,a.zhixiao_hm,‘‘魔百和点播’’ type,
round(a.price/10,1) 预结算数,0 考核停机,a.限定渠道,a.限定工号,a.applyoid
from shzc.xc_qdcn_pgtx_qsqdtype_sto a where a.限定渠道+a.限定工号>0
and a.price in (10,20,19.9,-5,-7) ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_stq’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_stq as
select a.*,nvl(nvl(b.status,d.status),’‘US20’') status_n
from shzc.xc_qdcn_pgtx_qsqdtype_stp a,
(select b.subsid,b.status from zhyw.subscriber b) b,
zhyw.subscriber d
where a.subsid=b.subsid(+)
and a.subsid=d.subsid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_sts’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_sts as
select a.ITEM, a.SUBSID, a.SERVNUMBER, a.RECDATE, a.startdate, a.RECORGID, a.RECOPID, a.家庭业务设备升级, a.大类, a.直销员电话, a.TYPE,
a.预结算数 结算数, 限定渠道, 限定工号,a.oid,a.status_n
from shzc.xc_qdcn_pgtx_qsqdtype_stq a where a.status_n<>’‘US10’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_qyb
select a.*,b.大类,’‘0’’ 直销员电话,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from zhyw.zjf_zxhy_mmx_‘||v_monsrq||’ a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.发展_渠道编码=b.渠道编码
and a.APPLYOPERID=t.operid(+)
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_qyb d where d.subsid=a.subsid and d.applyoid=a.applyoid)
and to_char(a.发展_考核时间,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_qyc
select a.prod_type,a.orgid,b.大类,a.RECOPID,a.servnumber,a.subsid,a.recdate,a.prodid,a.prodname,
a.privid,a.privname,a.oid,a.受理方式,a.鉴权,a.业务类型,
to_date(a.startdate,’‘yyyymmdd hh24:mi:ss’‘) startdate,
to_date(a.enddate,’‘yyyymmdd hh24:mi:ss’‘) enddate,
当前最新状态,’‘0’’ 直销员电话,
nvl(case when b.渠道编码 is not null then 1 end,0) 限定渠道,
nvl(case when t.operid is not null then 1 end,0) 限定工号
from zhyw.report_mx_month_‘||v_monsrq||’_new a,
shzc.xc_qdcn_pgtx_qsqdtype_sja b,
shzc.xc_qdcn_pgtx_opertype t
where a.orgid=b.渠道编码
and a.RECOPID=t.operid(+)
and a.prod_type =‘‘视频彩铃’’
and not exists ( select 1 from shzc.xc_qdcn_pgtx_qsqdtype_qyc d where d.subsid=a.subsid and d.oid=a.oid)
and to_char(a.recdate,‘‘yyyymm’’)=‘’‘||v_monsrq||’‘’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qyd’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_qyd as
select a.*,round(nvl(b.num,0),1) 结算数
from shzc.xc_qdcn_pgtx_qsqdtype_qyc a,
shzc.xc_qdcn_pgtx_qdtype_spclnum b
where a.prodid=b.privid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qye’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_qye as
select a.主指标 prod_type,a.subsid,a.servnumber,a.发展_受理时间 recdate,a.发展_考核时间 startdate,
a.发展_渠道编码 recorgid,a.applyoperid,a.privname,a.大类,a.直销员电话,’‘权益产品’’ type,a.折算 结算数,a.限定渠道,a.限定工号,a.applyoid,a.prodid,a.privid
from shzc.xc_qdcn_pgtx_qsqdtype_qyb a where a.折算 >= 0.3
union all
select a.prod_type,a.subsid,a.servnumber,a.recdate,a.startdate,a.orgid,a.recopid,a.prodname,a.大类,a.直销员电话,‘‘视频彩铃’’ type,
a.结算数,a.限定渠道,a.限定工号,a.oid,a.prodid,a.privid
from shzc.xc_qdcn_pgtx_qsqdtype_qyd a ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qyf’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_qyf as
select a.,row_number() over (partition by a.PROD_TYPE, SUBSID,APPLYOID, PRODID, PRIVID order by nvl(a.ENDDATE,sysdate+9999) desc ) 排名
from
(select distinct a.,b.enddate from shzc.xc_qdcn_pgtx_qsqdtype_qye a,
zhyw.subs_privilege b
where nvl(a.privid,’’ ‘’) <>‘’ ‘’
and a.privid=b.privid(+)
and a.applyoid=b.applyoid(+)
union all
select distinct a.*,b.enddate from shzc.xc_qdcn_pgtx_qsqdtype_qye a,
zhyw.subs_privilege b
where nvl(a.privid,‘’ ‘’) =‘’ ‘’
and a.prodid=b.prodid(+)
and a.applyoid=b.applyoid(+)) a ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qyg’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_qyg as
select * from shzc.xc_qdcn_pgtx_qsqdtype_qyf a
where a.排名=1 ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qyh’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_qyh as
select a.*,nvl(nvl(b.status,d.status),’‘US20’') status_n
from shzc.xc_qdcn_pgtx_qsqdtype_qyg a,
(select b.subsid,b.status from zhyw.subscriber b) b,
zhyw.subscriber d
where a.subsid=b.subsid(+)
and a.subsid=d.subsid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qyi’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_qyi as
select * from shzc.xc_qdcn_pgtx_qsqdtype_qyh a
where a.status_n<>’‘US10’’
or nvl(a.enddate,sysdate+9999)<=to_date(‘’‘||v_monsrh||’‘’,‘‘yyyymm’’) ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qys’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_qys as
select PROD_TYPE, SUBSID, SERVNUMBER, RECDATE, STARTDATE, RECORGID, APPLYOPERID, PRIVNAME, 大类, 直销员电话, TYPE, 结算数, 限定渠道, 限定工号, APPLYOID,
nvl(case when a.status_n<>’‘US10’’ then ‘‘用户停机’’ end,‘‘优惠结束’’) status_n
from shzc.xc_qdcn_pgtx_qsqdtype_qyi a ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_mxb’),‘SHZC’);
SQL_STRING:='create table shzc.xc_qdcn_pgtx_qsqdtype_mxb as
select a.item,
to_char(a.subsid) subsid,
a.servnumber,
a.recdate,
a.startdate,
a.recorgid,
a.recopid,
a.prodname,
a.大类,
a.直销员电话,
a.type,
a.结算数,
a.限定渠道,
a.限定工号,
a.oid,a.status_n
from shzc.xc_qdcn_pgtx_qsqdtype_fhs a
union all
select b.item,
to_char(b.subsid),
b.servnumber,
b.recdate,
b.startdate,
b.recorgid,
b.recopid,
b.prodname,
b.大类,
b.直销员电话,
b.type,
b.结算数,
b.限定渠道,
b.限定工号,
b.oid,b.status_n
from shzc.xc_qdcn_pgtx_qsqdtype_zh48s b
union all
select f.item,
to_char(f.subsid),
f.servnumber,
f.recdate,
f.startdate,
f.recorgid,
f.recopid,
f.prodid_fw,
f.大类,
f.直销员电话,
f.type,
f.结算数,
f.限定渠道,
f.限定工号,
f.applyoid,f.状态
from shzc.xc_qdcn_pgtx_qsqdtype_xhs f
union all
select g.item,
to_char(g.subsid),
g.servnumber,
g.recdate,
g.startdate,
g.recorgid,
g.recopid,
g.家庭业务设备升级,
g.大类,
g.直销员电话,
g.type,
g.结算数,
g.限定渠道,
g.限定工号,
g.oid,g.status_n
from shzc.xc_qdcn_pgtx_qsqdtype_sts g
union all
select h.prod_type,
to_char(h.subsid),
h.servnumber,
h.recdate,
h.startdate,
h.recorgid,
h.applyoperid,
h.privname,
h.大类,
h.直销员电话,
h.type,
h.结算数,
h.限定渠道,
h.限定工号,
h.applyoid,h.status_n
from shzc.xc_qdcn_pgtx_qsqdtype_qys h ';
EXECUTE IMMEDIATE (SQL_STRING);
----每月存档
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_mxb_’||v_monsrq),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_mxb_’||v_monsrq||’ as
select * from shzc.xc_qdcn_pgtx_qsqdtype_mxb ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘delete shzc.xc_qdcn_pgtx_qsqdtype_mx_bdcd where cycle = ‘’’||v_monsrq||‘’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
COMMIT;
------核减数据汇总,11月已经处理的就不再处理,12月开始只核减之前计算过的。
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_mx_bdcd
select a.*,’‘’||v_monsrq||‘’’ cycle from shzc.xc_qdcn_pgtx_qsqdtype_mxb_‘||v_monsrq||’ a
where not exists (select 1 from shzc.xc_qdcn_pgtx_qsqdtype_mx_bdcd t
where t.item=a.item
and t.subsid=a.subsid
and t.startdate=a.startdate
and t.type=a.type
and t.oid=a.oid)
and to_char(a.startdate,‘‘yyyymm’’)=‘‘2022’’||‘‘11’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
COMMIT;
----徐策计算明细,202212之后的计算范围内的。
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_jsmx_bd
select distinct a.item,a.subsid,a.startdate,a.type,a.结算数,a.oid from shzc.xc_qdcn_pgtx_qdtype_mxb_’||v_monsrq||’ a
where not exists (select 1 from shzc.xc_qdcn_pgtx_qsqdtype_jsmx_bd t
where t.item=a.item
and t.subsid=a.subsid
and t.startdate=a.startdate
and t.type=a.type
and t.oid=a.oid) ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_mx_bdcd
select a.*,’‘’||v_monsrq||‘’’ cycle from shzc.xc_qdcn_pgtx_qsqdtype_mxb_‘||v_monsrq||’ a
where not exists (select 1 from shzc.xc_qdcn_pgtx_qsqdtype_mx_bdcd t
where t.item=a.item
and t.subsid=a.subsid
and t.startdate=a.startdate
and t.type=a.type
and t.oid=a.oid)
and exists (select 1 from shzc.xc_qdcn_pgtx_qsqdtype_jsmx_bd t
where t.item=a.item
and t.subsid=a.subsid
and t.startdate=a.startdate
and t.type=a.type
and t.oid=a.oid)
and to_char(a.startdate,‘‘yyyymm’’) <> ‘‘2022’’||‘‘11’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
------2023-0130 -2022-12变动 :生态中清算量不再包括宽带权益包、千兆宽带,权益清算量不再包括视频彩铃,之前生态中的提速包项单独拿出来。
SQL_STRING:=‘delete shzc.xc_qdcn_pgtx_qsqdtype_mx_bdcd a where a.cycle >=’‘2022’‘||’‘12’’
and a.type in (‘‘宽带权益包’’,‘‘千兆宽带’’,‘‘视频彩铃’’) ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qdmxb’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_qdmxb as
select ‘’’||v_monsrq||‘’’ cycle,a.大类,a.recorgid,a.type,
sum(a.结算数) 当月结算数
from shzc.xc_qdcn_pgtx_qsqdtype_mx_bdcd a where a.cycle=‘’‘||v_monsrq||’‘’
and 大类 in (‘‘核心’’,‘‘泛渠道’’)
group by a.大类,a.recorgid,a.type ';
EXECUTE IMMEDIATE (SQL_STRING);
zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_qdhz’),‘SHZC’);
SQL_STRING:=‘create table shzc.xc_qdcn_pgtx_qsqdtype_qdhz as
select ‘’’||v_monsrq||‘’’ cycle,a.大类,a.recorgid,
sum(nvl(case when a.type=‘‘新入网’’ then a.当月结算数 end ,0)) 当月新入网,
sum(nvl(case when a.type=‘‘折后48’’ then a.当月结算数 end ,0)) 当月折后48,
sum(nvl(case when a.type=‘‘线盒新增’’ then a.当月结算数 end ,0)) 当月线盒新增,
–光猫升级 家庭安防 宽带权益包 路由器 提速包 千兆宽带 魔百和点播
sum(nvl(case when a.type in (‘‘千兆宽带’’,‘‘光猫升级’’,‘‘路由器’’,‘‘宽带权益包’’,‘‘家庭安防’’,‘‘魔百和点播’’) then a.当月结算数 end ,0)) 当月生态业务,
sum(nvl(case when a.type in (‘‘权益产品’’,‘‘视频彩铃’’) then a.当月结算数 end ,0)) 当月权益彩铃,
sum(nvl(case when a.type in (‘‘提速包’’) then a.当月结算数 end ,0)) 当月提速包
from shzc.xc_qdcn_pgtx_qsqdtype_qdmxb a
where 大类 in (‘‘核心’’,‘‘泛渠道’’)
group by a.大类,a.recorgid ';
EXECUTE IMMEDIATE (SQL_STRING);
SQL_STRING:=‘delete shzc.xc_qdcn_pgtx_qsqdtype_qdhza a where a.in_time=’‘’||v_last_day||‘’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
SQL_STRING:=‘insert into shzc.xc_qdcn_pgtx_qsqdtype_qdhza
select ‘’’||v_last_day||‘’’ in_time,a.区县,a.网格名称,a.渠道编码,
a.渠道名称,a.渠道类型,a.大类,a.职位,a.渠道归属,
nvl(b.当月新入网,0) 当月新入网,
nvl(b.当月折后48,0) 当月折后48,
nvl(b.当月线盒新增,0) 当月线盒新增,
nvl(b.当月生态业务,0) 当月生态业务,
nvl(b.当月权益彩铃,0) 当月权益彩铃,
nvl(b.当月提速包,0) 当月提速包
from shzc.xc_qdcn_pgtx_qsqdtype_sja a,
shzc.xc_qdcn_pgtx_qsqdtype_qdhz b
where a.渠道编码=b.recorgid(+)
and a.大类 in (‘‘核心’’,‘‘泛渠道’’) ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;
相关文章:
20230215_数据库过程_渠道业务清算过程
----2023-0131-清算过程 zhyw.shc_drop_retable(upper(‘xc_qdcn_pgtx_qsqdtype_sja’),‘SHZC’); SQL_STRING:‘create table shzc.xc_qdcn_pgtx_qsqdtype_sja as select * from shzc.xc_qdcn_pgtx_qdtype a where a.in_time ( select max(a.in_time) from shzc.xc_qdcn_pg…...

webpack(高级)--性能优化-代码分离
webpack webpack性能优化 优化一:打包后的结果 上线时的性能优化 (比如分包处理 减少包体积 CDN服务器) 优化二:优化打包速度 开发或者构建优化打包速度 (比如exclude cache-loader等) 大多数情况下我们侧…...

借助docker, 使用verdaccio搭建npm私服
为何要搭建npm私服 搭建npm私服好处多多,网上随便一篇教程搜出来都罗列了诸多好处,譬如: 公司内部开发环境与外网隔离,内部开发的一些库高度隐私不便外传,内网搭建npm服务保证私密性同属内网,可以确保使用npm下载依赖…...

c/c++开发,无可避免的模板编程实践(篇二)
一、开发者需要对模板参数负责 1.1 为您模板参数提供匹配的操作 在进行模板设计时,函数模板或类模板一般只做模板参数(typename T)无关的操作为主,但是也不见得就不会关联模板参数自身的操作,尤其是在一些自定义的数据…...

【2023】【standard-products项目】中查找的问题与解决方案 (未完待续)
10、el-table 判断是多选操作还是单选操作 9、判断数组对象中是否包含某个指定值 需求:修改时数据回填el-select下拉数据,发现当前id在原数组里没有找到,就显示了id值,应该显示name名, 处理:当查找到id…...

力扣sql简单篇练习(十六)
力扣sql简单篇练习(十六) 1 产品销售分析|| 1.1 题目内容 1.1.1 基本题目信息 1.1.2 示例输入输出 1.2 示例sql语句 SELECT p.product_id,sum(s.quantity) total_quantity FROM Product p INNER JOIN Sales s ON p.product_ids.product_id GROUP BY p.product_id1.3 运行截…...
青少年蓝桥杯python组(STEMA中级组)
第一套编程题第一题【编程实现】输入一个字符串(N),输出该字符串的长度。输入描述:输入一个字符串 N输出描述:输出该字符串的长度【样例输入】abcd【样例输出】4N input() print(len(N))第二题【提示信息】小蓝家的灯…...

JVM内存结构,Java内存模型,Java对象模型
一.整体方向JVM内存结构是和java虚拟机的运行时区域有关。Java内存模型和java并发编程有关。java对象模型和java对象在虚拟机中的表现形式有关。1.JVM内存结构堆:通过new或者其他指令创建的实例对象,会被垃圾回收。动态分配。虚拟机栈:基本数…...

跨境电商新形式下,如何选择市场?
2022年,全球经济已经有增长乏力、通胀高起的趋势,美国等国家的通货膨胀情况令人担忧,不少行业面临更为复杂的外部环境以及严峻的市场挑战。不过,跨境电商行业依旧保持着较高的增长速度,越来越多有远见的卖家将电商事业…...

MySQL的触发器
目录 一.概述 介绍 触发器的特性 操作—创建触发器 操作—new和old 操作—查看触发器 操作—删除触发器 注意事项 一.概述 介绍 触发器,就是一种特殊的存储过程。触发器和存储过程一样是一个能够完成特定功能、存储在数据库服务器上的SQL片段,但是…...
内存映射模块读写文件提高IO性能mmap
内存映射模块读写文件提高IO性能mmap 1.概述 这篇文章介绍下与普通读写文件不同的方式,内存映射读写文件。在什么情况下才会用到内存映射操作文件那,还是要先了解下他。 1.1.内存映射与IO区别 常规操作IO开销 常规的操作文件是经过下面几个环节操作I…...

存储硬件与协议
存储硬件与协议存储设备的历史轨迹存储介质的进化3D NAND3D XPointIntel Optane存储接口协议的演变NVMeNVMe-oF网络存储技术1)DAS2)NAS3)SAN4)iSCSIiSCSI层次结构存储设备的历史轨迹 1.穿孔卡2.磁带3.硬盘4.磁盘(软盘…...
智能物流半导体发展
智能物流半导体在国内的发展,国内巨大的人口基数,这将会不断促进智慧物流的发展。智能物流在未来发展的潜力巨大。 关于触屏的设计是界面越简单,越清晰越好,最近设计一个小车控制触屏软件。把小车当前所在信息通过图像显示出来。…...

SAP S/4HANA 概述
智能企业业务技术平台Business Technology Platform提供数据管理和分析,并支持应用程序开发和集成。它还允许我们的客户使用人工智能、机器学习和物联网等智能技术来推动创新。业务网络Business network帮助客户实现跨公司业务流程的数字化。该网络建立在我们的采购…...
太上感应篇
太上感应篇原文 太上曰。祸福无门。惟人自召。善恶之报。如影随形。 是以天地有司过之神。依人所犯轻重。以夺人算。算减则贫耗。多逢忧患。人皆恶之。刑祸随之。吉庆避之。恶星灾之。算尽则死。 又有三台北斗神君。在人头上。录人罪恶。夺其纪算。又有三尸神。在人身中。每…...

FPGA入门系列17--task
文章简介 本系列文章主要针对FPGA初学者编写,包括FPGA的模块书写、基础语法、状态机、RAM、UART、SPI、VGA、以及功能验证等。将每一个知识点作为一个章节进行讲解,旨在更快速的提升初学者在FPGA开发方面的能力,每一个章节中都有针对性的代码…...

React学习笔记(番外二)——列表多选批量处理复合组件
React学习笔记(番外二)——列表多选批量操作复合组件前言〇、Show you the code一、 任务分析及拆解表头行的Checkbox——总开关记录行的Checkbox——行级开关二、 基础实现表头行的文件——header-row.js记录行的文件——record-row.js页面的文件App.js…...

Pom.xml详解
目录 1、Maven的下载安装 2、什么是pom? 3、较完整的pom元素 4、默认生成Maven工程的pom内容 5、自定义的属性变量 6、依赖管理 6.1、整体依赖关系列表 6.2、依赖关系的传递性 6.3、依赖传递可能造成的问题 6.3.1、scope依赖范围 6.3.2、依赖调节 6.3.3…...

浅谈软件测试需求管理
什么是需求管理? 需求管理,指对产品、系统或工程的开发需求的搜集、定义、分析、评审、整理、维护、追溯和复用等相关的管理工作和流程。通常特指应用程序或软件系统的研发需求。需求管理和配置管理、测试管理、缺陷管理、风险管理、变更管理等管理流程…...
面试题复盘
Vuex与本地存储的区别Vuex是一个专门为Vue.js应用程序开发的状态管理模式和库。它提供了一个中央存储库,用于存储应用程序的所有组件之间共享的状态【组件间通信的一种方法,一般用于中大型应用】。Vuex的主要目的是在Vue.js应用程序中管理复杂的状态逻辑…...

K8S认证|CKS题库+答案| 11. AppArmor
目录 11. AppArmor 免费获取并激活 CKA_v1.31_模拟系统 题目 开始操作: 1)、切换集群 2)、切换节点 3)、切换到 apparmor 的目录 4)、执行 apparmor 策略模块 5)、修改 pod 文件 6)、…...
多场景 OkHttpClient 管理器 - Android 网络通信解决方案
下面是一个完整的 Android 实现,展示如何创建和管理多个 OkHttpClient 实例,分别用于长连接、普通 HTTP 请求和文件下载场景。 <?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas…...
今日学习:Spring线程池|并发修改异常|链路丢失|登录续期|VIP过期策略|数值类缓存
文章目录 优雅版线程池ThreadPoolTaskExecutor和ThreadPoolTaskExecutor的装饰器并发修改异常并发修改异常简介实现机制设计原因及意义 使用线程池造成的链路丢失问题线程池导致的链路丢失问题发生原因 常见解决方法更好的解决方法设计精妙之处 登录续期登录续期常见实现方式特…...
【Android】Android 开发 ADB 常用指令
查看当前连接的设备 adb devices 连接设备 adb connect 设备IP 断开已连接的设备 adb disconnect 设备IP 安装应用 adb install 安装包的路径 卸载应用 adb uninstall 应用包名 查看已安装的应用包名 adb shell pm list packages 查看已安装的第三方应用包名 adb shell pm list…...

Python 实现 Web 静态服务器(HTTP 协议)
目录 一、在本地启动 HTTP 服务器1. Windows 下安装 node.js1)下载安装包2)配置环境变量3)安装镜像4)node.js 的常用命令 2. 安装 http-server 服务3. 使用 http-server 开启服务1)使用 http-server2)详解 …...
机器学习的数学基础:线性模型
线性模型 线性模型的基本形式为: f ( x ) ω T x b f\left(\boldsymbol{x}\right)\boldsymbol{\omega}^\text{T}\boldsymbol{x}b f(x)ωTxb 回归问题 利用最小二乘法,得到 ω \boldsymbol{\omega} ω和 b b b的参数估计$ \boldsymbol{\hat{\omega}}…...
写一个shell脚本,把局域网内,把能ping通的IP和不能ping通的IP分类,并保存到两个文本文件里
写一个shell脚本,把局域网内,把能ping通的IP和不能ping通的IP分类,并保存到两个文本文件里 脚本1 #!/bin/bash #定义变量 ip10.1.1 #循环去ping主机的IP for ((i1;i<10;i)) doping -c1 $ip.$i &>/dev/null[ $? -eq 0 ] &&am…...

VSCode 使用CMake 构建 Qt 5 窗口程序
首先,目录结构如下图: 运行效果: cmake -B build cmake --build build 运行: windeployqt.exe F:\testQt5\build\Debug\app.exe main.cpp #include "mainwindow.h"#include <QAppli...

spring boot使用HttpServletResponse实现sse后端流式输出消息
1.以前只是看过SSE的相关文章,没有具体实践,这次接入AI大模型使用到了流式输出,涉及到给前端流式返回,所以记录一下。 2.resp要设置为text/event-stream resp.setContentType("text/event-stream"); resp.setCharacter…...
ubuntu清理垃圾
windows和ubuntu 双系统,ubuntu 150GB,开发用,基本不装太多软件。但是磁盘基本用完。 1、查看home目录 sudo du -h -d 1 $HOME | grep -v K 上面的命令查看$HOME一级目录大小,发现 .cache 有26GB,.local 有几个GB&am…...