- 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 等)
104 lines
5.9 KiB
JavaScript
104 lines
5.9 KiB
JavaScript
'use strict';
|
||
/**
|
||
* 全表核对:A 两步链路(收货单 1526 / 入库单 383) vs B 一步直入(收货单 1528 / 入库单 385)
|
||
* 覆盖 A 链路涉及的所有表(收货单阶段 + 转入库单 + 导入入库 + 提交确认)。
|
||
* 只读,不产生数据。
|
||
*/
|
||
const mysql = require('mysql2/promise');
|
||
|
||
const A = { receiving: 1526, entryOrder: 383, code: 'SCRK202608240003', detailIds: [ 2711, 2712 ] };
|
||
const B = { receiving: 1528, entryOrder: 385, code: 'SCRK202608240005', detailIds: [ 2715, 2716 ] };
|
||
|
||
(async () => {
|
||
const conn = await mysql.createConnection({
|
||
host: '127.0.0.1', port: 3307, user: 'wms', password: 'dspxmRwRdRbWtbm7', database: 'wms',
|
||
});
|
||
|
||
const show = async (title, sql, params) => {
|
||
const [rows] = await conn.query(sql, params);
|
||
console.log(`\n===== ${title} =====`);
|
||
console.log(JSON.stringify(rows, null, 2));
|
||
};
|
||
|
||
for (const [ tag, t ] of [ [ 'A-两步', A ], [ 'B-一步', B ] ]) {
|
||
console.log(`\n########## ${tag}(receiving=${t.receiving}, entry_order=${t.entryOrder}) ##########`);
|
||
|
||
await show('1. wms_receiving 收货单主表', `
|
||
SELECT id, receiving_number, status, is_review, storage_status, detail_status, store_id, warehouse_id, total_items, total_quantity
|
||
FROM wms_receiving WHERE id = ?`, [ t.receiving ]);
|
||
|
||
await show('2. wms_receiving_detail 收货明细', `
|
||
SELECT id, receiving_id, system_product_id, actual_quantity, stored_quantity, storage_status,
|
||
space_id, batch_number, production_date, expiry_date, barcode, receiving_status
|
||
FROM wms_receiving_detail WHERE receiving_id = ? ORDER BY id`, [ t.receiving ]);
|
||
|
||
await show('3. wms_entry_order 入库单', `
|
||
SELECT id, entry_order_code, order_type, order_status, sync_status, sync_message, source_type,
|
||
total_order_lines, warehouse_id, store_id, store_name, warehouse_name, remark
|
||
FROM wms_entry_order WHERE id = ?`, [ t.entryOrder ]);
|
||
|
||
await show('4. wms_entry_items 入库明细', `
|
||
SELECT id, order_id, order_line_no, item_code, stock_id, count, received_quantity, confirm_quantity, inventory_type
|
||
FROM wms_entry_items WHERE order_id = ? ORDER BY order_line_no`, [ t.entryOrder ]);
|
||
|
||
await show('5. wms_entry_order_receiving 主表绑定', `
|
||
SELECT id, entry_order_id, receiving_id, created_at FROM wms_entry_order_receiving WHERE entry_order_id = ?`, [ t.entryOrder ]);
|
||
|
||
await show('6. wms_inbound_direct_log 导入入库记录(两步中间态)', `
|
||
SELECT id, entry_order_id, entry_order_code, stock_id, quantity, entry_item_id, receiving_detail_id, space_id, status, inbound_type, remark
|
||
FROM wms_inbound_direct_log WHERE entry_order_id = ? ORDER BY id`, [ t.entryOrder ]);
|
||
|
||
await show('7. wms_stock_warehouse 商品总库存', `
|
||
SELECT id, item_code, quantity, locked_quantity, is_valid FROM wms_stock_warehouse WHERE id IN (159061, 159064) ORDER BY id`);
|
||
|
||
await show('8. wms_storage 库位库存', `
|
||
SELECT id, space_id, stock_id, batch_no, inventory_type, quantity, locked_quantity, available_quantity,
|
||
inbound_order_no, receiving_id, entry_order_id, production_date, expiry_date, inbound_time
|
||
FROM wms_storage WHERE entry_order_id = ? OR (inbound_order_no = ? AND receiving_id = ?) ORDER BY id`,
|
||
[ t.entryOrder, t.code, t.receiving ]);
|
||
|
||
await show('9. wms_stock_transaction 商品流水', `
|
||
SELECT id, transaction_type, stock_id, quantity, before_quantity, after_quantity,
|
||
before_locked_quantity, after_locked_quantity, batch_no, order_type, order_no, receiving_id, entry_order_id, remark
|
||
FROM wms_stock_transaction WHERE order_no = ? OR entry_order_id = ? ORDER BY id`, [ t.code, t.entryOrder ]);
|
||
|
||
await show('10. wms_storage_transaction 库位流水', `
|
||
SELECT id, transaction_type, stock_id, storage_id, space_id, quantity, before_quantity, after_quantity,
|
||
before_locked_quantity, after_locked_quantity, batch_no, inventory_type, order_type, order_no, order_id
|
||
FROM wms_storage_transaction WHERE order_no = ? OR order_id = ? ORDER BY id`, [ t.code, t.entryOrder ]);
|
||
|
||
await show('11. wms_operation_log 本流程操作日志', `
|
||
SELECT id, business_type, business_id, operation_code, operator_name, warehouse_id, message
|
||
FROM wms_operation_log
|
||
WHERE business_id = ? AND operation_code IN
|
||
('RECEIVING_CREATE','RECEIVING_ADD_DETAIL','RECEIVING_BIND_PRODUCT','RECEIVING_COMPLETE','RECEIVING_REVIEW',
|
||
'ENTRY_ORDER_QUICK_PUTAWAY','DIRECT_INBOUND_ADD','DIRECT_INBOUND_COMMIT',
|
||
'ENTRY_ORDER_DIRECT_PUTAWAY','STORAGE_DIRECT_PUTAWAY','STOCK_DIRECT_PUTAWAY')
|
||
ORDER BY id`, [ String(t.entryOrder) ]);
|
||
|
||
await show('12. wms_operation_log 收货单维度操作日志', `
|
||
SELECT id, business_type, business_id, operation_code, operator_name, warehouse_id, message
|
||
FROM wms_operation_log WHERE business_id = ? ORDER BY id`, [ String(t.receiving) ]);
|
||
|
||
await show('13. wms_store_warehouse 货主签约与开关', `
|
||
SELECT id, store_id, warehouse_id, warehouse_use_status,
|
||
JSON_EXTRACT(policy_config, '$.allow_receiving_quick_putaway') AS quick,
|
||
JSON_EXTRACT(policy_config, '$.allow_receiving_direct_putaway') AS direct
|
||
FROM wms_store_warehouse WHERE store_id = 1000000 AND warehouse_id = 100000`);
|
||
|
||
await show('14. wms_stock_barcodes 本次绑定的条码', `
|
||
SELECT id, stock_id, warehouse_id, barcode
|
||
FROM wms_stock_barcodes
|
||
WHERE stock_id IN (159061, 159064)
|
||
AND barcode IN (SELECT barcode FROM wms_receiving_detail WHERE receiving_id = ?)
|
||
ORDER BY id`, [ t.receiving ]);
|
||
|
||
await show('15. wms_location_space 库位统计快照(入库链路不维护该统计)', `
|
||
SELECT id, space_code, current_quantity, current_sku_count, is_enabled
|
||
FROM wms_location_space WHERE id IN (5918, 5919)`);
|
||
}
|
||
|
||
await conn.end();
|
||
process.exit(0);
|
||
})().catch(e => { console.error(e); process.exit(1); });
|