fix(panel): 拣货看板 top 分组 SQL 第一分支补今日任务窗口,消除 pto 全历史关联扫描(慢日志 1.75M 行/9.4s 超时)
This commit is contained in:
parent
3171ce4fab
commit
938e46e04c
@ -803,13 +803,19 @@ class WarehousePanelService extends Service {
|
|||||||
) x
|
) x
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
// 第一分支必须限定今日任务窗口(同 goodsSkuSelect):否则 pto 全历史关联订单分表,
|
||||||
|
// 派生子查询 g 物化扫描百万行(生产慢日志实测 1.75M 行 / 9.4s 超时)
|
||||||
|
const taskWindowWhereTp = taskWindowWhere.replace(/\bt\./g, 'tp.');
|
||||||
|
|
||||||
const topGoodsSkuSelect = tableName => `
|
const topGoodsSkuSelect = tableName => `
|
||||||
SELECT t.pick_user_id AS user_id, COALESCE(SUM(g.items_total), 0) AS goods, COALESCE(SUM(g.items_count), 0) AS sku
|
SELECT t.pick_user_id AS user_id, COALESCE(SUM(g.items_total), 0) AS goods, COALESCE(SUM(g.items_count), 0) AS sku
|
||||||
FROM wms_wave_pick_task t
|
FROM wms_wave_pick_task t
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT pto.task_id AS task_id, od.items_total, od.items_count
|
SELECT tp.id AS task_id, od.items_total, od.items_count
|
||||||
FROM wms_wave_pick_task_order pto
|
FROM wms_wave_pick_task tp
|
||||||
|
JOIN wms_wave_pick_task_order pto ON pto.task_id = tp.id
|
||||||
JOIN \`${tableName}\` od ON od.id = pto.order_id AND od.status != 'cancel'
|
JOIN \`${tableName}\` od ON od.id = pto.order_id AND od.status != 'cancel'
|
||||||
|
WHERE ${taskWindowWhereTp}
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT t2.id AS task_id, od2.items_total, od2.items_count
|
SELECT t2.id AS task_id, od2.items_total, od2.items_count
|
||||||
FROM wms_wave_pick_task t2
|
FROM wms_wave_pick_task t2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user