- systems/storage/inventory.js#directPutaway:一步写库存并生成入库单(SCRK,直接 COMPLETED) - 入库单明细与收货明细一一对应(不合并),按收货明细库位 space_id 入库,批次/效期取收货明细 - 悲观行锁更新 wms_stock_warehouse 总库存 + 写 wms_storage 库位库存(同键累加) - 全量日志:wms_stock_transaction(SCRK)+ wms_storage_transaction(entry_order)+ wms_inbound_direct_log(committed)+ 操作日志(entry_order/storage/stock 三维度) - 收货单锁定防重、重复直入 400 拒绝 - systemMethods/storage/inventory.js:注册 directPutaway 入口(_noNeedAuth) - store_warehouse.js:POLICY_CONFIG_FIELDS 白名单新增 allow_receiving_direct_putaway 开关(修复 getter sanitize 过滤导致开关读不到) - database/migrations/20260824-add-direct-putaway-permission.js:新增 API 权限记录(幂等,含 down) - methods/system.json / methods/changes/system.json:接口文档与变更记录 与 quickPutaway(转入库单)并存:转单链路为 quickPutaway→entry.addItem→entry.commit; 直入为 directPutaway 一步完成。两链路开发环境真实接口全量对比(15+ 表)一致。
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 新增 storage.inventory.directPutaway(收货单直入库存)API 权限记录。
|
||
*
|
||
* 幂等设计:先查询 path + type='api' 是否已存在,已存在则跳过。
|
||
*/
|
||
|
||
const TABLE = 'wms_permission';
|
||
|
||
module.exports.up = async queryInterface => {
|
||
const permissions = [
|
||
{ path: 'storage.inventory.directPutaway', meta_title: '收货单直入库存' },
|
||
];
|
||
|
||
const paths = permissions.map(p => p.path);
|
||
const placeholders = paths.map(() => '?').join(', ');
|
||
const [ rows ] = await queryInterface.sequelize.query(
|
||
`SELECT path FROM \`${TABLE}\` WHERE type = 'api' AND path IN (${placeholders})`,
|
||
{ replacements: paths }
|
||
);
|
||
const existingPaths = new Set(rows.map(r => r.path));
|
||
|
||
const toInsert = permissions.filter(p => !existingPaths.has(p.path));
|
||
|
||
if (toInsert.length > 0) {
|
||
const values = toInsert
|
||
.map(
|
||
p => `('${p.path.replace(/'/g, "\\'")}', '${p.path.replace(/'/g, "\\'")}', '${p.meta_title.replace(/'/g, "\\'")}', 'api', 1, NOW(), NOW())`
|
||
)
|
||
.join(',\n');
|
||
|
||
await queryInterface.sequelize.query(`
|
||
INSERT INTO \`${TABLE}\` (path, name, meta_title, type, status, created_at, update_at)
|
||
VALUES ${values}
|
||
`);
|
||
}
|
||
|
||
console.log(
|
||
`[Migration] wms_permission API 权限新增:共 ${permissions.length} 条,` +
|
||
`已存在 ${permissions.length - toInsert.length} 条,实际插入 ${toInsert.length} 条`
|
||
);
|
||
};
|
||
|
||
module.exports.down = async queryInterface => {
|
||
const paths = [ 'storage.inventory.directPutaway' ];
|
||
const placeholders = paths.map(() => '?').join(', ');
|
||
await queryInterface.sequelize.query(
|
||
`DELETE FROM \`${TABLE}\` WHERE type = 'api' AND path IN (${placeholders})`,
|
||
{ replacements: paths }
|
||
);
|
||
};
|