-- 协作任务中心新增四层人字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TASKCENTER' AND KSQL_COL_NAME IN ('FPERSONID')) 
 ALTER TABLE T_HPDI_TASKCENTER ADD (FPERSONID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TASKCENTER' AND KSQL_COL_NAME IN ('FEMPLOYEEID')) 
 ALTER TABLE T_HPDI_TASKCENTER ADD (FEMPLOYEEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TASKCENTER' AND KSQL_COL_NAME IN ('FDEPEMPID')) 
 ALTER TABLE T_HPDI_TASKCENTER ADD (FDEPEMPID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TASKCENTER' AND KSQL_COL_NAME IN ('FCMPEMPID')) 
 ALTER TABLE T_HPDI_TASKCENTER ADD (FCMPEMPID BIGINT DEFAULT 0 NOT NULL );

 
-- 协作任务中心增加新的协作任务编排关联字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TASKCENTERENT' AND KSQL_COL_NAME IN ('FCOLLARULECLASS')) 
 ALTER TABLE T_HPDI_TASKCENTERENT ADD (FCOLLARULECLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TASKCENTERENT' AND KSQL_COL_NAME IN ('FCOLLARULEID')) 
 ALTER TABLE T_HPDI_TASKCENTERENT ADD (FCOLLARULEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TASKCENTERENT' AND KSQL_COL_NAME IN ('FCOLLARULEVID')) 
 ALTER TABLE T_HPDI_TASKCENTERENT ADD (FCOLLARULEVID BIGINT DEFAULT 0 NOT NULL );

-- 薪资核定单增加关联新的协作任务编排和协作规则
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SALARYVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGECLASS')) 
 ALTER TABLE T_HPDI_SALARYVERBILL ADD (FTASKARRANGECLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SALARYVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGEID')) 
 ALTER TABLE T_HPDI_SALARYVERBILL ADD (FTASKARRANGEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SALARYVERBILL' AND KSQL_COL_NAME IN ('FCOLLATASKCLASS')) 
 ALTER TABLE T_HPDI_SALARYVERBILL ADD (FCOLLATASKCLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SALARYVERBILL' AND KSQL_COL_NAME IN ('FCOLLATASKID')) 
 ALTER TABLE T_HPDI_SALARYVERBILL ADD (FCOLLATASKID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SALARYVERBILL' AND KSQL_COL_NAME IN ('FMORGID')) 
 ALTER TABLE T_HPDI_SALARYVERBILL ADD (FMORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SALARYVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGEVID')) 
 ALTER TABLE T_HPDI_SALARYVERBILL ADD (FTASKARRANGEVID BIGINT DEFAULT 0 NOT NULL );
 
-- 社保核定单增加关联新的协作任务编排和协作规则
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SINSURVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGECLASS')) 
 ALTER TABLE T_HPDI_SINSURVERBILL ADD (FTASKARRANGECLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SINSURVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGEID')) 
 ALTER TABLE T_HPDI_SINSURVERBILL ADD (FTASKARRANGEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SINSURVERBILL' AND KSQL_COL_NAME IN ('FCOLLATASKCLASS')) 
 ALTER TABLE T_HPDI_SINSURVERBILL ADD (FCOLLATASKCLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SINSURVERBILL' AND KSQL_COL_NAME IN ('FCOLLATASKID')) 
 ALTER TABLE T_HPDI_SINSURVERBILL ADD (FCOLLATASKID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SINSURVERBILL' AND KSQL_COL_NAME IN ('FMORGID')) 
 ALTER TABLE T_HPDI_SINSURVERBILL ADD (FMORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SINSURVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGEVID')) 
 ALTER TABLE T_HPDI_SINSURVERBILL ADD (FTASKARRANGEVID BIGINT DEFAULT 0 NOT NULL );
 
-- 薪酬汇总核定单增加关联新的协作任务编排和协作规则
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SUMMARYVBILL' AND KSQL_COL_NAME IN ('FTASKARRANGECLASS')) 
 ALTER TABLE T_HPDI_SUMMARYVBILL ADD (FTASKARRANGECLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SUMMARYVBILL' AND KSQL_COL_NAME IN ('FTASKARRANGEID')) 
 ALTER TABLE T_HPDI_SUMMARYVBILL ADD (FTASKARRANGEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SUMMARYVBILL' AND KSQL_COL_NAME IN ('FCOLLATASKCLASS')) 
 ALTER TABLE T_HPDI_SUMMARYVBILL ADD (FCOLLATASKCLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SUMMARYVBILL' AND KSQL_COL_NAME IN ('FCOLLATASKID')) 
 ALTER TABLE T_HPDI_SUMMARYVBILL ADD (FCOLLATASKID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SUMMARYVBILL' AND KSQL_COL_NAME IN ('FMORGID')) 
 ALTER TABLE T_HPDI_SUMMARYVBILL ADD (FMORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_SUMMARYVBILL' AND KSQL_COL_NAME IN ('FTASKARRANGEVID')) 
 ALTER TABLE T_HPDI_SUMMARYVBILL ADD (FTASKARRANGEVID BIGINT DEFAULT 0 NOT NULL );

-- 个税汇总核定单增加关联新的协作任务编排和协作规则
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TAXVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGECLASS')) 
 ALTER TABLE T_HPDI_TAXVERBILL ADD (FTASKARRANGECLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TAXVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGEID')) 
 ALTER TABLE T_HPDI_TAXVERBILL ADD (FTASKARRANGEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TAXVERBILL' AND KSQL_COL_NAME IN ('FCOLLATASKCLASS')) 
 ALTER TABLE T_HPDI_TAXVERBILL ADD (FCOLLATASKCLASS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TAXVERBILL' AND KSQL_COL_NAME IN ('FCOLLATASKID')) 
 ALTER TABLE T_HPDI_TAXVERBILL ADD (FCOLLATASKID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TAXVERBILL' AND KSQL_COL_NAME IN ('FMORGID')) 
 ALTER TABLE T_HPDI_TAXVERBILL ADD (FMORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TAXVERBILL' AND KSQL_COL_NAME IN ('FTASKARRANGEVID')) 
 ALTER TABLE T_HPDI_TAXVERBILL ADD (FTASKARRANGEVID BIGINT DEFAULT 0 NOT NULL );


-- 薪酬汇总核定单增加关联协作规则版本分录
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HPDI_SUMVBCRENT') 
 CREATE TABLE T_HPDI_SUMVBCRENT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCOLLARULEVCLASS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCOLLARULEVID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL
);
