liufumingren 2597faac4c feat(report): stockFlow 报表 9 列新顺序重构与投递货主隔离修复
1) 报表导出列重构为 9 组列(产品名称/条码/外部编码/每日出入库/待处理订单占用数/可用库存/7日总出库数量/推荐采购量/是否触发预警),外部编码 stock_store 优先 fallback,新增 pending_occupy 取仓库主表锁定数量;2) 投递货主隔离修复(上传目录按货主/仓库隔离、投递与通知幂等键含 storeId、processOne 货主维度强校验);3) 文档与 methods 变更记录同步。
2026-09-01 00:42:30 +08:00

58 lines
2.3 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 sevenDayStockFlow = require('./sevenDayStockFlow');
/**
* 报表内置查询器注册表。
* key 对应 wms_report_definition.type;
* 新增查询器时在此登记,签名统一为
* async ({ ctx, storeId, warehouseId, params }) => ({ windows, rows, meta })。
* 每个查询器需在模块上挂载静态字段清单 `fields`(如 module.exports.fields)
* 与缺省窗口参数 `defaultWindow`,供报表引擎 report.definition.typeList 读取。
* 注意:该对象会作为 service 模块导出,egg 加载器需要在其上挂载
* `Symbol(EGG_LOADER_ITEM_FULLPATH)` 等内部符号,因此禁止对导出对象使用
* Object.freeze / Object.seal / Object.preventExtensions。
* @type {Object<string, Function>}
*/
const QUERIES = {
stockFlow: sevenDayStockFlow,
};
/**
* 注册表描述元数据:key/title/description/window/fields。
* @type {Array<{key: string, title: string, description: string, window: Object, fields: Array<Object>}>}
*/
const DESCRIPTIONS = [
{
key: 'stockFlow',
title: '库存变化以及补货报表',
description: '按日窗口聚合出入库流水与正品库存,输出每 SKU 每日出/入库、外部编码、'
+ '待处理订单占用数、可用库存、7日总出库数量、推荐采购量与是否触发预警',
window: {
...(sevenDayStockFlow.defaultWindow || { dayCount: 7, cutoverHour: 7 }),
},
fields: (Array.isArray(sevenDayStockFlow.fields) ? sevenDayStockFlow.fields : []).map(field => ({ ...field })),
},
];
/**
* 输出注册表可读描述(含全量字段清单),供 report.definition.typeList 复用。
* 返回副本,避免调用方误改注册表元数据。
* @return {Array<{key: string, title: string, description: string, window: Object, fields: Array<Object>}>} 注册描述列表
*/
function describe() {
return DESCRIPTIONS.map(entry => ({
...entry,
window: { ...(entry.window || {}) },
fields: (Array.isArray(entry.fields) ? entry.fields : []).map(field => ({
...field,
children: Array.isArray(field.children) ? field.children.map(child => ({ ...child })) : undefined,
})),
}));
}
// egg 加载器要求导出对象可扩展,describe 作为方法属性挂在 QUERIES 上
QUERIES.describe = describe;
module.exports = QUERIES;