

CREATE TABLE SCHEDULE_CONFIG(
   TASK                VARCHAR2(30) NOT NULL,
   ENABLE               VARCHAR2(1),
   SCHEDULE_TYPE        VARCHAR2(10),
   SCHEDULE_WEEK        VARCHAR2(15),
   SCHEDULE_TIME        VARCHAR2(50),
   SCHEDULE_PERIOD      VARCHAR2(10),
   SCHEDULE_RANGE       VARCHAR2(15),
    CONSTRAINT SCHEDULE_CONFIG_PK1 PRIMARY KEY (TASK)
);


CREATE TABLE TASK_CONFIG(
   CATEGORY_TYPE        VARCHAR2(5) NOT NULL,
   PROCESS_TYPE         VARCHAR2(10) NOT NULL,
   TASK                 VARCHAR2(15) NOT NULL,
   SRC_PATH             VARCHAR2(200),
   TARGET_PATH          VARCHAR2(200),
   FILE_FORMAT          VARCHAR2(20),
   VERSION              VARCHAR2(5),
   ENCODING             VARCHAR2(15),
   TRANS_CHINESE_DATE   VARCHAR2(1),
   CONSTRAINT TASK_CONFIG_PK1 PRIMARY KEY (CATEGORY_TYPE, PROCESS_TYPE, TASK)
);


CREATE TABLE TO_CONFIG(
   PARTY_ID             VARCHAR2(10) NOT NULL,
   PARTY_DESCRIPTION    VARCHAR2(200),
   ROUTING_ID           VARCHAR2(39),
   ROUTING_DESCRIPTION  VARCHAR2(200),
   FROM_PARTY_ID        VARCHAR2(10),
   CONSTRAINT TO_CONFIG_PK1 PRIMARY KEY (FROM_PARTY_ID, PARTY_ID)
);


CREATE TABLE TURNKEY_MESSAGE_LOG (
  SEQNO VARCHAR2(8) NOT NULL,
  SUBSEQNO VARCHAR2(5) NOT NULL,
  UUID VARCHAR2(40) DEFAULT NULL,
  MESSAGE_TYPE VARCHAR2(10) DEFAULT NULL,
  CATEGORY_TYPE VARCHAR2(5) DEFAULT NULL,
  PROCESS_TYPE VARCHAR2(10) DEFAULT NULL,
  FROM_PARTY_ID VARCHAR2(10) DEFAULT NULL,
  TO_PARTY_ID VARCHAR2(10) DEFAULT NULL,
  MESSAGE_DTS VARCHAR2(17) DEFAULT NULL,
  CHARACTER_COUNT VARCHAR2(10) DEFAULT NULL,
  STATUS VARCHAR2(5) DEFAULT NULL,
  IN_OUT_BOUND VARCHAR2(1) DEFAULT NULL,
  FROM_ROUTING_ID VARCHAR2(39) DEFAULT NULL,
  TO_ROUTING_ID VARCHAR2(39) DEFAULT NULL,
  INVOICE_IDENTIFIER VARCHAR2(30) DEFAULT NULL,
  CONSTRAINT TURNKEY_MESSAGE_LOG_PK1 PRIMARY KEY (SEQNO, SUBSEQNO)
);

CREATE INDEX "TURNKEY_MESSAGE_LOG_INDEX1"
  ON TURNKEY_MESSAGE_LOG
  (MESSAGE_DTS);

CREATE INDEX "TURNKEY_MESSAGE_LOG_INDEX2"
  ON TURNKEY_MESSAGE_LOG
  (UUID);

CREATE TABLE TURNKEY_MESSAGE_LOG_DETAIL(
   SEQNO                VARCHAR2(8) NOT NULL,
   SUBSEQNO             VARCHAR2(5) NOT NULL,
   PROCESS_DTS          VARCHAR2(17),
   TASK                 VARCHAR2(30) NOT NULL,
   STATUS               VARCHAR2(5),
   FILENAME             VARCHAR2(300),
   UUID                 VARCHAR2(40),
   CONSTRAINT TURNKEY_MESSAGE_LOG_DETAIL_PK1 PRIMARY KEY (SEQNO, SUBSEQNO, TASK)
);

CREATE INDEX "TK_MESSAGE_LOG_DETAIL_INDEX1"
  ON TURNKEY_MESSAGE_LOG_DETAIL
  (FILENAME);

CREATE TABLE TURNKEY_SEQUENCE(
   SEQUENCE VARCHAR2(8) NOT NULL,
   CONSTRAINT TURNKEY_SEQUENCE_PK1 PRIMARY KEY (SEQUENCE)
);




CREATE TABLE TURNKEY_SYSEVENT_LOG(
   EVENTDTS             VARCHAR2(17) NOT NULL,
   PARTY_ID             VARCHAR2(10),
   SEQNO                VARCHAR2(8),
   SUBSEQNO             VARCHAR2(5),
   ERRORCODE            VARCHAR2(4),
   UUID                 VARCHAR2(40),
   INFORMATION1         VARCHAR2(100),
   INFORMATION2         VARCHAR2(100),
   INFORMATION3         VARCHAR2(100),
   MESSAGE1             VARCHAR2(100),
   MESSAGE2             VARCHAR2(100),
   MESSAGE3             VARCHAR2(100),
   MESSAGE4             VARCHAR2(100),
   MESSAGE5             VARCHAR2(100),
   MESSAGE6             VARCHAR2(100),
   CONSTRAINT TURNKEY_SYSEVENT_LOG_PK1 PRIMARY KEY (EVENTDTS)
);

CREATE INDEX "TURNKEY_SYSEVENT_LOG_INDEX1"
  ON TURNKEY_SYSEVENT_LOG
  (SEQNO, SUBSEQNO);

CREATE INDEX "TURNKEY_SYSEVENT_LOG_INDEX2"
  ON TURNKEY_SYSEVENT_LOG
  (UUID);

 CREATE TABLE OUTGOINGINVOICE (
  INVOICEID VARCHAR(64) NOT NULL,
  INVOICENUMBER VARCHAR(64),
  CONTENTTYPE VARCHAR(64),
  SELLER VARCHAR(128),
  BUYER VARCHAR(128),
  STATUS VARCHAR(128),
  INSERTTIME TIMESTAMP ,
  COMPLETETIME TIMESTAMP ,
  LOCKTIME TIMESTAMP ,
  SENTTIME TIMESTAMP,
  ACKTIME TIMESTAMP ,
  CONVERSATIONID VARCHAR(64),
  FEEDBACKMESSAGE VARCHAR(370),
  XMLFILENAME VARCHAR(512),
  CENTERSTATUS VARCHAR(128),
  CENTERSTATUSDESC VARCHAR(256),
   CONSTRAINT OUTGOINGINVOICE_PK1 PRIMARY KEY (INVOICEID)
);

CREATE INDEX "OUTGOINGINVOICE_INDEX1" ON OUTGOINGINVOICE (INVOICENUMBER);
CREATE INDEX "OUTGOINGINVOICE_INDEX2" ON OUTGOINGINVOICE (CONTENTTYPE);
CREATE INDEX "OUTGOINGINVOICE_INDEX3" ON OUTGOINGINVOICE (STATUS);
CREATE INDEX "OUTGOINGINVOICE_INDEX4" ON OUTGOINGINVOICE (INSERTTIME);
CREATE INDEX "OUTGOINGINVOICE_INDEX5" ON OUTGOINGINVOICE (COMPLETETIME);
CREATE INDEX "OUTGOINGINVOICE_INDEX6" ON OUTGOINGINVOICE (LOCKTIME);
CREATE INDEX "OUTGOINGINVOICE_INDEX7" ON OUTGOINGINVOICE (SENTTIME);
CREATE INDEX "OUTGOINGINVOICE_INDEX8" ON OUTGOINGINVOICE (CONVERSATIONID);
CREATE INDEX "OUTGOINGINVOICE_INDEX9" ON OUTGOINGINVOICE (CENTERSTATUS);

CREATE TABLE INCOMINGINVOICE(
   INVOICEID          VARCHAR(64) NOT NULL,
   INVOICENUMBER      VARCHAR(64),
   CONTENTTYPE        VARCHAR(64), 
   SELLER             VARCHAR(128),
   BUYER              VARCHAR(128),
   STATUS             VARCHAR(128),
   INSERTTIME         TIMESTAMP,
   COMPLETETIME       TIMESTAMP,
   LOCKTIME           TIMESTAMP,
   CONVERSATIONID     VARCHAR(64),
   EBXMLMSGFILEID     VARCHAR(64),
   CONSTRAINT INCOMINGINVOICE_PK1 PRIMARY KEY (INVOICEID)   
);

CREATE INDEX "INCOMINGINVOICE_INDEX1" ON INCOMINGINVOICE (INVOICENUMBER);
CREATE INDEX "INCOMINGINVOICE_INDEX2" ON INCOMINGINVOICE (CONTENTTYPE);
CREATE INDEX "INCOMINGINVOICE_INDEX3" ON INCOMINGINVOICE (STATUS);
CREATE INDEX "INCOMINGINVOICE_INDEX4" ON INCOMINGINVOICE (INSERTTIME);
CREATE INDEX "INCOMINGINVOICE_INDEX5" ON INCOMINGINVOICE (COMPLETETIME);
CREATE INDEX "INCOMINGINVOICE_INDEX6" ON INCOMINGINVOICE (LOCKTIME);
CREATE INDEX "INCOMINGINVOICE_INDEX7" ON INCOMINGINVOICE (CONVERSATIONID);

CREATE TABLE ARCHIVEDFILE(
   FILEID                    VARCHAR(64) NOT NULL,
   FILEPATH                  VARCHAR(255),
   FILETYPE                  VARCHAR(64) NOT NULL,
   MIMETYPE                  VARCHAR(64),
   ATTACHLENGTH              INTEGER,
   CONSTRAINT ARCHIVEDFILE_PK1 PRIMARY KEY (FILEID, FILETYPE)   
);

CREATE INDEX "ARCHIVEDFILE_INDEX1" ON ARCHIVEDFILE (FILETYPE);
