/**Begin D:\work\kuaijishijian\pdm\PDM_UPGRADE_1.4\PDM_UPGRADE\PDM1\AI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVENT_HEADER')
CREATE TABLE T_FAH_EVENT_HEADER (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FORGID BIGINT DEFAULT 0 NOT NULL,
                                    FSRC_SYSTYPE BIGINT DEFAULT 0 NOT NULL,
                                    FSRC_SYSID BIGINT DEFAULT 0 NOT NULL,
                                    FSRC_BILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                    FSRC_BILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                    FSRC_BILLID BIGINT DEFAULT 0 NOT NULL,
                                    FSOURCEENTRY VARCHAR(36) DEFAULT ' ' NOT NULL,
                                    FSOURCEENTRYID BIGINT DEFAULT 0 NOT NULL,
                                    FEVTCLASSID BIGINT DEFAULT 0 NOT NULL,
                                    FEVTTYPEID BIGINT DEFAULT 0 NOT NULL,
                                    FBIZDATE DATETIME,
                                    FBOOKEDDATE DATETIME,
                                    FRULEID BIGINT DEFAULT 0 NOT NULL,
                                    FRULEVERSION INT DEFAULT 0 NOT NULL,
                                    FDISPATCHID BIGINT DEFAULT 0 NOT NULL,
                                    FDISPATCHVERSION INT DEFAULT 0 NOT NULL,
                                    FEVTLINECNT INT DEFAULT 0 NOT NULL,
                                    FCREATESTAGE CHAR(1) DEFAULT '0' NOT NULL,
                                    FCREATESTATUS CHAR(1) DEFAULT '0' NOT NULL,
                                    FNEEDACCT CHAR(1) DEFAULT '0' NOT NULL,
                                    FBIZDATASTATUS CHAR(1) DEFAULT '0' NOT NULL,
                                    FISPREVIEW CHAR(1) DEFAULT '0' NOT NULL,
                                    FRELATEID BIGINT DEFAULT 0 NOT NULL,
                                    FREVERSESTATUS CHAR(1) DEFAULT '0' NOT NULL,
                                    FCREATETIME DATETIME,
                                    FMODIFYTIME DATETIME,
                                    FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                    FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                    FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                    FPARTITIONGRPCODE INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVENT_LINE')
CREATE TABLE T_FAH_EVENT_LINE (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                  FSEQ INT DEFAULT 0 NOT NULL,
                                  FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
                                  FSOURCEENTRY VARCHAR(36) DEFAULT ' ' NOT NULL,
                                  FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
                                  FSRCLINERULEID BIGINT DEFAULT 0 NOT NULL,
                                  FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                  FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                  FBIZLINESTATUS CHAR(1) DEFAULT '0' NOT NULL,
                                  FDIMGRPVALID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVENT_LINE_TMP')
CREATE TABLE T_FAH_EVENT_LINE_TMP (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                      FSEQ INT DEFAULT 0 NOT NULL,
                                      FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
                                      FSOURCEENTRY VARCHAR(36) DEFAULT ' ' NOT NULL,
                                      FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
                                      FSRCLINERULEID BIGINT DEFAULT 0 NOT NULL,
                                      FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                      FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                      FLINESTATUS CHAR(1) DEFAULT '0' NOT NULL,
                                      FMSG NVARCHAR(2000) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVENT_SEQ')
CREATE TABLE T_FAH_EVENT_SEQ (
                                 FID BIGINT DEFAULT 0 NOT NULL,
                                 FSEQ INT DEFAULT 0 NOT NULL,
                                 FCREATETIME DATETIME,
                                 FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_AE_HEADERS')
CREATE TABLE T_FAH_AE_HEADERS (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FBOOKTYPEID BIGINT DEFAULT 0 NOT NULL,
                                  FBOOKID BIGINT DEFAULT 0 NOT NULL,
                                  FORGID BIGINT DEFAULT 0 NOT NULL,
                                  FPERIODID BIGINT DEFAULT 0 NOT NULL,
                                  FTYPEID BIGINT DEFAULT 0 NOT NULL,
                                  FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                  FBIZDATE DATETIME,
                                  FBOOKEDDATE DATETIME,
                                  FSRC_SYSTYPE BIGINT DEFAULT 0 NOT NULL,
                                  FSRC_SYSID BIGINT DEFAULT 0 NOT NULL,
                                  FSRC_BILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                  FSRC_BILLID BIGINT DEFAULT 0 NOT NULL,
                                  FSRC_BILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                  FATTACHMENTS INT DEFAULT 0 NOT NULL,
                                  FLOC_DEBITAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                  FLOC_CREDITAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                  FLOC_CURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                  FSRCEVENTID BIGINT DEFAULT 0 NOT NULL,
                                  FACCTRULEID BIGINT DEFAULT 0 NOT NULL,
                                  FACCTRULEVERSION INT DEFAULT 0 NOT NULL,
                                  FACCTPURPOSEID BIGINT DEFAULT 0 NOT NULL,
                                  FACCTPURPOSEVERSION INT DEFAULT 0 NOT NULL,
                                  FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                  FCREATETIME DATETIME,
                                  FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                  FMERGEGRPKEY NVARCHAR(1000) DEFAULT ' ' NOT NULL,
                                  FRELATEID BIGINT DEFAULT 0 NOT NULL,
                                  FREVERSESTATUS CHAR(1) DEFAULT '0' NOT NULL,
                                  FMERGERULEID BIGINT DEFAULT 0 NOT NULL,
                                  FVOUCHERSTATUS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_AE_HEADERS_TMP')
CREATE TABLE T_FAH_AE_HEADERS_TMP (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FBOOKTYPEID BIGINT DEFAULT 0 NOT NULL,
                                      FBOOKID BIGINT DEFAULT 0 NOT NULL,
                                      FORGID BIGINT DEFAULT 0 NOT NULL,
                                      FPERIODID BIGINT DEFAULT 0 NOT NULL,
                                      FTYPEID BIGINT DEFAULT 0 NOT NULL,
                                      FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                      FBIZDATE DATETIME,
                                      FBOOKEDDATE DATETIME,
                                      FSRC_SYSTYPE BIGINT DEFAULT 0 NOT NULL,
                                      FSRC_SYSID BIGINT DEFAULT 0 NOT NULL,
                                      FSRC_BILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                      FSRC_BILLID BIGINT DEFAULT 0 NOT NULL,
                                      FSRC_BILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                      FATTACHMENTS INT DEFAULT 0 NOT NULL,
                                      FLOC_DEBITAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                      FLOC_CREDITAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                      FLOC_CURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                      FSRCEVENTID BIGINT DEFAULT 0 NOT NULL,
                                      FACCTRULEID BIGINT DEFAULT 0 NOT NULL,
                                      FACCTRULEVERSION INT DEFAULT 0 NOT NULL,
                                      FACCTPURPOSEID BIGINT DEFAULT 0 NOT NULL,
                                      FACCTPURPOSEVERSION INT DEFAULT 0 NOT NULL,
                                      FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                      FCREATETIME DATETIME,
                                      FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                      FMERGEGRPKEY NVARCHAR(1000) DEFAULT ' ' NOT NULL,
                                      FRELATEID BIGINT DEFAULT 0 NOT NULL,
                                      FREVERSESTATUS CHAR(1) DEFAULT '0' NOT NULL,
                                      FMERGERULEID BIGINT DEFAULT 0 NOT NULL,
                                      FISPREVIEW CHAR(1) DEFAULT '0' NOT NULL,
                                      FISERROR CHAR(1) DEFAULT '0' NOT NULL,
                                      FERRORMESSAGE NVARCHAR(2000) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_AE_LINES')
CREATE TABLE T_FAH_AE_LINES (
                                FID BIGINT DEFAULT 0 NOT NULL,
                                FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                FSEQ INT DEFAULT 0 NOT NULL,
                                FACCOUNTID BIGINT DEFAULT 0 NOT NULL,
                                FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                FMEASUREUNITID BIGINT DEFAULT 0 NOT NULL,
                                FASSGRPID BIGINT DEFAULT 0 NOT NULL,
                                FORI_DEBIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FORI_CREDIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FLOCAL_DEBIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FLOCAL_CREDIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FLOCAL_EXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FQUANTITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                FMAINCF_ITEMID BIGINT DEFAULT 0 NOT NULL,
                                FMAINCF_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FSUPCF_ITEMID BIGINT DEFAULT 0 NOT NULL,
                                FSUPCF_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                FEXPIRE_DATE DATETIME,
                                FBUSINESSNUM NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                FSRC_EVENTLINEID BIGINT DEFAULT 0 NOT NULL,
                                FSOURCEENTRY VARCHAR(36) DEFAULT ' ' NOT NULL,
                                FSRC_BILLENTRYID BIGINT DEFAULT 0 NOT NULL,
                                FMAINCF_ASSGRPID BIGINT DEFAULT 0 NOT NULL,
                                FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
                                FENTRYDC VARCHAR(2) DEFAULT '1' NOT NULL,
                                FNEEDMERGE CHAR(1) DEFAULT '0' NOT NULL,
                                FDIMGRPVALID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_AE_LINES_TMP')
CREATE TABLE T_FAH_AE_LINES_TMP (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                    FSEQ INT DEFAULT 0 NOT NULL,
                                    FACCOUNTID BIGINT DEFAULT 0 NOT NULL,
                                    FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                    FMEASUREUNITID BIGINT DEFAULT 0 NOT NULL,
                                    FASSGRPID BIGINT DEFAULT 0 NOT NULL,
                                    FORI_DEBIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FORI_CREDIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FLOCAL_DEBIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FLOCAL_CREDIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FLOCAL_EXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FQUANTITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                    FMAINCF_ITEMID BIGINT DEFAULT 0 NOT NULL,
                                    FMAINCF_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FSUPCF_ITEMID BIGINT DEFAULT 0 NOT NULL,
                                    FSUPCF_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                    FEXPIRE_DATE DATETIME,
                                    FBUSINESSNUM NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FSRC_EVENTLINEID BIGINT DEFAULT 0 NOT NULL,
                                    FSOURCEENTRY VARCHAR(36) DEFAULT ' ' NOT NULL,
                                    FSRC_BILLENTRYID BIGINT DEFAULT 0 NOT NULL,
                                    FMAINCF_ASSGRPID BIGINT DEFAULT 0 NOT NULL,
                                    FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
                                    FENTRYDC VARCHAR(2) DEFAULT '1' NOT NULL,
                                    FNEEDMERGE CHAR(1) DEFAULT '0' NOT NULL,
                                    FERRORMESSAGE NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                    FISERROR CHAR(1) DEFAULT '0' NOT NULL,
                                    FDIMGRPVALID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_REQUEST_TASK')
CREATE TABLE T_FAH_REQUEST_TASK (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FTASKNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                    FCREATETIME DATETIME,
                                    FEXCUTESTARTTIME DATETIME,
                                    FEXCUTEENDTIME DATETIME,
                                    FTASKTYPE VARCHAR(1) DEFAULT ' ' NOT NULL,
                                    FQUERYSTARTDATE DATETIME,
                                    FQUERYENDDATE DATETIME,
                                    FREQUESTBILLCNT INT DEFAULT 0 NOT NULL,
                                    FPROCESSEVTCNT INT DEFAULT 0 NOT NULL,
                                    FFAILBILLCNT INT DEFAULT 0 NOT NULL,
                                    FSPLITBATCHCNT INT DEFAULT 0 NOT NULL,
                                    FLARGEENTRYCNT INT DEFAULT 0 NOT NULL,
                                    FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                    FBUILDBIZDIMGRPTASKSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                    FMSG_TAG NCLOB,
                                    FMSG VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_REQUEST_TASK_BILL')
CREATE TABLE T_FAH_REQUEST_TASK_BILL (
                                         FPKID BIGINT DEFAULT 0 NOT NULL,
                                         FID BIGINT DEFAULT 0 NOT NULL,
                                         FBASEDATAID VARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_REQUEST_TASK_ORG')
CREATE TABLE T_FAH_REQUEST_TASK_ORG (
                                        FPKID BIGINT DEFAULT 0 NOT NULL,
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_TASK_BATCH')
CREATE TABLE T_FAH_TASK_BATCH (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                  FSEQNO INT DEFAULT 0 NOT NULL,
                                  FBILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                  FEXCUTESTARTTIME DATETIME,
                                  FEXCUTEENDTIME DATETIME,
                                  FRECCNT INT DEFAULT 0 NOT NULL,
                                  FLOCKINSTANCEID VARCHAR(80) DEFAULT ' ' NOT NULL,
                                  FSTATUS CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_TASK_BATCH_EN')
CREATE TABLE T_FAH_TASK_BATCH_EN (
                                     FID BIGINT DEFAULT 0 NOT NULL,
                                     FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                     FSEQNO INT DEFAULT 0 NOT NULL,
                                     FSRCBILLID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_TASK_FAIL_BILLS')
CREATE TABLE T_FAH_TASK_FAIL_BILLS (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                       FBILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                       FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
                                       FSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                       FDISPATCHID BIGINT DEFAULT 0 NOT NULL,
                                       FDISPATCHVERSION INT DEFAULT 0 NOT NULL,
                                       FMSG NCLOB,
                                       FMSG_CODE VARCHAR(2) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_LOG_DISPATCH')
CREATE TABLE T_FAH_LOG_DISPATCH (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                    FBILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                    FSRCBILLENTRY VARCHAR(36) DEFAULT ' ' NOT NULL,
                                    FDISPATCHRULEID BIGINT DEFAULT 0 NOT NULL,
                                    FDISPATCHRULEVERSION INT DEFAULT 0 NOT NULL,
                                    FEVTRULEID BIGINT DEFAULT 0 NOT NULL,
                                    FEVTRULEVERSION INT DEFAULT 0 NOT NULL,
                                    FEVTHEADERCNT INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_LOG_DISPATCH_EN')
CREATE TABLE T_FAH_LOG_DISPATCH_EN (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                       FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
                                       FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_TRACKER')
CREATE TABLE T_FAH_EVT_TRACKER (
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FSRC_BILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                   FSRC_BILLID BIGINT DEFAULT 0 NOT NULL,
                                   FXLA_HEADER_ID BIGINT DEFAULT 0 NOT NULL,
                                   FGL_HEADER_ID BIGINT DEFAULT 0 NOT NULL,
                                   FREVERSEFLAG CHAR(1) DEFAULT '0' NOT NULL,
                                   FSRC_SYSTYPE CHAR(1) DEFAULT '0' NOT NULL,
                                   FREQUESTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_TRACKER_EN')
CREATE TABLE T_FAH_EVT_TRACKER_EN (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FSRC_BILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                      FSRC_BILLID BIGINT DEFAULT 0 NOT NULL,
                                      FSOURCEENTRY VARCHAR(36) DEFAULT ' ' NOT NULL,
                                      FSRC_BILLENTRYID BIGINT DEFAULT 0 NOT NULL,
                                      FXLA_HEADER_ID BIGINT DEFAULT 0 NOT NULL,
                                      FXLA_LINE_ID BIGINT DEFAULT 0 NOT NULL,
                                      FGL_HEADER_ID BIGINT DEFAULT 0 NOT NULL,
                                      FGL_LINE_ID BIGINT DEFAULT 0 NOT NULL,
                                      FREVERSEFLAG CHAR(1) DEFAULT '0' NOT NULL,
                                      FREQUESTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_VOUCHERENTRY_IF')
CREATE TABLE T_FAH_VOUCHERENTRY_IF (
                                       FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FACCOUNTID BIGINT DEFAULT 0 NOT NULL,
                                       FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                       FLOCALEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                       FMEASUREUNITID BIGINT DEFAULT 0 NOT NULL,
                                       FASSGRPID BIGINT DEFAULT 0 NOT NULL,
                                       FORIGINALDEBIT DECIMAL(21,6) DEFAULT 0 NOT NULL,
                                       FORIGINALCREDIT DECIMAL(21,6) DEFAULT 0 NOT NULL,
                                       FLOCALDEBIT DECIMAL(21,6) DEFAULT 0 NOT NULL,
                                       FLOCALCREDIT DECIMAL(21,6) DEFAULT 0 NOT NULL,
                                       FQUANTITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                       FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                       FSEQ INT DEFAULT 0 NOT NULL,
                                       FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                       FENTRYDC VARCHAR(2) DEFAULT '1' NOT NULL,
                                       FMAINCFITEMID BIGINT DEFAULT 0 NOT NULL,
                                       FMAINCFASSGRPID BIGINT DEFAULT 0 NOT NULL,
                                       FSUPPCFITEMID BIGINT DEFAULT 0 NOT NULL,
                                       FSUPPCFAMOUNT DECIMAL(21,6) DEFAULT 0 NOT NULL,
                                       FMAINCFAMOUNT DECIMAL(21,6) DEFAULT 0 NOT NULL,
                                       FEXPIREDATE DATETIME,
                                       FBUSINESSNUM NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FORGID BIGINT DEFAULT 0 NOT NULL,
                                       FPERIODID BIGINT DEFAULT 0 NOT NULL,
                                       FGRPKEYHASH BIGINT DEFAULT 0 NOT NULL,
                                       FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
                                       FISMERGE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_VOUCHER_IF')
CREATE TABLE T_FAH_VOUCHER_IF (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                  FBOOKTYPEID BIGINT DEFAULT 0 NOT NULL,
                                  FBOOKID BIGINT DEFAULT 0 NOT NULL,
                                  FORGID BIGINT DEFAULT 0 NOT NULL,
                                  FPERIODID BIGINT DEFAULT 0 NOT NULL,
                                  FTYPEID BIGINT DEFAULT 0 NOT NULL,
                                  FBILLSTATUS CHAR(1) DEFAULT '0' NOT NULL,
                                  FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                  FBIZDATE DATETIME,
                                  FBOOKEDDATE DATETIME,
                                  FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                  FCREATETIME DATETIME,
                                  FSOURCETYPE CHAR(1) DEFAULT '0' NOT NULL,
                                  FSOURCESYS VARCHAR(36) DEFAULT ' ' NOT NULL,
                                  FATTACHMENTS INT DEFAULT 0 NOT NULL,
                                  FSOURCEBILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                  FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
                                  FVDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                  FDEBITLOCAMOUNT DECIMAL(22,6) DEFAULT 0 NOT NULL,
                                  FCREDITLOCAMOUNT DECIMAL(22,6) DEFAULT 0 NOT NULL,
                                  FLOCCURRENCY BIGINT DEFAULT 0 NOT NULL,
                                  FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                  FMERGEGRPKEY VARCHAR(1000) DEFAULT ' ' NOT NULL,
                                  FGRPKEYHASH BIGINT DEFAULT 0 NOT NULL,
                                  FSOURCEBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_TASK_SKIP_BILLS')
CREATE TABLE T_FAH_TASK_SKIP_BILLS (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                       FBILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                       FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
                                       FSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                       FMSG NCLOB,
                                       FMSG_CODE VARCHAR(2) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_TASK_FAIL_BILLS_EN')
CREATE TABLE T_FAH_TASK_FAIL_BILLS_EN (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                          FMSG NCLOB
);



/**End D:\work\kuaijishijian\pdm\PDM_UPGRADE_1.4\PDM_UPGRADE\PDM1\AI_table.sql **/
