You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
6.4 KiB

  1. /*
  2. SQL Server
  3. */
  4. if object_id('dbo.lc_production_order', 'U') is null
  5. begin
  6. create table dbo.lc_production_order (
  7. id bigint identity(1,1) primary key,
  8. order_type nvarchar(30) not null,
  9. task_no nvarchar(64) null,
  10. task_type nvarchar(32) null,
  11. source_project_no nvarchar(64) null,
  12. project_no nvarchar(64) null,
  13. model_no nvarchar(64) null,
  14. color nvarchar(64) null,
  15. floor_count int null,
  16. special_requirement nvarchar(1000) null,
  17. task_qty decimal(18,2) null,
  18. report_qty decimal(18,2) not null default(0),
  19. plan_delivery_date date null,
  20. plan_finish_date date null,
  21. status nvarchar(20) not null default('已排产'),
  22. finish_date date null,
  23. create_time datetime not null default(getdate()),
  24. create_by bigint null,
  25. update_time datetime not null default(getdate()),
  26. update_by bigint null,
  27. is_deleted bit not null default(0)
  28. );
  29. end;
  30. go
  31. if object_id('dbo.lc_production_order_node', 'U') is null
  32. begin
  33. create table dbo.lc_production_order_node (
  34. id bigint identity(1,1) primary key,
  35. order_id bigint not null,
  36. node_code nvarchar(50) not null,
  37. node_name nvarchar(100) not null,
  38. sort_no int not null,
  39. status nvarchar(20) not null default('未开始'),
  40. last_report_time datetime null,
  41. last_report_user_id bigint null,
  42. last_report_remark nvarchar(500) null,
  43. create_time datetime not null default(getdate()),
  44. update_time datetime not null default(getdate())
  45. );
  46. end;
  47. go
  48. if object_id('dbo.lc_production_node_role', 'U') is null
  49. begin
  50. create table dbo.lc_production_node_role (
  51. id bigint identity(1,1) primary key,
  52. order_type nvarchar(30) not null,
  53. node_code nvarchar(50) not null,
  54. node_name nvarchar(100) not null,
  55. role_id bigint not null,
  56. role_name nvarchar(100) null,
  57. enabled bit not null default(1),
  58. create_time datetime not null default(getdate()),
  59. create_by bigint null
  60. );
  61. end;
  62. go
  63. if object_id('dbo.lc_production_node_report_log', 'U') is null
  64. begin
  65. create table dbo.lc_production_node_report_log (
  66. id bigint identity(1,1) primary key,
  67. order_id bigint not null,
  68. order_type nvarchar(30) not null,
  69. node_code nvarchar(50) not null,
  70. node_name nvarchar(100) not null,
  71. report_qty decimal(18,2) null,
  72. remark nvarchar(500) null,
  73. report_user_id bigint null,
  74. report_user_name nvarchar(100) null,
  75. report_time datetime not null default(getdate())
  76. );
  77. end;
  78. go
  79. if object_id('dbo.lc_production_node_assignee', 'U') is null
  80. begin
  81. create table dbo.lc_production_node_assignee (
  82. id bigint identity(1,1) primary key,
  83. order_id bigint not null,
  84. order_type nvarchar(30) not null,
  85. node_code nvarchar(50) not null,
  86. assignee_user_id bigint not null,
  87. assignee_user_name nvarchar(100) null,
  88. create_time datetime not null default(getdate()),
  89. create_by bigint null
  90. );
  91. end;
  92. go
  93. if not exists (select 1 from sys.indexes where name = 'ix_lc_order_type_status' and object_id = object_id('dbo.lc_production_order'))
  94. begin
  95. create index ix_lc_order_type_status on dbo.lc_production_order(order_type, status, is_deleted, create_time);
  96. end;
  97. go
  98. if not exists (select 1 from sys.indexes where name = 'ux_lc_node_order_code' and object_id = object_id('dbo.lc_production_order_node'))
  99. begin
  100. create unique index ux_lc_node_order_code on dbo.lc_production_order_node(order_id, node_code);
  101. end;
  102. go
  103. if not exists (select 1 from sys.indexes where name = 'ux_lc_node_role_unique' and object_id = object_id('dbo.lc_production_node_role'))
  104. begin
  105. create unique index ux_lc_node_role_unique on dbo.lc_production_node_role(order_type, node_code, role_id);
  106. end;
  107. go
  108. if exists (select 1 from sys.indexes where name = 'ux_lc_node_assignee_unique' and object_id = object_id('dbo.lc_production_node_assignee'))
  109. begin
  110. drop index ux_lc_node_assignee_unique on dbo.lc_production_node_assignee;
  111. end;
  112. go
  113. if not exists (select 1 from sys.indexes where name = 'ux_lc_node_assignee_user_unique' and object_id = object_id('dbo.lc_production_node_assignee'))
  114. begin
  115. create unique index ux_lc_node_assignee_user_unique on dbo.lc_production_node_assignee(order_id, node_code, assignee_user_id);
  116. end;
  117. go
  118. /*
  119. sys_role role_type
  120. */
  121. if col_length('dbo.sys_role', 'role_type') is null
  122. begin
  123. alter table dbo.sys_role add role_type nvarchar(50) null;
  124. end;
  125. go
  126. /*
  127. role_type +
  128. :
  129. LC_HOME_LIFT_STOCKING
  130. LC_HOME_LIFT_PLATFORM_DEBUG
  131. LC_HOME_LIFT_BG_CEILING
  132. LC_HOME_LIFT_DOOR_ASSY
  133. LC_HOME_LIFT_PACK
  134. 线/COP:
  135. LC_CABLE_COP_LINE_PRODUCTION
  136. LC_CABLE_COP_COP_PRODUCTION
  137. :
  138. LC_RENOVATION_STOCKING
  139. LC_RENOVATION_ASSY
  140. LC_RENOVATION_INSPECT
  141. LC_RENOVATION_PACK
  142. */
  143. update dbo.sys_role set role_type = 'LC_HOME_LIFT_STOCKING' where role_name like '%家用电梯%' and role_name like '%仓库配料%';
  144. update dbo.sys_role set role_type = 'LC_HOME_LIFT_PLATFORM_DEBUG' where role_name like '%家用电梯%' and role_name like '%平台组装%' ;
  145. update dbo.sys_role set role_type = 'LC_HOME_LIFT_BG_CEILING' where role_name like '%家用电梯%' and (role_name like '%背景墙%' or role_name like '%吊顶%');
  146. update dbo.sys_role set role_type = 'LC_HOME_LIFT_DOOR_ASSY' where role_name like '%家用电梯%' and role_name like '%门组装%';
  147. update dbo.sys_role set role_type = 'LC_HOME_LIFT_PACK' where role_name like '%家用电梯%' and role_name like '%打包%';
  148. update dbo.sys_role set role_type = 'LC_CABLE_COP_LINE_PRODUCTION' where role_name like '%线缆生产%';
  149. update dbo.sys_role set role_type = 'LC_CABLE_COP_COP_PRODUCTION' where role_name like '%COP生产%';
  150. update dbo.sys_role set role_type = 'LC_RENOVATION_STOCKING' where role_name like '%改造%' and role_name like '%仓库配料%';
  151. update dbo.sys_role set role_type = 'LC_RENOVATION_ASSY' where role_name like '%改造%' and role_name like '%组装%';
  152. update dbo.sys_role set role_type = 'LC_RENOVATION_INSPECT' where role_name like '%改造%' and role_name like '%检验%';
  153. update dbo.sys_role set role_type = 'LC_RENOVATION_PACK' where role_name like '%改造%' and role_name like '%打包%';
  154. go