IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INOUTCOLLECT')
CREATE TABLE T_FPM_INOUTCOLLECT (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                    FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                    FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                    FAUDITDATE DATETIME,
                                    FMODIFYTIME DATETIME,
                                    FCREATETIME DATETIME,
                                    FBUSINESSTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FAPPLYORGID BIGINT DEFAULT 0 NOT NULL,
                                    FAPPLYUSERID BIGINT DEFAULT 0 NOT NULL,
                                    FCREATEDATE DATETIME,
                                    FNAME VARCHAR(100) DEFAULT ' ' NOT NULL,
                                    FREMARK VARCHAR(256) DEFAULT ' ' NOT NULL,
                                    FAPPROVALSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FAPPLYSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FDATASOURCE VARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FSOURCEBILL VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FSOURCEBILLNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
                                    FSOURCEBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
                                    FABANDONSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FABANDONREASON VARCHAR(256) DEFAULT ' ' NOT NULL,
                                    FBATCHNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FAPPROVALBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FAPPROVALBILLID BIGINT DEFAULT 0 NOT NULL,
                                    FCRONTEMPLATEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INOUTCOLLECT_E')
CREATE TABLE T_FPM_INOUTCOLLECT_E (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FFUNDORGID BIGINT DEFAULT 0 NOT NULL,
                                      FINOUTDIRECTION VARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FFUNDPURPOSEID BIGINT DEFAULT 0 NOT NULL,
                                      FFEEPROJECTID BIGINT DEFAULT 0 NOT NULL,
                                      FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL,
                                      FOPUSERNAME BIGINT DEFAULT 0 NOT NULL,
                                      FOPUSERTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                      FEXPECTDATE DATETIME,
                                      FCURRENTPLANDATE DATETIME,
                                      FEXPECTCASHAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                      FCURRENTPLANAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                      FCOREBILLSUMAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                      FCOREBILLREMAINCASHAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                      FCONTRACTNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FCONTRACTNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FPROJECTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_COLLECTRELATEREPORT')
CREATE TABLE T_FPM_COLLECTRELATEREPORT (
                                           FID BIGINT DEFAULT 0 NOT NULL,
                                           FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                           FSEQ INT DEFAULT 0 NOT NULL,
                                           FBATCHNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                           FRELATEPLANREPORT VARCHAR(50) DEFAULT ' ' NOT NULL,
                                           FRELATEPLANREPORTID BIGINT DEFAULT 0 NOT NULL,
                                           FBODYSYSID BIGINT DEFAULT 0 NOT NULL,
                                           FREPORTTYPEID BIGINT DEFAULT 0 NOT NULL,
                                           FREPORTORGID BIGINT DEFAULT 0 NOT NULL,
                                           FREPORTPERIODID BIGINT DEFAULT 0 NOT NULL,
                                           FREFERPLANDATE DATETIME,
                                           FREFERPLANAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_CRONPLANMAINTAIN')
CREATE TABLE T_FPM_CRONPLANMAINTAIN (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                        FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
                                        FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                        FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                        FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                        FAUDITDATE DATETIME,
                                        FMODIFYTIME DATETIME,
                                        FCREATETIME DATETIME,
                                        FNAME VARCHAR(100) DEFAULT ' ' NOT NULL,
                                        FINOUTCYCLE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                        FREPEATCYCLE INT DEFAULT 0 NOT NULL,
                                        FFIRSTEXPECTDATE DATETIME,
                                        FEXPIREDATE DATETIME,
                                        FFUTURETHREEEXPECTDATE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                        FRECENTRECORDEXPECTDATE DATETIME,
                                        FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL,
                                        FOTHERINFO VARCHAR(256) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_CRONPLANMAINTAIN_E')
CREATE TABLE T_FPM_CRONPLANMAINTAIN_E (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FBUSINESSTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FAPPLYORGID BIGINT DEFAULT 0 NOT NULL,
                                          FAPPLYUSERID BIGINT DEFAULT 0 NOT NULL,
                                          FCREATEDATE DATETIME,
                                          FFUNDORGID BIGINT DEFAULT 0 NOT NULL,
                                          FINOUTDIRECTION VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FFUNDPURPOSEID BIGINT DEFAULT 0 NOT NULL,
                                          FFEEPROJECTID BIGINT DEFAULT 0 NOT NULL,
                                          FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL,
                                          FOPUSERNAME BIGINT DEFAULT 0 NOT NULL,
                                          FOPUSERTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                          FEXPECTDATE DATETIME,
                                          FCURRENTPLANDATE DATETIME,
                                          FEXPECTCASHAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FCURRENTPLANAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FCOREBILLSUMAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FCOREBILLREMAINCASHAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FCONTRACTNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FCONTRACTNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FPROJECTID BIGINT DEFAULT 0 NOT NULL,
                                          FREMARK VARCHAR(256) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INOUTCOLLECT_LK')
CREATE TABLE T_FPM_INOUTCOLLECT_LK (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FPKID BIGINT DEFAULT 0 NOT NULL,
                                       FSEQ INT DEFAULT 0 NOT NULL,
                                       FSTABLEID BIGINT DEFAULT 0 NOT NULL,
                                       FSBILLID BIGINT DEFAULT 0 NOT NULL,
                                       FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INOUTCOLLECT_TC')
CREATE TABLE T_FPM_INOUTCOLLECT_TC (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FTBILLID BIGINT DEFAULT 0 NOT NULL,
                                       FTTABLEID BIGINT DEFAULT 0 NOT NULL,
                                       FTID BIGINT DEFAULT 0 NOT NULL,
                                       FSBILLID BIGINT DEFAULT 0 NOT NULL,
                                       FSTABLEID BIGINT DEFAULT 0 NOT NULL,
                                       FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INOUTCOLLECT_WB')
CREATE TABLE T_FPM_INOUTCOLLECT_WB (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                       FSEQ INT DEFAULT 0 NOT NULL,
                                       FRULEVERID BIGINT DEFAULT 0 NOT NULL,
                                       FRULEITEMID BIGINT DEFAULT 0 NOT NULL,
                                       FOPERATE VARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FSTABLEID BIGINT DEFAULT 0 NOT NULL,
                                       FSID BIGINT DEFAULT 0 NOT NULL,
                                       FSBILLID BIGINT DEFAULT 0 NOT NULL,
                                       FWRITEVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_APPROVALDISPOSE')
CREATE TABLE T_FPM_APPROVALDISPOSE (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                       FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                       FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                       FAUDITDATE DATETIME,
                                       FMODIFYTIME DATETIME,
                                       FCREATETIME DATETIME,
                                       FBUSINESSTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FAPPLYORGID BIGINT DEFAULT 0 NOT NULL,
                                       FAPPROVALUSERID BIGINT DEFAULT 0 NOT NULL,
                                       FAPPROVALDATE DATETIME,
                                       FAUDITOPINION VARCHAR(256) DEFAULT ' ' NOT NULL,
                                       FFLOWINCOUNT INT DEFAULT 0 NOT NULL,
                                       FFLOWOUTCOUNT INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_APPROVAL_APPLYINFO')
CREATE TABLE T_FPM_APPROVAL_APPLYINFO (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                          FSEQ INT DEFAULT 0 NOT NULL,
                                          FBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FFUNDORGID BIGINT DEFAULT 0 NOT NULL,
                                          FEXPECTDATE DATETIME,
                                          FFUNDPURPOSEID BIGINT DEFAULT 0 NOT NULL,
                                          FINOUTDIRECTION VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FDATASOURCE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FFEEPROJECTID BIGINT DEFAULT 0 NOT NULL,
                                          FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL,
                                          FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                          FEXPECTCASHAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FCURRENTPLANAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FCURRENTPLANDATE DATETIME,
                                          FOPUSERTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FOPUSERNAME BIGINT DEFAULT 0 NOT NULL,
                                          FPROJECTID BIGINT DEFAULT 0 NOT NULL,
                                          FCONTRACTNO VARCHAR(100) DEFAULT ' ' NOT NULL,
                                          FCONTRACTNAME VARCHAR(100) DEFAULT ' ' NOT NULL,
                                          FREMARK VARCHAR(256) DEFAULT ' ' NOT NULL,
                                          FAPPLYINFOID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_APPROVAL_ENTRY_LK')
CREATE TABLE T_FPM_APPROVAL_ENTRY_LK (
                                         FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                         FPKID BIGINT DEFAULT 0 NOT NULL,
                                         FSEQ INT DEFAULT 0 NOT NULL,
                                         FSTABLEID BIGINT DEFAULT 0 NOT NULL,
                                         FSBILLID BIGINT DEFAULT 0 NOT NULL,
                                         FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_APPROVALDISPOSE_LK')
CREATE TABLE T_FPM_APPROVALDISPOSE_LK (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FPKID BIGINT DEFAULT 0 NOT NULL,
                                          FSEQ INT DEFAULT 0 NOT NULL,
                                          FSTABLEID BIGINT DEFAULT 0 NOT NULL,
                                          FSBILLID BIGINT DEFAULT 0 NOT NULL,
                                          FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_APPROVALDISPOSE_TC')
CREATE TABLE T_FPM_APPROVALDISPOSE_TC (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FTBILLID BIGINT DEFAULT 0 NOT NULL,
                                          FTTABLEID BIGINT DEFAULT 0 NOT NULL,
                                          FTID BIGINT DEFAULT 0 NOT NULL,
                                          FSBILLID BIGINT DEFAULT 0 NOT NULL,
                                          FSTABLEID BIGINT DEFAULT 0 NOT NULL,
                                          FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_APPROVALDISPOSE_WB')
CREATE TABLE T_FPM_APPROVALDISPOSE_WB (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                          FSEQ INT DEFAULT 0 NOT NULL,
                                          FRULEVERID BIGINT DEFAULT 0 NOT NULL,
                                          FRULEITEMID BIGINT DEFAULT 0 NOT NULL,
                                          FOPERATE VARCHAR(30) DEFAULT ' ' NOT NULL,
                                          FSTABLEID BIGINT DEFAULT 0 NOT NULL,
                                          FSID BIGINT DEFAULT 0 NOT NULL,
                                          FSBILLID BIGINT DEFAULT 0 NOT NULL,
                                          FWRITEVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_COLLECTLOG')
CREATE TABLE T_FPM_COLLECTLOG (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FBILLNO VARCHAR(100) DEFAULT ' ' NOT NULL,
                                  FBILLSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
                                  FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                  FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                  FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                  FAUDITDATE DATETIME,
                                  FMODIFYTIME DATETIME,
                                  FCREATETIME DATETIME,
                                  FEXECUTEDETAIL VARCHAR(255) DEFAULT ' ' NOT NULL,
                                  FSOURCEBILL VARCHAR(50) DEFAULT ' ' NOT NULL,
                                  FCOLLECTCASEID BIGINT DEFAULT 0 NOT NULL,
                                  FGATHERCOUNT INT DEFAULT 0 NOT NULL,
                                  FERRORINFO NCLOB,
                                  FERRORINFO_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_COLLECT_EXECRECORD')
CREATE TABLE T_FPM_COLLECT_EXECRECORD (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                          FSEQ INT DEFAULT 0 NOT NULL,
                                          FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
                                          FEXECDETAIL NCLOB,
                                          FEXECDETAIL_TAG NCLOB,
                                          FEXECUTERESULT CHAR(1) DEFAULT ' ' NOT NULL,
                                          FSOURCEBILLEID BIGINT DEFAULT 0 NOT NULL,
                                          FSOURCEBILLNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL
);


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