WMS_MAIN/script/tmp-verify-report-plan-2-preview.cjs
liufumingren c3f1c67592 chore(script): 沉淀波次池/报表/库存/订单本地排查脚本
新增一批一次性排查脚本(script/tmp-*.cjs),与仓库既有 script/tmp- 约定保持一致,
覆盖波次池边界与优先级核对、库位/出库报表核对、订单状态与更新范围核验等场景
2026-09-13 15:31:27 +08:00

78 lines
3.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';
/**
* 临时预演脚本(只读,不投递):按投递计划 id=2(store 1000000 / report_definition_id=3 /
* 时间点 19:40 → biz_date=2026-09-09)的参数,走报表引擎 buildWorkbookSheets 生成工作簿,
* 检查「库内确定拦截订单明细」投递结果是否与预期一致(行数 / 表头 / 抽样单元格)。
*
* 不做任何数据库写操作,不上传文件(用 generateBuffer)。
* 运行:node script/tmp-verify-report-plan-2-preview.cjs
*/
const path = require('node:path');
const mm = require('egg-mock');
const projectRoot = path.resolve(__dirname, '..');
const STORE_ID = 1000000;
const WAREHOUSE_ID = 100000;
const REPORT_ID = 3;
const BIZ_DATE = '2026-09-09';
(async () => {
mm.env('local');
const app = mm.app({ baseDir: projectRoot });
await app.ready();
const ctx = app.createAnonymousContext();
ctx.user = { store_id: WAREHOUSE_ID, role: 1, id: 1, name: 'preview', employees_id: 1, employees_name: 'preview' };
try {
// 1) 查询器口径(含 storeId 过滤)
const querier = require(path.join(projectRoot, 'app/service/systems/report/queries/interceptOrder.js'));
const queryData = await querier({
ctx,
storeId: STORE_ID,
warehouseId: WAREHOUSE_ID,
params: { bizDate: BIZ_DATE },
});
console.log('[查询器] meta=' + JSON.stringify(queryData.meta));
console.log('[查询器] rows=' + queryData.rows.length);
for (const row of queryData.rows.slice(0, 5)) {
console.log(' ' + JSON.stringify({
id: row.id,
delivery_order_code: row.delivery_order_code,
intercept_notice_time: row.intercept_notice_time,
intercept_confirm_time: row.intercept_confirm_time,
waybill_code: row.waybill_code,
item_quantity: row.item_quantity,
}));
}
// 2) 报表引擎(按报表定义 id=3 的勾选字段渲染工作簿)
const workbook = await ctx.service.systems.report.buildWorkbookSheets({
reportId: REPORT_ID,
storeId: STORE_ID,
warehouseId: WAREHOUSE_ID,
params: { bizDate: BIZ_DATE },
});
const sheet = workbook.sheets[0];
console.log('[工作簿] filename=' + workbook.filename);
console.log('[工作簿] sheet=' + sheet.name + ' 表头列数=' + (sheet.rows[0] || []).length + ' 总行数=' + sheet.rows.length);
console.log('[工作簿] 表头=' + JSON.stringify(sheet.rows[0]));
for (const row of sheet.rows.slice(1, 6)) {
console.log('[工作簿] 数据行=' + JSON.stringify(row));
}
// 3) 结论
const dataRows = Math.max(0, sheet.rows.length - 1);
console.log(
dataRows > 0
? `\n预演结果:投递将包含 ${dataRows} 行数据(订单 ${queryData.meta.orderCount} 单)`
: '\n预演结果:投递将为空表(0 行),需要检查统计窗口与 dispath_time 数据'
);
} finally {
await app.close();
}
})().catch(error => {
console.error('预演执行异常:', error && error.stack ? error.stack : error);
process.exit(1);
});