IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_flowworkstatus]') AND type = 'U')
CREATE TABLE [dbo].[mps_flowworkstatus]
(
    [ws_id] int NOT NULL IDENTITY(1, 1),
    [ws_swrkid] int NULL DEFAULT((0)),
    [ws_twrkid] int NULL DEFAULT((0)),
    [ws_tshape] varchar(30) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_caption] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_condition] nvarchar(4000) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_status] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_pickvalues] nvarchar(1000) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_status_f] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_status_ff] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_status_r] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_key] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_key_f] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_key_ff] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_key_r] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_sql] nvarchar(4000) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_prevwrkids] varchar(1000) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_fjbstatus] nvarchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_bizrelation] nvarchar(4000) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_accsource] int NULL DEFAULT((0)),
    [ws_acctype] varchar(10) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_accdate] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_accobjtype] varchar(10) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_accobj] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_accfid] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_accmethod] int NULL DEFAULT((0)),
    [ws_accvalue] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_accsuspend] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_accsql] nvarchar(1000) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_tosubflow] int NULL DEFAULT((1)),
    [ws_whsource] int NULL,
    [ws_whprdtag] int NULL,
    [ws_whprd] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whunit] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whbatch] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whbarn1] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whbarn2] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whmethod] int NULL,
    [ws_whvalue] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whprev] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whprice] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whlocation] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whnote] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whsql] nvarchar(1000) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_whexpire] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
    [ws_exec_end_msgid] int NULL DEFAULT((0)),
    [ws_exec_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_audit_end_msgid] int NULL DEFAULT((0)),
    [ws_audit_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_coop_end_msgid] int NULL DEFAULT((0)),
    [ws_coop_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_view_end_msgid] int NULL DEFAULT((0)),
    [ws_view_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_log_end_msgid] int NULL DEFAULT((0)),
    [ws_log_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_cst1_tag] int NULL DEFAULT((0)),
    [ws_cst1_datasource] int NULL DEFAULT((0)),
    [ws_cst1_source] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_cst1_end_msgid] int NULL DEFAULT((0)),
    [ws_cst1_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_cst2_tag] int NULL DEFAULT((0)),
    [ws_cst2_datasource] int NULL DEFAULT((0)),
    [ws_cst2_source] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_cst2_end_msgid] int NULL DEFAULT((0)),
    [ws_cst2_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_emp1_datasource] int NULL DEFAULT((0)),
    [ws_emp1_source] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_emp1_end_msgid] int NULL DEFAULT((0)),
    [ws_emp1_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_emp2_datasource] int NULL DEFAULT((0)),
    [ws_emp2_source] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_emp2_end_msgid] int NULL DEFAULT((0)),
    [ws_emp2_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_emp3_datasource] int NULL DEFAULT((0)),
    [ws_emp3_source] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_emp3_end_msgid] int NULL DEFAULT((0)),
    [ws_emp3_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_other_datasource] int NULL DEFAULT((0)),
    [ws_other_source] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [ws_other_end_msgid] int NULL DEFAULT((0)),
    [ws_other_end_msg] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    CONSTRAINT [PK_MPS_FLOWWORKSTATUS] PRIMARY KEY ([ws_id] ASC)
)


IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID('[dbo].[mps_flowworkstatus]') AND name = 'mps_flowworkstatus_index1')
CREATE NONCLUSTERED INDEX [mps_flowworkstatus_index1] ON [dbo].[mps_flowworkstatus]([ws_twrkid] ASC)