This commit is contained in:
van
2026-04-03 00:34:07 +08:00
parent 72d5856838
commit c841990b49
14 changed files with 634 additions and 22 deletions

View File

@@ -0,0 +1,30 @@
-- 企微「3.cn 分享链 + 备注」入队后的扫描/推送任务(便于排查未推送原因)
CREATE TABLE IF NOT EXISTS `wecom_share_link_logistics_job` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`job_key` varchar(64) NOT NULL COMMENT '与 Redis 队列 JSON 中 jobKey 一致',
`from_user_name` varchar(128) DEFAULT NULL COMMENT '发消息的企微 UserID',
`tracking_url` varchar(768) NOT NULL COMMENT '3.cn 物流短链',
`remark` mediumtext COMMENT '用户备注',
`touser_push` varchar(512) DEFAULT NULL COMMENT '解析后的推送接收人(企微成员 UserID多个逗号分隔',
`status` varchar(32) NOT NULL DEFAULT 'PENDING' COMMENT 'PENDING/WAITING/PUSHED/ABANDONED/IMPORTED',
`waybill_no` varchar(128) DEFAULT NULL COMMENT '成功解析并推送后的运单号',
`scan_attempts` int(11) NOT NULL DEFAULT 0 COMMENT '已扫描次数(含重新入队)',
`last_note` varchar(512) DEFAULT NULL COMMENT '最近一次处理说明',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_job_key` (`job_key`),
KEY `idx_status` (`status`),
KEY `idx_from_user` (`from_user_name`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='企微分享链物流扫描任务';
-- 菜单(与 wecom_inbound_trace 并列menu_id 若冲突请在库中改大号
INSERT INTO sys_menu VALUES (
2094, '企微分享链物流', 2, 9, 'wecomShareLinkLogistics', 'jarvis/wecomShareLinkLogistics/index', '', '', 1, 0, 'C', '0', '0',
'jarvis:wecom:shareLinkLog:list', 'guide', 'admin', sysdate(), '', NULL, '监控企微录入的 3.cn 物流任务与推送状态'
);
INSERT INTO sys_menu VALUES (
2096, '从追踪补录历史', 2094, 1, '#', '', '', '', 1, 0, 'F', '0', '0',
'jarvis:wecom:shareLinkLog:import', '#', 'admin', sysdate(), '', NULL, '从 wecom_inbound_trace 补录 IMPORTED 行'
);

View File

@@ -0,0 +1,48 @@
-- ---------------------------------------------------------------------------
-- 历史补录(可选):从 wecom_inbound_trace 批量写入 wecom_share_link_logistics_job
--
-- 优先使用后台「企微分享链物流」页「从追踪补录历史」按钮Java 与线上一致,支持 http/https、备注行含链等
--
-- 需 MySQL 8.0.14+LATERAL、REGEXP_SUBSTR。可重复执行按 job_key 去重)。
-- ---------------------------------------------------------------------------
INSERT INTO wecom_share_link_logistics_job (
job_key, from_user_name, tracking_url, remark, touser_push, status, scan_attempts, last_note,
create_time, update_time
)
SELECT
CONCAT('tracebf', t.id),
t.from_user_name,
COALESCE(
NULLIF(REGEXP_SUBSTR(t.content, 'https://3\\.cn/[A-Za-z0-9\\-]+'), ''),
NULLIF(REGEXP_SUBSTR(t.content, 'http://3\\.cn/[A-Za-z0-9\\-]+'), ''),
NULLIF(REGEXP_SUBSTR(p.content, 'https://3\\.cn/[A-Za-z0-9\\-]+'), ''),
NULLIF(REGEXP_SUBSTR(p.content, 'http://3\\.cn/[A-Za-z0-9\\-]+'), '')
),
t.content,
t.from_user_name,
'IMPORTED',
0,
CONCAT('from_trace_id=', t.id, '|sql_batch'),
t.create_time,
t.create_time
FROM wecom_inbound_trace t
LEFT JOIN LATERAL (
SELECT p0.content
FROM wecom_inbound_trace p0
WHERE p0.from_user_name = t.from_user_name
AND p0.id < t.id
AND (p0.content LIKE '%https://3.cn/%' OR p0.content LIKE '%http://3.cn/%')
ORDER BY p0.id DESC
LIMIT 1
) AS p ON TRUE
WHERE t.reply_content LIKE '%已加入查询队列%'
AND COALESCE(
NULLIF(REGEXP_SUBSTR(t.content, 'https://3\\.cn/[A-Za-z0-9\\-]+'), ''),
NULLIF(REGEXP_SUBSTR(t.content, 'http://3\\.cn/[A-Za-z0-9\\-]+'), ''),
NULLIF(REGEXP_SUBSTR(p.content, 'https://3\\.cn/[A-Za-z0-9\\-]+'), ''),
NULLIF(REGEXP_SUBSTR(p.content, 'http://3\\.cn/[A-Za-z0-9\\-]+'), '')
) IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM wecom_share_link_logistics_job e WHERE e.job_key = CONCAT('tracebf', t.id)
);

View File

@@ -0,0 +1,7 @@
-- 若已执行过 wecom_share_link_logistics_job.sql 但无「从追踪补录」按钮,单独执行本文件。
-- menu_id 2096 若冲突请改未占用 IDparent_id 2094 为「企微分享链物流」菜单 ID若不同请改。
INSERT INTO sys_menu VALUES (
2096, '从追踪补录历史', 2094, 1, '#', '', '', '', 1, 0, 'F', '0', '0',
'jarvis:wecom:shareLinkLog:import', '#', 'admin', sysdate(), '', NULL, '从 wecom_inbound_trace 补录 IMPORTED 行'
);