mes-md.sql 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. -- ----------------------------
  2. -- 1、物料产品表
  3. -- ----------------------------
  4. drop table if exists md_item;
  5. create table md_item (
  6. item_id bigint(20) not null auto_increment comment '产品物料ID',
  7. item_code varchar(64) not null comment '产品物料编码',
  8. item_name varchar(255) not null comment '产品物料名称',
  9. specification varchar(500) default null comment '规格型号',
  10. unit_of_measure varchar(64) not null comment '单位编码',
  11. unit_name varchar(64) comment '单位名称'
  12. item_or_product varchar(20) not null comment '产品物料标识',
  13. item_type_id bigint(20) default 0 comment '物料类型ID',
  14. item_type_code varchar(64) default '' comment '物料类型编码',
  15. item_type_name varchar(255) default '' comment '物料类型名称',
  16. enable_flag char(1) default 'Y' not null comment '是否启用',
  17. safe_stock_flag char(1) default 'N' not null comment '是否设置安全库存',
  18. min_stock double(12,4) default 0 comment '最低库存量',
  19. max_stock double(12,4) default 0 comment '最大库存量',
  20. high_value char(1) default 'N' not null comment '高价值物资',
  21. remark varchar(500) default '' comment '备注',
  22. attr1 varchar(64) default null comment '预留字段1',
  23. attr2 varchar(255) default null comment '预留字段2',
  24. attr3 int(11) default 0 comment '预留字段3',
  25. attr4 int(11) default 0 comment '预留字段4',
  26. create_by varchar(64) default '' comment '创建者',
  27. create_time datetime comment '创建时间',
  28. update_by varchar(64) default '' comment '更新者',
  29. update_time datetime comment '更新时间',
  30. primary key (item_id)
  31. ) engine=innodb auto_increment=200 comment = '物料产品表';
  32. -- ----------------------------
  33. -- 2、物料产品分类表
  34. -- ----------------------------
  35. drop table if exists md_item_type;
  36. create table md_item_type (
  37. item_type_id bigint(20) not null auto_increment comment '产品物料类型ID',
  38. item_type_code varchar(64) not null comment '产品物料类型编码',
  39. item_type_name varchar(255) not null comment '产品物料类型名称',
  40. parent_type_id bigint default 0 not null comment '父类型ID',
  41. ancestors varchar(255) not null comment '所有层级父节点',
  42. item_or_product varchar(20) not null comment '产品物料标识',
  43. order_num int(11) default 1 comment '排列顺序',
  44. enable_flag char(1) default 'Y' not null comment '是否启用',
  45. remark varchar(500) default '' comment '备注',
  46. attr1 varchar(64) default null comment '预留字段1',
  47. attr2 varchar(255) default null comment '预留字段2',
  48. attr3 int(11) default 0 comment '预留字段3',
  49. attr4 int(11) default 0 comment '预留字段4',
  50. create_by varchar(64) default '' comment '创建者',
  51. create_time datetime comment '创建时间',
  52. update_by varchar(64) default '' comment '更新者',
  53. update_time datetime comment '更新时间',
  54. primary key (item_type_id)
  55. ) engine=innodb auto_increment=200 comment = '物料产品分类表';
  56. -- ----------------------------
  57. -- 3、产品BOM关系表
  58. -- ----------------------------
  59. drop table if exists md_product_bom;
  60. create table md_product_bom (
  61. bom_id bigint(20) not null auto_increment comment '流水号',
  62. item_id bigint(20) not null comment '物料产品ID',
  63. bom_item_id bigint(20) not null comment 'BOM物料ID',
  64. bom_item_code varchar(64) not null comment 'BOM物料编码',
  65. bom_item_name varchar(255) not null comment 'BOM物料名称',
  66. bom_item_spec varchar(500) comment 'BOM物料规格',
  67. unit_of_measure varchar(64) not null comment 'BOM物料单位',
  68. item_or_product varchar(20) not null comment '产品物料标识',
  69. quantity double(12,4) default 0 not null comment '物料使用比例',
  70. enable_flag char(1) default 'Y' not null comment '是否启用',
  71. remark varchar(500) default '' comment '备注',
  72. attr1 varchar(64) default null comment '预留字段1',
  73. attr2 varchar(255) default null comment '预留字段2',
  74. attr3 int(11) default 0 comment '预留字段3',
  75. attr4 int(11) default 0 comment '预留字段4',
  76. create_by varchar(64) default '' comment '创建者',
  77. create_time datetime comment '创建时间',
  78. update_by varchar(64) default '' comment '更新者',
  79. update_time datetime comment '更新时间',
  80. primary key (bom_id)
  81. ) engine=innodb auto_increment=200 comment = '产品BOM关系表';
  82. -- ----------------------------
  83. -- 4、供应商表
  84. -- ----------------------------
  85. drop table if exists md_vendor;
  86. create table md_vendor (
  87. vendor_id bigint(20) not null auto_increment comment '供应商ID',
  88. vendor_code varchar(64) not null comment '供应商编码',
  89. vendor_name varchar(255) not null comment '供应商名称',
  90. vendor_nick varchar(255) comment '供应商简称',
  91. vendor_en varchar(255) comment '供应商英文名称',
  92. vendor_des varchar(500) comment '供应商简介',
  93. vendor_logo varchar(255) comment '供应商LOGO地址',
  94. vendor_level varchar(64) comment '供应商等级',
  95. vendor_score int(11) comment '供应商评分',
  96. address varchar(500) comment '供应商地址',
  97. website varchar(255) comment '供应商官网地址',
  98. email varchar(255) comment '供应商邮箱地址',
  99. tel varchar(64) comment '供应商电话',
  100. contact1 varchar(64) comment '联系人1',
  101. contact1_tel varchar(64) comment '联系人1-电话',
  102. contact1_email varchar(255) comment '联系人1-邮箱',
  103. contact2 varchar(64) comment '联系人2',
  104. contact2_tel varchar(64) comment '联系人2-电话',
  105. contact2_email varchar(255) comment '联系人2-邮箱',
  106. credit_code varchar(64) comment '统一社会信用代码',
  107. enable_flag char(1) default 'Y' not null comment '是否启用',
  108. remark varchar(500) default '' comment '备注',
  109. attr1 varchar(64) default null comment '预留字段1',
  110. attr2 varchar(255) default null comment '预留字段2',
  111. attr3 int(11) default 0 comment '预留字段3',
  112. attr4 int(11) default 0 comment '预留字段4',
  113. create_by varchar(64) default '' comment '创建者',
  114. create_time datetime comment '创建时间',
  115. update_by varchar(64) default '' comment '更新者',
  116. update_time datetime comment '更新时间',
  117. primary key (vendor_id)
  118. ) engine=innodb auto_increment=200 comment = '供应商表';
  119. -- ----------------------------
  120. -- 5、客户表
  121. -- ----------------------------
  122. drop table if exists md_client;
  123. create table md_client (
  124. client_id bigint(20) not null auto_increment comment '客户ID',
  125. client_code varchar(64) not null comment '客户编码',
  126. client_name varchar(255) not null comment '客户名称',
  127. client_nick varchar(255) comment '客户简称',
  128. client_en varchar(255) comment '客户英文名称',
  129. client_des varchar(500) comment '客户简介',
  130. client_logo varchar(255) comment '客户LOGO地址',
  131. client_type varchar(64) default 'ENTERPRISE' comment '客户类型',
  132. address varchar(500) comment '客户地址',
  133. website varchar(255) comment '客户官网地址',
  134. email varchar(255) comment '客户邮箱地址',
  135. tel varchar(64) comment '客户电话',
  136. contact1 varchar(64) comment '联系人1',
  137. contact1_tel varchar(64) comment '联系人1-电话',
  138. contact1_email varchar(255) comment '联系人1-邮箱',
  139. contact2 varchar(64) comment '联系人2',
  140. contact2_tel varchar(64) comment '联系人2-电话',
  141. contact2_email varchar(255) comment '联系人2-邮箱',
  142. credit_code varchar(64) comment '统一社会信用代码',
  143. enable_flag char(1) default 'Y' not null comment '是否启用',
  144. remark varchar(500) default '' comment '备注',
  145. attr1 varchar(64) default null comment '预留字段1',
  146. attr2 varchar(255) default null comment '预留字段2',
  147. attr3 int(11) default 0 comment '预留字段3',
  148. attr4 int(11) default 0 comment '预留字段4',
  149. create_by varchar(64) default '' comment '创建者',
  150. create_time datetime comment '创建时间',
  151. update_by varchar(64) default '' comment '更新者',
  152. update_time datetime comment '更新时间',
  153. primary key (client_id)
  154. ) engine=innodb auto_increment=200 comment = '客户表';
  155. -- ----------------------------
  156. -- 6、单位表
  157. -- ----------------------------
  158. drop table if exists md_unit_measure;
  159. create table md_unit_measure (
  160. measure_id bigint(20) not null auto_increment comment '单位ID',
  161. measure_code varchar(64) not null comment '单位编码',
  162. measure_name varchar(255) not null comment '单位名称',
  163. primary_flag char(1) default 'Y' not null comment '是否是主单位',
  164. primary_id bigint(20) comment '主单位ID',
  165. change_rate double(12,4) comment '与主单位换算比例',
  166. enable_flag char(1) default 'Y' not null comment '是否启用',
  167. remark varchar(500) default '' comment '备注',
  168. attr1 varchar(64) default null comment '预留字段1',
  169. attr2 varchar(255) default null comment '预留字段2',
  170. attr3 int(11) default 0 comment '预留字段3',
  171. attr4 int(11) default 0 comment '预留字段4',
  172. create_by varchar(64) default '' comment '创建者',
  173. create_time datetime comment '创建时间',
  174. update_by varchar(64) default '' comment '更新者',
  175. update_time datetime comment '更新时间',
  176. primary key (measure_id)
  177. ) engine=innodb auto_increment=200 comment = '单位表';
  178. -- ----------------------------
  179. -- 7、车间表
  180. -- ----------------------------
  181. drop table if exists md_workshop;
  182. create table md_workshop (
  183. workshop_id bigint(20) not null auto_increment comment '车间ID',
  184. workshop_code varchar(64) not null comment '车间编码',
  185. workshop_name varchar(255) not null comment '车间名称',
  186. area double(12,2) comment '面积',
  187. charge varchar(64) comment '负责人',
  188. enable_flag char(1) default 'Y' not null comment '是否启用',
  189. remark varchar(500) default '' comment '备注',
  190. attr1 varchar(64) default null comment '预留字段1',
  191. attr2 varchar(255) default null comment '预留字段2',
  192. attr3 int(11) default 0 comment '预留字段3',
  193. attr4 int(11) default 0 comment '预留字段4',
  194. create_by varchar(64) default '' comment '创建者',
  195. create_time datetime comment '创建时间',
  196. update_by varchar(64) default '' comment '更新者',
  197. update_time datetime comment '更新时间',
  198. primary key (workshop_id)
  199. ) engine=innodb auto_increment=200 comment = '车间表';
  200. -- ----------------------------
  201. -- 8、工作站表
  202. -- ----------------------------
  203. drop table if exists md_workstation;
  204. create table md_workstation (
  205. workstation_id bigint(20) not null auto_increment comment '工作站ID',
  206. workstation_code varchar(64) not null comment '工作站编码',
  207. workstation_name varchar(255) not null comment '工作站名称',
  208. workstation_address varchar(255) comment '工作站地点',
  209. workshop_id bigint(20) comment '所在车间ID',
  210. workshop_code varchar(64) comment '所在车间编码',
  211. workshop_name varchar(255) comment '所在车间名称',
  212. process_id bigint(20) comment '工序ID',
  213. process_code varchar(64) comment '工序编码',
  214. process_name varchar(255) comment '工序名称',
  215. warehouse_id bigint(20) not null comment '线边库ID',
  216. warehouse_code varchar(64) comment '线边库编码',
  217. warehouse_name varchar(255) comment '线边库名称',
  218. location_id bigint(20) not null comment '库区ID',
  219. location_code varchar(64) comment '库区编码',
  220. location_name varchar(255) comment '库区名称',
  221. area_id bigint(20) not null comment '库位ID',
  222. area_code varchar(64) comment '库位编码',
  223. area_name varchar(255) comment '库位名称',
  224. enable_flag char(1) default 'Y' not null comment '是否启用',
  225. remark varchar(500) default '' comment '备注',
  226. attr1 varchar(64) default null comment '预留字段1',
  227. attr2 varchar(255) default null comment '预留字段2',
  228. attr3 int(11) default 0 comment '预留字段3',
  229. attr4 int(11) default 0 comment '预留字段4',
  230. create_by varchar(64) default '' comment '创建者',
  231. create_time datetime comment '创建时间',
  232. update_by varchar(64) default '' comment '更新者',
  233. update_time datetime comment '更新时间',
  234. primary key (workstation_id)
  235. ) engine=innodb auto_increment=200 comment = '工作站表';
  236. -- ----------------------------
  237. -- 9、设备资源表
  238. -- ----------------------------
  239. drop table if exists md_workstation_machine;
  240. create table md_workstation_machine (
  241. record_id bigint(20) not null auto_increment comment '记录ID',
  242. workstation_id bigint(20) not null comment '工作站ID',
  243. machinery_id bigint(20) not null comment '设备ID',
  244. machinery_code varchar(64) comment '设备编码',
  245. machinery_name varchar(255) comment '设备名称',
  246. quantity int(4) default 1 comment '数量',
  247. remark varchar(500) default '' comment '备注',
  248. attr1 varchar(64) default null comment '预留字段1',
  249. attr2 varchar(255) default null comment '预留字段2',
  250. attr3 int(11) default 0 comment '预留字段3',
  251. attr4 int(11) default 0 comment '预留字段4',
  252. create_by varchar(64) default '' comment '创建者',
  253. create_time datetime comment '创建时间',
  254. update_by varchar(64) default '' comment '更新者',
  255. update_time datetime comment '更新时间',
  256. primary key (record_id)
  257. ) engine=innodb auto_increment=200 comment = '设备资源表';
  258. -- ----------------------------
  259. -- 10、人力资源表
  260. -- ----------------------------
  261. drop table if exists md_workstation_worker;
  262. create table md_workstation_worker (
  263. record_id bigint(20) not null auto_increment comment '记录ID',
  264. workstation_id bigint(20) not null comment '工作站ID',
  265. post_id bigint(20) not null comment '岗位ID',
  266. post_code varchar(64) comment '岗位编码',
  267. post_name varchar(255) comment '岗位名称',
  268. quantity int(4) default 1 not null comment '数量',
  269. remark varchar(500) default '' comment '备注',
  270. attr1 varchar(64) default null comment '预留字段1',
  271. attr2 varchar(255) default null comment '预留字段2',
  272. attr3 int(11) default 0 comment '预留字段3',
  273. attr4 int(11) default 0 comment '预留字段4',
  274. create_by varchar(64) default '' comment '创建者',
  275. create_time datetime comment '创建时间',
  276. update_by varchar(64) default '' comment '更新者',
  277. update_time datetime comment '更新时间',
  278. primary key (record_id)
  279. ) engine=innodb auto_increment=200 comment = '人力资源表';
  280. -- ----------------------------
  281. -- 11、工装夹具资源表
  282. -- ----------------------------
  283. drop table if exists md_workstation_tool;
  284. create table md_workstation_tool (
  285. record_id bigint(20) not null auto_increment comment '记录ID',
  286. workstation_id bigint(20) not null comment '工作站ID',
  287. tool_type_id bigint(20) not null comment '工装夹具类型ID',
  288. tool_type_code varchar(64) comment '类型编码',
  289. tool_type_name varchar(255) comment '类型名称',
  290. quantity int(4) default 1 not null comment '数量',
  291. remark varchar(500) default '' comment '备注',
  292. attr1 varchar(64) default null comment '预留字段1',
  293. attr2 varchar(255) default null comment '预留字段2',
  294. attr3 int(11) default 0 comment '预留字段3',
  295. attr4 int(11) default 0 comment '预留字段4',
  296. create_by varchar(64) default '' comment '创建者',
  297. create_time datetime comment '创建时间',
  298. update_by varchar(64) default '' comment '更新者',
  299. update_time datetime comment '更新时间',
  300. primary key (record_id)
  301. ) engine=innodb auto_increment=200 comment = '工装夹具资源表';
  302. -- ----------------------------
  303. -- 12、产品SOP表
  304. -- ----------------------------
  305. drop table if exists md_product_sop;
  306. create table md_product_sop (
  307. sop_id bigint(20) not null auto_increment comment '记录ID',
  308. item_id bigint(20) not null comment '物料产品ID',
  309. order_num int(4) comment '排列顺序',
  310. process_id bigint(20) comment '对应的工序',
  311. process_code varchar(64) comment '工序编号',
  312. process_name varchar(255) comment '工序名称',
  313. sop_title varchar(255) comment '标题',
  314. sop_description varchar(500) comment '详细描述',
  315. sop_url varchar(255) comment '图片地址',
  316. remark varchar(500) default '' comment '备注',
  317. attr1 varchar(64) default null comment '预留字段1',
  318. attr2 varchar(255) default null comment '预留字段2',
  319. attr3 int(11) default 0 comment '预留字段3',
  320. attr4 int(11) default 0 comment '预留字段4',
  321. create_by varchar(64) default '' comment '创建者',
  322. create_time datetime comment '创建时间',
  323. update_by varchar(64) default '' comment '更新者',
  324. update_time datetime comment '更新时间',
  325. primary key (sop_id)
  326. ) engine=innodb auto_increment=200 comment = '产品SOP表';
  327. -- ----------------------------
  328. -- 12、产品SIP表
  329. -- ----------------------------
  330. drop table if exists md_product_sip;
  331. create table md_product_sip (
  332. sip_id bigint(20) not null auto_increment comment '记录ID',
  333. item_id bigint(20) not null comment '物料产品ID',
  334. order_num int(4) comment '排列顺序',
  335. process_id bigint(20) comment '对应的工序',
  336. process_code varchar(64) comment '工序编号',
  337. process_name varchar(255) comment '工序名称',
  338. sip_title varchar(255) comment '标题',
  339. sip_description varchar(500) comment '详细描述',
  340. sip_url varchar(255) comment '图片地址',
  341. remark varchar(500) default '' comment '备注',
  342. attr1 varchar(64) default null comment '预留字段1',
  343. attr2 varchar(255) default null comment '预留字段2',
  344. attr3 int(11) default 0 comment '预留字段3',
  345. attr4 int(11) default 0 comment '预留字段4',
  346. create_by varchar(64) default '' comment '创建者',
  347. create_time datetime comment '创建时间',
  348. update_by varchar(64) default '' comment '更新者',
  349. update_time datetime comment '更新时间',
  350. primary key (sip_id)
  351. ) engine=innodb auto_increment=200 comment = '产品SIP表';