-- 项目奖金核算_奖金周期表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_PB_BonusCycle')
Create Table CT_PB_BonusCycle ( FFivouchered INT DEFAULT 0,CFName_l1 NVARCHAR(255),CFName_l2 NVARCHAR(255),CFName_l3 NVARCHAR(255),CFCycleName VARCHAR(100),CFState INT DEFAULT 0 NOT NULL ,CFReminderContent VARCHAR(2000),FNumber NVARCHAR(80),FBizDate DateTime,FHandlerID VARCHAR(44),FDescription VARCHAR(512),FHasEffected INT,FAuditorID VARCHAR(44),FSourceBillID VARCHAR(80),FSourceFunction VARCHAR(80),FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44),FID VARCHAR(44) DEFAULT '' NOT NULL ,CONSTRAINT PK_BonusCycle PRIMARY KEY (FID));

-- 项目奖金核算_事业部项目表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_PB_BonusCycleBusDepProject')
Create Table CT_PB_BonusCycleBusDepProject ( FParentID VARCHAR(44),CFBusDepID VARCHAR(44),CFSecondcenterID VARCHAR(44),CFType VARCHAR(100),CFProjectID VARCHAR(44),CFState INT DEFAULT 0,CFPrincipalID VARCHAR(44),CFBonusAmount NUMERIC(28,10),CFNotPrincipalPropor NUMERIC(28,10),CFPrincipalPropor NUMERIC(28,10),CFTotalBonusHalf NUMERIC(28,10),CFDirectManProjBonus NUMERIC(28,10),CFContraManProjBonus NUMERIC(28,10),CFCondManProjectBonus NUMERIC(28,10),CFStraManProjectBonus NUMERIC(28,10),CFBonusAdjustment NUMERIC(28,10),CFBonusAdjustmentDesc VARCHAR(255),CFTotalBonusReal NUMERIC(28,10),CFInitialAllocationRatio1 NUMERIC(28,10),CFInitialAllocationRatio2 NUMERIC(28,10),CFInitialAllocationRatio3 NUMERIC(28,10),FSeq INT,FID VARCHAR(44) DEFAULT '' NOT NULL ,CONSTRAINT PK_BonusCycleBusDe PRIMARY KEY (FID));

-- 项目奖金核算_分配人员明细表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_PB_BonusCAPD')
Create Table CT_PB_BonusCAPD ( FParentID VARCHAR(44) DEFAULT '',CFPersonID VARCHAR(44),CFPositionID VARCHAR(44),CFGradeID VARCHAR(44),CFInitialProportion NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFFunctionCoefficient NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFEnergyInputCoeff NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFPerformanceGradeQ1 VARCHAR(100),CFPerformanceCoeffQ1 NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFPerformanceGradeQ2 VARCHAR(100),CFPerformanceCoeffQ2 NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFAssessmentCoeff NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFBonusStartingDate DateTime,CFBonusDueDate DateTime,CFAttendanceRate NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFCumulative NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFBonusProportion NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFIndivBonusAmount NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFOpinionAmount NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFAdjustmentDesc VARCHAR(1000),CFApprovalAmount NUMERIC(28,10) DEFAULT 0 NOT NULL ,CFRemarks VARCHAR(1000),FSeq INT,FID VARCHAR(44) DEFAULT '' NOT NULL ,CONSTRAINT PK_BonusCycleBusDe PRIMARY KEY (FID));

-- 拓展人员考核_扩展人员计算规则附件表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_EXP_ComRule')
Create Table CT_EXP_ComRule ( FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44),FNumber NVARCHAR(80),FBizDate DateTime,FHandlerID VARCHAR(44),FDescription NVARCHAR(80),FHasEffected INT,FAuditorID VARCHAR(44),FSourceBillID NVARCHAR(80),FSourceFunction NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FFivouchered INT,CONSTRAINT CPK_EXP_ComRuleulh PRIMARY KEY (FID));

-- 拓展人员考核_拓展人员考核表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_EXP_ExpandAssess')
Create Table CT_EXP_ExpandAssess ( FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44),FNumber NVARCHAR(80),FBizDate DateTime,FHandlerID VARCHAR(44),FDescription NVARCHAR(80),FHasEffected INT,FAuditorID VARCHAR(44),FSourceBillID NVARCHAR(80),FSourceFunction NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FFivouchered INT,CFYear INT,CFQuarter INT,CFPeriodType VARCHAR(100),CFPeriodStatus VARCHAR(100),CONSTRAINT CPK_EXP_ExpandAar2 PRIMARY KEY (FID));

-- 拓展人员考核_考核人明细表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_EXP_ExpandAssessEntry')
Create Table CT_EXP_ExpandAssessEntry ( FParentID VARCHAR(44),CFAssessorID VARCHAR(44),CFAdminOrgID VARCHAR(44),CFCoefficient NUMERIC(6,4) DEFAULT 0,CFThreshold NUMERIC(28,10) DEFAULT 0,CFTarget NUMERIC(28,10) DEFAULT 0,CFChallenge NUMERIC(28,10) DEFAULT 0,CFPrincipalID VARCHAR(44),CFOneLift NUMERIC(28,10) DEFAULT 0,CFUniteLift NUMERIC(28,10) DEFAULT 0,CFAsseStatus VARCHAR(100) DEFAULT 'UNSTART',CFShareLiftRes NUMERIC(28,10) DEFAULT 0,CFShareLiftZY NUMERIC(28,10) DEFAULT 0,CFShareLiftLC NUMERIC(28,10) DEFAULT 0,CFContracts NUMERIC(28,10) DEFAULT 0,CFRankings INT,CFAssessRate VARCHAR(100) DEFAULT 'APLUS',CFCheckRate VARCHAR(100) DEFAULT 'APLUS',CFRemark VARCHAR(254),CFAmendAssessRate VARCHAR(100) DEFAULT 'APLUS',FSeq INT,FID VARCHAR(44) DEFAULT '' NOT NULL ,CONSTRAINT PK_ExpandAssessEnt PRIMARY KEY (FID));

-- 拓展人员考核_季度比例表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_EXP_QuarterlyRatio')
Create Table CT_EXP_QuarterlyRatio ( FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44),FNumber NVARCHAR(80),FBizDate DateTime,FHandlerID VARCHAR(44),FDescription NVARCHAR(80),FHasEffected INT,FAuditorID VARCHAR(44),FSourceBillID NVARCHAR(80),FSourceFunction NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FFivouchered INT,CFYear INT,CFQuarterOne INT,CFQuarterTwo INT,CFQuarterThree INT,CFQuarterFour INT,CONSTRAINT CPK_EXP_QrtrlRI7ai PRIMARY KEY (FID));

-- 拓展人员考核_考核人明细分录表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_EXP_QuarterlyRatioEntry')
Create Table CT_EXP_QuarterlyRatioEntry ( FSeq INT,FID VARCHAR(44) DEFAULT '' NOT NULL ,FParentID VARCHAR(44),CONSTRAINT CPK_EXP_QrtrlREpbi PRIMARY KEY (FID));

-- 正态分布_组织绩效得分分录表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_PER_ExamineGPES')
Create Table CT_PER_ExamineGPES ( FID VARCHAR(44) DEFAULT '' NOT NULL ,FSeq INT DEFAULT 0 NOT NULL ,FParentID VARCHAR(44) DEFAULT '' NOT NULL ,CFSeq INT,CFAdminOrgID VARCHAR(44),CFScoreMeritOrg NVARCHAR(100),CONSTRAINT CPK_PER_ExmnGPEgd3 PRIMARY KEY (FID));

-- 正态分布_周期季度表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_PER_ExamineGradePerson')
Create Table CT_PER_ExamineGradePerson ( FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44),FNumber NVARCHAR(80),FBizDate DateTime,FHandlerID VARCHAR(44),FDescription NVARCHAR(80),FHasEffected INT,FAuditorID VARCHAR(44),FSourceBillID NVARCHAR(80),FSourceFunction NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FFivouchered INT,CFYear INT,CFPeriodType VARCHAR(100),CFQuarter INT,CFPeriodStatus VARCHAR(100),CONSTRAINT CPK_PER_ExmnGPI86p PRIMARY KEY (FID));

-- 正态分布_周期季度分录表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_PER_ExamineGradePersonEntry')
Create Table CT_PER_ExamineGradePersonEntry ( FParentID VARCHAR(44),CFAdminOrgID VARCHAR(44),CFAuditorID VARCHAR(44),CFScorerID VARCHAR(44),CFIndex INT,CFScore VARCHAR(100),CFScoreLeader VARCHAR(100),CFOrderStatuc VARCHAR(100) DEFAULT 'closeOrder',CFRemark VARCHAR(256),CFPerformanceScore VARCHAR(44),CFAfterScoreNumMap VARCHAR(100),CFLastScore NUMERIC(28,10),CFUpLastScore NUMERIC(28,10),CFLastLevel VARCHAR(100) DEFAULT 'A',CFUpLastLevel VARCHAR(100) DEFAULT 'A',FSeq INT,FID VARCHAR(44) DEFAULT '' NOT NULL ,CONSTRAINT PK_ExamineGradePer PRIMARY KEY (FID));

-- 正态分布_组织绩效与个人绩效分布对应关系表
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_PER_PersonRelationOrg')
Create Table CT_PER_PersonRelationOrg ( FName_l1 NVARCHAR(255),FName_l2 NVARCHAR(255),FName_l3 NVARCHAR(255),FNumber NVARCHAR(80),FDescription_l1 NVARCHAR(255),FDescription_l2 NVARCHAR(255),FDescription_l3 NVARCHAR(255),FSimpleName NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44) DEFAULT '11111111-1111-1111-1111-111111111111CCE7AED4',CFMeritA INT,CFMeritBplus INT,CFMeritB INT,CFMeritBminus INT,CFMeritC INT,CFMeritD INT,CFScore VARCHAR(100),CFRatioPerformance NVARCHAR(100),CONSTRAINT CPK_PER_PersonRvgn PRIMARY KEY (FID));

-- OA待办集成
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_NOT_NotifyTodo')
Create Table CT_NOT_NotifyTodo ( FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44),FNumber NVARCHAR(80),FBizDate DateTime,FHandlerID VARCHAR(44),FDescription NVARCHAR(80),FHasEffected INT,FAuditorID VARCHAR(44),FSourceBillID NVARCHAR(80),FSourceFunction NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FFivouchered INT,CFOperationType NVARCHAR(200),CFSendTodoID VARCHAR(44),CFUpdateTodoID VARCHAR(44),CFSetdelTodoDoneID VARCHAR(44),CFReturnState VARCHAR(100),CFMessage NVARCHAR(200),CFTodoType VARCHAR(100),CONSTRAINT CPK_NOT_NotifyT6uj PRIMARY KEY (FID));

--删除待办请求参数体
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_NOT_RemoveContext')
Create Table CT_NOT_RemoveContext ( FName_l1 NVARCHAR(255),FName_l2 NVARCHAR(255),FName_l3 NVARCHAR(255),FNumber NVARCHAR(80),FDescription_l1 NVARCHAR(255),FDescription_l2 NVARCHAR(255),FDescription_l3 NVARCHAR(255),FSimpleName NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44) DEFAULT '11111111-1111-1111-1111-111111111111CCE7AED4',CFAppName NVARCHAR(100),CFModelName NVARCHAR(100),CFModelId NVARCHAR(255),CFKey NVARCHAR(100),CFParam1 NVARCHAR(255),CFParam2 NVARCHAR(255),CFTargets NVARCHAR(255),CFOptType INT,CFType INT,CONSTRAINT CPK_NOT_RemoveCij3 PRIMARY KEY (FID));

--发送待办请求参数体
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_NOT_SendContext')
Create Table CT_NOT_SendContext ( FName_l1 NVARCHAR(255),FName_l2 NVARCHAR(255),FName_l3 NVARCHAR(255),FNumber NVARCHAR(80),FDescription_l1 NVARCHAR(255),FDescription_l2 NVARCHAR(255),FDescription_l3 NVARCHAR(255),FSimpleName NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44) DEFAULT '11111111-1111-1111-1111-111111111111CCE7AED4',CFAppName NVARCHAR(255),CFModelName NVARCHAR(255),CFModelId NVARCHAR(255),CFSubject NVARCHAR(255),CFLink NVARCHAR(255),CFType INT,CFKey NVARCHAR(255),CFParam1 NVARCHAR(255),CFParam2 NVARCHAR(255),CFTargets NVARCHAR(255),CFDocCreator NVARCHAR(255),CFLevel INT,CFExtendContent NVARCHAR(255),CFOthers NUMERIC(28,10),CONSTRAINT CPK_NOT_SendCIDdkh PRIMARY KEY (FID));

--更新待办请求参数体
If not exists (select 1 from KSQL_USERTABLES where KSQL_TABNAME='CT_NOT_UpdateContent')
Create Table CT_NOT_UpdateContent ( FName_l1 NVARCHAR(255),FName_l2 NVARCHAR(255),FName_l3 NVARCHAR(255),FNumber NVARCHAR(80),FDescription_l1 NVARCHAR(255),FDescription_l2 NVARCHAR(255),FDescription_l3 NVARCHAR(255),FSimpleName NVARCHAR(80),FID VARCHAR(44) DEFAULT '' NOT NULL ,FCreatorID VARCHAR(44),FCreateTime DateTime,FLastUpdateUserID VARCHAR(44),FLastUpdateTime DateTime,FControlUnitID VARCHAR(44) DEFAULT '11111111-1111-1111-1111-111111111111CCE7AED4',CFAppName NVARCHAR(200),CFModelName NVARCHAR(200),CFModelId NVARCHAR(200),CFKey NVARCHAR(200),CFParam1 NVARCHAR(200),CFParam2 NVARCHAR(200),CFSubject NVARCHAR(200),CFLink NVARCHAR(200),CFExtendContent NVARCHAR(200),CFType INT,CFLevel INT,CONSTRAINT CPK_NOT_UpdateC4bm PRIMARY KEY (FID));


