1.0.339.sql 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. -- ============================================================
  2. -- 1.0.339.sql
  3. -- S5 搴撳瓨鍙e緞鏀舵暃 C1锛欴omain脳绉熸埛鏄犲皠 / 搴撲綅鐧藉悕鍗?/ 鏍囧噯灞?/ 瀹炰綋淇
  4. -- 鍙噸澶嶆墽琛岋紱涓嶆敼宸叉墽琛岀殑 1.0.300/304/332/335/336銆?-- ============================================================
  5. CREATE TABLE IF NOT EXISTS `ado_source_domain_tenant_map` (
  6. `id` bigint NOT NULL AUTO_INCREMENT,
  7. `source_code` varchar(64) NOT NULL,
  8. `domain` varchar(32) NOT NULL,
  9. `tenant_id` bigint NOT NULL,
  10. `status` tinyint NOT NULL DEFAULT 1,
  11. `remark` varchar(500) DEFAULT NULL,
  12. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  13. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  14. PRIMARY KEY (`id`),
  15. UNIQUE KEY `uk_source_domain` (`source_code`,`domain`),
  16. KEY `idx_domain_tenant` (`tenant_id`,`status`)
  17. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
  18. COMMENT='澶栭儴鏁版嵁婧怐omain鍒拌处濂楃鎴风殑鏄惧紡鏄犲皠';
  19. INSERT INTO `ado_source_domain_tenant_map`
  20. (`source_code`,`domain`,`tenant_id`,`status`,`remark`)
  21. VALUES
  22. ('DOPDEMORQ_SQLSERVER','8010',797403760988229,1,'165 WMS dopdemorq 鈫?AIDOP 绉熸埛')
  23. ON DUPLICATE KEY UPDATE
  24. `tenant_id`=VALUES(`tenant_id`),`status`=VALUES(`status`),
  25. `remark`=VALUES(`remark`),`update_time`=NOW();
  26. CREATE TABLE IF NOT EXISTS `ado_inventory_location_scope` (
  27. `id` bigint NOT NULL AUTO_INCREMENT,
  28. `tenant_id` bigint NOT NULL,
  29. `source_code` varchar(64) NOT NULL,
  30. `domain` varchar(32) NOT NULL,
  31. `location` varchar(32) NOT NULL,
  32. `scope_type` varchar(32) NOT NULL DEFAULT 'AVAILABLE',
  33. `status` tinyint NOT NULL DEFAULT 1,
  34. `remark` varchar(500) DEFAULT NULL,
  35. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  36. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  37. PRIMARY KEY (`id`),
  38. UNIQUE KEY `uk_inventory_location_scope`
  39. (`tenant_id`,`source_code`,`domain`,`location`,`scope_type`),
  40. KEY `idx_inventory_scope_enabled` (`tenant_id`,`domain`,`scope_type`,`status`)
  41. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
  42. COMMENT='搴撳瓨鍙敤閲忕瓑涓氬姟鍙e緞鐨勫簱浣嶇櫧鍚嶅崟';
  43. INSERT INTO `ado_inventory_location_scope`
  44. (`tenant_id`,`source_code`,`domain`,`location`,`scope_type`,`status`,`remark`)
  45. VALUES
  46. (797403760988229,'DOPDEMORQ_SQLSERVER','8010','1001','AVAILABLE',1,'鐜伴噰璐彛寰?),
  47. (797403760988229,'DOPDEMORQ_SQLSERVER','8010','5007','AVAILABLE',1,'鐜伴噰璐彛寰?),
  48. (797403760988229,'DOPDEMORQ_SQLSERVER','8010','5008','AVAILABLE',1,'鐜伴噰璐彛寰?),
  49. (797403760988229,'DOPDEMORQ_SQLSERVER','8010','8000','AVAILABLE',1,'鐜伴噰璐彛寰?),
  50. (797403760988229,'DOPDEMORQ_SQLSERVER','8010','8001','AVAILABLE',1,'鐜伴噰璐彛寰?)
  51. ON DUPLICATE KEY UPDATE
  52. `status`=VALUES(`status`),`remark`=VALUES(`remark`),`update_time`=NOW();
  53. CREATE TABLE IF NOT EXISTS `mdp_std_inventory` (
  54. `id` bigint NOT NULL AUTO_INCREMENT,
  55. `tenant_id` bigint NOT NULL,
  56. `source_system` varchar(64) NOT NULL,
  57. `domain` varchar(32) NOT NULL,
  58. `location` varchar(32) NOT NULL,
  59. `lot_serial` varchar(120) NOT NULL DEFAULT '',
  60. `item_num` varchar(80) NOT NULL,
  61. `dimension1` varchar(32) NOT NULL DEFAULT '',
  62. `dimension2` varchar(32) NOT NULL DEFAULT '',
  63. `refs` varchar(32) NOT NULL DEFAULT '',
  64. `site` varchar(32) NOT NULL DEFAULT '',
  65. `inv_status` varchar(32) DEFAULT NULL,
  66. `qty_on_hand` decimal(18,5) NOT NULL DEFAULT 0,
  67. `qty_unrestricted` decimal(18,5) NOT NULL DEFAULT 0,
  68. `qty_inspection` decimal(18,5) NOT NULL DEFAULT 0,
  69. `qty_frozen` decimal(18,5) NOT NULL DEFAULT 0,
  70. `qty_available` decimal(18,5) NOT NULL DEFAULT 0 COMMENT '鍥哄畾绛変簬qty_unrestricted',
  71. `src_rec_id` varchar(100) NOT NULL,
  72. `source_update_time` datetime(3) DEFAULT NULL,
  73. `as_of` datetime(3) NOT NULL,
  74. `sync_batch_id` varchar(100) NOT NULL,
  75. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  76. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  77. PRIMARY KEY (`id`),
  78. UNIQUE KEY `uk_std_inventory_biz`
  79. (`tenant_id`,`source_system`,`domain`,`location`,`lot_serial`,`item_num`,
  80. `dimension1`,`dimension2`,`refs`,`site`),
  81. KEY `idx_std_inventory_item_lot`
  82. (`tenant_id`,`domain`,`item_num`,`lot_serial`),
  83. KEY `idx_std_inventory_location`
  84. (`tenant_id`,`domain`,`location`,`item_num`),
  85. KEY `idx_std_inventory_asof` (`tenant_id`,`as_of`)
  86. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
  87. COMMENT='165 LocationDetail鏍囧噯搴撳瓨浣欓锛圓i-DOP鍞竴鍐疯妯″瀷锛?;
  88. CREATE TABLE IF NOT EXISTS `mdp_std_inv_trans` (
  89. `id` bigint NOT NULL AUTO_INCREMENT,
  90. `tenant_id` bigint NOT NULL,
  91. `source_system` varchar(64) NOT NULL,
  92. `domain` varchar(32) NOT NULL,
  93. `src_rec_id` varchar(100) NOT NULL,
  94. `trans_type` varchar(32) DEFAULT NULL,
  95. `item_num` varchar(80) DEFAULT NULL,
  96. `lot_serial` varchar(120) DEFAULT NULL,
  97. `location` varchar(32) DEFAULT NULL,
  98. `dimension1` varchar(32) NOT NULL DEFAULT '',
  99. `dimension2` varchar(32) NOT NULL DEFAULT '',
  100. `refs` varchar(32) DEFAULT NULL,
  101. `site` varchar(32) DEFAULT NULL,
  102. `qty_change` decimal(18,5) NOT NULL DEFAULT 0,
  103. `begin_balance` decimal(18,5) NOT NULL DEFAULT 0,
  104. `end_balance` decimal(18,5) NOT NULL DEFAULT 0,
  105. `eff_date` datetime(3) DEFAULT NULL,
  106. `trans_time` datetime(3) DEFAULT NULL,
  107. `ord_nbr` varchar(120) DEFAULT NULL,
  108. `work_ord` varchar(80) DEFAULT NULL,
  109. `shipper_num` varchar(120) DEFAULT NULL,
  110. `ship_type` varchar(16) DEFAULT NULL,
  111. `reason` varchar(120) DEFAULT NULL,
  112. `remark` varchar(500) DEFAULT NULL,
  113. `create_user` varchar(80) DEFAULT NULL,
  114. `history_from` datetime(3) NOT NULL COMMENT '鏈妯″瀷鎵胯瑕嗙洊鐨勫巻鍙蹭笅鐣?,
  115. `as_of` datetime(3) NOT NULL,
  116. `sync_batch_id` varchar(100) NOT NULL,
  117. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  118. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  119. PRIMARY KEY (`id`),
  120. UNIQUE KEY `uk_std_inv_trans_src`
  121. (`tenant_id`,`source_system`,`src_rec_id`),
  122. KEY `idx_std_inv_trans_item_lot`
  123. (`tenant_id`,`domain`,`item_num`,`lot_serial`,`trans_time`),
  124. KEY `idx_std_inv_trans_location`
  125. (`tenant_id`,`domain`,`location`,`trans_time`),
  126. KEY `idx_std_inv_trans_type`
  127. (`tenant_id`,`domain`,`trans_type`,`trans_time`),
  128. KEY `idx_std_inv_trans_workord`
  129. (`tenant_id`,`work_ord`,`trans_time`)
  130. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
  131. COMMENT='165 InvTransHist杩?2涓湀鏍囧噯娴佹按';
  132. UPDATE mdp_entity
  133. SET biz_key_expr='Domain,Location,LotSerial,ItemNum,Dimension1,Dimension2,Refs,Site',
  134. batch_size=5000,
  135. sync_mode='INCR',
  136. incr_column='UpdateTime',
  137. status=1,
  138. update_time=NOW()
  139. WHERE entity_code='S5_LOCATION_DETAIL_SQLSERVER';
  140. UPDATE mdp_entity
  141. SET biz_key_expr='RecID',
  142. batch_size=2000,
  143. sync_mode='INCR',
  144. incr_column='CreateTime',
  145. status=1,
  146. update_time=NOW()
  147. WHERE entity_code='S5_INV_TRANS_HIST_SQLSERVER';
  148. -- 鏈换鍔′笉鍐嶆妸 InvMaster 寤烘垚绗簩濂椾綑棰濇潵婧愩€?UPDATE mdp_entity
  149. SET status=0,
  150. remark=CONCAT(IFNULL(remark,''),' | INV-CONVERGENCE: balance derives from LocationDetail'),
  151. update_time=NOW()
  152. WHERE entity_code='S5_INV_MASTER_SQLSERVER';