IF
NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_INVATTACHHB')
CREATE TABLE T_ER_INVATTACHHB
(
    FID          BIGINT      DEFAULT 0   NOT NULL,
    FBILLNO      VARCHAR(80) DEFAULT ' ' NOT NULL,
    FISUPGRADE   CHAR(1)     DEFAULT '0' NOT NULL,
    FENTITYNAME  NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FCOSTCOMPANY BIGINT      DEFAULT 0   NOT NULL,
    FUPGRADETIME DATETIME NULL
);

EXEC P_ALTERPK 'PK_T_ER_INVATTACHHB', 'T_ER_INVATTACHHB', 'FID', '1';

 IF
NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_INVATTACHHB' AND KSQL_INDNAME = 'IDX_ER_INVATTACHHB_ISUPGRADE') CREATE
INDEX IDX_ER_INVATTACHHB_ISUPGRADE ON T_ER_INVATTACHHB ( FISUPGRADE );


delete from T_ER_INVATTACHHB;

-- 调度任务预置

/**
DELETE FROM T_SCH_JOB WHERE FID = '3BID07AP4L=6';
INSERT INTO T_SCH_JOB(FID,FTASKCLASSNAME,FTASKDEFINEID,FRUNMODE,FRUNBYUSERID,FJOBTYPE,FSTATUS,FNUMBER,FCONCURRENT,FSTRATEGY,FTIMEOUT,FRETRYTIME,FRUNBYLANG,FCANSTOP,FPARAMS,FRUNBYORGID) VALUES ('3BID07AP4L=6','kd.fi.er.business.invoicecloud.task.TInvoiceAttachUpgradeTask','3BICF0FBXTZ9','0',1236081998485809152,'BIZ','1','em_invoiceattach_sync_SKDJ_S','1','1',0,0,' ','0','{}',0);
DELETE FROM T_SCH_JOB_L WHERE FPKID = '3BID07AP6GO4';
INSERT INTO T_SCH_JOB_L(FID,FPKID,FLOCALEID,FNAME) VALUES ('3BID07AP4L=6','3BID07AP6GO4','zh_CN','费用-发票集成-附件同步');
DELETE FROM T_SCH_JOB_N WHERE FID = '3BID07AP4L=6';
INSERT INTO T_SCH_JOB_N(FID,FJOBPRINCIPAL,FOVERTIME,FSUCCESSNOTIFY,FJOBMSGRECEIVER,FMSGCONTENT,FFAILNOTIFY,FNOTIFYTYPE,FCAPTION) VALUES ('3BID07AP4L=6',1236081998485809152,'0','0',0,' ','1',' ','调度作业通知');

DELETE FROM T_SCH_SCHEDULE WHERE FID = '3BIE3=A/UN90';
INSERT INTO T_SCH_SCHEDULE(FTWENTY,FFIVE,FELEVEN,FNINE,FNO,FSUN,FTWO,FEIGHT,FNOV,FPLAN,FWED,FHOST,FTWENTYTWO,FFOUR,FMAR,FSEP,FENDTIME,FSIX,FMAY,FREPEATMODE,FTHIRTYONE,FBYDAYORWEEK,FTWENTYSEVEN,FTWENTYSIX,FTHIRTEEN,FAUG,FDESC,FFIFTEEN,FTWENTYONE,FBYWEEK,FTUES,FSEVENTEEN,FSEVEN,FTWENTYFOUR,FMON,FTHIRTY,FTHREE,FFOURTEEN,FJAN,FNINETEEN,FTHUR,FTEN,FFRI,FJOBID,FSTARTTIME,FOCT,FAPR,FSIXTEEN,FID,FSAT,FONE,FTWENTYEIGHT,FTWENTYTHREE,FTWELVE,FNOWEEK,FSTATUS,FNUMBER,FTWENTYFIVE,FEIGHTEEN,FCYCLENUM,FTWENTYNINE,FJUL,FDEC,FJUN,FFEB) VALUES ('0','0','0','0',' ','0','0','0','0','0 0 0 12 6 ? 2023','0','172.19.81.72','0','0','0','0',{ts'2099-12-31  00:00:00'},'0','0','n','0','d','0','0','0','0','事件不重复','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3BID07AP4L=6',{ts'2023-06-12  00:00:00'},'0','0','0','3BIE3=A/UN90','0','0','0','0','0',' ','1','em_SyncInvoiceAttachment_SKDP_S','0','0',1,'0','0','0','0','0');
DELETE FROM T_SCH_SCHEDULE_L WHERE FPKID = '3BIE3=A/WIN+';
INSERT INTO T_SCH_SCHEDULE_L(FID,FPKID,FLOCALEID,FNAME) VALUES ('3BIE3=A/UN90','3BIE3=A/WIN+','zh_CN','费用-发票集成-发票云附件历史数据升级');
DELETE FROM T_SCH_SCHEDULE_L WHERE FPKID = '3BIE3=A/WIN/';
INSERT INTO T_SCH_SCHEDULE_L(FID,FPKID,FLOCALEID,FNAME) VALUES ('3BIE3=A/UN90','3BIE3=A/WIN/','zh_TW','費用-發票集成-發票雲附件曆史數據升級');
DELETE FROM T_SCH_SCHEDULE_N WHERE FID = '3BIE3=A/UN90';
INSERT INTO T_SCH_SCHEDULE_N(FID,FSNOTIFYTYPE,FMSGRECEIVER,FSMSGCONTENT,FSTIMEOUT,FSCHPRINCIPAL,FSSUCCESSNOTIFY,FSFAILNOTIFY) VALUES ('3BIE3=A/UN90',' ',0,' ','0',0,'0','1');
DELETE FROM T_SCH_SCHEDULE_ENTRY WHERE FENTRYID = '3BIE3=A/UN91';
INSERT INTO T_SCH_SCHEDULE_ENTRY(FID,FJOBNUMBER,FENTRYID,FSEQ) VALUES ('3BIE3=A/UN90','3BID07AP4L=6','3BIE3=A/UN91',1);

DELETE FROM T_SCH_TASKDEFINE WHERE FID = '3BICF0FBXTZ9';
INSERT INTO T_SCH_TASKDEFINE(FID,FCLASSNAME,FAPPID,FNUMBER) VALUES ('3BICF0FBXTZ9','kd.fi.er.business.invoicecloud.task.TInvoiceAttachUpgradeTask','em','er_syncInvoiceAttachment');
DELETE FROM T_SCH_TASKDEFINE_L WHERE FPKID = '3BICF0FBVYKA';
INSERT INTO T_SCH_TASKDEFINE_L(FID,FPKID,FLOCALEID,FNAME) VALUES ('3BICF0FBXTZ9','3BICF0FBVYKA','zh_CN','费用-发票集成-同步附件');
DELETE FROM T_SCH_TASKDEFINE_L WHERE FPKID = '3BICF0FBVYKB';
INSERT INTO T_SCH_TASKDEFINE_L(FID,FPKID,FLOCALEID,FNAME) VALUES ('3BICF0FBXTZ9','3BICF0FBVYKB','zh_TW','費用-發票集成-同步附件');

 */
