/* 预置HR的相关职能类型 */
DELETE FROM t_org_bizlist WHERE FID = 38;
INSERT INTO t_org_bizlist(FID,FISENABLED,FDISABLEDATE,FMASTERID,FSTATUS,FUSERDEFINE,FVISIABLE,FNAME,FNUMBER,FPROPERTYNAME,FCREATETIME,FENABLE,FMODIFIERID,FMODIFYTIME,FISBASETYPE,FCATEGORY,FFIELDNAME,FCREATORID,FDISABLERID) VALUES (38,'1',NULL,38,'C','0','0','薪酬成本组织','38','fishrlc',{ts'2018-08-08  18:08:08'},'1',1,{ts'2018-08-08  18:08:08'},'1','1','fishrlc',1,0);
DELETE FROM t_org_bizlist WHERE FID = 39;
INSERT INTO t_org_bizlist(FID,FISENABLED,FDISABLEDATE,FMASTERID,FSTATUS,FUSERDEFINE,FVISIABLE,FNAME,FNUMBER,FPROPERTYNAME,FCREATETIME,FENABLE,FMODIFIERID,FMODIFYTIME,FISBASETYPE,FCATEGORY,FFIELDNAME,FCREATORID,FDISABLERID) VALUES (39,'1',NULL,39,'C','0','0','假期组织','39','fishrab',{ts'2018-08-08  18:08:08'},'1',1,{ts'2018-08-08  18:08:08'},'1','1','fishrab',1,0);

DELETE FROM t_org_bizlist_l WHERE FPKID = '1R775DYTEHKY';
INSERT INTO t_org_bizlist_l(FID,FPKID,FLOCALEID,FNAME) VALUES (38,'1R775DYTEHKY','zh_CN','薪酬成本组织');
DELETE FROM t_org_bizlist_l WHERE FPKID = '1R77764SG7ML';
INSERT INTO t_org_bizlist_l(FID,FPKID,FLOCALEID,FNAME) VALUES (39,'1R77764SG7ML','zh_CN','假期组织');

DELETE FROM t_org_viewschema WHERE FID = 38;
INSERT INTO t_org_viewschema(FID,FSTARTDATE,FCHECKDATE,FISDEFAULT,FMASTERID,FSTATUS,FNUMBER,FNAME,FCREATETIME,FTREETYPE,FENABLE,FMODIFIERID,FTREETYPEID,FMODIFYTIME,FENDDATE,FUSAGE,FCHECKERID,FCREATORID) VALUES (38,{ts'2018-08-08  18:08:08'},NULL,'1',38,'C','38','薪酬成本组织',{ts'2018-08-08  18:08:08'},'38','1',1,38,{ts'2018-08-08  18:08:08'},{ts'2999-12-31  00:00:00'},' ',0,1);
DELETE FROM t_org_viewschema WHERE FID = 39;
INSERT INTO t_org_viewschema(FID,FSTARTDATE,FCHECKDATE,FISDEFAULT,FMASTERID,FSTATUS,FNUMBER,FNAME,FCREATETIME,FTREETYPE,FENABLE,FMODIFIERID,FTREETYPEID,FMODIFYTIME,FENDDATE,FUSAGE,FCHECKERID,FCREATORID) VALUES (39,{ts'2018-08-08  18:08:08'},NULL,'1',39,'C','39','假期组织',{ts'2018-08-08  18:08:08'},'39','1',1,39,{ts'2018-08-08  18:08:08'},{ts'2999-12-31  00:00:00'},' ',0,1);

DELETE FROM t_org_viewschema_l WHERE FPKID = '1R775E/L6ZCA';
INSERT INTO t_org_viewschema_l(FID,FPKID,FLOCALEID,FCOMMENT,FNAME) VALUES (38,'1R775E/L6ZCA','zh_CN',' ','薪酬成本业务视图默认方案');
DELETE FROM t_org_viewschema_l WHERE FPKID = '1R777651BG74';
INSERT INTO t_org_viewschema_l(FID,FPKID,FLOCALEID,FCOMMENT,FNAME) VALUES (39,'1R777651BG74','zh_CN',' ','假期业务视图默认方案');

DELETE from t_org_structure WHERE forgid = 100000 and fviewid in (38,39);
DELETE from t_org_structure_l t WHERE not exists (SELECT FID from t_org_structure s where s.fid = t.fid);

DELETE FROM t_org_structure WHERE FID = 1198567438656995328;
INSERT INTO t_org_structure(FSEALUPTIME,FCREATEORGID,FISHR,FYZJORGID,FMASTERID,FCREATETIME,FENABLE,FVIEWID,FLEVEL,FLONGNUMBER,FFULLNAME,FID,FSORTCODE,FMODIFYORGID,FSTARTDATE,FISBIZUNIT,FYZJPARENTORGID,FORGID,FSTATUS,FPARENTID,FNUMBER,FISFREEZE,FMODIFIERID,FISLEAF,FISSTATSUM,FISCTRLUNIT,FMODIFYTIME,FENDDATE,FCREATORID) VALUES (NULL,0,'0',' ',1198567438656995328,{ts'2018-08-08  18:08:08'},'1',38,1,' ',' ',1198567438656995328,'0',0,{ts'2018-08-08  18:08:08'},'1',' ',100000,'C',0,' ','0',1,'1','0','1',{ts'2018-08-08  18:08:08'},{ts'2999-12-31  00:00:00'},1);
DELETE FROM t_org_structure WHERE FID = 1198567681842741248;
INSERT INTO t_org_structure(FSEALUPTIME,FCREATEORGID,FISHR,FYZJORGID,FMASTERID,FCREATETIME,FENABLE,FVIEWID,FLEVEL,FLONGNUMBER,FFULLNAME,FID,FSORTCODE,FMODIFYORGID,FSTARTDATE,FISBIZUNIT,FYZJPARENTORGID,FORGID,FSTATUS,FPARENTID,FNUMBER,FISFREEZE,FMODIFIERID,FISLEAF,FISSTATSUM,FISCTRLUNIT,FMODIFYTIME,FENDDATE,FCREATORID) VALUES (NULL,0,'0',' ',1198567681842741248,{ts'2018-08-08  18:08:08'},'1',39,1,' ',' ',1198567681842741248,'0',0,{ts'2018-08-08  18:08:08'},'1',' ',100000,'C',0,' ','0',1,'1','0','1',{ts'2018-08-08  18:08:08'},{ts'2999-12-31  00:00:00'},1);

DELETE FROM t_org_structure_l WHERE FPKID = '1R775E2335K5';
INSERT INTO t_org_structure_l(FID,FPKID,FLOCALEID,FFULLNAME,FNAME) VALUES (1198567438656995328,'1R775E2335K5','zh_CN',' ',' ');
DELETE FROM t_org_structure_l WHERE FPKID = '1R77766FQP2U';
INSERT INTO t_org_structure_l(FID,FPKID,FLOCALEID,FFULLNAME,FNAME) VALUES (1198567681842741248,'1R77766FQP2U','zh_CN',' ',' ');


/** 更新根组织长编码、长名称 */
update T_ORG_STRUCTURE set flongnumber = isnull(select max(fnumber) from t_org_org where fid = 100000, ' ') where forgid = 100000 and fviewid between 38 and 39;
update T_ORG_STRUCTURE set ffullname = isnull(select max(fname) from t_org_org_l ol where flocaleid = 'zh_CN' and fid = 100000, ' ') where forgid = 100000 and fviewid between 38 and 39;
update T_ORG_STRUCTURE_L set ffullname = isnull(select max(fname) from t_org_org_l ol where T_ORG_STRUCTURE_L.flocaleid = ol.flocaleid and fid = 100000, ' ') where fid in (select fid from t_org_structure where forgid = 100000 and fviewid between 38 and 39);

/** 组织表勾选相应职能类型 */
update t_org_org set fishrlc = '1',fishrab = '1' where fid = 100000;

