|
@@ -0,0 +1,205 @@
|
|
|
|
|
+set serveroutput on
|
|
|
|
|
+set define off
|
|
|
|
|
+set feedback on
|
|
|
|
|
+
|
|
|
|
|
+declare
|
|
|
|
|
+ v_exists number;
|
|
|
|
|
+begin
|
|
|
|
|
+ select count(*) into v_exists
|
|
|
|
|
+ from user_tables
|
|
|
|
|
+ where table_name='PMS_STARCLASS_RBAR_GRCD_BAK_20261027';
|
|
|
|
|
+ if v_exists=0 then
|
|
|
|
|
+ execute immediate '
|
|
|
|
|
+ create table PMS_STARCLASS_RBAR_GRCD_BAK_20261027 as
|
|
|
|
|
+ select * from GRCD where 1=0';
|
|
|
|
|
+ end if;
|
|
|
|
|
+end;
|
|
|
|
|
+/
|
|
|
|
|
+
|
|
|
|
|
+insert into PMS_STARCLASS_RBAR_GRCD_BAK_20261027
|
|
|
|
|
+select g.*
|
|
|
|
|
+ from GRCD g
|
|
|
|
|
+ where g.DXM='ssnwjcStarClassSummary'
|
|
|
|
|
+ and g.GNM='search'
|
|
|
|
|
+ and not exists (
|
|
|
|
|
+ select 1
|
|
|
|
|
+ from PMS_STARCLASS_RBAR_GRCD_BAK_20261027 b
|
|
|
|
|
+ where b.GRCDID=g.GRCDID
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+declare
|
|
|
|
|
+ v_bgmbid number;
|
|
|
|
|
+ v_grtjid number;
|
|
|
|
|
+ v_grtjmxid number;
|
|
|
|
|
+ v_root_grtjid number;
|
|
|
|
|
+ v_root_grtjmxid number;
|
|
|
|
|
+ v_count number;
|
|
|
|
|
+ v_menu_count number;
|
|
|
|
|
+ c_name constant varchar2(64) := '星级文明班级评比总表';
|
|
|
|
|
+ c_page constant varchar2(64) := 'ssnwjc_starClassSummary';
|
|
|
|
|
+begin
|
|
|
|
|
+ select count(*) into v_count
|
|
|
|
|
+ from BGMB
|
|
|
|
|
+ where DXM='bj'
|
|
|
|
|
+ and BJM=c_page
|
|
|
|
|
+ and BGMBLBM=51;
|
|
|
|
|
+ if v_count > 1 then
|
|
|
|
|
+ raise_application_error(-20001, 'BGMB duplicate');
|
|
|
|
|
+ elsif v_count = 1 then
|
|
|
|
|
+ select max(BGMBID) into v_bgmbid
|
|
|
|
|
+ from BGMB
|
|
|
|
|
+ where DXM='bj'
|
|
|
|
|
+ and BJM=c_page
|
|
|
|
|
+ and BGMBLBM=51;
|
|
|
|
|
+ update BGMB
|
|
|
|
|
+ set MC=c_name,
|
|
|
|
|
+ MS='星级文明班级评比总表',
|
|
|
|
|
+ LMMS='班级星级评比报表',
|
|
|
|
|
+ BGMBLXM=1,
|
|
|
|
|
+ FWSBLBM=1,
|
|
|
|
|
+ FWM=null,
|
|
|
|
|
+ JLZTM=51
|
|
|
|
|
+ where BGMBID=v_bgmbid;
|
|
|
|
|
+ else
|
|
|
|
|
+ insert into BGMB
|
|
|
|
|
+ (BGMBLBM,BGMBLXM,FWSBLBM,XH,MC,MS,LMMS,
|
|
|
|
|
+ DXM,FWM,BJM,JLZTM)
|
|
|
|
|
+ values
|
|
|
|
|
+ (51,1,1,0,c_name,'星级文明班级评比总表',
|
|
|
|
|
+ '班级星级评比报表','bj',null,c_page,51)
|
|
|
|
|
+ returning BGMBID into v_bgmbid;
|
|
|
|
|
+ end if;
|
|
|
|
|
+
|
|
|
|
|
+ select count(*) into v_count
|
|
|
|
|
+ from GRTJ
|
|
|
|
|
+ where DXM='bj'
|
|
|
|
|
+ and GRTJMBID=5712
|
|
|
|
|
+ and YYRYID is null
|
|
|
|
|
+ and GRTJLBM=51
|
|
|
|
|
+ and MC=c_name;
|
|
|
|
|
+ if v_count > 1 then
|
|
|
|
|
+ raise_application_error(-20002, 'GRTJ duplicate');
|
|
|
|
|
+ elsif v_count = 1 then
|
|
|
|
|
+ select max(GRTJID) into v_grtjid
|
|
|
|
|
+ from GRTJ
|
|
|
|
|
+ where DXM='bj'
|
|
|
|
|
+ and GRTJMBID=5712
|
|
|
|
|
+ and YYRYID is null
|
|
|
|
|
+ and GRTJLBM=51
|
|
|
|
|
+ and MC=c_name;
|
|
|
|
|
+ update GRTJ
|
|
|
|
|
+ set XH=1,KD=0,GD=0,JLZTM=51
|
|
|
|
|
+ where GRTJID=v_grtjid;
|
|
|
|
|
+ else
|
|
|
|
|
+ insert into GRTJ
|
|
|
|
|
+ (YYRYID,TJTLBM,GRTJMBID,YJTJZBM,MC,DXM,
|
|
|
|
|
+ XH,KD,GD,JLZTM,GRTJLBM)
|
|
|
|
|
+ values
|
|
|
|
|
+ (null,null,5712,null,c_name,'bj',
|
|
|
|
|
+ 1,0,0,51,51)
|
|
|
|
|
+ returning GRTJID into v_grtjid;
|
|
|
|
|
+ end if;
|
|
|
|
|
+
|
|
|
|
|
+ select count(*) into v_count
|
|
|
|
|
+ from GRTJMX
|
|
|
|
|
+ where GRTJID=v_grtjid
|
|
|
|
|
+ and BGMBID=v_bgmbid;
|
|
|
|
|
+ if v_count > 1 then
|
|
|
|
|
+ raise_application_error(-20003, 'GRTJMX duplicate');
|
|
|
|
|
+ elsif v_count = 1 then
|
|
|
|
|
+ select max(GRTJMXID) into v_grtjmxid
|
|
|
|
|
+ from GRTJMX
|
|
|
|
|
+ where GRTJID=v_grtjid
|
|
|
|
|
+ and BGMBID=v_bgmbid;
|
|
|
|
|
+ update GRTJMX
|
|
|
|
|
+ set MC=c_name,XH=1,JLZTM=51
|
|
|
|
|
+ where GRTJMXID=v_grtjmxid;
|
|
|
|
|
+ else
|
|
|
|
|
+ insert into GRTJMX
|
|
|
|
|
+ (GRTJID,TJZBM,SJGRTJMXID,MC,XH,JLZTM,BGMBID)
|
|
|
|
|
+ values
|
|
|
|
|
+ (v_grtjid,null,null,c_name,1,51,v_bgmbid)
|
|
|
|
|
+ returning GRTJMXID into v_grtjmxid;
|
|
|
|
|
+ end if;
|
|
|
|
|
+
|
|
|
|
|
+ select count(*) into v_count
|
|
|
|
|
+ from GRTJ
|
|
|
|
|
+ where DXM='bj'
|
|
|
|
|
+ and GRTJMBID is null
|
|
|
|
|
+ and YYRYID is null
|
|
|
|
|
+ and GRTJLBM=51
|
|
|
|
|
+ and MC=c_name;
|
|
|
|
|
+ if v_count > 1 then
|
|
|
|
|
+ raise_application_error(-20004, 'root GRTJ duplicate');
|
|
|
|
|
+ elsif v_count = 1 then
|
|
|
|
|
+ select max(GRTJID) into v_root_grtjid
|
|
|
|
|
+ from GRTJ
|
|
|
|
|
+ where DXM='bj'
|
|
|
|
|
+ and GRTJMBID is null
|
|
|
|
|
+ and YYRYID is null
|
|
|
|
|
+ and GRTJLBM=51
|
|
|
|
|
+ and MC=c_name;
|
|
|
|
|
+ update GRTJ
|
|
|
|
|
+ set XH=1,KD=0,GD=0,JLZTM=51
|
|
|
|
|
+ where GRTJID=v_root_grtjid;
|
|
|
|
|
+ else
|
|
|
|
|
+ insert into GRTJ
|
|
|
|
|
+ (YYRYID,TJTLBM,GRTJMBID,YJTJZBM,MC,DXM,
|
|
|
|
|
+ XH,KD,GD,JLZTM,GRTJLBM)
|
|
|
|
|
+ values
|
|
|
|
|
+ (null,null,null,null,c_name,'bj',
|
|
|
|
|
+ 1,0,0,51,51)
|
|
|
|
|
+ returning GRTJID into v_root_grtjid;
|
|
|
|
|
+ end if;
|
|
|
|
|
+
|
|
|
|
|
+ select count(*) into v_count
|
|
|
|
|
+ from GRTJMX
|
|
|
|
|
+ where GRTJID=v_root_grtjid
|
|
|
|
|
+ and BGMBID=v_bgmbid;
|
|
|
|
|
+ if v_count > 1 then
|
|
|
|
|
+ raise_application_error(-20005, 'root GRTJMX duplicate');
|
|
|
|
|
+ elsif v_count = 1 then
|
|
|
|
|
+ select max(GRTJMXID) into v_root_grtjmxid
|
|
|
|
|
+ from GRTJMX
|
|
|
|
|
+ where GRTJID=v_root_grtjid
|
|
|
|
|
+ and BGMBID=v_bgmbid;
|
|
|
|
|
+ update GRTJMX
|
|
|
|
|
+ set MC=c_name,XH=1,JLZTM=51
|
|
|
|
|
+ where GRTJMXID=v_root_grtjmxid;
|
|
|
|
|
+ else
|
|
|
|
|
+ insert into GRTJMX
|
|
|
|
|
+ (GRTJID,TJZBM,SJGRTJMXID,MC,XH,JLZTM,BGMBID)
|
|
|
|
|
+ values
|
|
|
|
|
+ (v_root_grtjid,null,null,c_name,1,51,v_bgmbid)
|
|
|
|
|
+ returning GRTJMXID into v_root_grtjmxid;
|
|
|
|
|
+ end if;
|
|
|
|
|
+
|
|
|
|
|
+ delete from GRCD
|
|
|
|
|
+ where DXM='ssnwjcStarClassSummary'
|
|
|
|
|
+ and GNM='search';
|
|
|
|
|
+ v_menu_count := sql%rowcount;
|
|
|
|
|
+
|
|
|
|
|
+ dbms_output.put_line('BGMBID=' || v_bgmbid);
|
|
|
|
|
+ dbms_output.put_line('GRTJID=' || v_grtjid);
|
|
|
|
|
+ dbms_output.put_line('GRTJMXID=' || v_grtjmxid);
|
|
|
|
|
+ dbms_output.put_line('ROOT_GRTJID=' || v_root_grtjid);
|
|
|
|
|
+ dbms_output.put_line('ROOT_GRTJMXID=' || v_root_grtjmxid);
|
|
|
|
|
+ dbms_output.put_line('removed_legacy_menus=' || v_menu_count);
|
|
|
|
|
+end;
|
|
|
|
|
+/
|
|
|
|
|
+
|
|
|
|
|
+commit;
|
|
|
|
|
+
|
|
|
|
|
+select g.GRTJID,g.GRTJMBID,g.DXM,g.GRTJLBM,g.MC grtj_mc,m.GRTJMXID,
|
|
|
|
|
+ b.BGMBID,b.MC bgmb_mc,b.FWM,b.BJM,b.JLZTM
|
|
|
|
|
+ from GRTJ g
|
|
|
|
|
+ join GRTJMX m on m.GRTJID=g.GRTJID
|
|
|
|
|
+ join BGMB b on b.BGMBID=m.BGMBID
|
|
|
|
|
+ where g.DXM='bj'
|
|
|
|
|
+ and (g.GRTJMBID=5712 or g.GRTJMBID is null)
|
|
|
|
|
+ and g.GRTJLBM=51
|
|
|
|
|
+ and b.BJM='ssnwjc_starClassSummary';
|
|
|
|
|
+
|
|
|
|
|
+select GRCDID,DXM,GNM,MC
|
|
|
|
|
+ from GRCD
|
|
|
|
|
+ where DXM='ssnwjcStarClassSummary';
|