Просмотр исходного кода

脚本支持增量更新数据

lijihong 6 лет назад
Родитель
Сommit
b3c9c26afe

+ 1 - 1
TRS.WCM.Developer/贵州项目/3_sp_data_migration_wcmchannel.sql

@@ -69,7 +69,7 @@ CREATE PROCEDURE sp_data_migration_wcmchannel(IN citySuffix VARCHAR(20),
 		SELECT
       CHANNELID,
       SITEID,
-      CHNLNAME,
+      CONCAT(CHNLNAME, citySuffix),
       CHNLDESC,
       CHNLTABLE,
       CHNLQUERY,

+ 1 - 1
TRS.WCM.Developer/贵州项目/3_sp_data_migration_wcmwebsite.sql

@@ -61,7 +61,7 @@ CREATE PROCEDURE sp_data_migration_wcmwebsite(IN citySuffix VARCHAR(255), IN pre
     DECLARE cur CURSOR FOR
 		SELECT
       SITEID,
-      SITENAME,
+      CONCAT(SITENAME, citySuffix),,
       SITEDESC,
       FTPSERVER,
       FTPUSER,

+ 10 - 18
TRS.WCM.Developer/贵州项目/4_sp_city_n.sql

@@ -31,18 +31,14 @@ CREATE PROCEDURE sp_city_n(IN n INT)
     SET @prevViewFieldInfoId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmviewfieldinfo'), 0);
     SET @prevViewId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmviewinfo'), 0);
     SET @prevMetaViewFieldGroupId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmmetaviewfieldgroup'), 0);
-    SET @prevAppendixId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmappendix'), 0);
 
 
     # 支持数据增量 偏移量  修改
-
     # xx ID 偏移量,获取海云系统中的对应 xx maxID 错开一段距离,改为存入最大id
 	  SET @maxSiteId = IFNULL((SELECT MAX(siteId) from trs_hycloud_iip.wcmwebsite),0);
 		SET @siteIdOffset = @maxSiteId - @prevSiteId;
 	  SET @maxChannelId= IFNULL((SELECT MAX(channelId) from trs_hycloud_iip.wcmchannel),0);
 	  SET @channelIdOffset = @maxChannelId - @prevChannelId;
-	  SET @maxAppendixId= IFNULL((SELECT MAX(appendixId) from trs_hycloud_iip.wcmappendix),0);
-	  SET @appendixIdOffset = @maxAppendixId - @prevAppendixId;
     SET @maxRecId= IFNULL((SELECT MAX(recId) from trs_hycloud_iip.wcmchnldoc),0);
 	  SET @recIdOffset = @maxRecId - @prevRecId;
 	  SET @maxDocId= IFNULL((SELECT MAX(DOCID) from trs_hycloud_iip.wcmdocument),0);
@@ -75,11 +71,8 @@ CREATE PROCEDURE sp_city_n(IN n INT)
 	  SET @classInfoIdOffset = @maxClassInfoId - @prevClassInfoId;
 	  SET @maxClassInfoViewId = IFNULL((SELECT MAX(CLASSINFOVIEWID) from trs_hycloud_iip.xwcmclassinfoview),0);
 	  SET @classInfoViewIdOffset = @maxClassInfoViewId - @prevClassInfoViewId;
-    #字段分组不用迁移,旧环境分组无法复用
---     SET @maxMetaViewFieldGroupId = IFNULL((SELECT MAX(METAVIEWFIELDGROUPID) from trs_hycloud_iip.xwcmmetaviewfieldgroup),0);
---     SET @metaViewFieldGroupIdOffset = @maxMetaViewFieldGroupId - @prevMetaViewFieldGroupId;
-
 
+    #基本信息迁移
     call sp_data_migration_wcmwebsite(@citySuffix, @prevSiteId, @siteIdOffset);
     call sp_data_migration_wcmchannel(@citySuffix, @prevChannelId, @siteIdOffset, @channelIdOffset);
     call sp_data_migration_wcmchannelsyn(@prevChannelSynId, @channelSynIdOffset, @channelIdOffset);
@@ -94,37 +87,36 @@ CREATE PROCEDURE sp_city_n(IN n INT)
     call sp_data_migration_wcmchannelchildindexquote(@templateIdOffset, @siteIdOffset, @channelIdOffset);
     call sp_data_migration_xwcmviewinfo(@citySuffix, @prevViewId, @viewIdOffset, @tableInfoIdOffset);
     call sp_data_migration_xwcmdbfieldinfo(@citySuffix, @prevFieldId, @fieldIdOffset, @prevClassInfoId, @tableInfoIdOffset);
-    call sp_data_migration_wcmdocument(@prevDocId, @docIdOffset, @viewIdOffset, @siteIdOffset, @channelIdOffset);
-    call sp_data_migration_wcmappendix(@prevAppendixId, @appendixIdOffset, @docIdOffset);
-    call sp_data_migration_wcmchnldoc(@prevRecId, @recIdOffset, @docIdOffset, @siteIdOffset, @channelIdOffset, @viewIdOffset);
-    call sp_data_migration_xwcmclassinfoview(@prevClassInfoViewId, @classInfoViewIdOffset, @classInfoIdOffset, @docIdOffset, @viewIdOffset);
     call sp_data_migration_xwcmmetaviewemployer(@prevMetaViewEmployerId, @metaViewEmployerIdOffset, @viewIdOffset, @siteIdOffset, @channelIdOffset);
     call sp_data_migration_xwcmviewfieldinfo(@citySuffix, @prevViewFieldInfoId, @viewFieldInfoIdOffset, @tableInfoIdOffset, @prevClassInfoId, @dbFieldIdOffset, @metaViewFieldGroupIdOffset, @viewIdOffset, @viewIdOffset);
 
+    #数据迁移
+    call sp_data_migration_wcmdocument(@prevDocId, @docIdOffset, @viewIdOffset, @siteIdOffset, @channelIdOffset);
+    call sp_data_migration_wcmchnldoc(@prevRecId, @recIdOffset, @docIdOffset, @siteIdOffset, @channelIdOffset, @viewIdOffset);
+    call sp_data_migration_xwcmclassinfoview(@prevClassInfoViewId, @classInfoViewIdOffset, @classInfoIdOffset, @docIdOffset, @viewIdOffset);
     call sp_data_migration_wcmmetatable(@citySuffix, @prevTableInfoId, @prevDocId, @docIdOffset, @channelIdOffset);
---     call sp_data_migration_xwcmmetaviewfieldgroup(@prevMetaViewFieldGroupId, @metaViewFieldGroupIdOffset, @viewIdOffset);
-
 
-    # 待优化
+    #附件迁移
     # 迁移 MAS 视频,6个wcm节点的视频是在一起的。可重复执行。
-
     # 支持断点续传,上一次迁移的最后一个 xx ID
     SET @prevMasId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'mas_masid'), 0);
     SET @prevMasVideoId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'mas_masvideo'), 0);
-
     SET @prevMaterialquoteId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmmaterial'), 0);
+    SET @prevAppendixId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmappendix'), 0);
 
     SET @maxMasId = IFNULL((SELECT MAX(ID) from trs_mas.mas_masid),0);
     SET @masIdOffset = @maxMasId - @prevMasId;
     SET @maxMasVideoId = IFNULL((SELECT MAX(ID) from trs_mas.mas_videostream),0);
     SET @masVideoIdOffset = @maxMasVideoId - @prevMasVideoId;
-
     SET @maxNAppendixId= IFNULL((SELECT MAX(appendixId) from trs_hycloud_iip.wcmappendix),0);
 	  SET @nappendixIdOffset = @maxNAppendixId - @prevMaterialquoteId;
+	  SET @maxAppendixId= IFNULL((SELECT MAX(appendixId) from trs_hycloud_iip.wcmappendix),0);
+	  SET @appendixIdOffset = @maxAppendixId - @prevAppendixId;
 
     call trs_data_migration.sp_data_migration_masid(@prevMasId, @masIdOffset);
     call trs_data_migration.sp_data_migration_masvideo(@prevMasVideoId, @masVideoIdOffset);
     #处理素材表
+    call sp_data_migration_wcmappendix(@prevAppendixId, @appendixIdOffset, @docIdOffset);
     call trs_data_migration.sp_data_migration_xwcmmaterial(@prevMaterialquoteId, @nappendixIdOffset, @docIdOffset);
 
   END $$