Blame view

yudao-module-wms/src/test/resources/sql/create_tables.sql 11.8 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,
5f31b32c   YunaiV   feat(wms): 持久化出入库...
131
      "total_price" decimal(24, 6) DEFAULT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
      "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):新增出库管理
148
      "type" int NOT NULL,
d1b20eeb   YunaiV   feat(wms):增加 orde...
149
      "order_time" timestamp NOT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
150
      "status" int NOT NULL DEFAULT '0',
eba504d0   YunaiV   feat(wms):补充 inve...
151
152
153
154
      "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...
155
      "total_quantity" decimal(20, 2) NOT NULL DEFAULT '0',
70a6316c   YunaiV   feat(wms):入库管理,调整...
156
      "total_price" decimal(10, 2) DEFAULT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
157
158
159
160
161
162
163
164
165
166
167
      "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...
168
169
170
      "order_id" bigint NOT NULL,
      "sku_id" bigint NOT NULL,
      "warehouse_id" bigint NOT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
171
      "quantity" decimal(20, 2) NOT NULL DEFAULT '0',
70a6316c   YunaiV   feat(wms):入库管理,调整...
172
      "price" decimal(10, 2) DEFAULT NULL,
5f31b32c   YunaiV   feat(wms): 持久化出入库...
173
      "total_price" decimal(10, 2) DEFAULT NULL,
eba504d0   YunaiV   feat(wms):补充 inve...
174
175
176
177
178
179
180
181
      "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):新增出库管理
182
183
184
185
186
  
  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...
187
      "order_time" timestamp NOT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
188
189
190
191
192
      "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):新增出库管理
193
      "total_quantity" decimal(20, 2) NOT NULL DEFAULT '0',
273d911e   YunaiV   feat(wms):出库管理,调整...
194
      "total_price" decimal(10, 2) DEFAULT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
195
196
197
198
199
200
201
202
203
204
205
      "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):新增出库管理
206
207
208
      "order_id" bigint NOT NULL,
      "sku_id" bigint NOT NULL,
      "warehouse_id" bigint NOT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
209
      "quantity" decimal(20, 2) NOT NULL DEFAULT '0',
273d911e   YunaiV   feat(wms):出库管理,调整...
210
      "price" decimal(10, 2) DEFAULT NULL,
5f31b32c   YunaiV   feat(wms): 持久化出入库...
211
      "total_price" decimal(10, 2) DEFAULT NULL,
93607eb9   YunaiV   feat(wms):新增出库管理
212
213
214
215
216
217
218
219
      "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):减法,去掉批次...
220
221
222
223
  
  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...
224
      "order_time" timestamp NOT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
225
226
227
228
229
      "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):移库管理,调整...
230
      "total_price" decimal(10, 2) DEFAULT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
231
232
233
234
235
236
237
238
239
240
241
      "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):减法,去掉批次...
242
243
244
245
246
      "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):移库管理,调整...
247
      "price" decimal(10, 2) DEFAULT NULL,
5f31b32c   YunaiV   feat(wms): 持久化出入库...
248
      "total_price" decimal(10, 2) DEFAULT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
249
250
251
252
253
254
255
256
257
258
259
260
      "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...
261
      "order_time" timestamp NOT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
262
263
264
265
      "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):优化盘库单的实现
266
267
      "total_price" decimal(10, 2) DEFAULT NULL,
      "actual_price" decimal(10, 2) DEFAULT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
268
269
270
271
272
273
274
275
276
277
278
      "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):减法,去掉批次...
279
280
281
282
283
284
285
      "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):优化盘库单的实现
286
      "price" decimal(10, 2) DEFAULT NULL,
86d760fd   YunaiV   feat(wms):减法,去掉批次...
287
288
289
290
291
292
293
294
      "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 盘库单明细表';