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.

183 lines
6.8 KiB

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