diff --git a/docs/脚本/Oracle/组织架构图触发器.sql b/docs/脚本/Oracle/组织架构图触发器.sql index 29292d5f..75277090 100644 --- a/docs/脚本/Oracle/组织架构图触发器.sql +++ b/docs/脚本/Oracle/组织架构图触发器.sql @@ -10,19 +10,33 @@ vleader int; vdatebegin date; vplan int; vonjob int; + vcnt int; begin if :new.companyname!=:old.companyname then + +select count(1) into vcnt from jcl_info where id=1; +if vcnt=1 then select to_number(fvalue) into vleader from jcl_info where id=1; +end if; +select count(1) into vcnt from hrmresource where id=vleader; +if vcnt=1 then select messagerurl,lastname,jobtitle into vleaderimg,vleadername,vleaderjobid from hrmresource where id=vleader; +end if; +select count(1) into vcnt from hrmjobtitles where id=vleaderjobid; +if vcnt=1 then select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid; +end if; +select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=vleader; +if vcnt=1 then select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=vleader; +end if; -vdatebegin:=sysdate; + vdatebegin:=sysdate; select sum(nvl(staff_num,0)) into vplan from JCL_ORG_STAFF where plan_id in (select id from JCL_ORG_STAFFPLAN where time_start<=vdatebegin and time_end>=vdatebegin); @@ -60,6 +74,7 @@ vdatebegin date; vobjparentid int; vplan int; vonjob int; + vcnt int; begin if :new.comp_name!=:old.comp_name or :new.comp_principal!=:old.comp_principal or :new.parent_company!=:old.parent_company or :new.forbidden_tag!=:old.forbidden_tag or :new.DELETE_TYPE!=:old.DELETE_TYPE then @@ -68,13 +83,28 @@ begin vparentid:=nvl(:new.parent_company,0); vobjparentid:=nvl(:new.parent_company,0); +select count(1) into vcnt from HrmSubCompany where uuid=:new.uuid; +if vcnt=1 then select id into vecid from HrmSubCompany where uuid=:new.uuid; +end if; + +select count(1) into vcnt from hrmresource where id=:new.comp_principal; +if vcnt=1 then select messagerurl,lastname,jobtitle into vleaderimg,vleadername,vleaderjobid from hrmresource where id=:new.comp_principal; +end if; + +select count(1) into vcnt from hrmjobtitles where id=vleaderjobid; +if vcnt=1 then select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid; +end if; + +select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.comp_principal; +if vcnt=1 then select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.comp_principal; -select sum(nvl(staff_num,0)) into vplan from JCL_ORG_STAFF -where plan_id in (select id from JCL_ORG_STAFFPLAN where time_start<=vdatebegin and time_end>=vdatebegin) and comp_id=:new.id; +end if; + +select sum(nvl(staff_num,0)) into vplan from JCL_ORG_STAFF; select count(1) into vonjob from hrmresource where status<=3 and subcompanyid1=vecid; delete from jcl_org_map where ftype=1 and fobjid=:new.id and fdatebegin=vdatebegin; @@ -108,6 +138,7 @@ st int; vleaderlv VARCHAR2(255); vplan int; vonjob int; + vcnt int; begin if :new.dept_name!=:old.dept_name or :new.dept_principal!=:old.dept_principal or :new.parent_comp!=:old.parent_comp or :new.parent_dept!=:old.parent_dept or :new.forbidden_tag!=:old.forbidden_tag or :new.DELETE_TYPE!=:old.DELETE_TYPE then @@ -126,15 +157,28 @@ else vobjparentid:=:new.parent_dept+st; end if; +select count(1) into vcnt from HrmDepartment where uuid=:new.uuid; +if vcnt=1 then select id into vecid from HrmDepartment where uuid=:new.uuid; +end if; +select count(1) into vcnt from hrmresource where id=:new.dept_principal; +if vcnt=1 then select messagerurl,lastname,jobtitle into vleaderimg,vleadername,veaderjobid from hrmresource where id=:new.dept_principal; +end if; +select count(1) into vcnt from hrmjobtitles where id=:new.dept_principal; +if vcnt=1 then select jobtitlemark into vleaderjob from hrmjobtitles where id=:new.dept_principal; +end if; + +select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.dept_principal; +if vcnt=1 then select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.dept_principal; +end if; select sum(nvl(staff_num,0)) into vplan from JCL_ORG_STAFF where plan_id in (select id from JCL_ORG_STAFFPLAN where time_start<=vdatebegin and time_end>=vdatebegin) and dept_id=:new.id; @@ -215,6 +259,7 @@ st int; vleaderlv VARCHAR2(255); vstr VARCHAR2(255); vwz int; + vcnt int; begin if :new.lastname!=:old.lastname or :new.status!=:old.status then st:=100000000; @@ -227,18 +272,30 @@ begin else vdelete:=1; end if; + +select count(1) into vcnt from hrmjobtitles where id=:new.jobtitle; +if vcnt=1 then select jobtitlemark into vleaderjob from hrmjobtitles where id=:new.jobtitle; +end if; +select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id; +if vcnt=1 then select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id; +end if; 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; -select nvl(field100002,'') into vstr from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id; -vwz:=Instr(vstr,'_'); + +select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=:new.id; +if vcnt=1 then +select nvl(field100002,'') into vstr from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=:new.id; +end if; + + vwz:=Instr(vstr,'_'); vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz)); vparentid:=vobjparentid+sj; @@ -274,6 +331,7 @@ st int; vleaderlv VARCHAR2(255); vstr VARCHAR2(255); vwz int; + vcnt int; begin if :new.field100002!=:old.field100002 then st:=100000000; @@ -281,19 +339,28 @@ begin sk:=300000000; vdatebegin:=to_date(sysdate); - +select count(1) into vcnt from hrmresource where id=:new.id; +if vcnt=1 then 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; +end if; +select count(1) into vcnt from hrmjobtitles where id=vleaderjobid; +if vcnt=1 then select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid; +end if; +select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id; +if vcnt=1 then select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id; +end if; -vstr:=nvl(:new.field100002,''); + vstr:=nvl(:new.field100002,''); vwz:=Instr(vstr,'_'); vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz)); vparentid:=vobjparentid+sj; + 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; if vdelete=0 then diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index 6832e6b6..96ca0365 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -317,8 +317,8 @@ select - id, - dept_name as name + id as "id", + dept_name as "name" from jcl_org_dept t WHERE delete_type = 0 AND id IN diff --git a/src/com/engine/organization/mapper/job/JobMapper.xml b/src/com/engine/organization/mapper/job/JobMapper.xml index 15158253..434bed68 100644 --- a/src/com/engine/organization/mapper/job/JobMapper.xml +++ b/src/com/engine/organization/mapper/job/JobMapper.xml @@ -396,8 +396,8 @@ select - id, - post_info_name as name + id as "id", + post_info_name as "name" from jcl_org_post_info t WHERE delete_type = 0 AND id IN diff --git a/src/com/engine/organization/mapper/post/PostMapper.xml b/src/com/engine/organization/mapper/post/PostMapper.xml index b10eb867..4ceb10c3 100644 --- a/src/com/engine/organization/mapper/post/PostMapper.xml +++ b/src/com/engine/organization/mapper/post/PostMapper.xml @@ -38,8 +38,8 @@ select - id, - level_name as name + id as "id", + level_name as "name" from jcl_org_level t WHERE delete_type = 0 AND id IN diff --git a/src/com/engine/organization/mapper/scheme/SchemeMapper.xml b/src/com/engine/organization/mapper/scheme/SchemeMapper.xml index d7ac5226..94cc2695 100644 --- a/src/com/engine/organization/mapper/scheme/SchemeMapper.xml +++ b/src/com/engine/organization/mapper/scheme/SchemeMapper.xml @@ -47,8 +47,8 @@ select - id, - sequence_name as name + id as "id", + sequence_name as "name" from jcl_org_sequence t WHERE delete_type = 0 AND id IN diff --git a/src/com/engine/organization/mapper/staff/StaffPlanMapper.xml b/src/com/engine/organization/mapper/staff/StaffPlanMapper.xml index cb7e8789..6640a79f 100644 --- a/src/com/engine/organization/mapper/staff/StaffPlanMapper.xml +++ b/src/com/engine/organization/mapper/staff/StaffPlanMapper.xml @@ -52,8 +52,8 @@