|
|
@@ -0,0 +1,481 @@
|
|
|
+SET NAMES utf8mb4;
|
|
|
+USE sp_gzhx_apps;
|
|
|
+
|
|
|
+START TRANSACTION;
|
|
|
+
|
|
|
+SET @source_website_id := 10007;
|
|
|
+SET @parent_website_id := 10070;
|
|
|
+SET @target_template_id := 61;
|
|
|
+SET @target_website_name := '新闻网-2026';
|
|
|
+SET @target_domain_host := 'xinwen2026.hxcs.feifan.net';
|
|
|
+SET @target_domains := CONCAT(@target_domain_host, ';');
|
|
|
+SET @target_id_code := 'hxcs_news_2026_copy_site';
|
|
|
+SET @operator_pid := 10000;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @source_guard_count
|
|
|
+FROM website
|
|
|
+WHERE websiteid = @source_website_id
|
|
|
+ AND dcode = 61
|
|
|
+ AND name = '新闻网';
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @parent_guard_count
|
|
|
+FROM website
|
|
|
+WHERE websiteid = @parent_website_id
|
|
|
+ AND dcode = 61
|
|
|
+ AND name = '广州华夏职业学院';
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @template_guard_count
|
|
|
+FROM website_template
|
|
|
+WHERE wtid = @target_template_id
|
|
|
+ AND dcode = 61
|
|
|
+ AND config = 'ffkjcollegered1'
|
|
|
+ AND name = '非繁二级网站模板-红色';
|
|
|
+
|
|
|
+SET @guard_sql := IF(
|
|
|
+ @source_guard_count = 1
|
|
|
+ AND @parent_guard_count = 1
|
|
|
+ AND @template_guard_count = 1,
|
|
|
+ 'SELECT 1',
|
|
|
+ 'SELECT * FROM __news2026_source_parent_or_template_guard_failed__'
|
|
|
+);
|
|
|
+PREPARE guard_stmt FROM @guard_sql;
|
|
|
+EXECUTE guard_stmt;
|
|
|
+DEALLOCATE PREPARE guard_stmt;
|
|
|
+
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_nav_source;
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_article_source;
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_nav_map;
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_nav_parent_map;
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_article_map;
|
|
|
+
|
|
|
+CREATE TEMPORARY TABLE tmp_news2026_nav_source AS
|
|
|
+SELECT *
|
|
|
+FROM website_navigation
|
|
|
+WHERE websiteid = @source_website_id
|
|
|
+ AND wnccode = 10000
|
|
|
+ AND dcode = 61;
|
|
|
+
|
|
|
+CREATE TEMPORARY TABLE tmp_news2026_article_source AS
|
|
|
+SELECT a.*
|
|
|
+FROM article a
|
|
|
+JOIN tmp_news2026_nav_source source_nav ON source_nav.navigationid = a.navigationid
|
|
|
+WHERE a.websiteid = @source_website_id
|
|
|
+ AND a.dcode = 61;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @source_nav_count FROM tmp_news2026_nav_source;
|
|
|
+SELECT COUNT(*) INTO @source_article_count FROM tmp_news2026_article_source;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @source_active_nav_orphan_count
|
|
|
+FROM tmp_news2026_nav_source child
|
|
|
+LEFT JOIN website_navigation parent_nav
|
|
|
+ ON parent_nav.navigationid = child.parent_nid
|
|
|
+ AND parent_nav.websiteid = @source_website_id
|
|
|
+ AND parent_nav.wnccode = 10000
|
|
|
+ AND parent_nav.dcode = 61
|
|
|
+WHERE child.parent_nid IS NOT NULL
|
|
|
+ AND parent_nav.navigationid IS NULL;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @duplicate_article_key_count
|
|
|
+FROM (
|
|
|
+ SELECT navigationid, title, url, COUNT(*) AS c
|
|
|
+ FROM tmp_news2026_article_source
|
|
|
+ GROUP BY navigationid, title, url
|
|
|
+ HAVING COUNT(*) > 1
|
|
|
+) duplicate_keys;
|
|
|
+
|
|
|
+SET @guard_sql := IF(
|
|
|
+ @source_nav_count = 15
|
|
|
+ AND @source_article_count = 439
|
|
|
+ AND @source_active_nav_orphan_count = 0
|
|
|
+ AND @duplicate_article_key_count = 0,
|
|
|
+ 'SELECT 1',
|
|
|
+ 'SELECT * FROM __news2026_source_shape_changed__'
|
|
|
+);
|
|
|
+PREPARE guard_stmt FROM @guard_sql;
|
|
|
+EXECUTE guard_stmt;
|
|
|
+DEALLOCATE PREPARE guard_stmt;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @target_candidate_count
|
|
|
+FROM website
|
|
|
+WHERE id_code = @target_id_code
|
|
|
+ OR name = @target_website_name
|
|
|
+ OR FIND_IN_SET(@target_domain_host, REPLACE(TRIM(BOTH ';' FROM IFNULL(domains, '')), ';', ',')) > 0;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @target_matching_count
|
|
|
+FROM website
|
|
|
+WHERE name = @target_website_name
|
|
|
+ AND domains = @target_domains
|
|
|
+ AND wtid = @target_template_id
|
|
|
+ AND parent_wid = @parent_website_id;
|
|
|
+
|
|
|
+SET @guard_sql := IF(
|
|
|
+ @target_candidate_count = 0
|
|
|
+ OR (@target_candidate_count = 1 AND @target_matching_count = 1),
|
|
|
+ 'SELECT 1',
|
|
|
+ 'SELECT * FROM __news2026_target_name_or_domain_conflict__'
|
|
|
+);
|
|
|
+PREPARE guard_stmt FROM @guard_sql;
|
|
|
+EXECUTE guard_stmt;
|
|
|
+DEALLOCATE PREPARE guard_stmt;
|
|
|
+
|
|
|
+INSERT INTO website (
|
|
|
+ dcode, unitid, wtcode, wtid, parent_wid, name, `desc`, protocol, port, domains, catalog_uri,
|
|
|
+ logo, white_logo_file, seo_icon, seo_title, seo_keywords, seo_description,
|
|
|
+ create_time, create_pid, id_code, sort_number
|
|
|
+)
|
|
|
+SELECT
|
|
|
+ 61, parent_website.unitid, 10010, @target_template_id, parent_website.websiteid,
|
|
|
+ @target_website_name, '以 HXCS 现有“新闻网”在用内容复制生成,用于 2026 对照。',
|
|
|
+ 'https', 443, @target_domains, '/',
|
|
|
+ source_website.logo, source_website.white_logo_file,
|
|
|
+ COALESCE(source_website.seo_icon, parent_website.seo_icon),
|
|
|
+ '广州华夏职业学院-新闻网-2026',
|
|
|
+ '广州华夏职业学院,新闻网,新闻网-2026',
|
|
|
+ '广州华夏职业学院新闻网 2026 对照站。',
|
|
|
+ NOW(), @operator_pid, @target_id_code, 9991
|
|
|
+FROM website source_website
|
|
|
+JOIN website parent_website ON parent_website.websiteid = @parent_website_id
|
|
|
+WHERE source_website.websiteid = @source_website_id
|
|
|
+ AND @target_candidate_count = 0;
|
|
|
+
|
|
|
+SET @target_website_id := (
|
|
|
+ SELECT websiteid
|
|
|
+ FROM website
|
|
|
+ WHERE id_code = @target_id_code
|
|
|
+ OR (name = @target_website_name AND domains = @target_domains)
|
|
|
+ ORDER BY (id_code = @target_id_code) DESC, websiteid DESC
|
|
|
+ LIMIT 1
|
|
|
+);
|
|
|
+
|
|
|
+UPDATE website target_website
|
|
|
+JOIN website source_website ON source_website.websiteid = @source_website_id
|
|
|
+JOIN website parent_website ON parent_website.websiteid = @parent_website_id
|
|
|
+SET target_website.dcode = 61,
|
|
|
+ target_website.unitid = parent_website.unitid,
|
|
|
+ target_website.wtcode = 10010,
|
|
|
+ target_website.wtid = @target_template_id,
|
|
|
+ target_website.parent_wid = parent_website.websiteid,
|
|
|
+ target_website.name = @target_website_name,
|
|
|
+ target_website.`desc` = '以 HXCS 现有“新闻网”在用内容复制生成,用于 2026 对照。',
|
|
|
+ target_website.protocol = 'https',
|
|
|
+ target_website.port = 443,
|
|
|
+ target_website.domains = @target_domains,
|
|
|
+ target_website.catalog_uri = '/',
|
|
|
+ target_website.logo = source_website.logo,
|
|
|
+ target_website.white_logo_file = source_website.white_logo_file,
|
|
|
+ target_website.seo_icon = COALESCE(source_website.seo_icon, parent_website.seo_icon),
|
|
|
+ target_website.seo_title = '广州华夏职业学院-新闻网-2026',
|
|
|
+ target_website.seo_keywords = '广州华夏职业学院,新闻网,新闻网-2026',
|
|
|
+ target_website.seo_description = '广州华夏职业学院新闻网 2026 对照站。',
|
|
|
+ target_website.id_code = @target_id_code,
|
|
|
+ target_website.sort_number = 9991
|
|
|
+WHERE target_website.websiteid = @target_website_id;
|
|
|
+
|
|
|
+INSERT INTO website_manage (unitid, websiteid, mtcode, objectid, create_time, create_pid)
|
|
|
+SELECT DISTINCT parent_website.unitid, @target_website_id, source_manage.mtcode, source_manage.objectid,
|
|
|
+ NOW(), @operator_pid
|
|
|
+FROM (
|
|
|
+ SELECT mtcode, objectid FROM website_manage WHERE websiteid = @source_website_id
|
|
|
+ UNION
|
|
|
+ SELECT mtcode, objectid FROM website_manage WHERE websiteid = @parent_website_id
|
|
|
+) source_manage
|
|
|
+JOIN website parent_website ON parent_website.websiteid = @parent_website_id
|
|
|
+WHERE NOT EXISTS (
|
|
|
+ SELECT 1
|
|
|
+ FROM website_manage existing_manage
|
|
|
+ WHERE existing_manage.websiteid = @target_website_id
|
|
|
+ AND existing_manage.mtcode = source_manage.mtcode
|
|
|
+ AND existing_manage.objectid = source_manage.objectid
|
|
|
+);
|
|
|
+
|
|
|
+INSERT INTO website_navigation (
|
|
|
+ dcode, unitid, wnccode, websiteid, wtid, idcard, name, name_assistant, title, `desc`,
|
|
|
+ wntcode, wnscode, wnjtcode, wnlscode, uri, url, jump_url, jump_websiteid, parent_nid,
|
|
|
+ photo_size_width, photo_size_height, background_image, sort_number, create_time, create_pid,
|
|
|
+ id_code, guest_access_flag
|
|
|
+)
|
|
|
+SELECT
|
|
|
+ source_nav.dcode, parent_website.unitid, 10000, @target_website_id, NULL,
|
|
|
+ source_nav.idcard, source_nav.name, source_nav.name_assistant, source_nav.title, source_nav.`desc`,
|
|
|
+ source_nav.wntcode, source_nav.wnscode, source_nav.wnjtcode, source_nav.wnlscode,
|
|
|
+ source_nav.uri, source_nav.url, source_nav.jump_url, source_nav.jump_websiteid, NULL,
|
|
|
+ source_nav.photo_size_width, source_nav.photo_size_height, source_nav.background_image,
|
|
|
+ source_nav.sort_number, source_nav.create_time, source_nav.create_pid,
|
|
|
+ MD5(CONCAT('hxcs_news2026_nav_', source_nav.navigationid)), source_nav.guest_access_flag
|
|
|
+FROM tmp_news2026_nav_source source_nav
|
|
|
+JOIN website parent_website ON parent_website.websiteid = @parent_website_id
|
|
|
+WHERE NOT EXISTS (
|
|
|
+ SELECT 1
|
|
|
+ FROM website_navigation existing_nav
|
|
|
+ WHERE existing_nav.websiteid = @target_website_id
|
|
|
+ AND existing_nav.wnccode = 10000
|
|
|
+ AND existing_nav.id_code = MD5(CONCAT('hxcs_news2026_nav_', source_nav.navigationid))
|
|
|
+);
|
|
|
+
|
|
|
+CREATE TEMPORARY TABLE tmp_news2026_nav_map AS
|
|
|
+SELECT
|
|
|
+ source_nav.navigationid AS source_navigationid,
|
|
|
+ target_nav.navigationid AS target_navigationid
|
|
|
+FROM tmp_news2026_nav_source source_nav
|
|
|
+JOIN website_navigation target_nav
|
|
|
+ ON target_nav.websiteid = @target_website_id
|
|
|
+ AND target_nav.wnccode = 10000
|
|
|
+ AND target_nav.id_code = MD5(CONCAT('hxcs_news2026_nav_', source_nav.navigationid));
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @nav_map_count FROM tmp_news2026_nav_map;
|
|
|
+
|
|
|
+SET @guard_sql := IF(
|
|
|
+ @nav_map_count = @source_nav_count,
|
|
|
+ 'SELECT 1',
|
|
|
+ 'SELECT * FROM __news2026_nav_mapping_failed__'
|
|
|
+);
|
|
|
+PREPARE guard_stmt FROM @guard_sql;
|
|
|
+EXECUTE guard_stmt;
|
|
|
+DEALLOCATE PREPARE guard_stmt;
|
|
|
+
|
|
|
+CREATE TEMPORARY TABLE tmp_news2026_nav_parent_map AS
|
|
|
+SELECT * FROM tmp_news2026_nav_map;
|
|
|
+
|
|
|
+UPDATE website_navigation target_nav
|
|
|
+JOIN tmp_news2026_nav_map nav_map ON nav_map.target_navigationid = target_nav.navigationid
|
|
|
+JOIN tmp_news2026_nav_source source_nav ON source_nav.navigationid = nav_map.source_navigationid
|
|
|
+LEFT JOIN tmp_news2026_nav_parent_map parent_map ON parent_map.source_navigationid = source_nav.parent_nid
|
|
|
+JOIN website parent_website ON parent_website.websiteid = @parent_website_id
|
|
|
+SET target_nav.dcode = source_nav.dcode,
|
|
|
+ target_nav.unitid = parent_website.unitid,
|
|
|
+ target_nav.wnccode = 10000,
|
|
|
+ target_nav.websiteid = @target_website_id,
|
|
|
+ target_nav.wtid = NULL,
|
|
|
+ target_nav.idcard = source_nav.idcard,
|
|
|
+ target_nav.name = source_nav.name,
|
|
|
+ target_nav.name_assistant = source_nav.name_assistant,
|
|
|
+ target_nav.title = source_nav.title,
|
|
|
+ target_nav.`desc` = source_nav.`desc`,
|
|
|
+ target_nav.wntcode = source_nav.wntcode,
|
|
|
+ target_nav.wnscode = source_nav.wnscode,
|
|
|
+ target_nav.wnjtcode = source_nav.wnjtcode,
|
|
|
+ target_nav.wnlscode = source_nav.wnlscode,
|
|
|
+ target_nav.uri = source_nav.uri,
|
|
|
+ target_nav.url = source_nav.url,
|
|
|
+ target_nav.jump_url = source_nav.jump_url,
|
|
|
+ target_nav.jump_websiteid = source_nav.jump_websiteid,
|
|
|
+ target_nav.parent_nid = parent_map.target_navigationid,
|
|
|
+ target_nav.photo_size_width = source_nav.photo_size_width,
|
|
|
+ target_nav.photo_size_height = source_nav.photo_size_height,
|
|
|
+ target_nav.background_image = source_nav.background_image,
|
|
|
+ target_nav.sort_number = source_nav.sort_number,
|
|
|
+ target_nav.guest_access_flag = source_nav.guest_access_flag;
|
|
|
+
|
|
|
+INSERT INTO website_navigation_manage (
|
|
|
+ unitid, navigationid, wnmcode, mtcode, objectid, create_time, create_pid
|
|
|
+)
|
|
|
+SELECT DISTINCT
|
|
|
+ parent_website.unitid, nav_map.target_navigationid,
|
|
|
+ source_manage.wnmcode, source_manage.mtcode, source_manage.objectid,
|
|
|
+ NOW(), @operator_pid
|
|
|
+FROM website_navigation_manage source_manage
|
|
|
+JOIN tmp_news2026_nav_map nav_map ON nav_map.source_navigationid = source_manage.navigationid
|
|
|
+JOIN website parent_website ON parent_website.websiteid = @parent_website_id
|
|
|
+WHERE NOT EXISTS (
|
|
|
+ SELECT 1
|
|
|
+ FROM website_navigation_manage existing_manage
|
|
|
+ WHERE existing_manage.navigationid = nav_map.target_navigationid
|
|
|
+ AND existing_manage.wnmcode = source_manage.wnmcode
|
|
|
+ AND existing_manage.mtcode = source_manage.mtcode
|
|
|
+ AND existing_manage.objectid = source_manage.objectid
|
|
|
+);
|
|
|
+
|
|
|
+INSERT INTO article (
|
|
|
+ dcode, websiteid, unitid, ascode, navigationid, title, ajtcode, `desc`, source, thumbnail,
|
|
|
+ sticktop, sticktop_end_time, sticktop_schedulesid, `release`, release_time, release_task_schedulesid,
|
|
|
+ content, edit_content, url, read_count, create_time, last_change_time, create_pid, last_change_pid,
|
|
|
+ guest_access_flag, sort_number
|
|
|
+)
|
|
|
+SELECT
|
|
|
+ source_article.dcode, @target_website_id, parent_website.unitid,
|
|
|
+ source_article.ascode, nav_map.target_navigationid, source_article.title, source_article.ajtcode,
|
|
|
+ source_article.`desc`, source_article.source, source_article.thumbnail,
|
|
|
+ source_article.sticktop, source_article.sticktop_end_time, source_article.sticktop_schedulesid,
|
|
|
+ 1, source_article.release_time, source_article.release_task_schedulesid,
|
|
|
+ source_article.content, source_article.edit_content, source_article.url, source_article.read_count,
|
|
|
+ source_article.create_time, source_article.last_change_time, source_article.create_pid,
|
|
|
+ source_article.last_change_pid, source_article.guest_access_flag, source_article.sort_number
|
|
|
+FROM tmp_news2026_article_source source_article
|
|
|
+JOIN tmp_news2026_nav_map nav_map ON nav_map.source_navigationid = source_article.navigationid
|
|
|
+JOIN website parent_website ON parent_website.websiteid = @parent_website_id
|
|
|
+WHERE NOT EXISTS (
|
|
|
+ SELECT 1
|
|
|
+ FROM article existing_article
|
|
|
+ WHERE existing_article.websiteid = @target_website_id
|
|
|
+ AND existing_article.navigationid = nav_map.target_navigationid
|
|
|
+ AND existing_article.title = source_article.title
|
|
|
+ AND existing_article.url = source_article.url
|
|
|
+ AND existing_article.dcode <> 72
|
|
|
+);
|
|
|
+
|
|
|
+CREATE TEMPORARY TABLE tmp_news2026_article_map AS
|
|
|
+SELECT
|
|
|
+ source_article.articleid AS source_articleid,
|
|
|
+ target_article.articleid AS target_articleid
|
|
|
+FROM tmp_news2026_article_source source_article
|
|
|
+JOIN tmp_news2026_nav_map nav_map ON nav_map.source_navigationid = source_article.navigationid
|
|
|
+JOIN article target_article
|
|
|
+ ON target_article.websiteid = @target_website_id
|
|
|
+ AND target_article.navigationid = nav_map.target_navigationid
|
|
|
+ AND target_article.title = source_article.title
|
|
|
+ AND target_article.url = source_article.url
|
|
|
+ AND target_article.dcode <> 72;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @article_map_count FROM tmp_news2026_article_map;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @article_map_duplicate_source_count
|
|
|
+FROM (
|
|
|
+ SELECT source_articleid
|
|
|
+ FROM tmp_news2026_article_map
|
|
|
+ GROUP BY source_articleid
|
|
|
+ HAVING COUNT(*) > 1
|
|
|
+) duplicate_source;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @article_map_duplicate_target_count
|
|
|
+FROM (
|
|
|
+ SELECT target_articleid
|
|
|
+ FROM tmp_news2026_article_map
|
|
|
+ GROUP BY target_articleid
|
|
|
+ HAVING COUNT(*) > 1
|
|
|
+) duplicate_target;
|
|
|
+
|
|
|
+SET @guard_sql := IF(
|
|
|
+ @article_map_count = @source_article_count
|
|
|
+ AND @article_map_duplicate_source_count = 0
|
|
|
+ AND @article_map_duplicate_target_count = 0,
|
|
|
+ 'SELECT 1',
|
|
|
+ 'SELECT * FROM __news2026_article_mapping_failed__'
|
|
|
+);
|
|
|
+PREPARE guard_stmt FROM @guard_sql;
|
|
|
+EXECUTE guard_stmt;
|
|
|
+DEALLOCATE PREPARE guard_stmt;
|
|
|
+
|
|
|
+UPDATE article target_article
|
|
|
+JOIN tmp_news2026_article_map article_map ON article_map.target_articleid = target_article.articleid
|
|
|
+JOIN tmp_news2026_article_source source_article ON source_article.articleid = article_map.source_articleid
|
|
|
+JOIN tmp_news2026_nav_map nav_map ON nav_map.source_navigationid = source_article.navigationid
|
|
|
+JOIN website parent_website ON parent_website.websiteid = @parent_website_id
|
|
|
+SET target_article.dcode = source_article.dcode,
|
|
|
+ target_article.websiteid = @target_website_id,
|
|
|
+ target_article.unitid = parent_website.unitid,
|
|
|
+ target_article.ascode = source_article.ascode,
|
|
|
+ target_article.navigationid = nav_map.target_navigationid,
|
|
|
+ target_article.title = source_article.title,
|
|
|
+ target_article.ajtcode = source_article.ajtcode,
|
|
|
+ target_article.`desc` = source_article.`desc`,
|
|
|
+ target_article.source = source_article.source,
|
|
|
+ target_article.thumbnail = source_article.thumbnail,
|
|
|
+ target_article.sticktop = source_article.sticktop,
|
|
|
+ target_article.sticktop_end_time = source_article.sticktop_end_time,
|
|
|
+ target_article.sticktop_schedulesid = source_article.sticktop_schedulesid,
|
|
|
+ target_article.`release` = 1,
|
|
|
+ target_article.release_time = source_article.release_time,
|
|
|
+ target_article.release_task_schedulesid = source_article.release_task_schedulesid,
|
|
|
+ target_article.content = source_article.content,
|
|
|
+ target_article.edit_content = source_article.edit_content,
|
|
|
+ target_article.url = source_article.url,
|
|
|
+ target_article.read_count = source_article.read_count,
|
|
|
+ target_article.create_time = source_article.create_time,
|
|
|
+ target_article.last_change_time = source_article.last_change_time,
|
|
|
+ target_article.create_pid = source_article.create_pid,
|
|
|
+ target_article.last_change_pid = source_article.last_change_pid,
|
|
|
+ target_article.guest_access_flag = source_article.guest_access_flag,
|
|
|
+ target_article.sort_number = source_article.sort_number;
|
|
|
+
|
|
|
+INSERT INTO article_copy (
|
|
|
+ dcode, articleid, navigationid, create_time, create_pid
|
|
|
+)
|
|
|
+SELECT DISTINCT
|
|
|
+ source_copy.dcode, article_map.target_articleid, target_copy_nav.target_navigationid,
|
|
|
+ source_copy.create_time, source_copy.create_pid
|
|
|
+FROM article_copy source_copy
|
|
|
+JOIN tmp_news2026_article_map article_map ON article_map.source_articleid = source_copy.articleid
|
|
|
+JOIN tmp_news2026_nav_map target_copy_nav ON target_copy_nav.source_navigationid = source_copy.navigationid
|
|
|
+WHERE source_copy.dcode = 61
|
|
|
+ AND NOT EXISTS (
|
|
|
+ SELECT 1
|
|
|
+ FROM article_copy existing_copy
|
|
|
+ WHERE existing_copy.articleid = article_map.target_articleid
|
|
|
+ AND existing_copy.navigationid = target_copy_nav.target_navigationid
|
|
|
+ AND existing_copy.dcode <> 72
|
|
|
+ );
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @target_nav_count
|
|
|
+FROM website_navigation
|
|
|
+WHERE websiteid = @target_website_id
|
|
|
+ AND wnccode = 10000
|
|
|
+ AND dcode = 61;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @target_article_count
|
|
|
+FROM article
|
|
|
+WHERE websiteid = @target_website_id
|
|
|
+ AND dcode = 61;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @target_released_article_count
|
|
|
+FROM article
|
|
|
+WHERE websiteid = @target_website_id
|
|
|
+ AND dcode = 61
|
|
|
+ AND `release` = 1;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @target_nav_orphan_count
|
|
|
+FROM website_navigation child
|
|
|
+LEFT JOIN website_navigation parent_nav
|
|
|
+ ON parent_nav.navigationid = child.parent_nid
|
|
|
+ AND parent_nav.websiteid = @target_website_id
|
|
|
+ AND parent_nav.wnccode = 10000
|
|
|
+ AND parent_nav.dcode = 61
|
|
|
+WHERE child.websiteid = @target_website_id
|
|
|
+ AND child.wnccode = 10000
|
|
|
+ AND child.dcode = 61
|
|
|
+ AND child.parent_nid IS NOT NULL
|
|
|
+ AND parent_nav.navigationid IS NULL;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @target_article_bad_nav_count
|
|
|
+FROM article target_article
|
|
|
+LEFT JOIN website_navigation target_nav
|
|
|
+ ON target_nav.navigationid = target_article.navigationid
|
|
|
+ AND target_nav.websiteid = @target_website_id
|
|
|
+ AND target_nav.wnccode = 10000
|
|
|
+ AND target_nav.dcode = 61
|
|
|
+WHERE target_article.websiteid = @target_website_id
|
|
|
+ AND target_article.dcode = 61
|
|
|
+ AND target_nav.navigationid IS NULL;
|
|
|
+
|
|
|
+SELECT COUNT(*) INTO @source_post_nav_count FROM tmp_news2026_nav_source;
|
|
|
+SELECT COUNT(*) INTO @source_post_article_count FROM tmp_news2026_article_source;
|
|
|
+
|
|
|
+SET @guard_sql := IF(
|
|
|
+ @target_nav_count = 15
|
|
|
+ AND @target_article_count = 439
|
|
|
+ AND @target_released_article_count = 439
|
|
|
+ AND @target_nav_orphan_count = 0
|
|
|
+ AND @target_article_bad_nav_count = 0
|
|
|
+ AND @source_post_nav_count = 15
|
|
|
+ AND @source_post_article_count = 439,
|
|
|
+ 'SELECT 1',
|
|
|
+ 'SELECT * FROM __news2026_copy_verify_failed__'
|
|
|
+);
|
|
|
+PREPARE guard_stmt FROM @guard_sql;
|
|
|
+EXECUTE guard_stmt;
|
|
|
+DEALLOCATE PREPARE guard_stmt;
|
|
|
+
|
|
|
+SELECT
|
|
|
+ @target_website_id AS target_websiteid,
|
|
|
+ @target_nav_count AS target_active_nav_count,
|
|
|
+ @target_article_count AS target_active_article_count,
|
|
|
+ @target_released_article_count AS target_released_article_count,
|
|
|
+ @target_nav_orphan_count AS target_nav_orphan_count,
|
|
|
+ @target_article_bad_nav_count AS target_article_bad_nav_count;
|
|
|
+
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_article_map;
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_nav_parent_map;
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_nav_map;
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_article_source;
|
|
|
+DROP TEMPORARY TABLE IF EXISTS tmp_news2026_nav_source;
|
|
|
+
|
|
|
+COMMIT;
|