新增一批一次性排查脚本(script/tmp-*.cjs),与仓库既有 script/tmp- 约定保持一致, 覆盖波次池边界与优先级核对、库位/出库报表核对、订单状态与更新范围核验等场景
79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* 复现 getWaveStrategyFetchCandidateOrders 的第一池查询,
|
|
* 验证 createdBefore='2026-09-06 00:00:00' 时 8 条今日前订单是否被命中。
|
|
*
|
|
* @return {Promise<void>}
|
|
*/
|
|
|
|
const mysql = require('mysql2/promise');
|
|
|
|
async function main() {
|
|
const connection = await mysql.createConnection({
|
|
host: '127.0.0.1',
|
|
port: 3307,
|
|
user: 'wms',
|
|
password: 'dspxmRwRdRbWtbm7',
|
|
database: 'wms',
|
|
});
|
|
|
|
try {
|
|
const warehouseId = 100000;
|
|
const createdBefore = new Date(2026, 8, 6, 0, 0, 0);
|
|
const minSameStructure = 2;
|
|
const maxSameStructure = 999;
|
|
const [ rows ] = await connection.query(
|
|
`SELECT o.id, o.items_hash
|
|
FROM wms_order_wave_strategy_match m
|
|
INNER JOIN wms_order_delivery_100000 o
|
|
ON o.id = m.order_id
|
|
AND o.warehouse_id = ?
|
|
AND o.wave_id = 0
|
|
AND o.step != 0
|
|
AND o.post_status = 'fin'
|
|
AND o.storage_status = 'fin'
|
|
AND o.print_status != 'fin'
|
|
AND o.status != 'cancel'
|
|
AND o.outbound_status != 'padding'
|
|
AND o.intercept_status = 'none'
|
|
AND o.lock_status = 'none'
|
|
AND (? IS NULL OR o.create_at < ?)
|
|
INNER JOIN (
|
|
SELECT
|
|
src.items_hash AS structure_key,
|
|
COUNT(1) AS same_structure_count
|
|
FROM wms_order_delivery_100000 src
|
|
WHERE src.warehouse_id = ?
|
|
AND src.wave_id = 0
|
|
AND src.step != 0
|
|
AND src.post_status = 'fin'
|
|
AND src.storage_status = 'fin'
|
|
AND src.print_status != 'fin'
|
|
AND src.status != 'cancel'
|
|
AND src.outbound_status != 'padding'
|
|
AND src.intercept_status = 'none'
|
|
AND src.lock_status = 'none'
|
|
GROUP BY src.items_hash
|
|
) same_structure
|
|
ON same_structure.structure_key = o.items_hash
|
|
WHERE m.warehouse_id = ?
|
|
AND m.strategy_id = 7
|
|
AND same_structure.same_structure_count >= ?
|
|
AND (? IS NULL OR same_structure.same_structure_count <= ?)
|
|
ORDER BY o.id ASC`,
|
|
[ warehouseId, createdBefore, createdBefore, warehouseId, warehouseId, minSameStructure, maxSameStructure, maxSameStructure ]
|
|
);
|
|
|
|
console.log(`第一池(createdBefore=2026-09-06 00:00)命中数: ${rows.length}`);
|
|
console.log(JSON.stringify(rows.slice(0, 30)));
|
|
} finally {
|
|
await connection.end();
|
|
}
|
|
}
|
|
|
|
main().catch(error => {
|
|
console.error(`查询失败: ${error.message}`);
|
|
process.exit(1);
|
|
});
|