新增一批一次性排查脚本(script/tmp-*.cjs),与仓库既有 script/tmp- 约定保持一致, 覆盖波次池边界与优先级核对、库位/出库报表核对、订单状态与更新范围核验等场景
86 lines
2.7 KiB
JavaScript
86 lines
2.7 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 排查联调问题:
|
||
* 1. 历史成功订单(122442)使用的商品 stock_id(可用于选一个能完整走通的商品);
|
||
* 2. 订单 122546 储位分配失败原因;
|
||
* 3. 商品 159063 的库位库存分布。
|
||
*
|
||
* @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 [ historyItems ] = await connection.query(
|
||
`SELECT order_id, item_id, stock_id, item_name, plan_qty
|
||
FROM wms_order_items_100000
|
||
WHERE order_id IN (122442, 122546)
|
||
ORDER BY order_id ASC`
|
||
);
|
||
console.log('===== 历史成功订单/联调订单明细 =====');
|
||
console.log(JSON.stringify(historyItems));
|
||
|
||
const [ logColumns ] = await connection.query(
|
||
`SHOW COLUMNS FROM wms_operation_log`
|
||
);
|
||
console.log('===== wms_operation_log 列 =====');
|
||
console.log(JSON.stringify(logColumns.map(item => item.Field)));
|
||
|
||
const [ failLogs ] = await connection.query(
|
||
`SELECT business_id, operation_code, message
|
||
FROM wms_operation_log
|
||
WHERE business_id IN ('122546', '122547') AND operation_code LIKE '%STORAGE%'
|
||
ORDER BY id DESC
|
||
LIMIT 10`
|
||
);
|
||
console.log('===== 储位分配相关日志 =====');
|
||
console.log(JSON.stringify(failLogs));
|
||
|
||
const [ stockWarehouseRows ] = await connection.query(
|
||
`SELECT id, store_id, quantity, locked_quantity, prohibited_id, is_valid, deleted_at
|
||
FROM wms_stock_warehouse WHERE id = 101397`
|
||
);
|
||
console.log('===== 商品101397 主表 =====');
|
||
console.log(JSON.stringify(stockWarehouseRows));
|
||
|
||
const [ stockLocationRows ] = await connection.query(
|
||
`SELECT id, stock_id, location_id, qty
|
||
FROM wms_stock_location WHERE stock_id = 101397 LIMIT 10`
|
||
);
|
||
console.log('===== 商品101397 库位库存 =====');
|
||
console.log(JSON.stringify(stockLocationRows));
|
||
|
||
const [ storageAllocRows ] = await connection.query(
|
||
`SELECT * FROM wms_order_storage_allocation
|
||
WHERE order_id IN (122546, 122547)
|
||
ORDER BY id DESC
|
||
LIMIT 10`
|
||
);
|
||
console.log('===== 122546/122547 储位分配记录 =====');
|
||
console.log(JSON.stringify(storageAllocRows));
|
||
|
||
const [ storageTables ] = await connection.query(
|
||
`SHOW TABLES LIKE '%storage%'`
|
||
);
|
||
console.log('===== storage 相关表 =====');
|
||
console.log(JSON.stringify(storageTables));
|
||
} finally {
|
||
await connection.end();
|
||
}
|
||
}
|
||
|
||
main().catch(error => {
|
||
console.error(`查询失败: ${error.message}`);
|
||
process.exit(1);
|
||
});
|