WMS_MAIN/script/tmp-check-storage-stock.cjs
liufumingren 3352fbaff6 test(storage): directPutaway 与 quickPutaway 链路对比测试脚本
- tmp-test-putaway-full-compare.cjs:全链路真实接口对比(A 两步 quickPutaway→addItem→commit / B 一步 directPutaway),支持 A|B 参数单独跑
- tmp-test-putaway-batch-compare.cjs:批次维度对比(不同批次建行 / 同批次累加)
- tmp-verify-all-tables.cjs:15 张表逐表核对输出
- tmp-check-*:条码、请求日志、通知失败表、权限、库存行/流水等定点核对
- tmp-clear-user-cache.cjs:清 Redis 用户缓存(权限变更后刷新)
- 测试数据保留不清理(收货单 1521-1535、入库单 381-392 等)
2026-08-24 03:23:23 +08:00

42 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const mysql = require('mysql2/promise');
(async () => {
const c = await mysql.createConnection({ host: '127.0.0.1', port: 3307, user: 'wms', password: 'dspxmRwRdRbWtbm7', database: 'wms' });
// 1. wms_storage 当前状态(A/B 共用的累加行)
const [storages] = await c.query(`
SELECT id, space_id, stock_id, batch_no, quantity, locked_quantity, available_quantity,
inbound_order_no, receiving_id, entry_order_id, inbound_time
FROM wms_storage WHERE id IN (408, 409)`);
console.log('== wms_storage 当前行(408/409) ==');
console.log(JSON.stringify(storages, null, 2));
// 2. wms_stock_warehouse 当前数量
const [stocks] = await c.query(`
SELECT id, item_code, quantity, locked_quantity, is_valid
FROM wms_stock_warehouse WHERE id IN (159061, 159064)`);
console.log('== wms_stock_warehouse 当前数量 ==');
console.log(JSON.stringify(stocks, null, 2));
// 3. A(入库单 387)与 B(入库单 388)各自的库位流水(证明 storage 写入)
const [storageTxns] = await c.query(`
SELECT order_no, transaction_type, stock_id, storage_id, space_id, quantity, before_quantity, after_quantity, batch_no
FROM wms_storage_transaction
WHERE order_id IN (387, 388) OR order_no IN ('SCRK202608240007','SCRK202608240008')
ORDER BY id`);
console.log('== wms_storage_transaction:A(387)/B(388) 的库位流水 ==');
console.log(JSON.stringify(storageTxns, null, 2));
// 4. A/B 各自的商品流水(证明 stock_warehouse 数量变更)
const [stockTxns] = await c.query(`
SELECT order_no, transaction_type, stock_id, quantity, before_quantity, after_quantity, entry_order_id
FROM wms_stock_transaction
WHERE entry_order_id IN (387, 388) OR order_no IN ('SCRK202608240007','SCRK202608240008')
ORDER BY id`);
console.log('== wms_stock_transaction:A(387)/B(388) 的商品流水 ==');
console.log(JSON.stringify(stockTxns, null, 2));
await c.end();
process.exit(0);
})().catch(e => { console.error(e); process.exit(1); });