02_install_test.sql 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_grjjid number;
  10. v_fwc clob;
  11. v_obj json_object_t;
  12. v_arr json_array_t;
  13. v_out clob;
  14. v_found boolean;
  15. type t_names is table of varchar2(100);
  16. v_names t_names := t_names('fjyrjc','fjyrjc_ck','fjyrjc_lr');
  17. procedure add_service(p_name varchar2) is
  18. begin
  19. v_found := false;
  20. for i in 0 .. v_arr.get_size - 1 loop
  21. if v_arr.get_string(i) = p_name then
  22. v_found := true;
  23. exit;
  24. end if;
  25. end loop;
  26. if not v_found then
  27. v_arr.append(p_name);
  28. end if;
  29. end;
  30. begin
  31. select count(*) into v_count
  32. from RY
  33. where RYID=111157142 and RYH='cssg1' and GWID=1015504 and JLZTM=51;
  34. if v_count <> 1 then
  35. raise_application_error(-20001,'cssg1 人员、账号或宿管岗位关系不完整');
  36. end if;
  37. select count(*) into v_count
  38. from GRJJ where YYRYID=111157142;
  39. if v_count = 0 then
  40. raise_application_error(-20002,'cssg1 当前没有个人快捷入口,禁止退化为共享模板授权');
  41. end if;
  42. select count(*) into v_count
  43. from QZ q join QZCY qc on qc.QZID=q.QZID
  44. where q.QZID=5001141 and q.JLZTM=51
  45. and qc.RYID=111157142 and qc.JLZTM=51;
  46. if v_count < 1 then
  47. raise_application_error(-20003,'cssg1 专属权限群组或成员关系不完整');
  48. end if;
  49. select count(*) into v_count
  50. from GRJJ where YYRYID=111157142 and DXM='fjyrjc';
  51. if v_count = 0 then
  52. select nvl(max(XH),0)+1 into v_xh
  53. from GRJJ where YYRYID=111157142;
  54. insert into GRJJ(
  55. YYRYID,XH,MC,BJM,TBM,DXM,FWM,GNM,JLZTM,FWSBLBM
  56. ) values(
  57. 111157142,v_xh,'风纪仪容检查','mp_objList','icon-obj-xxwjjl',
  58. 'fjyrjc','fjyrjc_cx','search',51,51
  59. ) returning GRJJID into v_grjjid;
  60. insert into PMS_FJYRJC_CSSG1_CREATED_20261119(GRJJID,QZID,QZCYID,CREATED_AT)
  61. select v_grjjid,5001141,qc.QZCYID,systimestamp
  62. from QZCY qc where qc.QZID=5001141 and qc.RYID=111157142;
  63. end if;
  64. select FWC into v_fwc from QZ where QZID=5001141 for update;
  65. v_obj := json_object_t.parse(v_fwc);
  66. v_arr := v_obj.get_array('bjpj');
  67. if v_arr is null then
  68. v_arr := json_array_t();
  69. end if;
  70. for n in 1 .. v_names.count loop
  71. add_service(v_names(n));
  72. end loop;
  73. v_obj.put('bjpj',v_arr);
  74. v_out := v_obj.stringify;
  75. update QZ set FWC=v_out where QZID=5001141;
  76. commit;
  77. dbms_output.put_line('FJYRJC_CSSG1_TEST_OK');
  78. end;
  79. /
  80. exit