/**Begin D:\PDM_UPGRADE\PDM1\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INSPECTION_LOG')
CREATE TABLE T_FPM_INSPECTION_LOG (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                      FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                      FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FCREATETIME DATETIME,
                                      FMODIFYTIME DATETIME,
                                      FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                      FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                      FENABLERID BIGINT DEFAULT 0 NOT NULL,
                                      FENABLEDATE DATETIME,
                                      FDISABLEDATE DATETIME,
                                      FBODYSYSID BIGINT DEFAULT 0 NOT NULL,
                                      FINSPECTIONTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FINSPECTIONSCOPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FEXECDATE DATETIME,
                                      FFINISHDATE DATETIME,
                                      FEXECSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FEXECRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FREPAIRRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FINSPECTIONCONFIGID BIGINT DEFAULT 0 NOT NULL,
                                      FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                      FAUDITDATE DATETIME,
                                      FSTARTDATE DATETIME,
                                      FENDDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INSPECT_LOG_DETAIL')
CREATE TABLE T_FPM_INSPECT_LOG_DETAIL (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                          FSEQ INT DEFAULT 0 NOT NULL,
                                          FBIZOBJ NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FINSPECTTARGET NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FINSPECTRANGE NVARCHAR(1024) DEFAULT ' ' NOT NULL,
                                          FINSPECTRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FREPAIRMETHOD NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FREPAIRRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FERRORBIZINFO NVARCHAR(1024) DEFAULT ' ' NOT NULL,
                                          FERROREXECRECORD NVARCHAR(1024) DEFAULT ' ' NOT NULL,
                                          FMATCHRULE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INSPECT_LOG_RECORD')
CREATE TABLE T_FPM_INSPECT_LOG_RECORD (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                          FSEQ INT DEFAULT 0 NOT NULL,
                                          FCREATEDATE DATETIME,
                                          FEXECRECORDID BIGINT DEFAULT 0 NOT NULL,
                                          FREPAIRRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INSPECT_LOG_CONS')
CREATE TABLE T_FPM_INSPECT_LOG_CONS (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FPERIODID BIGINT DEFAULT 0 NOT NULL,
                                        FORGID BIGINT DEFAULT 0 NOT NULL,
                                        FREPORTPLANID BIGINT DEFAULT 0 NOT NULL,
                                        FREPORTPLANNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                        FERRORDIM NVARCHAR(1024) DEFAULT ' ' NOT NULL,
                                        FERRORINFO NVARCHAR(1024) DEFAULT ' ' NOT NULL,
                                        FREPAIRRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_LOG_CHAINERROR')
CREATE TABLE T_FPM_LOG_CHAINERROR (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                      FSEQ INT DEFAULT 0 NOT NULL,
                                      FEXECRECORDNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FRESULTENTRYID BIGINT DEFAULT 0 NOT NULL,
                                      FEXECRECORDID BIGINT DEFAULT 0 NOT NULL,
                                      FERRORINFO NVARCHAR(1024) DEFAULT ' ' NOT NULL,
                                      FREPAIRRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_LOG_BIZBILLERROR')
CREATE TABLE T_FPM_LOG_BIZBILLERROR (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FBIZBILLNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                        FRESUTLENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FBIZBILLID BIGINT DEFAULT 0 NOT NULL,
                                        FERRORINFO NVARCHAR(1024) DEFAULT ' ' NOT NULL,
                                        FREPAIRRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INSPECTLOG_PERIOD')
CREATE TABLE T_FPM_INSPECTLOG_PERIOD (
                                         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_FPM_INSPECTLOG_ORG')
CREATE TABLE T_FPM_INSPECTLOG_ORG (
                                      FPKID BIGINT DEFAULT 0 NOT NULL,
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);



/**End D:\PDM_UPGRADE\PDM1\FPM_table.sql **/
