WMS_MAIN/script/tmp-explore-putaway-test-data.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

59 lines
2.5 KiB
JavaScript

'use strict';
/* 临时探索脚本:查询直入/转入库单对比测试所需数据(只读) */
const mysql = require('mysql2/promise');
(async () => {
const conn = await mysql.createConnection({
host: '127.0.0.1', port: 3307, user: 'wms', password: 'dspxmRwRdRbWtbm7', database: 'wms',
});
const [cols] = await conn.query('SHOW COLUMNS FROM wms_employee_role');
console.log('== wms_employee_role columns ==');
console.log(cols.map(c => c.Field).join(','));
const [whUsers] = await conn.query(`
SELECT a.id account_id, a.username, a.status, e.id employee_id, e.store_id warehouse_id, r.id role_id, r.role_type
FROM wms_account a
JOIN wms_account_store_employee e ON e.account_id = a.id AND e.deleted_at IS NULL
LEFT JOIN wms_employee_role er ON er.employee_id = e.id
LEFT JOIN wms_role r ON r.id = er.role_id
WHERE a.status = 1
ORDER BY e.id ASC LIMIT 8`);
console.log('== accounts ==');
console.log(JSON.stringify(whUsers, null, 2));
if (whUsers.length === 0) { await conn.end(); return; }
const whId = whUsers[0].warehouse_id;
console.log('== using warehouse_id = ' + whId + ' ==');
const [stores] = await conn.query(`
SELECT sw.store_id, sw.warehouse_use_status, sw.policy_config, s.company_name
FROM wms_store_warehouse sw JOIN wms_store s ON s.id = sw.store_id
WHERE sw.warehouse_id = ? AND sw.warehouse_use_status = 1
ORDER BY sw.id DESC LIMIT 5`, [ whId ]);
console.log('== store_warehouse contracts (warehouse=' + whId + ') ==');
console.log(JSON.stringify(stores, null, 2));
const [stocks] = await conn.query(`
SELECT sw.id, sw.item_code, sw.item_name, sw.is_batch_mgmt, sw.is_shelf_life_mgmt, sw.is_valid, sw.quantity, sw.store_id
FROM wms_stock_warehouse sw
WHERE sw.warehouse_id = ? AND sw.is_valid = 'Y' AND sw.deleted_at IS NULL
ORDER BY sw.id DESC LIMIT 8`, [ whId ]);
console.log('== stock_warehouse products ==');
console.log(JSON.stringify(stocks, null, 2));
const [spacesCols] = await conn.query('SHOW COLUMNS FROM wms_location_space');
console.log('== wms_location_space columns ==');
console.log(spacesCols.map(c => c.Field).join(','));
const [spaces] = await conn.query(`
SELECT id, space_code, custom_name, is_enabled, current_quantity
FROM wms_location_space
WHERE warehouse_id = ? AND is_enabled = 1 AND deleted_at IS NULL
ORDER BY id LIMIT 8`, [ whId ]);
console.log('== location spaces ==');
console.log(JSON.stringify(spaces, null, 2));
await conn.end();
})().catch(e => { console.error(e); process.exit(1); });