Blame view

yudao-module-wms/src/test/resources/sql/create_tables.sql 11.6 KB
9ff3593f   YunaiV   feat(wms):增加 code...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  CREATE TABLE IF NOT EXISTS "wms_warehouse" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "code" varchar(20) NOT NULL,
      "name" varchar(50) NOT NULL,
      "remark" varchar(255) DEFAULT NULL,
      "sort" int DEFAULT '0',
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 仓库表';
  
  CREATE TABLE IF NOT EXISTS "wms_merchant" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "code" varchar(20) DEFAULT NULL,
      "name" varchar(50) NOT NULL,
      "type" int NOT NULL,
      "level" varchar(20) DEFAULT NULL,
      "bank_name" varchar(50) DEFAULT NULL,
      "bank_account" varchar(50) DEFAULT NULL,
      "address" varchar(255) DEFAULT NULL,
      "mobile" varchar(20) DEFAULT NULL,
      "telephone" varchar(20) DEFAULT NULL,
      "contact" varchar(20) DEFAULT NULL,
      "email" varchar(64) DEFAULT NULL,
      "remark" varchar(255) DEFAULT NULL,
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 往来企业表';
  
  CREATE TABLE IF NOT EXISTS "wms_item_brand" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "code" varchar(20) NOT NULL,
      "name" varchar(60) NOT NULL,
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 商品品牌表';
  
  CREATE TABLE IF NOT EXISTS "wms_item_category" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "parent_id" bigint NOT NULL DEFAULT '0',
      "code" varchar(20) NOT NULL,
      "name" varchar(60) NOT NULL,
      "sort" int DEFAULT '0',
      "status" tinyint NOT NULL DEFAULT '0',
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 商品分类表';
  
144963d0   YunaiV   feat(wms):优化 inve...
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  CREATE TABLE IF NOT EXISTS "wms_item" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "code" varchar(20) NOT NULL,
      "name" varchar(60) NOT NULL,
      "unit" varchar(20) DEFAULT NULL,
      "category_id" bigint NOT NULL,
      "brand_id" bigint DEFAULT NULL,
      "remark" varchar(255) DEFAULT NULL,
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 商品表';
  
  CREATE TABLE IF NOT EXISTS "wms_item_sku" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "name" varchar(255) NOT NULL,
      "item_id" bigint NOT NULL,
      "bar_code" varchar(64) DEFAULT NULL,
      "code" varchar(64) DEFAULT NULL,
      "length" decimal(24, 6) DEFAULT NULL,
      "width" decimal(24, 6) DEFAULT NULL,
      "height" decimal(24, 6) DEFAULT NULL,
      "gross_weight" decimal(24, 6) DEFAULT NULL,
      "net_weight" decimal(24, 6) DEFAULT NULL,
      "cost_price" decimal(24, 6) DEFAULT NULL,
      "selling_price" decimal(24, 6) DEFAULT NULL,
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 商品 SKU 表';
  
  CREATE TABLE IF NOT EXISTS "wms_inventory" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "sku_id" bigint NOT NULL,
      "warehouse_id" bigint NOT NULL,
144963d0   YunaiV   feat(wms):优化 inve...
111
112
113
114
115
116
117
118
      "quantity" decimal(24, 6) NOT NULL DEFAULT '0',
      "remark" varchar(255) DEFAULT NULL,
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
eba504d0   YunaiV   feat(wms):补充 inve...
119
      PRIMARY KEY ("id"),
fe38e4fd   YunaiV   feat(wms):减法,去掉 a...
120
      CONSTRAINT "uk_wms_inventory_sku_warehouse" UNIQUE ("sku_id", "warehouse_id", "tenant_id", "deleted")
144963d0   YunaiV   feat(wms):优化 inve...
121
  ) COMMENT 'WMS 库存表';
28f62af7   YunaiV   feat(wms):优化 inve...
122
  
eba504d0   YunaiV   feat(wms):补充 inve...
123
124
125
  CREATE TABLE IF NOT EXISTS "wms_inventory_history" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "warehouse_id" bigint NOT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
126
127
128
129
      "sku_id" bigint NOT NULL,
      "quantity" decimal(24, 6) NOT NULL DEFAULT '0',
      "before_quantity" decimal(24, 6) DEFAULT NULL,
      "after_quantity" decimal(24, 6) DEFAULT NULL,
70a6316c   YunaiV   feat(wms):入库管理,调整...
130
      "price" decimal(24, 6) DEFAULT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
      "remark" varchar(255) DEFAULT NULL,
      "order_id" bigint DEFAULT NULL,
      "order_no" varchar(64) DEFAULT NULL,
      "order_type" tinyint DEFAULT NULL,
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 库存流水表';
  
  CREATE TABLE IF NOT EXISTS "wms_receipt_order" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "no" varchar(64) NOT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
147
      "type" int NOT NULL,
d1b20eeb   YunaiV   feat(wms):增加 orde...
148
      "order_time" timestamp NOT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
149
      "status" int NOT NULL DEFAULT '0',
eba504d0   YunaiV   feat(wms):补充 inve...
150
151
152
153
      "biz_order_no" varchar(64) DEFAULT NULL,
      "merchant_id" bigint DEFAULT NULL,
      "remark" varchar(255) DEFAULT NULL,
      "warehouse_id" bigint NOT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
154
      "total_quantity" decimal(20, 2) NOT NULL DEFAULT '0',
70a6316c   YunaiV   feat(wms):入库管理,调整...
155
      "total_price" decimal(10, 2) DEFAULT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
156
157
158
159
160
161
162
163
164
165
166
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 入库单表';
  
  CREATE TABLE IF NOT EXISTS "wms_receipt_order_detail" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
eba504d0   YunaiV   feat(wms):补充 inve...
167
168
169
      "order_id" bigint NOT NULL,
      "sku_id" bigint NOT NULL,
      "warehouse_id" bigint NOT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
170
      "quantity" decimal(20, 2) NOT NULL DEFAULT '0',
70a6316c   YunaiV   feat(wms):入库管理,调整...
171
      "price" decimal(10, 2) DEFAULT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
172
173
174
175
176
177
178
179
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 入库单明细表';
93607eb9   YunaiV   feat(wms):新增出库管理
180
181
182
183
184
  
  CREATE TABLE IF NOT EXISTS "wms_shipment_order" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "no" varchar(64) NOT NULL,
      "type" int NOT NULL,
d1b20eeb   YunaiV   feat(wms):增加 orde...
185
      "order_time" timestamp NOT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
186
187
188
189
190
      "status" int NOT NULL DEFAULT '0',
      "biz_order_no" varchar(64) DEFAULT NULL,
      "merchant_id" bigint DEFAULT NULL,
      "remark" varchar(255) DEFAULT NULL,
      "warehouse_id" bigint NOT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
191
      "total_quantity" decimal(20, 2) NOT NULL DEFAULT '0',
273d911e   YunaiV   feat(wms):出库管理,调整...
192
      "total_price" decimal(10, 2) DEFAULT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
193
194
195
196
197
198
199
200
201
202
203
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 出库单表';
  
  CREATE TABLE IF NOT EXISTS "wms_shipment_order_detail" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
93607eb9   YunaiV   feat(wms):新增出库管理
204
205
206
      "order_id" bigint NOT NULL,
      "sku_id" bigint NOT NULL,
      "warehouse_id" bigint NOT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
207
      "quantity" decimal(20, 2) NOT NULL DEFAULT '0',
273d911e   YunaiV   feat(wms):出库管理,调整...
208
      "price" decimal(10, 2) DEFAULT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
209
210
211
212
213
214
215
216
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 出库单明细表';
86d760fd   YunaiV   feat(wms):减法,去掉批次...
217
218
219
220
  
  CREATE TABLE IF NOT EXISTS "wms_movement_order" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "no" varchar(64) NOT NULL,
d1b20eeb   YunaiV   feat(wms):增加 orde...
221
      "order_time" timestamp NOT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
222
223
224
225
226
      "status" int NOT NULL DEFAULT '0',
      "remark" varchar(255) DEFAULT NULL,
      "source_warehouse_id" bigint NOT NULL,
      "target_warehouse_id" bigint NOT NULL,
      "total_quantity" decimal(20, 2) NOT NULL DEFAULT '0',
65a1337d   YunaiV   feat(wms):移库管理,调整...
227
      "total_price" decimal(10, 2) DEFAULT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
228
229
230
231
232
233
234
235
236
237
238
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 移库单表';
  
  CREATE TABLE IF NOT EXISTS "wms_movement_order_detail" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
239
240
241
242
243
      "order_id" bigint NOT NULL,
      "sku_id" bigint NOT NULL,
      "source_warehouse_id" bigint NOT NULL,
      "target_warehouse_id" bigint NOT NULL,
      "quantity" decimal(20, 2) NOT NULL DEFAULT '0',
65a1337d   YunaiV   feat(wms):移库管理,调整...
244
      "price" decimal(10, 2) DEFAULT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
245
246
247
248
249
250
251
252
253
254
255
256
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 移库单明细表';
  
  CREATE TABLE IF NOT EXISTS "wms_check_order" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
      "no" varchar(64) NOT NULL,
d1b20eeb   YunaiV   feat(wms):增加 orde...
257
      "order_time" timestamp NOT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
258
259
260
261
      "status" int NOT NULL DEFAULT '0',
      "remark" varchar(255) DEFAULT NULL,
      "warehouse_id" bigint NOT NULL,
      "total_quantity" decimal(20, 2) NOT NULL DEFAULT '0',
a9464080   YunaiV   feat(wms):优化盘库单的实现
262
263
      "total_price" decimal(10, 2) DEFAULT NULL,
      "actual_price" decimal(10, 2) DEFAULT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
264
265
266
267
268
269
270
271
272
273
274
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 盘库单表';
  
  CREATE TABLE IF NOT EXISTS "wms_check_order_detail" (
      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
275
276
277
278
279
280
281
      "order_id" bigint NOT NULL,
      "sku_id" bigint NOT NULL,
      "warehouse_id" bigint NOT NULL,
      "inventory_id" bigint DEFAULT NULL,
      "receipt_time" timestamp DEFAULT NULL,
      "quantity" decimal(20, 2) NOT NULL DEFAULT '0',
      "check_quantity" decimal(20, 2) NOT NULL DEFAULT '0',
a9464080   YunaiV   feat(wms):优化盘库单的实现
282
      "price" decimal(10, 2) DEFAULT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
283
284
285
286
287
288
289
290
      "creator" varchar(64) DEFAULT '',
      "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "updater" varchar(64) DEFAULT '',
      "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      "deleted" bit NOT NULL DEFAULT FALSE,
      "tenant_id" bigint NOT NULL DEFAULT '0',
      PRIMARY KEY ("id")
  ) COMMENT 'WMS 盘库单明细表';