Oracle脚本

pull/186/MERGE^2
dxfeng 3 years ago
parent 4907b5647e
commit b7827fa083

@ -13,7 +13,6 @@ from JCL_ORG_LEVEL zd inner join JCL_ORG_GRADE zj
on ','+zj.level_id+',' like '%,'+cast(zd.id as varchar(10))+',%' on ','+zj.level_id+',' like '%,'+cast(zd.id as varchar(10))+',%'
where nvl(zd.forbidden_tag,0)<>1 and nvl(zd.delete_type,0)<>1; where nvl(zd.forbidden_tag,0)<>1 and nvl(zd.delete_type,0)<>1;
--
create or replace view v_jcl_post as create or replace view v_jcl_post as
select id*-1 fid,post_name fname,0 fparentid from JCL_ORG_POST select id*-1 fid,post_name fname,0 fparentid from JCL_ORG_POST
where nvl(delete_type,0)<>1 where nvl(delete_type,0)<>1
@ -21,7 +20,6 @@ union
select id,post_info_name,post_id*-1 from JCL_ORG_POST_INFO select id,post_info_name,post_id*-1 from JCL_ORG_POST_INFO
where nvl(forbidden_tag,0)<>1 and nvl(delete_type,0)<>1; where nvl(forbidden_tag,0)<>1 and nvl(delete_type,0)<>1;
--newid
CREATE OR REPLACE FUNCTION newid RETURN VARCHAR2 CREATE OR REPLACE FUNCTION newid RETURN VARCHAR2
IS IS
guid VARCHAR2 (50); guid VARCHAR2 (50);
@ -31,7 +29,6 @@ RETURN substr(guid,1,8)||'-'||substr(guid,9,4)||'-'||substr(guid,13,4)||'-'||sub
END newid; END newid;
--
declare declare
orgid int; orgid int;
cubeuuid1 varchar2(100); cubeuuid1 varchar2(100);
@ -66,8 +63,6 @@ else
select id into appid1 from modetreefield where cubeuuid=cubeuuid1; select id into appid1 from modetreefield where cubeuuid=cubeuuid1;
end if; end if;
--
--
uuid :=lower(replace(newid(),'-','')); uuid :=lower(replace(newid(),'-',''));
insert into mode_customtree(treename,creater, createdate, createtime, rootname, defaultaddress, insert into mode_customtree(treename,creater, createdate, createtime, rootname, defaultaddress,
showtype, isselsub, isonlyleaf, appid, treecode, isRefreshTree, isshowsearchtab, showtype, isselsub, isonlyleaf, appid, treecode, isRefreshTree, isshowsearchtab,
@ -79,7 +74,6 @@ insert into mode_customtreedetail(mainid, nodename, nodedesc, sourcefrom, source
hreftype, hrefid, hreftarget, hrefrelatefield, nodeicon, supnode, supnodefield, nodefield, showorder, hreftype, hrefid, hreftarget, hrefrelatefield, nodeicon, supnode, supnodefield, nodefield, showorder,
iconField, dataorder, datacondition, hrefField, rootids, isshowrootnode, isContainsSub) iconField, dataorder, datacondition, hrefField, rootids, isshowrootnode, isContainsSub)
values(treeid,'职等职级','',2,0,'v_jcl_zdzj','fid','fparentid','fname',2,0,'#','','',0,'','',1,'','fno','','','',1,0); values(treeid,'职等职级','',2,0,'v_jcl_zdzj','fid','fparentid','fname',2,0,'#','','',0,'','',1,'','fno','','','',1,0);
--
uuid :=lower(replace(newid(),'-','')); uuid :=lower(replace(newid(),'-',''));
insert into mode_customtree(treename,creater, createdate, createtime, rootname, defaultaddress, insert into mode_customtree(treename,creater, createdate, createtime, rootname, defaultaddress,
showtype, isselsub, isonlyleaf, appid, treecode, isRefreshTree, isshowsearchtab, showtype, isselsub, isonlyleaf, appid, treecode, isRefreshTree, isshowsearchtab,
@ -93,8 +87,6 @@ insert into mode_customtreedetail(mainid, nodename, nodedesc, sourcefrom, source
values(treeid,'职务','',2,0,'v_jcl_post','fid','fparentid','fname',2,0,'#','','',0,'','',1,'','','','','',1,0); values(treeid,'职务','',2,0,'v_jcl_post','fid','fparentid','fname',2,0,'#','','',0,'','',1,'','','','','',1,0);
--
--
fieldname:='职等职级'; fieldname:='职等职级';
fieldid1:=100001; fieldid1:=100001;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -119,7 +111,6 @@ values (fieldid1,'varchar(1000)',3,256,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(1000)'; sql1 :='alter table cus_fielddata add '||field||' varchar(1000)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='担任岗位'; fieldname:='担任岗位';
fieldid1:=100002; fieldid1:=100002;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -145,7 +136,6 @@ values (fieldid1,'varchar(1000)',3,666,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(1000)'; sql1 :='alter table cus_fielddata add '||field||' varchar(1000)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='担任职务'; fieldname:='担任职务';
fieldid1:=100003; fieldid1:=100003;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -170,7 +160,6 @@ values (fieldid1,'varchar(1000)',3,256,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(1000)'; sql1 :='alter table cus_fielddata add '||field||' varchar(1000)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='职务序列名称'; fieldname:='职务序列名称';
fieldid1:=100005; fieldid1:=100005;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -195,7 +184,6 @@ values (fieldid1,'varchar(200)',1,1,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(200)'; sql1 :='alter table cus_fielddata add '||field||' varchar(200)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='等级方案'; fieldname:='等级方案';
fieldid1:=100006; fieldid1:=100006;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -220,7 +208,6 @@ values (fieldid1,'varchar(200)',1,1,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(200)'; sql1 :='alter table cus_fielddata add '||field||' varchar(200)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='职级'; fieldname:='职级';
fieldid1:=100007; fieldid1:=100007;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -245,7 +232,6 @@ values (fieldid1,'varchar(200)',1,1,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(200)'; sql1 :='alter table cus_fielddata add '||field||' varchar(200)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='职等'; fieldname:='职等';
fieldid1:=100008; fieldid1:=100008;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -270,7 +256,6 @@ values (fieldid1,'varchar(200)',1,1,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(200)'; sql1 :='alter table cus_fielddata add '||field||' varchar(200)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='职务分类'; fieldname:='职务分类';
fieldid1:=100009; fieldid1:=100009;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -295,7 +280,6 @@ values (fieldid1,'varchar(200)',1,1,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(200)'; sql1 :='alter table cus_fielddata add '||field||' varchar(200)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='职务'; fieldname:='职务';
fieldid1:=100010; fieldid1:=100010;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -320,7 +304,6 @@ values (fieldid1,'varchar(200)',1,1,field,field,'');
sql1 :='alter table cus_fielddata add '||field||' varchar(200)'; sql1 :='alter table cus_fielddata add '||field||' varchar(200)';
execute immediate sql1; execute immediate sql1;
--
fieldname:='虚线上级'; fieldname:='虚线上级';
fieldid1:=100004; fieldid1:=100004;
field:='field'||to_char(fieldid1); field:='field'||to_char(fieldid1);
@ -347,15 +330,14 @@ execute immediate sql1;
end; end;
-- update hrm_formfield set isuse=1,ismand=1,allowhide=-1 where fieldname='sex';
update hrm_formfield set isuse=1,ismand=1,allowhide=-1 where fieldname='sex'; -- update hrm_formfield set isuse=1,ismand=0,allowhide=-1 where fieldname='departmentid';
update hrm_formfield set isuse=1,ismand=0,allowhide=-1 where fieldname='departmentid'; -- update hrm_formfield set isuse=1,ismand=0,allowhide=-1 where fieldname='jobtitle';
update hrm_formfield set isuse=1,ismand=0,allowhide=-1 where fieldname='jobtitle'; -- update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='jobactivity';
update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='jobactivity'; -- update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='joblevel';
update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='joblevel'; -- update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='jobcall';
update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='jobcall'; -- update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='jobGroupId';
update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='jobGroupId'; -- update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='jobactivitydesc';
update hrm_formfield set isuse=0,ismand=0,allowhide=-1 where fieldname='jobactivitydesc';-- update hrm_formfield set isuse=1,ismand=0,allowhide=1,groupid=1,fieldorder=18 where fieldname='managerid';
update hrm_formfield set isuse=1,ismand=0,allowhide=1,groupid=1,fieldorder=18 where fieldname='managerid';-- update hrm_formfield set isuse=1,ismand=0,allowhide=1,groupid=1,fieldorder=99 where fieldname='systemlanguage';
update hrm_formfield set isuse=1,ismand=0,allowhide=1,groupid=1,fieldorder=99 where fieldname='systemlanguage';-- update hrm_formfield set isuse=1,ismand=0,allowhide=1,groupid=1,fieldorder=21 where fieldname='assistantid';
update hrm_formfield set isuse=1,ismand=0,allowhide=1,groupid=1,fieldorder=21 where fieldname='assistantid';--

@ -45,7 +45,6 @@ values
end if; end if;
end; end;
--2
create or replace trigger JCL_ORG_COMP_ed after insert or update on JCL_ORG_COMP FOR EACH ROW create or replace trigger JCL_ORG_COMP_ed after insert or update on JCL_ORG_COMP FOR EACH ROW
declare declare
vdatebegin date; vdatebegin date;
@ -92,7 +91,6 @@ end if;
end if; end if;
end; end;
--3
create or replace trigger JCL_ORG_dept_ed after insert or update on JCL_ORG_dept FOR EACH ROW create or replace trigger JCL_ORG_dept_ed after insert or update on JCL_ORG_dept FOR EACH ROW
declare declare
st int; st int;
@ -157,7 +155,6 @@ end if;
end if; end if;
end; end;
--4
create or replace trigger JCL_ORG_job_ed after insert or update on JCL_ORG_job FOR EACH ROW create or replace trigger JCL_ORG_job_ed after insert or update on JCL_ORG_job FOR EACH ROW
declare declare
@ -200,8 +197,6 @@ end if;
end if; end if;
end; end;
--5,
--
create or replace trigger hrmresource_ed after insert or update on hrmresource FOR EACH ROW create or replace trigger hrmresource_ed after insert or update on hrmresource FOR EACH ROW
declare declare
st int; st int;
@ -237,12 +232,10 @@ delete from jcl_org_map where ftype=4 and fobjid=:new.id and fdatebegin=vdatebeg
update jcl_org_map set fdateend=vdatebegin-1 where ftype=4 and fobjid=:new.id and fdateend>vdatebegin; update jcl_org_map set fdateend=vdatebegin-1 where ftype=4 and fobjid=:new.id and fdateend>vdatebegin;
--fparentididintidjcl
--fobjparentididintidjcl
select nvl(field100002,'') into vstr from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id; select nvl(field100002,'') into vstr from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id;
vwz:=Instr(vstr,'_'); vwz:=Instr(vstr,'_');
vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz));--idjcl vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz));
vparentid:=vobjparentid+sj; vparentid:=vobjparentid+sj;
if vdelete=0 then if vdelete=0 then
@ -256,7 +249,6 @@ end if;
end if; end if;
end; end;
--
create or replace trigger cus_fielddata_jclgw after insert or update on cus_fielddata FOR EACH ROW create or replace trigger cus_fielddata_jclgw after insert or update on cus_fielddata FOR EACH ROW
declare declare
st int; st int;
@ -284,7 +276,6 @@ begin
sk:=300000000; sk:=300000000;
vdatebegin:=to_date(sysdate); vdatebegin:=to_date(sysdate);
--select @fobjid=id,@id=id+@sk,@str=isnull(field100002,'') from inserted
select workcode,lastname,case when status<=3 then 0 else 1 end,messagerurl,lastname,jobtitle,uuid select workcode,lastname,case when status<=3 then 0 else 1 end,messagerurl,lastname,jobtitle,uuid
into vnumber,vname,vdelete,vleaderimg,vleadername,vleaderjobid,vuuid from hrmresource where id=:new.id; into vnumber,vname,vdelete,vleaderimg,vleadername,vleaderjobid,vuuid from hrmresource where id=:new.id;
@ -296,7 +287,7 @@ where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id;
vstr:=nvl(:new.field100002,''); vstr:=nvl(:new.field100002,'');
vwz:=Instr(vstr,'_'); vwz:=Instr(vstr,'_');
vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz));--idjcl vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz));
vparentid:=vobjparentid+sj; vparentid:=vobjparentid+sj;
delete from jcl_org_map where ftype=4 and fobjid=:new.id and fdatebegin=vdatebegin; delete from jcl_org_map where ftype=4 and fobjid=:new.id and fdatebegin=vdatebegin;
update jcl_org_map set fdateend=vdatebegin-1 where ftype=4 and fobjid=:new.id and fdateend>vdatebegin; update jcl_org_map set fdateend=vdatebegin-1 where ftype=4 and fobjid=:new.id and fdateend>vdatebegin;
@ -311,16 +302,12 @@ end if;
end if; end if;
end; end;
------------------------------
--
--0
insert into jcl_org_map insert into jcl_org_map
(id,ftype,fobjid,fecid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, (id,ftype,fobjid,fecid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,
fplan,fonjob,fisvitual,fdatebegin,fdateend) fplan,fonjob,fisvitual,fdatebegin,fdateend)
select 0,0,0,1,uuid,0,'行政维度','00',companyname,0,'','',0,'','','',-1,0,0,0,0,to_date(sysdate),to_date('2099-12-31','yyyy-mm-dd') from HrmCompany; select 0,0,0,1,uuid,0,'行政维度','00',companyname,0,'','',0,'','','',-1,0,0,0,0,to_date(sysdate),to_date('2099-12-31','yyyy-mm-dd') from HrmCompany;
--1
insert into jcl_org_map insert into jcl_org_map
(id,ftype,fobjid,fecid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, (id,ftype,fobjid,fecid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,
@ -342,7 +329,6 @@ from
left join cus_fielddata g on c.id=g.id and g.scope='HrmCustomFieldByInfoType' and g.scopeid=3 left join cus_fielddata g on c.id=g.id and g.scope='HrmCustomFieldByInfoType' and g.scopeid=3
where nvl(a.delete_type,0) <>1 and nvl(a.forbidden_tag,0) <>1; where nvl(a.delete_type,0) <>1 and nvl(a.forbidden_tag,0) <>1;
--2
insert into jcl_org_map insert into jcl_org_map
(id,ftype,fobjid,fecid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, (id,ftype,fobjid,fecid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,
@ -365,7 +351,6 @@ from
left join cus_fielddata g on c.id=g.id and g.scope='HrmCustomFieldByInfoType' and g.scopeid=3 left join cus_fielddata g on c.id=g.id and g.scope='HrmCustomFieldByInfoType' and g.scopeid=3
where nvl(a.delete_type,0) <>1 and nvl(a.forbidden_tag,0) <>1; where nvl(a.delete_type,0) <>1 and nvl(a.forbidden_tag,0) <>1;
--3
insert into jcl_org_map insert into jcl_org_map
(id,ftype,fobjid,fclass,fclassname,fnumber,fname, (id,ftype,fobjid,fclass,fclassname,fnumber,fname,
fparentid,fobjparentid, fparentid,fobjparentid,
@ -388,9 +373,6 @@ from JCL_ORG_job a
on f.id=a.parent_dept and a.job_name=f.jobtitlename on f.id=a.parent_dept and a.job_name=f.jobtitlename
where nvl(a.delete_type,0) <>1 and nvl(a.forbidden_tag,0) <>1; where nvl(a.delete_type,0) <>1 and nvl(a.forbidden_tag,0) <>1;
--4
--
delete from cus_fielddata where scopeid=-1; delete from cus_fielddata where scopeid=-1;
insert into cus_fielddata(scope, scopeid, id, field100002) insert into cus_fielddata(scope, scopeid, id, field100002)
select 'HrmCustomFieldByInfoType',-1,a.id,'199_'||to_char(e.id) select 'HrmCustomFieldByInfoType',-1,a.id,'199_'||to_char(e.id)
@ -400,7 +382,6 @@ from hrmresource a
left join JCL_ORG_DEPT d on c.uuid=d.uuid left join JCL_ORG_DEPT d on c.uuid=d.uuid
left join jcl_org_job e on d.id=e.parent_dept and e.job_name=b.jobtitlename; left join jcl_org_job e on d.id=e.parent_dept and e.job_name=b.jobtitlename;
--
insert into jcl_org_map insert into jcl_org_map
(id,ftype,fobjid,fecid,uuid,fclass,fclassname,fnumber,fname,fleaderimg, (id,ftype,fobjid,fecid,uuid,fclass,fclassname,fnumber,fname,fleaderimg,
fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,

@ -1,27 +1,21 @@
----------1: ----------
--
insert into JCL_ORG_COMP(comp_no,comp_name_short,comp_name,parent_company,forbidden_tag, insert into JCL_ORG_COMP(comp_no,comp_name_short,comp_name,parent_company,forbidden_tag,
show_order,uuid,creator,delete_type,create_time) show_order,uuid,creator,delete_type,create_time)
select nvl(subcompanycode,''),subcompanyname,subcompanydesc,nvl(supsubcomid,0), select nvl(subcompanycode,''),subcompanyname,subcompanydesc,nvl(supsubcomid,0),
nvl(canceled,0) ,nvl(showorder,0),uuid,1,0,SYSDATE nvl(canceled,0) ,nvl(showorder,0),uuid,1,0,SYSDATE
from HrmSubCompany; from HrmSubCompany;
--
update JCL_ORG_COMP t1 set t1.parent_company=(select c.id update JCL_ORG_COMP t1 set t1.parent_company=(select c.id
from HrmSubCompany a from HrmSubCompany a
inner join HrmSubCompany b on a.supsubcomid=b.id inner join HrmSubCompany b on a.supsubcomid=b.id
inner join JCL_ORG_COMP c on b.uuid=c.uuid inner join JCL_ORG_COMP c on b.uuid=c.uuid
where a.uuid=t1.uuid); where a.uuid=t1.uuid);
---3ECHrmDepartment-->JCL_ORG_DEPT
--
insert into JCL_ORG_DEPT(dept_no, dept_name, dept_name_short,parent_comp, insert into JCL_ORG_DEPT(dept_no, dept_name, dept_name_short,parent_comp,
show_order,forbidden_tag,creator,delete_type,create_time,uuid) show_order,forbidden_tag,creator,delete_type,create_time,uuid)
select a.departmentcode,a.departmentname,a.departmentmark,a.subcompanyid1,a.showorder,nvl(a.canceled,0),1,0,SYSDATE,uuid select a.departmentcode,a.departmentname,a.departmentmark,a.subcompanyid1,a.showorder,nvl(a.canceled,0),1,0,SYSDATE,uuid
from HrmDepartment a from HrmDepartment a
left join HrmDepartmentDefined b on a.id=b.deptid; left join HrmDepartmentDefined b on a.id=b.deptid;
--id
update JCL_ORG_DEPT t1 update JCL_ORG_DEPT t1
set t1.parent_comp=(select c.id set t1.parent_comp=(select c.id
from HrmDepartment a from HrmDepartment a
@ -29,7 +23,6 @@ set t1.parent_comp=(select c.id
inner join JCL_ORG_COMP c on b.uuid=c.uuid inner join JCL_ORG_COMP c on b.uuid=c.uuid
where t1.uuid=a.uuid); where t1.uuid=a.uuid);
--id
update JCL_ORG_dept t1 update JCL_ORG_dept t1
set t1.parent_dept=(select c.id set t1.parent_dept=(select c.id
from HrmDepartment a from HrmDepartment a
@ -37,7 +30,6 @@ set t1.parent_dept=(select c.id
inner join JCL_ORG_dept c on b.uuid=c.uuid inner join JCL_ORG_dept c on b.uuid=c.uuid
where t1.uuid=a.uuid); where t1.uuid=a.uuid);
---4
insert into jcl_org_job(job_no, job_name, parent_comp, parent_dept, insert into jcl_org_job(job_no, job_name, parent_comp, parent_dept,
description, work_duty, work_authority, description, work_duty, work_authority,
forbidden_tag, creator, delete_type, create_time, forbidden_tag, creator, delete_type, create_time,

Loading…
Cancel
Save