Oracle存储过程日常工作整理写法实例
create or replace package body CUX_HRMIS_SYNC_PKG is
/*
*-- Creation time:2016-12-26 09:47:26
*-- Description:同步人才搜索员工基本信息
*/
procedure PROC_SYNC_SRCH_BASE_INFO is
begin
-- 同步前删除人才搜索员工基本信息
delete from TM_HRMIS_USER;
-- 重新同步所有员工的基本信息(包括已离职员工)
insert into TM_HRMIS_USER
(USER_ID,
EMP_CODE,
EMP_NAME,
STATUS,
SUPER_EMP_CODE,
SUPER_EMP_NAME,
PICTURE,
SEX,
BIRTH_DATE,
AGE,
EDUCATION,
EDUCATION_TXT,
IN_TIME,
OUT_TIME,
WORK_AREA,
EMAIL,
POST_AGE,
ENTRY_AGE,
POS_RANK,
MAIN_POS_RANK,
POS_FUNCTION,
POS_FUNCTION_NAME,
ORG_ID,
ORG_NAME,
ORG_SHORT_NAME,
POSITION_ID,
POSITION_NAME,
POS_ATTR,
JOB_ID,
JOB_NAME,
POST_ID,
POST_NAME,
MAIN_SEQ_ID,
MAIN_SEQ_NAME,
SUB_SEQ_ID,
SUB_SEQ_NAME,
CUR_RANK_START,
CUR_POST_START,
CUR_SEQ_START)
select
USR.USERID USER_ID,
USR.ACCOUNT EMP_CODE,
USR.FULLNAME EMP_NAME,
USR.STATUS,
SUS.ACCOUNT SUPER_EMP_CODE,
SUS.FULLNAME SUPER_EMP_NAME,
USR.PICTURE,
USR.SEX,
USR.DATEOFBIRTH BIRTH_DATE,
trunc(MONTHS_BETWEEN(trunc(sysdate), trunc(USR.DATEOFBIRTH))/12) AGE,
BWU.ZCXL1 EDUCATION,
BWU.ZCZGXLMS EDUCATION_TXT,
USR.INTIME IN_TIME,
USR.OUTTIME OUT_TIME,
USR.OFFICE_ADDR WORK_AREA,
USR.EMAIL,
BWU.ZKGALN POST_AGE,
BWU.ZCGL ENTRY_AGE,
/*trunc(MONTHS_BETWEEN(trunc(sysdate), trunc(EXT.HIRE_DATE))/12, 2) ENTRY_AGE,*/
USR.JOB_ID POS_RANK,
substr(USR.JOB_ID, 2) MAIN_POS_RANK,
EXT.BTRTL POS_FUNCTION,
EXT.BTRTL_TXT POS_FUNCTION_NAME,
OGR.ORGID ORG_ID,
OGR.ORGNAME ORG_NAME,
OGR.ORG_SHORT_NAME,
POS.POSID POSITION_ID,
POS.POSNAME POSITION_NAME,
POS.POSATTR POS_ATTR,
JOB.OBJID JOB_ID,
JOB.STEXT JOB_NAME,
PST.OBJID POST_ID,
PST.STEXT POST_NAME,
SEQ.OBJID_PARENT MAIN_SEQ_ID,
SEQ.ZHRXLFLMC MAIN_SEQ_NAME,
SEQ.OBJID SUB_SEQ_ID,
SEQ.STEXT SUB_SEQ_NAME,
BWU.ZCDQZJKSR CUR_RANK_START,
BWU.ZCGWKSRQ CUR_POST_START,
BWU.ZCDQZLKSR CUR_SEQ_START
from
/*(select
USERID,
ACCOUNT,
FULLNAME,
STATUS,
PICTURE,
SEX,
DATEOFBIRTH,
INTIME,
OUTTIME,
OFFICE_ADDR,
EMAIL,
ORGID,
POSID,
JOB_ID
from
TM_USER
where
STATUS = 1
and trunc(nvl(OUTTIME, sysdate)) >= trunc(sysdate)) USR*/
TM_USER USR
left join SYS_SAP_USER_EXT EXT on USR.ACCOUNT = EXT.ACCOUNT
left join TM_SUPERIOR SUP on USR.ACCOUNT = SUP.ACCOUNT
left join TM_USER SUS on SUP.SUPERACCOUNT = SUS.ACCOUNT
left join TM_ORG OGR on USR.ORGID = OGR.ORGID and OGR.STATE = 1
left join TM_POSITION POS on USR.POSID = POS.POSID and POS.STATE = 1
left join SYS_SAP_JOB_SYS JOB on POS.STELL = JOB.OBJID and JOB.OTYPE = 'C'
left join SYS_SAP_JOB_SYS PST on JOB.OBJID_PARENT = PST.OBJID and PST.OTYPE = 'JF' and PST.ZHRXLJGMC = '岗' and substr(PST.ZHRNLCJ,2,1) = substr(USR.JOB_ID,2,1)
left join SYS_SAP_JOB_SYS SEQ on JOB.ZHRGZ = SEQ.OBJID and SEQ.OTYPE = 'JF' and substr(SEQ.ZHRNLCJ,2,1) = substr(USR.JOB_ID,2,1)
left join TM_HRMIS_BW_USER BWU on USR.ACCOUNT = BWU.EMPLOYEE;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工基本信息',
'PROC_SYNC_SRCH_BASE_INFO',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_BASE_INFO;
/*
*-- Creation time:2016-12-26 09:47:26
*-- Description:同步人才搜索员工基本信息-最高学历
*/
procedure PROC_SYNC_BASE_EDU_BACK is
V_EDU_BACK varchar2(30);
V_EDU_BACK_TXT varchar2(60);
begin
-- 查询员工的最高学历
for EM in (select
HUR.EMP_CODE,
min(EDU.SLART) EDU_BACK
from
TM_HRMIS_USER HUR
inner join SYS_SAP_EDU EDU on HUR.EMP_CODE = EDU.PERNR
group by
HUR.EMP_CODE) loop
-- 根据学历编号查询学历文本
select
LOOKUP_CODE,
MEANING
into
V_EDU_BACK,
V_EDU_BACK_TXT
from
FND_LOOKUP_VALUES
where
LOOKUP_TYPE = 'T517T'
and LANGUAGE = '1'
and ENABLED_FLAG = 'Y'
and LOOKUP_CODE = EM.EDU_BACK;
-- 修改员工的最高学历编码和文本
update TM_HRMIS_USER set EDUCATION = V_EDU_BACK, EDUCATION_TXT = V_EDU_BACK_TXT where EMP_CODE = EM.EMP_CODE;
end loop;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工基本信息-最高学历',
'PROC_SYNC_BASE_EDU_BACK',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_BASE_EDU_BACK;
/*
*-- Creation time:2016-12-26 09:47:26
*-- Description:同步人才搜索员工基本信息-近一年行政扣分
*/
procedure PROC_SYNC_BASE_RCNT_1Y_DMARKS is
V_RCNT_1YEAR_DMARKS varchar2(30);
begin
-- 查询员工的近一年行政扣分
for MID in (select
PZP.ACCOUNT,
max(decode(PZP.CAUSE_CATE,'S07',PUNISH_SCORE,0)) MANAGE_SCORE,
max(decode(PZP.CAUSE_CATE,'S06',PUNISH_SCORE,0)) INTEGRITY_SCORE,
sum(decode(PZP.CAUSE_CATE,'S07',0,PUNISH_SCORE)) DIRECT_SCORE
from
(select
SSP.PERNR ACCOUNT,
SSP.ZHRJCYYFL CAUSE_CATE,
sum(SSP.ZHRJCCSFS) PUNISH_SCORE
from
SYS_SAP_PAJC SSP
where
SSP.ZHRJCFL = '1'
and SSP.ZHRJCLX = '11'
and SSP.BEGDA >= ADD_MONTHS(sysdate, -12)
group by
SSP.PERNR,
SSP.ZHRJCYYFL) PZP
inner join TM_HRMIS_USER USR on PZP.ACCOUNT = USR.EMP_CODE and USR.STATUS = 1
group by
PZP.ACCOUNT) loop
-- 拼接直接责任扣分
if MID.DIRECT_SCORE is not null then
V_RCNT_1YEAR_DMARKS := TO_CHAR(MID.DIRECT_SCORE,'FM990.09');
else
V_RCNT_1YEAR_DMARKS := '0';
end if;
-- 拼接管理责任扣分
if MID.MANAGE_SCORE is not null then
V_RCNT_1YEAR_DMARKS := V_RCNT_1YEAR_DMARKS || '/' || TO_CHAR(MID.MANAGE_SCORE,'FM990.09');
else
V_RCNT_1YEAR_DMARKS := V_RCNT_1YEAR_DMARKS || '/0';
end if;
-- 拼接诚信类扣分
if MID.INTEGRITY_SCORE is not null then
V_RCNT_1YEAR_DMARKS := V_RCNT_1YEAR_DMARKS || '/' || TO_CHAR(MID.INTEGRITY_SCORE,'FM990.09');
else
V_RCNT_1YEAR_DMARKS := V_RCNT_1YEAR_DMARKS || '/0';
end if;
-- 修改员工的近一年行政扣分
update TM_HRMIS_USER set RCNT_1YEAR_DMARKS = V_RCNT_1YEAR_DMARKS where EMP_CODE = MID.ACCOUNT;
end loop;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工基本信息-近一年行政扣分',
'PROC_SYNC_BASE_RCNT_1Y_DMARKS',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_BASE_RCNT_1Y_DMARKS;
/*
*-- Creation time:2016-12-26 10:03:16
*-- Description:同步人才搜索员工未来发展方向信息
*/
procedure PROC_SYNC_SRCH_FUTR_DIR is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
V_ITEM_CODE varchar2(150);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的未来发展方向标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'DEV_DIR'
and T.STYP_CODE = 'DEV_DIR'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 查找近两年的未来发展方向原数据
for FUTR_DIR in(select
USR.EMP_CODE,
DMI.INV_YEAR,
DMI.FUTURE_DIRECTIONS,
DMI.FUTURE_DIRECTIONS_OTHER
from
(select
EMP_CODE_ID,
-- 替换勾选的未来发展方向中的换行符、回车符、制表符
replace(replace(replace(FUTURE_DIRECTIONS,chr(10)),chr(13)),chr(9)) FUTURE_DIRECTIONS,
-- 替换其它未来发展方向中的换行符、回车符、制表符
replace(replace(replace(FUTURE_DIRECTIONS_OTHER,chr(10)),chr(13)),chr(9)) FUTURE_DIRECTIONS_OTHER,
INV_YEAR
from
TM_HRMIS_DYNAMIC_MAP_INVENTORY
where
INV_YEAR in(V_LAST_YEAR, V_CURR_YEAR)
and (FUTURE_DIRECTIONS is not null or FUTURE_DIRECTIONS_OTHER is not null)) DMI
inner join TM_HRMIS_USER USR on DMI.EMP_CODE_ID = USR.USER_ID and USR.STATUS = 1) loop
-- 处理勾选的未来发展方向
for DIR_ITEM in(select
COLUMN_VALUE
from
table(CUX_HRMIS_UTILS_PKG.STRING_SPLIT(FUTR_DIR.FUTURE_DIRECTIONS,';'))) loop
-- 查询未来发展方向对应的编码
select
case
when count(CODE) = 0 then
'UNKNOWN'
else
max(CODE)
end CODE into V_ITEM_CODE
from
SYS_DICT_ITEM
where
TYPE_CODE = 'RC_WLFZFX'
and ITEM_NAME = DIR_ITEM.COLUMN_VALUE;
-- 处理带描述的未来发展方向项
if V_ITEM_CODE = 'XMGLJY'
or V_ITEM_CODE = 'ZYYJX'
or V_ITEM_CODE = 'ZN'
or V_ITEM_CODE = 'JY' then
DIR_ITEM.COLUMN_VALUE := substr(DIR_ITEM.COLUMN_VALUE,1,5);
end if;
-- 插入未来发展方向标签数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR2,
DATA_SOURCE,
IS_LABEL)
values
(HRMIS_SEQ_SEARCH.NEXTVAL,
FUTR_DIR.EMP_CODE,
'DEV_DIR',
'发展方向',
'DEV_DIR',
'未来发展方向',
V_ITEM_CODE,
DIR_ITEM.COLUMN_VALUE,
DIR_ITEM.COLUMN_VALUE,
TO_DATE(FUTR_DIR.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE(TO_NUMBER(FUTR_DIR.INV_YEAR) + 1||'-12-31', 'yyyy-mm-dd'),
FUTR_DIR.INV_YEAR,
'HRMI', 1);
end loop;
-- 处理其它未来发展方向
for DIR_ITEM in(select
COLUMN_VALUE
from
table(CUX_HRMIS_UTILS_PKG.STRING_SPLIT(FUTR_DIR.FUTURE_DIRECTIONS_OTHER,';'))) loop
-- 插入未来发展方向标签数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
DATA_SOURCE,
IS_LABEL)
values
(HRMIS_SEQ_SEARCH.NEXTVAL,
FUTR_DIR.EMP_CODE,
'DEV_DIR',
'发展方向',
'DEV_DIR',
'未来发展方向',
'OTHER',
'其它',
'其它',
TO_DATE(FUTR_DIR.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE(TO_NUMBER(FUTR_DIR.INV_YEAR) + 1||'-12-31', 'yyyy-mm-dd'),
DIR_ITEM.COLUMN_VALUE,
FUTR_DIR.INV_YEAR,
'HRMI', 1);
end loop;
end loop;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工未来发展方向信息',
'PROC_SYNC_SRCH_FUTR_DIR',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_FUTR_DIR;
/*
*-- Creation time:2016-12-26 10:06:39
*-- Description:同步人才搜索员工能力优势信息
*/
procedure PROC_SYNC_SRCH_ABIL_ADV is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
V_ITEM_CODE varchar2(150);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的能力优势标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'ABILITY'
and T.STYP_CODE = 'ABIL_ADV'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 查找近两年的能力优势原数据
for ABIL_ADV in(select
USR.EMP_CODE,
DMI.INV_YEAR,
DMI.ADBILITY_ADVANTAGE,
DMI.ADBILITY_ADVANTAGE_OTHER
from
(select
EMP_CODE_ID,
-- 替换勾选的能力优势中的换行符、回车符、制表符
replace(replace(replace(ADBILITY_ADVANTAGE,chr(10)),chr(13)),chr(9)) ADBILITY_ADVANTAGE,
-- 替换其它能力优势中的换行符、回车符、制表符
replace(replace(replace(ADBILITY_ADVANTAGE_OTHER,chr(10)),chr(13)),chr(9)) ADBILITY_ADVANTAGE_OTHER,
INV_YEAR
from
TM_HRMIS_DYNAMIC_MAP_INVENTORY
where
INV_YEAR in(V_LAST_YEAR, V_CURR_YEAR)
and (ADBILITY_ADVANTAGE is not null or ADBILITY_ADVANTAGE_OTHER is not null)) DMI
inner join TM_HRMIS_USER USR on DMI.EMP_CODE_ID = USR.USER_ID and USR.STATUS = 1) loop
-- 处理勾选的能力优势
for ADV_ITEM in(select
COLUMN_VALUE
from
table(CUX_HRMIS_UTILS_PKG.STRING_SPLIT(ABIL_ADV.ADBILITY_ADVANTAGE,';'))) loop
-- 查询能力优势对应的编码
select
case
when count(CODE) = 0 then
'UNKNOWN'
else
max(CODE)
end CODE into V_ITEM_CODE
from
SYS_DICT_ITEM
where
TYPE_CODE = 'RC_NLYS'
and ITEM_NAME = ADV_ITEM.COLUMN_VALUE;
-- 插入能力优势标签数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR2,
DATA_SOURCE,
IS_LABEL)
values
(HRMIS_SEQ_SEARCH.NEXTVAL,
ABIL_ADV.EMP_CODE,
'ABILITY',
'能力',
'ABIL_ADV',
'能力优势',
V_ITEM_CODE,
ADV_ITEM.COLUMN_VALUE,
ADV_ITEM.COLUMN_VALUE,
TO_DATE(ABIL_ADV.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE(TO_NUMBER(ABIL_ADV.INV_YEAR) + 1||'-12-31', 'yyyy-mm-dd'),
ABIL_ADV.INV_YEAR,
'HRMI', 1);
end loop;
-- 处理其它能力优势
for ADV_ITEM in(select
COLUMN_VALUE
from
table(CUX_HRMIS_UTILS_PKG.STRING_SPLIT(ABIL_ADV.ADBILITY_ADVANTAGE_OTHER,';'))) loop
-- 插入能力优势标签数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
DATA_SOURCE,
IS_LABEL)
values
(HRMIS_SEQ_SEARCH.NEXTVAL,
ABIL_ADV.EMP_CODE,
'ABILITY',
'能力',
'ABIL_ADV',
'能力优势',
'OTHER',
'其它',
'其它',
TO_DATE(ABIL_ADV.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE(TO_NUMBER(ABIL_ADV.INV_YEAR) + 1||'-12-31', 'yyyy-mm-dd'),
ADV_ITEM.COLUMN_VALUE,
ABIL_ADV.INV_YEAR,
'HRMI', 1);
end loop;
end loop;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工能力优势信息',
'PROC_SYNC_SRCH_ABIL_ADV',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_ABIL_ADV;
/*
*-- Creation time:2016-12-26 10:35:35
*-- Description:同步人才搜索员工高潜信息
*/
procedure PROC_SYNC_SRCH_HIGH_POT is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的高潜标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'TLNTS_POOL'
and T.STYP_CODE = 'HIGH_POT'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 员工高潜信息分析
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
ATTR3,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'TLNTS_POOL' TYPE_CODE,
'人才池' TYPE_NAME,
'HIGH_POT' STYP_CODE,
'高潜' STYP_NAME,
'HIGH_POT' LABEL_CODE,
'高潜' LABEL_NAME,
HCI.YEAR||'年高潜' LABEL_ALIAS,
TO_DATE(HCI.YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE(HCI.YEAR + 1||'-12-31', 'yyyy-mm-dd'),
HCI.CHECK_RESULT,
HCI.YEAR,
HCI.TAL_DEV_PLAN,
'SAP', 1
from
(select
ACCOUNT,
BEGIN_DATE,
END_DATE,
CHECK_RESULT,
YEAR,
TAL_DEV_PLAN
from
TM_HRMIS_CHECK_INFO
where
CHECK_RESULT in(select
CODE
from
SYS_DICT_ITEM
where
STATUS = '1'
and TYPE_CODE = 'HIGH_POT_QVALUE')
and YEAR in(TO_NUMBER(V_LAST_YEAR), TO_NUMBER(V_CURR_YEAR))) HCI
inner join TM_HRMIS_USER USR on HCI.ACCOUNT = USR.EMP_CODE and USR.STATUS = 1;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工高潜信息',
'PROC_SYNC_SRCH_HIGH_POT',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_HIGH_POT;
/*
*-- Creation time:2016-12-26 10:44:10
*-- Description:同步人才搜索员工任职资格信息
*/
procedure PROC_SYNC_SRCH_QUALIFICATION is
begin
-- 同步前先删除任职资格标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'BASE_INFO'
and T.STYP_CODE = 'QLFCTN';
-- 员工任职资格信息分析
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
ATTR3,
ATTR4,
ATTR5,
ATTR6,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL INFO_ID,
USR.EMP_CODE,
'BASE_INFO' TYPE_CODE,
'基本信息' TYPE_NAME,
'QLFCTN' STYP_CODE,
'任职资格' STYP_NAME,
RNK.LOOKUP_CODE||'-'||TYP.LOOKUP_CODE LABEL_CODE,
RNK.MEANING||'-'||TYP.MEANING||'-任职资格' LABEL_NAME,
RNK.MEANING||'-'||TYP.MEANING||'-任职资格' LABEL_ALIAS,
SSA.BEGDA BEGIN_DATE,
ADD_MONTHS(SSA.BEGDA,24) END_DATE,
TYP.LOOKUP_CODE TYPE_CODE,
TYP.MEANING TYPE_NAME,
RNK.LOOKUP_CODE RANK_CODE,
RNK.MEANING RANK_NAME,
RST.LOOKUP_CODE RESULT_CODE,
RST.MEANING RESULT_TEXT,
'SAP', 1
from
(select
distinct
PERSNO,
BEGDA,
ENDDA,
ZHRXL,
ZHRRZLB,
ZHRDJ,
ZHRRZJG
from
SYS_SAP_AUTH
where
ZHRRZJG = '1'
and ZHRRZLB is not null
and ZHRDJ is not null) SSA
inner join TM_HRMIS_USER USR on SSA.PERSNO = USR.EMP_CODE and USR.STATUS = 1
left join FND_LOOKUP_VALUES TYP on SSA.ZHRRZLB = TYP.LOOKUP_CODE and TYP.LOOKUP_TYPE = 'ZDMHRRZLB' and TYP.LANGUAGE = '1' and TYP.ENABLED_FLAG = 'Y'
left join FND_LOOKUP_VALUES RNK on SSA.ZHRDJ = RNK.LOOKUP_CODE and RNK.LOOKUP_TYPE = 'ZDMHRDJ' and RNK.LANGUAGE = '1' and RNK.ENABLED_FLAG = 'Y'
left join FND_LOOKUP_VALUES RST on SSA.ZHRRZJG = RST.LOOKUP_CODE and RST.LOOKUP_TYPE = 'ZDMHRRZJG' and RST.LANGUAGE = '1' and RST.ENABLED_FLAG = 'Y';
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工任职资格信息',
'PROC_SYNC_SRCH_QUALIFICATION',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_QUALIFICATION;
/*
*-- Creation time:2016-12-26 10:53:13
*-- Description:同步人才搜索员工项目经验信息
*/
procedure PROC_SYNC_SRCH_PROJ_EXP is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
begin
-- 同步前先删除项目经验标签数据(来源于SAP)
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'PROJ_EXP'
and T.DATA_SOURCE = 'SAP';
-- 员工项目经验信息分析
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
ATTR3,
ATTR4,
ATTR5,
ATTR6,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'EXPERIENCE' TYPE_CODE,
'经验' TYPE_NAME,
'PROJ_EXP' STYP_CODE,
'项目经验' STYP_NAME,
'PROJ_EXP' LABEL_CODE,
'项目经验' LABEL_NAME,
'项目经验' LABEL_ALIAS,
EXP.BEGIN_DATE,
EXP.END_DATE,
EXP.PROJECT_NAME,
CAT.LOOKUP_CODE PROJECT_CATE,
CAT.MEANING PROJECT_CATE_NAME,
STS.LOOKUP_CODE STATUS,
STS.MEANING STATUS_TXT,
EXP.ROLE,
'SAP', 1
from
TM_HRMIS_PROJECT_EXPERIENCE EXP
inner join TM_HRMIS_USER USR on EXP.ACCOUNT = USR.EMP_CODE and USR.STATUS = 1
left join FND_LOOKUP_VALUES CAT on EXP.PROJECT_CATE = CAT.LOOKUP_CODE and CAT.LOOKUP_TYPE = 'ZDMHRXMLB' and CAT.LANGUAGE = '1' and CAT.ENABLED_FLAG = 'Y'
left join FND_LOOKUP_VALUES STS on EXP.STATUS = STS.LOOKUP_CODE and STS.LOOKUP_TYPE = 'ZDMHRCYZT' and STS.LANGUAGE = '1' and STS.ENABLED_FLAG = 'Y';
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的项目经验标签数据(来源于HRMI)
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'PROJ_EXP'
and T.DATA_SOURCE = 'HRMI'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 人才盘点评价的项目经验标签
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR2,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'EXPERIENCE' TYPE_CODE,
'经验' TYPE_NAME,
'PROJ_EXP' STYP_CODE,
'项目经验' STYP_NAME,
'PROJ_EXP' LABEL_CODE,
'项目经验' LABEL_NAME,
'项目经验' LABEL_ALIAS,
TO_DATE(DMI.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE('9999-12-31', 'yyyy-mm-dd'),
DMI.INV_YEAR,
'HRMI', 1
from
(select
EMP_CODE_ID,
INV_YEAR
from
TM_HRMIS_DYNAMIC_MAP_INVENTORY
where
EXPERIENCE is not null
and instr(EXPERIENCE,'项目经验') > 0
and INV_YEAR in(V_LAST_YEAR, V_CURR_YEAR)) DMI
inner join TM_HRMIS_USER USR on DMI.EMP_CODE_ID = USR.USER_ID and USR.STATUS = 1;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工项目经验信息',
'PROC_SYNC_SRCH_PROJ_EXP',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_PROJ_EXP;
/*
*-- Creation time:2016-12-26 11:01:38
*-- Description:同步人才搜索员工近一年行政扣分信息
*/
procedure PROC_SYNC_SRCH_RCNT_1Y_DMARKS is
begin
-- 全量同步,先删除原表中的近一年行政扣分数据
delete
from TM_HRMIS_SEARCH_INFO
where
TYPE_CODE = 'OTHER'
and STYP_CODE = 'RCNT_1YEAR_DMARKS';
-- 近一年行政扣分数据分析
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
ATTR13,
ATTR14,
ATTR15,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
ACCOUNT,
'OTHER' TYPE_CODE,
'其它' TYPE_NAME,
'RCNT_1YEAR_DMARKS' STYP_CODE,
'近一年行政扣分' STYP_NAME,
'RCNT_1YEAR_DMARKS' LABEL_CODE,
'近一年行政扣分' LABEL_NAME,
DIRECT_SCORE,
MANAGE_SCORE,
INTEGRITY_SCORE,
'SAP', 0
from
(select
PZP.ACCOUNT,
max(decode(PZP.CAUSE_CATE,'S07',PUNISH_SCORE,0)) MANAGE_SCORE,
max(decode(PZP.CAUSE_CATE,'S06',PUNISH_SCORE,0)) INTEGRITY_SCORE,
sum(decode(PZP.CAUSE_CATE,'S07',0,PUNISH_SCORE)) DIRECT_SCORE
from
(select
SSP.PERNR ACCOUNT,
SSP.ZHRJCYYFL CAUSE_CATE,
sum(SSP.ZHRJCCSFS) PUNISH_SCORE
from
SYS_SAP_PAJC SSP
where
SSP.ZHRJCFL = '1'
and SSP.ZHRJCLX = '11'
and SSP.BEGDA >= ADD_MONTHS(sysdate, -12)
group by
SSP.PERNR,
SSP.ZHRJCYYFL) PZP
inner join TM_HRMIS_USER USR on PZP.ACCOUNT = USR.EMP_CODE and USR.STATUS = 1
group by
PZP.ACCOUNT);
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工近一年行政扣分信息',
'PROC_SYNC_SRCH_RCNT_1Y_DMARKS',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_RCNT_1Y_DMARKS;
/*
*-- Creation time:2016-12-26 11:17:03
*-- Description:同步人才搜索员工团队管理经验信息
*/
procedure PROC_SYNC_SRCH_TEAM_MGMT is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的团队管理经验标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'TEAM_MGMT'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 人才盘点评价的团队管理经验标签
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR2,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'EXPERIENCE' TYPE_CODE,
'经验' TYPE_NAME,
'TEAM_MGMT' STYP_CODE,
'团队管理' STYP_NAME,
'TEAM_MGMT' LABEL_CODE,
'团队管理经验' LABEL_NAME,
'团队管理经验' LABEL_ALIAS,
TO_DATE(DMI.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE('9999-12-31', 'yyyy-mm-dd'),
DMI.INV_YEAR,
'HRMI', 1
from
(select
EMP_CODE_ID,
INV_YEAR
from
TM_HRMIS_DYNAMIC_MAP_INVENTORY
where
EXPERIENCE is not null
and instr(EXPERIENCE,'团队管理经验') > 0
and INV_YEAR in(V_LAST_YEAR, V_CURR_YEAR)) DMI
inner join TM_HRMIS_USER USR on DMI.EMP_CODE_ID = USR.USER_ID and USR.STATUS = 1;
-- 同步由BW分析的团队管理经验标签数据
-- 同步前先删除人才搜索标签表中来自于BW的团队管理经验标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'TEAM_MGMT'
and T.DATA_SOURCE = 'BW';
-- BW中分析出的团队管理经验数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'EXPERIENCE' TYPE_CODE,
'经验' TYPE_NAME,
'TEAM_MGMT' STYP_CODE,
'团队管理' STYP_NAME,
'TEAM_MGMT' LABEL_CODE,
'团队管理经验' LABEL_NAME,
'团队管理经验' LABEL_ALIAS,
'BW', 1
from
(select
EMP_CODE
from
TM_HRMIS_BW_EXP
where
TYPE = 'TEAM_MGMT'
and FLAG = '1') EXP
inner join TM_HRMIS_USER USR on EXP.EMP_CODE = USR.EMP_CODE and USR.STATUS = 1;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工团队管理经验信息',
'PROC_SYNC_SRCH_TEAM_MGMT',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_TEAM_MGMT;
/*
*-- Creation time:2016-12-26 11:29:48
*-- Description:同步人才搜索员工行业标杆经验信息
*/
procedure PROC_SYNC_SRCH_INDS_BENM is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的行业标杆经验标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'INDS_BENM'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 查找近两年的行业标杆经验原数据
for MDEL_EXP in(select
USR.EMP_CODE,
DMI.MODEL_EXPERIENCE,
DMI.INV_YEAR
from
(select
EMP_CODE_ID,
MODEL_EXPERIENCE,
INV_YEAR
from
TM_HRMIS_DYNAMIC_MAP_INVENTORY
where
MODEL_EXPERIENCE is not null
and INV_YEAR in(V_LAST_YEAR, V_CURR_YEAR)) DMI
inner join TM_HRMIS_USER USR on DMI.EMP_CODE_ID = USR.USER_ID and USR.STATUS = 1) loop
-- 处理人才评价中填写的行业标杆经验
for EXP_ITEM in(select
COLUMN_VALUE
from
table(CUX_HRMIS_UTILS_PKG.STRING_SPLIT(MDEL_EXP.MODEL_EXPERIENCE,';'))) loop
-- 插入行业标杆经验标签数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
DATA_SOURCE,
IS_LABEL)
values
(HRMIS_SEQ_SEARCH.NEXTVAL,
MDEL_EXP.EMP_CODE,
'EXPERIENCE',
'经验',
'INDS_BENM',
'行业标杆',
'INDS_BENM',
'行业标杆经验',
'行业标杆经验',
TO_DATE(MDEL_EXP.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE('9999-12-31', 'yyyy-mm-dd'),
EXP_ITEM.COLUMN_VALUE,
MDEL_EXP.INV_YEAR,
'HRMI', 1);
end loop;
end loop;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工行业标杆经验信息',
'PROC_SYNC_SRCH_INDS_BENM',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_INDS_BENM;
/*
*-- Creation time:2016-12-26 11:29:48
*-- Description:同步人才搜索员工跨组织经验信息
*/
procedure PROC_SYNC_SRCH_TRANS_ORG is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的跨组织经验标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'TRANS_ORG'
and T.DATA_SOURCE = 'HRMI'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 人才评价中勾选的跨组织经验标签
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR2,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'EXPERIENCE' TYPE_CODE,
'经验' TYPE_NAME,
'TRANS_ORG' STYP_CODE,
'跨组织' STYP_NAME,
'TRANS_ORG' LABEL_CODE,
'跨组织经验' LABEL_NAME,
'跨组织经验' LABEL_ALIAS,
TO_DATE(DMI.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE('9999-12-31', 'yyyy-mm-dd'),
DMI.INV_YEAR,
'HRMI', 1
from
(select
EMP_CODE_ID,
INV_YEAR
from
TM_HRMIS_DYNAMIC_MAP_INVENTORY
where
EXPERIENCE is not null
and instr(EXPERIENCE,'跨组织经验') > 0
and INV_YEAR in(V_LAST_YEAR, V_CURR_YEAR)) DMI
inner join TM_HRMIS_USER USR on DMI.EMP_CODE_ID = USR.USER_ID and USR.STATUS = 1;
-- 同步由BW分析的跨组织经验标签数据
-- 同步前先删除人才搜索标签表中来自于BW的跨组织经验标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'TRANS_ORG'
and T.DATA_SOURCE = 'BW';
-- BW中分析出的跨组织经验数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'EXPERIENCE' TYPE_CODE,
'经验' TYPE_NAME,
'TRANS_ORG' STYP_CODE,
'跨组织' STYP_NAME,
'TRANS_ORG' LABEL_CODE,
'跨组织经验' LABEL_NAME,
'跨组织经验' LABEL_ALIAS,
'BW', 1
from
(select
EMP_CODE
from
TM_HRMIS_BW_EXP
where
TYPE = 'TRANS_ORG'
and FLAG = '1') EXP
inner join TM_HRMIS_USER USR on EXP.EMP_CODE = USR.EMP_CODE and USR.STATUS = 1;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工跨组织经验信息',
'PROC_SYNC_SRCH_TRANS_ORG',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_TRANS_ORG;
/*
*-- Creation time:2016-12-26 11:29:48
*-- Description:同步人才搜索员工跨职能经验信息
*/
procedure PROC_SYNC_SRCH_TRANS_POS is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的跨职能经验标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'TRANS_POS'
and T.DATA_SOURCE = 'HRMI'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 人才评价中勾选的跨职能经验标签
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR2,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'EXPERIENCE' TYPE_CODE,
'经验' TYPE_NAME,
'TRANS_POS' STYP_CODE,
'跨职能' STYP_NAME,
'TRANS_POS' LABEL_CODE,
'跨职能经验' LABEL_NAME,
'跨职能经验' LABEL_ALIAS,
TO_DATE(DMI.INV_YEAR||'-01-01', 'yyyy-mm-dd'),
TO_DATE('9999-12-31', 'yyyy-mm-dd'),
DMI.INV_YEAR,
'HRMI', 1
from
(select
EMP_CODE_ID,
INV_YEAR
from
TM_HRMIS_DYNAMIC_MAP_INVENTORY
where
EXPERIENCE is not null
and instr(EXPERIENCE,'跨职能经验') > 0
and INV_YEAR in(V_LAST_YEAR, V_CURR_YEAR)) DMI
inner join TM_HRMIS_USER USR on DMI.EMP_CODE_ID = USR.USER_ID and USR.STATUS = 1;
-- 同步由BW分析的跨职能经验标签数据
-- 同步前先删除人才搜索标签表中来自于BW的跨职能经验标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'EXPERIENCE'
and T.STYP_CODE = 'TRANS_POS'
and T.DATA_SOURCE = 'BW';
-- BW中分析出的跨职能经验数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR3,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'EXPERIENCE' TYPE_CODE,
'经验' TYPE_NAME,
'TRANS_POS' STYP_CODE,
'跨职能' STYP_NAME,
'TRANS_POS' LABEL_CODE,
'跨职能经验' LABEL_NAME,
'跨职能经验' LABEL_ALIAS,
EXP.DATE_FROM,
EXP.DATE_TO,
POF.ZCZN,
POF.TXTSH,
'BW', 1
from
(select
EMP_CODE,
DATE_FROM,
DATE_TO,
POS_FUNC
from
TM_HRMIS_BW_EXP
where
TYPE = 'TRANS_POS'
and FLAG = '1') EXP
inner join TM_HRMIS_USER USR on EXP.EMP_CODE = USR.EMP_CODE and USR.STATUS = 1
left join TM_HRMIS_POSFUNC_FBW POF on EXP.POS_FUNC = POF.ZCZN and POF.LANGU = '1' and EXP.DATE_FROM between POF.DATEFROM and POF.DATETO
/*left join (select
distinct LOOKUP_CODE,
MEANING
from
FND_LOOKUP_VALUES
where
LOOKUP_TYPE = 'ZTHRZN'
and LANGUAGE = '1'
and ENABLED_FLAG = 'Y') POF on EXP.POS_FUNC = POF.LOOKUP_CODE*/;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工跨职能经验信息',
'PROC_SYNC_SRCH_TRANS_POS',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_TRANS_POS;
/*
*-- Creation time:2016-12-26 14:47:02
*-- Description:同步人才搜索员工年度绩效信息
*/
procedure PROC_SYNC_SRCH_PERFORMANCE is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的年度绩效数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'OTHER'
and T.STYP_CODE = 'PERFOR'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 员工年度绩效信息分析
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
ATTR3,
ATTR4,
ATTR11,
ATTR12,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'OTHER' TYPE_CODE,
'其它' TYPE_NAME,
'PERFOR' STYP_CODE,
'年度绩效' STYP_NAME,
GRD.LOOKUP_CODE LABEL_CODE,
GRD.MEANING LABEL_NAME,
SSJ.BEGDA,
SSJ.ENDDA,
SSJ.ZHRKHZQ,
SSJ.ZHRKHND,
GRD.LOOKUP_CODE PERF,
GRD.MEANING PERF_TXT,
SSJ.ZHRZYYD,
SSJ.ZHRZYQD,
'SAP', 0
from
(select
PERNR,
BEGDA,
ENDDA,
ZHRKHZQ,
ZHRKHND,
ZHRDJJGLX,
ZHRZYYD,
ZHRZYQD
from
SYS_SAP_JXRE
where
ZHRKHZQ = 'YD'
and ZHRDJJGLX is not null
and ZHRKHND in(TO_NUMBER(V_LAST_YEAR), TO_NUMBER(V_CURR_YEAR))) SSJ
inner join TM_HRMIS_USER USR on SSJ.PERNR = USR.EMP_CODE and USR.STATUS = 1
left join FND_LOOKUP_VALUES GRD
on SSJ.ZHRDJJGLX = GRD.LOOKUP_CODE
and GRD.LOOKUP_TYPE = 'ZDEHRDJJGLX'
and GRD.LANGUAGE = '1'
and GRD.ENABLED_FLAG = 'Y';
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工年度绩效信息',
'PROC_SYNC_SRCH_PERFORMANCE',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_PERFORMANCE;
/*
*-- Creation time:2016-12-26 14:47:02
*-- Description:同步人才搜索员工人才盘点信息
*/
procedure PROC_SYNC_SRCH_TLNTS_CHECK is
V_CURR_YEAR varchar2(4);
V_LAST_YEAR varchar2(4);
begin
V_CURR_YEAR := TO_CHAR(sysdate,'yyyy');
V_LAST_YEAR := TO_CHAR(TO_NUMBER(V_CURR_YEAR) - 1);
-- 同步前先删除近两年的人才盘点数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'OTHER'
and T.STYP_CODE = 'TLNTS_CHECK'
and T.ATTR2 in(V_LAST_YEAR, V_CURR_YEAR);
-- 员工人才盘点信息分析
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
ATTR3,
ATTR11,
ATTR12,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'OTHER' TYPE_CODE,
'其它' TYPE_NAME,
'TLNTS_CHECK' STYP_CODE,
'人才盘点' STYP_NAME,
CHI.CHECK_RESULT LABEL_CODE,
CHI.CHECK_RESULT LABEL_NAME,
CHI.BEGIN_DATE,
CHI.END_DATE,
CHI.CHECK_RESULT,
CHI.YEAR,
CHI.TAL_DEV_PLAN,
CHI.ADVANTAGE,
CHI.SHORTAGE,
'SAP', 0
from
(select
ACCOUNT,
YEAR,
BEGIN_DATE,
END_DATE,
CHECK_RESULT,
TAL_DEV_PLAN,
ADVANTAGE,
SHORTAGE
from
TM_HRMIS_CHECK_INFO
where
CHECK_RESULT is not null
and YEAR in(TO_NUMBER(V_LAST_YEAR), TO_NUMBER(V_CURR_YEAR))) CHI
inner join TM_HRMIS_USER USR on CHI.ACCOUNT = USR.EMP_CODE and USR.STATUS = 1;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工人才盘点信息',
'PROC_SYNC_SRCH_TLNTS_CHECK',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_TLNTS_CHECK;
/*
*-- Creation time:2016-12-26 14:47:02
*-- Description:同步人才搜索员工外语能力信息
*/
procedure PROC_SYNC_SRCH_FOR_LANG is
begin
-- 同步前先删除员工外语能力数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'OTHER'
and T.STYP_CODE = 'FOR_LANG';
-- 员工外语能力信息分析
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
ATTR3,
ATTR4,
ATTR5,
ATTR6,
ATTR7,
ATTR8,
ATTR9,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'OTHER' TYPE_CODE,
'其它' TYPE_NAME,
'FOR_LANG' STYP_CODE,
'外语能力' STYP_NAME,
TYP.LOOKUP_CODE||LAB.GRADE LABEL_CODE,
TYP.MEANING||LAB.GRADE LABEL_NAME,
LAB.BEGIN_DATE,
LAB.END_DATE,
TYP.LOOKUP_CODE LANGUAGE,
TYP.MEANING LANGUAGE_TXT,
LAB.GRADE,
WLV.LOOKUP_CODE WRITING,
WLV.MEANING WRITING_TXT,
SLV.LOOKUP_CODE SPOKEN,
SLV.MEANING SPOKEN_TXT,
RLV.LOOKUP_CODE READ,
RLV.MEANING READ_TXT,
'SAP', 0
from
(select
ACCOUNT,
BEGIN_DATE,
END_DATE,
LANGUAGE,
GRADE,
WRITING,
SPOKEN,
READ
from
TM_HRMIS_LANGUAGE_ABILITY
where
LANGUAGE is not null) LAB
inner join TM_HRMIS_USER USR on LAB.ACCOUNT = USR.EMP_CODE and USR.STATUS = 1
left join FND_LOOKUP_VALUES TYP on LAB.LANGUAGE = TYP.LOOKUP_CODE and TYP.LOOKUP_TYPE = 'T591S' and TYP.ATTRIBUTE1 = '9000' and TYP.LANGUAGE = '1' and TYP.ENABLED_FLAG = 'Y'
left join FND_LOOKUP_VALUES WLV on LAB.WRITING = WLV.LOOKUP_CODE and WLV.LOOKUP_TYPE = 'ZDMHRWYJB' and WLV.LANGUAGE = '1' and WLV.ENABLED_FLAG = 'Y'
left join FND_LOOKUP_VALUES SLV on LAB.SPOKEN = SLV.LOOKUP_CODE and SLV.LOOKUP_TYPE = 'ZDMHRWYJB' and SLV.LANGUAGE = '1' and SLV.ENABLED_FLAG = 'Y'
left join FND_LOOKUP_VALUES RLV on LAB.READ = RLV.LOOKUP_CODE and RLV.LOOKUP_TYPE = 'ZDMHRWYJB' and RLV.LANGUAGE = '1' and RLV.ENABLED_FLAG = 'Y';
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工外语能力信息',
'PROC_SYNC_SRCH_FOR_LANG',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_FOR_LANG;
/*
*-- Creation time:2016-12-26 14:47:02
*-- Description:同步人才搜索员工大学生标签信息
*/
procedure PROC_SYNC_SRCH_UNDERGRADUATE is
begin
-- 同步前先删除大学生标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'TLNTS_POOL'
and T.STYP_CODE = 'UNDGR';
-- 员工大学生信息分析
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
ATTR3,
ATTR4,
ATTR5,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'TLNTS_POOL' TYPE_CODE,
'人才池' TYPE_NAME,
'UNDGR' STYP_CODE,
'大学生' STYP_NAME,
XMT.LOOKUP_CODE LABEL_CODE,
XMT.MEANING LABEL_NAME,
XMT.MEANING LABEL_ALIAS,
REC.BEGDA,
REC.ENDDA,
XMT.MEANING,
REC.ZHRBYNF,
REC.ZHRXZXM,
REC.ZHRZPQD,
REC.ZHRQDMC,
'SAP', 1
from
(select
PERNR,
BEGDA,
ENDDA,
ZHRZPQD,
ZHRQDMC,
ZHRXZXM,
ZHRBYNF
from
TM_HRMIS_RECR_CHANNEL
where
ZHRZPQD = '18'
and ZHRXZXM is not null) REC
inner join TM_HRMIS_USER USR on REC.PERNR = USR.EMP_CODE and USR.STATUS = 1
left join FND_LOOKUP_VALUES XMT
on REC.ZHRXZXM = XMT.LOOKUP_CODE
and XMT.LOOKUP_TYPE = 'ZTHRXZXMT'
and XMT.LANGUAGE = '1'
and XMT.ENABLED_FLAG = 'Y'
and XMT.LOOKUP_CODE is not null;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工大学生标签信息',
'PROC_SYNC_SRCH_UNDERGRADUATE',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_UNDERGRADUATE;
/*
*-- Creation time:2016-12-29 19:53:31
*-- Description:同步人才搜索员工后备标签信息
*/
procedure PROC_SYNC_SRCH_RESERVE is
begin
-- 同步前先删除后备标签数据
delete
from TM_HRMIS_SEARCH_INFO T
where
T.TYPE_CODE = 'TLNTS_POOL'
and T.STYP_CODE = 'RESERVE'
and T.DATA_SOURCE = 'BW';
-- 分析人才搜索员工后备标签数据
insert into TM_HRMIS_SEARCH_INFO
(INFO_ID,
EMP_CODE,
TYPE_CODE,
TYPE_NAME,
STYP_CODE,
STYP_NAME,
LABEL_CODE,
LABEL_NAME,
LABEL_ALIAS,
INVALID_START,
INVALID_END,
ATTR1,
ATTR2,
ATTR3,
ATTR4,
ATTR5,
ATTR6,
ATTR7,
ATTR8,
ATTR9,
DATA_SOURCE,
IS_LABEL)
select
HRMIS_SEQ_SEARCH.NEXTVAL,
USR.EMP_CODE,
'TLNTS_POOL' TYPE_CODE,
'人才池' TYPE_NAME,
'RESERVE' STYP_CODE,
'后备信息' STYP_NAME,
TYP.CODE LABEL_CODE,
TYP.ITEM_NAME LABEL_NAME,
TYP.ITEM_NAME LABEL_ALIAS,
RES.DATE_FROM,
ADD_MONTHS(RES.DATE_FROM,24),
TYP.CODE,
TO_CHAR(RES.DATE_FROM,'yyyy'),
TYP.ITEM_NAME,
SOU.LOOKUP_CODE,
SOU.MEANING,
JOB.OBJID,
JOB.STEXT,
STS.LOOKUP_CODE,
STS.MEANING,
'BW', 1
from
TM_HRMIS_BW_RESERVE RES
inner join TM_HRMIS_USER USR on RES.EMP_CODE = USR.EMP_CODE and USR.STATUS = 1
left join SYS_DICT_ITEM TYP on RES.TYPE = TYP.CODE and TYP.TYPE_CODE = 'RESERVE_TYPE' and TYP.STATUS = '1'
left join SYS_SAP_JOB_SYS JOB on RES.POST = JOB.OBJID and JOB.OTYPE = 'C'
left join FND_LOOKUP_VALUES SOU on RES.SOURCE = SOU.LOOKUP_CODE and SOU.LOOKUP_TYPE = 'ZDMHRCBLY' and SOU.LANGUAGE = '1' and SOU.ENABLED_FLAG = 'Y'
left join FND_LOOKUP_VALUES STS on RES.STATUS = STS.LOOKUP_CODE and STS.LOOKUP_TYPE = 'ZDMHRZT' and STS.LANGUAGE = '1' and STS.ENABLED_FLAG = 'Y';
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('人才搜索员工后备标签信息',
'PROC_SYNC_SRCH_RESERVE',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_SRCH_RESERVE;
/*
*-- Creation time:2016-12-27 16:21:53
*-- Description:同步SAP推送的个人职级报表数据至HRMIS正式表
*/
procedure PROC_SYNC_RANK_REPORT_FSAP is
TEMP_COUNT number;
begin
-- 查询临时表中未同步至正式表的数据数量
select
count(PERNR) into TEMP_COUNT
from
TM_HRMIS_RANK_REPORT_FROM_SAP
where
IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null;
if TEMP_COUNT > 0 then
-- 根据临时表中未同步数据的批次号
-- 将临时表数据逐批的同步至正式表
for BNO in(select
distinct BATCH_NO
from
TM_HRMIS_RANK_REPORT_FROM_SAP
where
IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null
order by
BATCH_NO) loop
-- 每同步一批次前先清空正式表的数据
-- 正式表的数据只取临时表中最后一批次的数据
delete from TM_HRMIS_RANK_REPORT;
-- 插入当前批次未同步的所有数据至正式表
insert into TM_HRMIS_RANK_REPORT
(MANDT,
NUM,
PERNR,
PERNR_CP,
ENAME,
WERKS,
NAME1,
BTRTL,
BTEXT,
ORGEH,
STEXT,
ZHRGWCJ,
ZHRGWCJMC,
BEGDA,
FWQX_ZY,
FWQX_GL,
FWQX_LJ,
BEGDA_ZIXL,
FWQX_ZIXL,
ZHRNLCJ,
ZHRNLCJ_BEGDA,
ZHRNLCJ_SC,
PLANT,
MASSG,
MGTXT,
ZHRJZLX,
ZHRJZLX_TXT,
ZHRJZYYSM)
select
MANDT,
NUM,
PERNR,
PERNR_CP,
ENAME,
WERKS,
NAME1,
BTRTL,
BTEXT,
ORGEH,
STEXT,
ZHRGWCJ,
ZHRGWCJMC,
BEGDA,
FWQX_ZY,
FWQX_GL,
FWQX_LJ,
BEGDA_ZIXL,
FWQX_ZIXL,
ZHRNLCJ,
ZHRNLCJ_BEGDA,
ZHRNLCJ_SC,
PLANT,
MASSG,
MGTXT,
ZHRJZLX,
ZHRJZLX_TXT,
ZHRJZYYSM
from
TM_HRMIS_RANK_REPORT_FROM_SAP
where
BATCH_NO = BNO.BATCH_NO
and (IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null);
end loop;
-- 所有批次同步完成后修改临时表数据的同步状态
update TM_HRMIS_RANK_REPORT_FROM_SAP set IS_SYNC_HRMIS = 'Y', SYNC_HRMIS_TIME = sysdate where IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null;
-- 删除临时表中两个月前已同步过的数据
delete from TM_HRMIS_RANK_REPORT_FROM_SAP where IS_SYNC_HRMIS = 'Y' and SYNC_HRMIS_TIME < (sysdate - 60);
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('个人职级报表',
'PROC_SYNC_RANK_REPORT_FSAP',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_RANK_REPORT_FSAP;
/*
*-- Creation time:2016-12-21 14:57:19
*-- Description:同步SAP推送的招聘渠道数据至HRMIS正式表
*/
procedure PROC_SYNC_RECR_CHANNEL_FSAP is
TEMP_COUNT number;
begin
-- 查询临时表中未同步至正式表的数据数量
select
count(PERNR) into TEMP_COUNT
from
TM_HRMIS_RECR_CHANNEL_FROM_SAP
where
IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null;
if TEMP_COUNT > 0 then
-- 根据临时表中未同步数据的批次号
-- 将临时表数据逐批的同步至正式表
for BNO in(select
distinct BATCH_NO
from
TM_HRMIS_RECR_CHANNEL_FROM_SAP
where
IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null
order by
BATCH_NO) loop
-- 根据临时表中当前批次未同步数据的工号
-- 删除正式表中这些工号对应的数据
delete from TM_HRMIS_RECR_CHANNEL where PERNR in(select
distinct CUX_HRMIS_UTILS_PKG.CODE_8BIT_TO_6BIT(PERNR)
from
TM_HRMIS_RECR_CHANNEL_FROM_SAP
where
BATCH_NO = BNO.BATCH_NO
and (IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null));
-- 插入当前批次未同步的所有数据至正式表
insert into TM_HRMIS_RECR_CHANNEL
(PERNR,
SUBTY,
OBJPS,
SPRPS,
ENDDA,
BEGDA,
SEQNR,
AEDTM,
UNAME,
ZHRZPQD,
ZHRQDMC,
ZHRXZXM,
ZHRXZCBFX,
ZHRBYNF,
ZHRCXPYYY)
select
CUX_HRMIS_UTILS_PKG.CODE_8BIT_TO_6BIT(PERNR),
SUBTY,
OBJPS,
SPRPS,
TO_DATE(ENDDA,'yyyy.mm.dd'),
TO_DATE(BEGDA,'yyyy.mm.dd'),
SEQNR,
TO_DATE(AEDTM,'yyyy.mm.dd'),
UNAME,
ZHRZPQD,
ZHRQDMC,
ZHRXZXM,
ZHRXZCBFX,
ZHRBYNF,
ZHRCXPYYY
from
TM_HRMIS_RECR_CHANNEL_FROM_SAP
where
BATCH_NO = BNO.BATCH_NO
and (IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null);
end loop;
-- 所有批次同步完成后修改临时表数据的同步状态
update TM_HRMIS_RECR_CHANNEL_FROM_SAP set IS_SYNC_HRMIS = 'Y', SYNC_HRMIS_TIME = sysdate where IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null;
-- 删除临时表中两个月前已同步过的数据
delete from TM_HRMIS_RECR_CHANNEL_FROM_SAP where IS_SYNC_HRMIS = 'Y' and SYNC_HRMIS_TIME < (sysdate - 60);
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('招聘渠道',
'PROC_SYNC_RECR_CHANNEL_FSAP',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_RECR_CHANNEL_FSAP;
/*
*-- Creation time:2016-12-21 14:57:19
*-- Description:同步SAP推送的员工组织分配数据至HRMIS正式表
*/
procedure PROC_SYNC_CHANGE_FSAP is
TEMP_COUNT number;
begin
-- 查询临时表中未同步至正式表的数据数量
select
count(PERNR) into TEMP_COUNT
from
TM_HRMIS_CHANGE_FROM_SAP
where
IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null;
if TEMP_COUNT > 0 then
-- 根据临时表中未同步数据的批次号
-- 将临时表数据逐批的同步至正式表
for BNO in(select
distinct BATCH_NO
from
TM_HRMIS_CHANGE_FROM_SAP
where
IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null
order by
BATCH_NO) loop
-- 根据临时表中当前批次未同步数据的工号
-- 删除正式表中这些工号对应的数据
delete from TM_HRMIS_CHANGE where PERNR in(select
distinct PERNR
from
TM_HRMIS_CHANGE_FROM_SAP
where
BATCH_NO = BNO.BATCH_NO
and (IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null));
-- 插入当前批次未同步的所有数据至正式表
insert into TM_HRMIS_CHANGE
(PERNR,
SUBTY,
OBJPS,
SPRPS,
ENDDA,
BEGDA,
SEQNR,
AEDTM,
UNAME,
BUKRS,
WERKS,
PERSG,
PERSK,
VDSK1,
GSBER,
BTRTL,
JUPER,
ABKRS,
ANSVH,
KOSTL,
ORGEH,
PLANS,
STELL,
MSTBR,
SACHA,
SACHP,
SACHZ,
SNAME,
ENAME,
OTYPE,
SBMOD,
KOKRS,
FISTL,
GEBER,
FKBER,
GRANT_NBR,
SGMNT,
BUDGET_PD,
ZHRGZZT,
ZHRGZD,
ZHRYGZT,
ZHRGWCJ)
select
PERNR,
SUBTY,
OBJPS,
SPRPS,
TO_DATE(ENDDA,'dd-mm-yy','NLS_DATE_LANGUAGE=AMERICAN'),
TO_DATE(BEGDA,'dd-mm-yy','NLS_DATE_LANGUAGE=AMERICAN'),
SEQNR,
TO_DATE(AEDTM,'dd-mm-yy','NLS_DATE_LANGUAGE=AMERICAN'),
UNAME,
BUKRS,
WERKS,
PERSG,
PERSK,
VDSK1,
GSBER,
BTRTL,
JUPER,
ABKRS,
ANSVH,
KOSTL,
ORGEH,
PLANS,
STELL,
MSTBR,
SACHA,
SACHP,
SACHZ,
SNAME,
ENAME,
OTYPE,
SBMOD,
KOKRS,
FISTL,
GEBER,
FKBER,
GRANT_NBR,
SGMNT,
BUDGET_PD,
ZHRGZZT,
ZHRGZD,
ZHRYGZT,
ZHRGWCJ
from
TM_HRMIS_CHANGE_FROM_SAP
where
BATCH_NO = BNO.BATCH_NO
and (IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null);
end loop;
-- 所有批次同步完成后修改临时表数据的同步状态
update TM_HRMIS_CHANGE_FROM_SAP set IS_SYNC_HRMIS = 'Y', SYNC_HRMIS_TIME = sysdate where IS_SYNC_HRMIS = 'N' or IS_SYNC_HRMIS is null;
-- 删除临时表中两个月前已同步过的数据
delete from TM_HRMIS_CHANGE_FROM_SAP where IS_SYNC_HRMIS = 'Y' and SYNC_HRMIS_TIME < (sysdate - 60);
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('员工组织分配数据',
'PROC_SYNC_CHANGE_FSAP',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_CHANGE_FSAP;
/*
*-- Creation time:2016-12-29 15:41:29
*-- Description:同步BW推送的跨组织经验、跨职能经验、团队管理经验数据至HRMIS正式表
*/
procedure PROC_SYNC_BW_EXP_FBW is
TEMP_COUNT number;
begin
-- 同步跨组织经验前先检查临时表中是否有数据
select
count(EMPLOYEE) into TEMP_COUNT
from
TM_HRMIS_TRANS_ORG_FBW;
if TEMP_COUNT > 0 then
-- 全量同步
-- 同步前先删除正式表中的跨组织经验数据
delete from TM_HRMIS_BW_EXP where TYPE = 'TRANS_ORG';
-- 将最新的跨组织经验同步至正式表中
insert into TM_HRMIS_BW_EXP
(EMP_CODE,
FLAG,
TYPE)
select
CUX_HRMIS_UTILS_PKG.CODE_8BIT_TO_6BIT(EMPLOYEE),
ZCZZFZRBZ,
'TRANS_ORG'
from
TM_HRMIS_TRANS_ORG_FBW;
end if;
commit;
-- 同步跨职能经验前先检查临时表中是否有数据
select
count(EMPLOYEE) into TEMP_COUNT
from
TM_HRMIS_TRANS_POS_FBW;
if TEMP_COUNT > 0 then
-- 全量同步
-- 同步前先删除正式表中的跨职能经验数据
delete from TM_HRMIS_BW_EXP where TYPE = 'TRANS_POS';
-- 将最新的跨职能经验同步至正式表中
insert into TM_HRMIS_BW_EXP
(EMP_CODE,
FLAG,
DATE_FROM,
DATE_TO,
POS_FUNC,
TYPE)
select
CUX_HRMIS_UTILS_PKG.CODE_8BIT_TO_6BIT(EMPLOYEE),
ZCZZFZRBZ,
DATEFROM,
DATETO,
ZCZN,
'TRANS_POS'
from
TM_HRMIS_TRANS_POS_FBW;
end if;
commit;
-- 同步团队管理经验前先检查临时表中是否有数据
select
count(EMPLOYEE) into TEMP_COUNT
from
TM_HRMIS_TEAM_MGMT_FBW;
if TEMP_COUNT > 0 then
-- 全量同步
-- 同步前先删除正式表中的团队管理经验数据
delete from TM_HRMIS_BW_EXP where TYPE = 'TEAM_MGMT';
-- 将最新的团队管理经验同步至正式表中
insert into TM_HRMIS_BW_EXP
(EMP_CODE,
FLAG,
TYPE)
select
CUX_HRMIS_UTILS_PKG.CODE_8BIT_TO_6BIT(EMPLOYEE),
ZCZZFZRBZ,
'TEAM_MGMT'
from
TM_HRMIS_TEAM_MGMT_FBW;
end if;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('跨组织经验、跨职能经验、团队管理经验数据',
'PROC_SYNC_BW_EXP_FBW',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_BW_EXP_FBW;
/*
*-- Creation time:2016-12-29 15:41:29
*-- Description:同步BW推送的员工后备信息至HRMIS正式表
*/
procedure PROC_SYNC_BW_RESERVE_FBW is
TEMP_COUNT number;
begin
-- 同步后备信息前先检查临时表中是否有数据
select
count(EMPLOYEE) into TEMP_COUNT
from
TM_HRMIS_RESERVE_FBW;
if TEMP_COUNT > 0 then
-- 全量同步
-- 同步先删除正式表中的后备信息
delete from TM_HRMIS_BW_RESERVE;
-- 将最新的后备信息同步至正式表中
insert into TM_HRMIS_BW_RESERVE
(EMP_CODE,
DATE_FROM,
DATE_TO,
TYPE,
SOURCE,
POST,
STATUS)
select
CUX_HRMIS_UTILS_PKG.CODE_8BIT_TO_6BIT(EMPLOYEE),
DATEFROM,
DATETO,
ZCCHBLX,
ZCCBLY,
ZCCBGW,
ZCCBZT
from
TM_HRMIS_RESERVE_FBW;
end if;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('员工后备信息',
'PROC_SYNC_BW_RESERVE_FBW',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_BW_RESERVE_FBW;
/*
*-- Creation time:2016-12-30 17:42:37
*-- Description:同步BW推送的员工基本信息至HRMIS正式表
*/
procedure PROC_SYNC_BW_USER_FBW is
TEMP_COUNT number;
begin
-- 同步BW员工基本信息前先检查临时表中是否有数据
select
count(EMPLOYEE) into TEMP_COUNT
from
TM_HRMIS_USER_FBW;
if TEMP_COUNT > 0 then
-- 全量同步
-- 同步前先删除BW员工基本信息正式表
delete from TM_HRMIS_BW_USER;
-- 全量插入最新的BW员工基本信息至正式表
insert into TM_HRMIS_BW_USER
(EMPLOYEE,
ORGUNIT,
ZCZZMC,
ZCZJ,
ZCZXL,
ZCZIXL,
HRPOSITION,
ZCZWMC,
ZCG,
ZCGMC,
JOB,
ZCGWMC,
GENDER,
ZCGWSX,
ZCXL1,
TCTLSTCHNG,
ZKGALN,
ZCGL,
ZCGZD,
ZCLUSRID,
ENTRYDATE,
ZCGWKSRQ,
PERS_SAREA,
PERS_AREA,
DATEBIRTH,
ZCZGXLMS,
ZCZXLMC,
ZCZIXLMC,
ZCDQZLKSR,
ZCDQZJKSR,
CALDAY,
EE_SNAME,
ZCQJRSFWT)
select
CUX_HRMIS_UTILS_PKG.CODE_8BIT_TO_6BIT(EMPLOYEE),
ORGUNIT,
ZCZZMC,
ZCZJ,
ZCZXL,
ZCZIXL,
HRPOSITION,
ZCZWMC,
ZCG,
ZCGMC,
JOB,
ZCGWMC,
GENDER,
ZCGWSX,
ZCXL1,
TCTLSTCHNG,
trunc(ZKGALN,2),
trunc(ZCGL,2),
ZCGZD,
ZCLUSRID,
ENTRYDATE,
ZCGWKSRQ,
PERS_SAREA,
PERS_AREA,
DATEBIRTH,
ZCZGXLMS,
ZCZXLMC,
ZCZIXLMC,
ZCDQZLKSR,
ZCDQZJKSR,
CALDAY,
EE_SNAME,
ZCQJRSFWT
from
TM_HRMIS_USER_FBW;
end if;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('BW员工基本信息',
'PROC_SYNC_BW_USER_FBW',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_BW_USER_FBW;
/*
*-- Creation time:2017-01-04 18:19:18
*-- Description:同步SAP推送的员工外部工作经历信息至HRMIS正式表
*/
procedure PROC_SYNC_EXTERNAL_EXP_FSAP is
begin
-- 全量同步
-- 同步前先删除员工外部工作经历表中的数据
delete from TM_HRMIS_EXTERNAL_EXP;
-- 全量插入最新的员工外部工作经历信息至正式表
insert into TM_HRMIS_EXTERNAL_EXP
(BEGDA,
ENDDA,
PERNR,
SUBTY,
OBJPS,
SPRPS,
SEQNR,
ZHRGZJLLX,
ZHRDW,
LAND1,
BRANC,
ZHRBM,
ZHRZW,
ZHRLZYY,
ZHRZMR,
ZHRZMRLXDH,
ZHRZWXLT,
ZHRZWSX,
ZHRSFLG,
ZHRLGDQSJ,
ZHRSFNP,
ZHRBDLX,
ZHRFPLB,
ZHRYGZT,
ZHRJB,
ZHRGZDT,
ZHRSFZZCF,
DESCRIPTION)
select
BEGDA,
ENDDA,
PERNR,
SUBTY,
OBJPS,
SPRPS,
SEQNR,
ZHRGZJLLX,
ZHRDW,
LAND1,
BRANC,
ZHRBM,
ZHRZW,
ZHRLZYY,
ZHRZMR,
ZHRZMRLXDH,
ZHRZWXLT,
ZHRZWSX,
ZHRSFLG,
ZHRLGDQSJ,
ZHRSFNP,
ZHRBDLX,
ZHRFPLB,
ZHRYGZT,
ZHRJB,
ZHRGZDT,
ZHRSFZZCF,
BRANC||ZHRDW||ZHRBM||ZHRZW
from
SYS_SAP_EXP
where
ZHRGZJLLX = '0003';
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('员工外部工作经历信息',
'PROC_SYNC_EXTERNAL_EXP_FSAP',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_EXTERNAL_EXP_FSAP;
/*
*-- Creation time:2017-05-02 16:16:00
*-- Description:计算人才对比项信息至中间表tm_hrmis_comparison
*/
procedure PROC_SYNC_COMPARISON_ITEM is
begin
delete from tm_hrmis_comparison;
commit;
insert into tm_hrmis_comparison
(account,
jx_str,
inv_str,
rz_str,
wy_str,
kzz_str,
kzn_str,
inds_benm_str,
proj_exp,
team_mgmt)
select ur.emp_code,
s1.jxStr,
s2.invStr,
s3.rzStr,
s4.wyStr,
s5.kzzStr,
s6.kznStr,
s7.indsBenmStr,
s8.PROJ_EXP,
s9.TEAM_MGMT
from tm_hrmis_user ur
left join (select b.EMP_CODE, max(TO_CHAR(b.TXT)) jxStr
from (select EMP_CODE,
yr,
WM_CONCAT(PERF) OVER(PARTITION BY EMP_CODE ORDER BY yr desc) TXT
from (select attr2 || '-' || max(a.label_name) PERF,
a.emp_code,
a.attr2 yr
from tm_hrmis_search_info a
where a.type_code = 'OTHER'
and a.styp_code = 'PERFOR'
and a.attr2 between
to_char(to_number(to_char(sysdate,
'yyyy')) - 3) and
to_char(to_number(to_char(sysdate,
'yyyy')) - 1)
group by a.attr2, a.emp_code
order by a.attr2 desc)) b
group by b.EMP_CODE) s1
on s1.emp_code = ur.emp_code
left join (select b.EMP_CODE, max(TO_CHAR(b.TXT)) invStr
from (select EMP_CODE,
yr,
WM_CONCAT(PERF) OVER(PARTITION BY EMP_CODE ORDER BY yr desc) TXT
from (select attr2 || '-' || max(a.label_name) PERF,
a.emp_code,
a.attr2 yr
from tm_hrmis_search_info a
where a.type_code = 'OTHER'
and a.styp_code = 'TLNTS_CHECK'
and a.attr2 between
to_char(to_number(to_char(sysdate,
'yyyy')) - 2) and
to_char(to_number(to_char(sysdate,
'yyyy')) - 0)
group by a.attr2, a.emp_code
order by a.attr2 desc)) b
group by b.EMP_CODE) s2
on s2.emp_code = ur.emp_code
left join (select wm_concat(a.label_name) rzStr, a.emp_code
from tm_hrmis_search_info a
where a.type_code = 'BASE_INFO'
and a.styp_code = 'QLFCTN'
group by a.emp_code) s3
on s3.emp_code = ur.emp_code
left join (select wm_concat(a.label_name) wyStr, a.emp_code
from tm_hrmis_search_info a
where a.type_code = 'OTHER'
and a.styp_code = 'FOR_LANG'
group by a.emp_code) s4
on s4.emp_code = ur.emp_code
left join (select wm_concat(a.label_name) kzzStr, a.emp_code
from tm_hrmis_search_info a
where a.type_code = 'EXPERIENCE'
and a.styp_code = 'TRANS_ORG'
group by a.emp_code) s5
on s5.emp_code = ur.emp_code
left join (select wm_concat(b.attr3) kznStr, b.emp_code kznStrFlag
from (select a.attr3, a.emp_code, a.label_name
from tm_hrmis_search_info a
where a.type_code = 'EXPERIENCE'
and a.styp_code = 'TRANS_POS'
group by a.emp_code, a.attr3, a.label_name) b
group by b.emp_code) s6
on s6.kznStrFlag = ur.emp_code
left join (select wm_concat(b.attr1) indsBenmStr,
b.emp_code indsBenmStrFlag
from (select a.attr1, a.emp_code
from TM_HRMIS_SEARCH_INFO a
where a.type_code = 'EXPERIENCE'
and a.styp_code = 'INDS_BENM'
group by a.attr1, a.emp_code) b
group by b.emp_code) s7
on s7.indsBenmStrFlag = ur.emp_code
left join (select wm_concat(a.label_name) PROJ_EXP, a.emp_code
from TM_HRMIS_SEARCH_INFO a
where a.type_code = 'EXPERIENCE'
and a.styp_code = 'PROJ_EXP'
group by a.emp_code) s8
on s8.emp_code = ur.emp_code
left join (select wm_concat(a.label_name) TEAM_MGMT, a.emp_code
from TM_HRMIS_SEARCH_INFO a
where a.type_code = 'EXPERIENCE'
and a.styp_code = 'TEAM_MGMT'
group by a.emp_code) s9
on s9.emp_code = ur.emp_code;
commit;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('计算人才对比项',
'PROC_SYNC_COMPARISON_ITEM',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_COMPARISON_ITEM;
/*
*-- Creation time:2017-05-08 12:16:00
*-- Description:ActualCom同步实战值模型
*/
procedure PROC_SYNC_ACTUALCOM is
V_TEMP_COUNT number;
V_TEMPBIG_COUNT number;
begin
select
count(*)
into
V_TEMP_COUNT
from
TM_HRMIS_ACTUALCOMBAT;
if V_TEMP_COUNT > 0 then
delete from TM_HRMIS_ACTUALCOMBAT;
commit;
--xmfzr项目负责人
--xmjl项目经理
--xmcy项目成员
insert into TM_HRMIS_ACTUALCOMBAT(emp_code,xmsum,xmjxtype,constr, constr1,xmnametype,xmnamet,cratedate )
select three.emp_code,three.xmsum,three.xmjxType,five.conStr,'' constr1,'hxxmjy' xmNameType,'项目经验' xmNameT,sysdate cratedate from (select empTwo.emp_code, wm_concat('在司参加过'|| empTwo.tjsumzh||'个项目')xmsum,empTwo.xmjxType from (
select emp.emp_code,sum(emp.tjsum) tjsumzh,to_char(wm_concat(emp.tjsum||'个项目担任'||emp.attr6)) xmjxType from
(select hsi.emp_code,hsi.attr6,count(*) tjsum from tm_hrmis_search_info hsi
inner join sys_dict_item sdi on sdi.item_name=hsi.attr6 and sdi.type_code='hxxmjy'
where hsi.styp_code='PROJ_EXP' and hsi.attr4 in('1','2') group by hsi.emp_code,hsi.attr6) emp group by emp.emp_code
)empTwo group by empTwo.emp_code,empTwo.xmjxType)three
left join
(
select four.emp_code,'曾参与的项目有:'||four.contentStr conStr from (
select hsiTwo.emp_code,max(to_char(text)) contentStr from (select hsiOne.emp_code,wm_concat(hsiOne.attr1) OVER(PARTITION BY hsiOne.emp_code ORDER BY hsiOne.invalid_start desc) text from(
select hsi.emp_code,'\n'||hsi.attr1||hsi.attr5||to_char(hsi.invalid_start, 'yyyy-mm-dd') as attr1,to_char(hsi.invalid_start, 'yyyy-mm-dd') invalid_start from tm_hrmis_search_info hsi
where hsi.styp_code='PROJ_EXP' and hsi.attr4 in('1','2') order by hsi.emp_code asc,hsi.invalid_start desc
)hsiOne )hsiTwo group by hsiTwo.emp_code
)four )five on five.emp_code=three.emp_code;
commit;
---司外经验
insert into TM_HRMIS_ACTUALCOMBAT(emp_code,xmsum,xmjxtype,constr,constr1,xmnametype,xmnamet,cratedate )
select expl.pernr emp_code,to_char(expl.begda, 'yyyy-mm-dd') xmsum,to_char(expl.begda, 'yyyy-mm')||'~'||to_char(expl.endda, 'yyyy-mm') xmjxtype,expl.zhrdw constr1,expl.Zhrzw constr1,'expl' xmNameType,'司外经验' xmNameT,sysdate crateDate from tm_hrmis_external_exp expl
left join tm_hrmis_user thu on thu.emp_code=expl.pernr
where 1=1 order by expl.pernr asc,expl.begda desc ;
commit;
--其它经验
insert into TM_HRMIS_ACTUALCOMBAT(emp_code,xmsum,xmjxtype,constr,constr1,xmnametype,xmnamet,cratedate )
select oneEmp.emp_code,'' xmsum,'在司有跨'||oneEmp.str constr,'' constr1,'' xmjxtype,'trans_org_team_mgmt' xmNameType,'其它经验' xmNameT,sysdate crateDate from(
select hsi.emp_code,wm_concat(hsi.label_alias) str from tm_hrmis_search_info hsi
where hsi.styp_code in('TEAM_MGMT','TRANS_ORG') group by hsi.emp_code
) oneEmp ;
end if;
commit;
-----检查清理大数据同步数据
select
count(*)
into
V_TEMPBIG_COUNT
from
SYNC_TM_HRMIS_BIG_GSJS ;
if V_TEMPBIG_COUNT > 0 then
delete from TM_HRMIS_TECHNICALABILITY ttc where ttc.xmnametype in('big_gsjs');
commit;
-------同步大数据同步过来岗位经验
insert into TM_HRMIS_TECHNICALABILITY value
select * from SYNC_TM_HRMIS_BIG_GSJS;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('同步实战值模型',
'PROC_SYNC_ACTUALCOM',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_ACTUALCOM;
/*
*-- Creation time:2017-05-08 15:16:00
*-- Description:ActualCom同步 技能值模型
*/
procedure PROC_SYNC_TECHNICALABILITY is
V_TEMP_COUNT number;
V_TEMPBIG_COUNT number;
begin
----清理 专业技能、任职资格QLFCTN、后备信息RESERVE、技能证书数据
select
count(*)
into
V_TEMP_COUNT
from
TM_HRMIS_TECHNICALABILITY ttc where ttc.xmnametype in('profSkill','qlfctn','reserve','jnzs');
if V_TEMP_COUNT > 0 then
delete from TM_HRMIS_TECHNICALABILITY ttc where ttc.xmnametype in('profSkill','qlfctn','reserve','jnzs');
commit;
--专业技能
insert into TM_HRMIS_TECHNICALABILITY(emp_code,invalidstar, titlestr,titlestr1,xmnametype,xmnamet,cratedate)
select cn.pernr,''invalidstar,wm_concat(cn.zhrjnmc)titleStr,'' titleStr1,'profSkill' xmNameType,'专业技能' xmName,sysdate crateDate from(
select skll.pernr,to_char(skll.begda, 'yyyy-mm-dd') invalidstar,skll.zhrjnmc
from TM_HRMIS_PROF_SKILL skll order by skll.pernr asc,skll.begda desc
) cn group by cn.pernr;
commit;
--任职资格QLFCTN
insert into TM_HRMIS_TECHNICALABILITY(emp_code,invalidstar, titlestr,titlestr1,xmnametype,xmnamet,cratedate)
select hsi.emp_code,to_char(hsi.invalid_start, 'yyyy-mm-dd') invalidstar,to_char(hsi.invalid_start, 'yyyy"年"mm"月"')||'获'||hsi.label_alias titleStr,'' titleStr1,'qlfctn' xmNameType,'任职资格' xmNameT,sysdate crateDate from tm_hrmis_search_info hsi
where hsi.styp_code='QLFCTN' order by hsi.emp_code asc,hsi.invalid_end desc;
commit;
---后备信息RESERVE
insert into TM_HRMIS_TECHNICALABILITY(emp_code,invalidstar, titlestr,titlestr1,xmnametype,xmnamet,cratedate)
select hsi.emp_code,to_char(hsi.invalid_start, 'yyyy-mm-dd') invalidstar,to_char(hsi.invalid_start, 'yyyy"年"mm"月"')||'获'||hsi.label_alias||' 资格' titleStr,'' titleStr1,'reserve' xmNameType,'后备信息' xmNameT,sysdate crateDate from tm_hrmis_search_info hsi
where hsi.styp_code='RESERVE' order by hsi.emp_code asc,hsi.invalid_end desc;
commit;
--技能证书
insert into TM_HRMIS_TECHNICALABILITY(emp_code,invalidstar, titlestr,titlestr1,xmnametype,xmnamet,cratedate)
select ssc.pernr,to_char(ssc.begda, 'yyyy-mm-dd') begda,to_char(ssc.begda, 'yyyy"年"mm"月"')||'获'||ssc.zhrzgzsmc titleStr,'' titleStr1,'jnzs' xmNameType,'技能证书' xmNameT,sysdate crateDate from sys_sap_certi ssc where ssc.zhrzgzsmc not like '%驾驶%' order by ssc.pernr asc, ssc.begda desc;
commit;
end if;
-----检查清理大数据同步数据
select
count(*)
into
V_TEMPBIG_COUNT
from
SYNC_TM_HRMIS_BIG_GSJS ;
if V_TEMPBIG_COUNT > 0 then
delete from TM_HRMIS_TECHNICALABILITY ttc where ttc.xmnametype in('big_gsjs');
commit;
-------同步大数据同步过来岗位经验
insert into TM_HRMIS_TECHNICALABILITY value
select * from SYNC_TM_HRMIS_BIG_GSJS;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('同步实战值模型',
'PROC_SYNC_ACTUALCOM',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_TECHNICALABILITY;
/*
*-- Creation time:2017-05-20 10:43:28
*-- Description:同步大数据过来的数据关键事件、奖惩、奖励
*/
procedure PROC_SYNC_TEMP_HRMIS_SQOOP_JC is
V_TEMP_COUNT number;
begin
----检查大数据是否同步成功,
select
count(*)
into
V_TEMP_COUNT
from
SYNC_TEMP_HRMIS_SQOOP_JC;
if V_TEMP_COUNT > 0 then
--删除正式表同步新表
delete from TM_HRMIS_SQOOP_JC;
commit;
--转正式表
insert into TM_HRMIS_SQOOP_JC value
select * from SYNC_TEMP_HRMIS_SQOOP_JC;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('同步关键模型',
'PROC_SYNC_TEMP_HRMIS_SQOOP_JC',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_TEMP_HRMIS_SQOOP_JC;
/*
*-- Creation time:2017-05-24 18:43:28
*-- Description:同步从多棱镜、大数据中心过来的数据、区总处理更新
*/
procedure PROC_SYNC_TM_HISTORY_PERSON is
V_TEMP_COUNT number;
begin
----检查大数据是否同步成功,
select
count(*)
into
V_TEMP_COUNT
from
SYNC_TM_HRMIS_HISTORY_PERSON;
if V_TEMP_COUNT > 0 then
--删除正式表同步新表
delete from TM_HRMIS_HISTORY_PERSON;
commit;
---处理正式表
insert into TM_HRMIS_HISTORY_PERSON value
select * from SYNC_TM_HRMIS_HISTORY_PERSON ;
---下面处理区总历史数据更新
merge into TM_HRMIS_DLJ_BIE_IDXEL empu
using (
select thp.empcode,thp.zcwddm,thp.movedate
from TM_HRMIS_HISTORY_PERSON thp) zn
on (empu.mont_code=zn.movedate and empu.dept_code=zn.zcwddm)
when matched then--满足逻辑
update
set
empu.emp_code = zn.empcode;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('同步战绩值区总数据',
'PROC_SYNC_TM_HRMIS_HISTORY_PERSON',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_TM_HISTORY_PERSON;
/*
*-- Creation time:2017-05-16 10:43:28
*-- Description:同步从KMS抽取的微访谈数据至HRMIS正式表
*/
procedure PROC_SYNC_MICRO_INTERVIEW is
V_TEMP_COUNT number;
begin
-- 查询临时表中数据的数量
select
count(*)
into
V_TEMP_COUNT
from
TM_HRMIS_INTERVIEW_FKMS;
if V_TEMP_COUNT > 0 then
-- 同步最新数据前先删除正式表中的微访谈数据
delete from TM_HRMIS_INTERVIEW;
-- 将最新的微访谈数据插入到正式表
insert into TM_HRMIS_INTERVIEW
(GUEST_ID,
BEGIN_TIME,
END_TIME,
TITLE)
select
GUEST_ID,
BEGIN_TIME,
END_TIME,
TITLE
from
TM_HRMIS_INTERVIEW_FKMS
where
GUEST_ID is not null;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('微访谈信息',
'PROC_SYNC_MICRO_INTERVIEW',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_MICRO_INTERVIEW;
/*
*-- Creation time:2017-05-16 11:21:11
*-- Description:同步从KMS抽取的知识地图数据至HRMIS正式表
*/
procedure PROC_SYNC_KNOWLEDGE_MAP is
V_TEMP_COUNT number;
begin
-- 查询临时表中数据的数量
select
count(*)
into
V_TEMP_COUNT
from
TM_HRMIS_KNO_MAP_FKMS;
if V_TEMP_COUNT > 0 then
-- 同步最新数据前先删除正式表中的知识地图数据
delete from TM_HRMIS_KNO_MAP;
-- 将最新的知识地图数据插入到正式表
insert into TM_HRMIS_KNO_MAP
(CREATER_ID,
CREATE_DATE,
END_DATE,
TITLE)
select
CREATER_ID,
CREATE_DATE,
END_DATE,
TITLE
from
TM_HRMIS_KNO_MAP_FKMS
where
CREATER_ID is not null;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('知识地图信息',
'PROC_SYNC_KNOWLEDGE_MAP',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_KNOWLEDGE_MAP;
/*
*-- Creation time:2017-05-16 14:23:45
*-- Description:同步BW推送的团队动态数据至HRMIS正式表
*/
procedure PROC_SYNC_TEAM_DYNAMIC is
V_TEMP_COUNT number;
begin
-- 查询临时表中是否有未同步至正式表的数据
select
count(*)
into
V_TEMP_COUNT
from
TM_HRMIS_TEAM_DYNAMIC_FBW
where
IS_SYNC_HRMI = 'N'
or IS_SYNC_HRMI is null;
if V_TEMP_COUNT > 0 then
-- 确定临时表中未同步的数据的是哪些年月的数据
-- 根据确定出来的年月先删除正式表中对应年月的数据
delete from TM_HRMIS_TEAM_DYNAMIC where CALMONTH in(select
distinct CALMONTH
from
TM_HRMIS_TEAM_DYNAMIC_FBW
where
IS_SYNC_HRMI = 'N'
or IS_SYNC_HRMI is null);
-- 将临时表中的新团队动态数据插入到正式表中
insert into TM_HRMIS_TEAM_DYNAMIC
(CALDAY,
EMPLOYEE,
ZKEYNUM,
RECORDMODE,
CALMONTH,
CALMONTH2,
CALYEAR,
EE_SNAME,
BIRTHDAY,
AGE,
ZCNLDSF,
ZCXL1,
ZCZGXLMS,
EMPLGROUP,
EMPLSGROUP,
PERS_AREA,
ZCRSFWMS,
PERS_SAREA,
ZCRSZFWMC,
ZCZN,
ENTRYDATE,
ZCGL,
ZCGLD,
ORGUNIT,
ZCZZMC,
ZCZZMCEL,
ZCORGLVL1,
ZCORGLVL2,
ZCORGLVL3,
ZCORGLVL4,
ZCORGLVL5,
ZCORGLVL6,
ZCORGLVL7,
ZCWDDM,
JOB,
ZCGWMC,
ZCGWJSC,
ZCGWJSCMS,
ZCGWSX,
ZCGWYWD,
ZCZXL,
ZCZXLMC,
ZCZIXL,
ZCZIXLMC,
ZCZJ_LOW,
ZCZJ_HIGH,
HRPOSITION,
ZCZWMC,
ZCZZFZRBZ,
ZCZZFZRZW,
ZCZJ,
ACTIONTYPE,
ZCCZLXMS,
ACTIONREAS,
ZCLZLB,
ZCLZLBT,
ZCLZLX,
ZCLZLXT,
ZCLZRQ,
ZCDJKHJG,
ZCXJKHJG,
ZCSNKHJG,
ZCSFJYYG,
ZCYDHZZ,
ZCYDORGL2,
ZCYDHGW,
ZCYDGWSX,
ZCYDGWYWD,
ZCYDHZW,
ZCYDHZJ,
ZCYDYGZ,
EMPLSTATUS,
ACTION_CNT)
select
CALDAY,
CUX_HRMIS_UTILS_PKG.CODE_8BIT_TO_6BIT(EMPLOYEE),
ZKEYNUM,
RECORDMODE,
CALMONTH,
CALMONTH2,
CALYEAR,
EE_SNAME,
BIRTHDAY,
AGE,
ZCNLDSF,
ZCXL1,
ZCZGXLMS,
EMPLGROUP,
EMPLSGROUP,
PERS_AREA,
ZCRSFWMS,
PERS_SAREA,
ZCRSZFWMC,
ZCZN,
ENTRYDATE,
ZCGL,
ZCGLD,
ORGUNIT,
ZCZZMC,
ZCZZMCEL,
ZCORGLVL1,
ZCORGLVL2,
ZCORGLVL3,
ZCORGLVL4,
ZCORGLVL5,
ZCORGLVL6,
ZCORGLVL7,
ZCWDDM,
JOB,
ZCGWMC,
ZCGWJSC,
ZCGWJSCMS,
ZCGWSX,
ZCGWYWD,
ZCZXL,
ZCZXLMC,
ZCZIXL,
ZCZIXLMC,
ZCZJ_LOW,
ZCZJ_HIGH,
HRPOSITION,
ZCZWMC,
ZCZZFZRBZ,
ZCZZFZRZW,
ZCZJ,
ACTIONTYPE,
ZCCZLXMS,
ACTIONREAS,
ZCLZLB,
ZCLZLBT,
ZCLZLX,
ZCLZLXT,
ZCLZRQ,
ZCDJKHJG,
ZCXJKHJG,
ZCSNKHJG,
ZCSFJYYG,
ZCYDHZZ,
ZCYDORGL2,
ZCYDHGW,
ZCYDGWSX,
ZCYDGWYWD,
ZCYDHZW,
ZCYDHZJ,
ZCYDYGZ,
EMPLSTATUS,
ACTION_CNT
from
TM_HRMIS_TEAM_DYNAMIC_FBW
where
IS_SYNC_HRMI = 'N'
or IS_SYNC_HRMI is null;
-- 同步完成后将临时表中的数据同步状态设置为已同步
update TM_HRMIS_TEAM_DYNAMIC_FBW set IS_SYNC_HRMI = 'Y', SYNC_HRMI_TIME = sysdate where IS_SYNC_HRMI = 'N' or IS_SYNC_HRMI is null;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('团队动态数据',
'PROC_SYNC_TEAM_DYNAMIC',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_TEAM_DYNAMIC;
/*
*-- Creation time:2017-05-24 16:43:42
*-- Description:同步SAP推送的组织编制数据至HRMIS正式表
*/
procedure PROC_SYNC_AUTH_STRENGTH is
V_TEMP_COUNT number;
begin
-- 查询临时表中数据的数量
select
count(*)
into
V_TEMP_COUNT
from
TM_HRMIS_AUTH_STRENGTH_FSAP;
if V_TEMP_COUNT > 0 then
-- 同步最新数据前先删除正式表中的组织编制数据
delete from TM_HRMIS_AUTH_STRENGTH;
-- 将临时表中最新的组织编制数据同步至正式表
insert into TM_HRMIS_AUTH_STRENGTH
(ZHRBZGLNO,
ZHRBZGLITEM,
ZHRDQID,
ZHRZZID,
ZHRGWID,
ZHRRYLXID,
ZHRSJZZID,
ZHRZN,
ZHRN,
ZHRDQ,
ZHRZZQC,
ZHRGWMC,
ZHRRYLX,
ZHRBZS01,
ZHRBZS02,
ZHRBZS03,
ZHRBZS04,
ZHRBZS05,
ZHRBZS06,
ZHRBZS07,
ZHRBZS08,
ZHRBZS09,
ZHRBZS10,
ZHRBZS11,
ZHRBZS12,
ZHRBGYY,
ZHRXXYY,
ZHRQQRQ,
ZHRSXRQ,
ZHRYSLX,
ZHRWLDM,
ZHRZZMC,
ZHRSJZZMC,
ZHRZNT,
ZHRGWJSC,
ZHRGWYWD,
ZHRGWSX,
ZHRGWZXL,
ZHRGWZIXL,
ZHRXLFL,
ZHRGLZYCJ,
ZHRGWLB,
ZHRGWCJ,
ZHRZQ,
ZHRGZ,
ZHRXL,
ZHRG,
CREATED_US,
CREATED_TS)
select
ZHRBZGLNO,
ZHRBZGLITEM,
ZHRDQID,
ZHRZZID,
ZHRGWID,
ZHRRYLXID,
ZHRSJZZID,
ZHRZN,
ZHRN,
ZHRDQ,
ZHRZZQC,
ZHRGWMC,
ZHRRYLX,
ZHRBZS01,
ZHRBZS02,
ZHRBZS03,
ZHRBZS04,
ZHRBZS05,
ZHRBZS06,
ZHRBZS07,
ZHRBZS08,
ZHRBZS09,
ZHRBZS10,
ZHRBZS11,
ZHRBZS12,
ZHRBGYY,
ZHRXXYY,
ZHRQQRQ,
ZHRSXRQ,
ZHRYSLX,
ZHRWLDM,
ZHRZZMC,
ZHRSJZZMC,
ZHRZNT,
ZHRGWJSC,
ZHRGWYWD,
ZHRGWSX,
ZHRGWZXL,
ZHRGWZIXL,
ZHRXLFL,
ZHRGLZYCJ,
ZHRGWLB,
ZHRGWCJ,
ZHRZQ,
ZHRGZ,
ZHRXL,
ZHRG,
CREATED_US,
CREATED_TS
from
TM_HRMIS_AUTH_STRENGTH_FSAP;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('组织编制数据同步至正式表',
'PROC_SYNC_AUTH_STRENGTH',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_AUTH_STRENGTH;
/*
*-- Creation time:2017-05-24 16:43:42
*-- Description:同步SAP推送的讲师管理数据至HRMIS正式表
*/
procedure PROC_SYNC_LECTURER_MGMT is
V_TEMP_COUNT number;
begin
-- 查询临时表中数据的数量
select
count(*)
into
V_TEMP_COUNT
from
TM_HRMIS_LECTURER_MGMT_FSAP;
if V_TEMP_COUNT > 0 then
-- 同步最新数据前先删除正式表中的讲师管理数据
delete from TM_HRMIS_LECTURER_MGMT;
-- 将临时表中最新的讲师管理数据同步至正式表
insert into TM_HRMIS_LECTURER_MGMT
(PERNR,
SUBTY,
OBJPS,
SPRPS,
ENDDA,
BEGDA,
SEQNR,
AEDTM,
UNAME,
GRPVL,
ZHRSKNR,
ZHRKHQK,
ZHRTCYY,
ZHRJSDJ,
ZHRJSZT,
ZHRRYMC,
ZHRBBJG,
ZHRRZKCMC,
ZHRRZKCZSH,
ZHRRZZZ,
ZHRKCGS,
ZHRKFKCMC,
ZHRKCKS,
ZHRJSGLLX,
ZHRKCPGJG,
ZHRJSMYD,
ZHRBJMC)
select
PERNR,
SUBTY,
OBJPS,
SPRPS,
ENDDA,
BEGDA,
SEQNR,
AEDTM,
UNAME,
GRPVL,
ZHRSKNR,
ZHRKHQK,
ZHRTCYY,
ZHRJSDJ,
ZHRJSZT,
ZHRRYMC,
ZHRBBJG,
ZHRRZKCMC,
ZHRRZKCZSH,
ZHRRZZZ,
ZHRKCGS,
ZHRKFKCMC,
ZHRKCKS,
ZHRJSGLLX,
ZHRKCPGJG,
ZHRJSMYD,
ZHRBJMC
from
TM_HRMIS_LECTURER_MGMT_FSAP;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('讲师管理数据同步至正式表',
'PROC_SYNC_LECTURER_MGMT',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_LECTURER_MGMT;
/*
*-- Creation time:2017-05-24 16:43:42
*-- Description:同步从ECP抽取的流程制度信息至HRMIS正式表
*/
procedure PROC_SYNC_WORKFLOW_RULE is
V_TEMP_COUNT number;
begin
-- 查询临时表中数据的数量
select
count(*)
into
V_TEMP_COUNT
from
TM_HRMIS_WORKFLOW_RULE_FECP;
if V_TEMP_COUNT > 0 then
-- 同步最新数据前先删除正式表中的流程制度信息
delete from TM_HRMIS_WORKFLOW_RULE;
-- 将临时表中最新的流程制度信息同步至正式表
insert into TM_HRMIS_WORKFLOW_RULE
(FSID,
VERSION_NUM,
REPEALED_PROCESS,
TITLE,
FICTION_DEPARTMENT,
ACCESS_PERMISSION,
CARBON_COPY_UNIT,
RELEASE_TYPE,
RELEASE_DATE,
FSFILES,
ACCESSORIES,
PROCESS_NUMBERS,
PROCESS_CODE_ID,
PROCESS_IDENTIFICATION,
PROCESS_SYSTEM_CODE,
PROCESS_SYSTEM_OUTGOING,
PROCESS_SYSTEM_NAME,
PROCESS_SYSTEM_TEMPLATE,
PROCESS_SYSTEM_ARTIFICIAL,
SECRECYLEVELID,
APPLICATION_DEPARTMENT,
USERNUM,
USERNAME,
DATE_OF_APPLICATION,
EFFECTIVE_TIME,
REFINING_PROCESS,
BUSINESS_EXECUTIVE,
HONGKONG_IMPLEMENTATION,
BOARD_IMPLEMENTATION,
GOODS_IMPLEMENTATION,
FURTHER_REFINEMENT,
STORE_IMPLEMENTATION,
REFINING_CODE,
RESPONSIBILITY_DEPARTMENT,
LORD_SENT_UNIT,
ORGANIZATION_CODE,
RUNID,
FS_TYPE,
ORGIDS,
POSIDS,
RULES,
JOBS,
YZYH_ORGIDS,
YZYH_POSIDS,
YZYH_RULES,
YZYH_JOBS,
YZYH_USERS,
USERS,
ISALLUSERS,
YZYHAUTHORITYGROUPID,
AUTHORITYGROUPID,
FS_SERIAL_NUMBER,
WORKFLOW_STATUS,
TOPMOST,
FLAGRED,
STATUS,
SPECIALOPERFIELD,
INBEDEDRED,
SIGNED,
SETCODEDFLAG,
DOCMGRPOSEDIT,
SFBANKPAY,
OUTGOING_MAIL,
ORGTYPE,
CREATETIME,
CORRFUNCDEPT,
SFSSYBZZ,
FUNCDEPTTYPE,
LASTUPDATOR,
LASTUPDATETIME,
FLOWDIAGRAMDETIALS,
CONTAINFLOWDIAGRAM,
RELEASENOTES,
PROCESSNAME,
PROPERTY)
select
FSID,
VERSION_NUM,
REPEALED_PROCESS,
TITLE,
FICTION_DEPARTMENT,
ACCESS_PERMISSION,
CARBON_COPY_UNIT,
RELEASE_TYPE,
RELEASE_DATE,
FSFILES,
ACCESSORIES,
PROCESS_NUMBERS,
PROCESS_CODE_ID,
PROCESS_IDENTIFICATION,
PROCESS_SYSTEM_CODE,
PROCESS_SYSTEM_OUTGOING,
PROCESS_SYSTEM_NAME,
PROCESS_SYSTEM_TEMPLATE,
PROCESS_SYSTEM_ARTIFICIAL,
SECRECYLEVELID,
APPLICATION_DEPARTMENT,
USERNUM,
USERNAME,
DATE_OF_APPLICATION,
EFFECTIVE_TIME,
REFINING_PROCESS,
BUSINESS_EXECUTIVE,
HONGKONG_IMPLEMENTATION,
BOARD_IMPLEMENTATION,
GOODS_IMPLEMENTATION,
FURTHER_REFINEMENT,
STORE_IMPLEMENTATION,
REFINING_CODE,
RESPONSIBILITY_DEPARTMENT,
LORD_SENT_UNIT,
ORGANIZATION_CODE,
RUNID,
FS_TYPE,
ORGIDS,
POSIDS,
RULES,
JOBS,
YZYH_ORGIDS,
YZYH_POSIDS,
YZYH_RULES,
YZYH_JOBS,
YZYH_USERS,
USERS,
ISALLUSERS,
YZYHAUTHORITYGROUPID,
AUTHORITYGROUPID,
FS_SERIAL_NUMBER,
WORKFLOW_STATUS,
TOPMOST,
FLAGRED,
STATUS,
SPECIALOPERFIELD,
INBEDEDRED,
SIGNED,
SETCODEDFLAG,
DOCMGRPOSEDIT,
SFBANKPAY,
OUTGOING_MAIL,
ORGTYPE,
CREATETIME,
CORRFUNCDEPT,
SFSSYBZZ,
FUNCDEPTTYPE,
LASTUPDATOR,
LASTUPDATETIME,
FLOWDIAGRAMDETIALS,
CONTAINFLOWDIAGRAM,
RELEASENOTES,
PROCESSNAME,
PROPERTY
from
TM_HRMIS_WORKFLOW_RULE_FECP;
commit;
end if;
exception
when others then
rollback;
RECORD_PROC_ERR_LOG('流程制度信息同步至正式表',
'PROC_SYNC_WORKFLOW_RULE',
sqlcode,
sqlerrm,
SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 400));
end PROC_SYNC_WORKFLOW_RULE;
end CUX_HRMIS_SYNC_PKG;