02_install.sql 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. set define off
  2. set echo on
  3. whenever sqlerror exit sql.sqlcode
  4. alter session set container=ORCLPDB;
  5. alter session set current_schema=PMS_TEST;
  6. declare
  7. v_count number;
  8. v_xh number;
  9. v_fwc clob;
  10. v_obj json_object_t;
  11. v_arr json_array_t;
  12. v_out clob;
  13. v_found boolean;
  14. type t_gw is table of number;
  15. type t_names is table of varchar2(100);
  16. v_gws t_gw := t_gw(1015564, 1015565, 1015566);
  17. v_names t_names := t_names('fjyrjc', 'fjyrjc_ck', 'fjyrjc_lr');
  18. procedure add_service(p_name varchar2) is
  19. begin
  20. v_found := false;
  21. for i in 0 .. v_arr.get_size - 1 loop
  22. if v_arr.get_string(i) = p_name then
  23. v_found := true;
  24. exit;
  25. end if;
  26. end loop;
  27. if not v_found then
  28. v_arr.append(p_name);
  29. end if;
  30. end;
  31. begin
  32. select count(*) into v_count
  33. from GRJJ
  34. where GRJJMBID = 10543
  35. and JLZTM = 51;
  36. if v_count = 0 then
  37. raise_application_error(-20001, '未找到有效的团委手机快捷入口模板 10543');
  38. end if;
  39. select count(*) into v_count
  40. from GW
  41. where GWID in (1015564, 1015565, 1015566)
  42. and FWC is not null;
  43. if v_count <> 3 then
  44. raise_application_error(-20002, '团委岗位或岗位权限不完整');
  45. end if;
  46. select count(*) into v_count
  47. from GRJJ
  48. where GRJJMBID = 10543
  49. and DXM = 'fjyrjc';
  50. if v_count = 0 then
  51. select nvl(max(XH), 0) + 1
  52. into v_xh
  53. from GRJJ
  54. where GRJJMBID = 10543;
  55. insert into GRJJ(
  56. GRJJMBID, XH, MC, BJM, TBM, DXM, FWM, GNM, JLZTM, FWSBLBM
  57. ) values(
  58. 10543, v_xh, '风纪仪容检查', 'mp_objList',
  59. 'icon-obj-xxwjjl', 'fjyrjc', 'fjyrjc_cx', 'search', 51, 51
  60. );
  61. end if;
  62. for g in 1 .. v_gws.count loop
  63. select FWC into v_fwc
  64. from GW
  65. where GWID = v_gws(g)
  66. for update;
  67. v_obj := json_object_t.parse(v_fwc);
  68. v_arr := v_obj.get_array('bjpj');
  69. if v_arr is null then
  70. v_arr := json_array_t();
  71. end if;
  72. for n in 1 .. v_names.count loop
  73. add_service(v_names(n));
  74. end loop;
  75. v_obj.put('bjpj', v_arr);
  76. v_out := v_obj.stringify;
  77. update GW set FWC = v_out where GWID = v_gws(g);
  78. end loop;
  79. commit;
  80. dbms_output.put_line('FJYRJC_MOBILE_ENTRY_OK');
  81. end;
  82. /
  83. exit