WMS_MAIN/database/migrations/20260924150000-add-wave-scope-to-pack-task.js
liufumingren 4bf3268596 feat(workbench): 大团购打包系数与打包时长闸门,packOrder/queryOrder 响应新增 wave_scope 与倒计时字段
- 仓库设置新增 big_group_pack_coefficient(数字,默认 3,单位秒/单):store.js 默认值与归一化校验、setting.warehouse 字段元信息(type=number、min=0.1)

- workbench.queryOrder:响应 order 新增 wave_scope;当前工作台 wave_scope=1 打包任务未到「打包数x系数」秒时扫描其他波次订单返回「打包时长不足」,本波次放行,已到时不受限;闸门按 wms_pack_task.wave_scope=1 快捷判定

- workbench.packOrder:wms_pack_task 落库 wave_scope(服务端复查,非法/缺省兜底订单行值);响应新增 pack_wait_seconds(当前波次打包数x系数)与 pack_start_time(毫秒时间戳),仅 wave_scope=1 下发,其他为 0

- 迁移 20260924150000-add-wave-scope-to-pack-task.js:wms_pack_task 新增 wave_scope 列(幂等;开发与生产均已执行,生产因存在更早 pending 迁移改为等价 DDL+SequelizeMeta 记录)

- 测试:新增 workbench.bigGroupTimeGate.regression.test.js(11 用例全绿);workbench.queryOrder.performance.test.js 与基线一致(8 pass / 6 既有失败,非本次引入);ESLint 通过(workbench.js 历史类字段 parse error 为既有问题,与基线一致)

- 文档:methods/system.json 升至 0.3.181、changes 新增 2 条记录;已全量导入库表(wms_api_method_doc/wms_method_doc_meta)后重新导出,恢复 3 条库表已有但文件缺失的 setting.warehouse 前端配置方法
2026-09-24 03:16:35 +08:00

73 lines
2.4 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';
/**
* 打包任务表 wms_pack_task 增加 wave_scope(波次范围)字段。
*
* 取值约定(与 wms_order_delivery.wave_scope 一致):
* - 0 = 未分配波次
* - 1 = 大团购
* - 2 = 散单
* - 3 = 小团购
* - 4 = 单品单件
* 默认 0。
*
* 来源:workbench.packOrder 创建打包任务时落库,值由服务端复查
* (优先取打包上下文上报值,非法/缺省时兜底取订单行 wave_scope)。
*
* 幂等:列已存在则跳过。
*/
const TABLE_NAME = 'wms_pack_task';
const COLUMN_NAME = 'wave_scope';
/**
* 判断列是否已存在。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
* @param {string} tableName 表名。
* @param {string} columnName 列名。
* @return {Promise<boolean>} 是否存在。
*/
async function columnExists(queryInterface, tableName, columnName) {
const described = await queryInterface.describeTable(tableName);
return Boolean(described && described[columnName]);
}
module.exports = {
/**
* 执行迁移:为 wms_pack_task 增加 wave_scope 列。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
* @param {import('sequelize')} Sequelize Sequelize 构造器。
* @return {Promise<void>} 无返回值。
*/
async up(queryInterface, Sequelize) {
if (await columnExists(queryInterface, TABLE_NAME, COLUMN_NAME)) {
console.log('[20260924150000-add-wave-scope-to-pack-task] up: 列已存在,跳过');
return;
}
await queryInterface.addColumn(TABLE_NAME, COLUMN_NAME, {
type: Sequelize.TINYINT(4),
allowNull: false,
defaultValue: 0,
comment: '波次范围:0未分配波次 1大团购 2散单 3小团购 4单品单件',
});
console.log('[20260924150000-add-wave-scope-to-pack-task] up: 已为 wms_pack_task 添加 wave_scope 列');
},
/**
* 回滚迁移:移除 wms_pack_task 的 wave_scope 列。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
* @return {Promise<void>} 无返回值。
*/
async down(queryInterface) {
if (!await columnExists(queryInterface, TABLE_NAME, COLUMN_NAME)) {
console.log('[20260924150000-add-wave-scope-to-pack-task] down: 列不存在,跳过');
return;
}
await queryInterface.removeColumn(TABLE_NAME, COLUMN_NAME);
console.log('[20260924150000-add-wave-scope-to-pack-task] down: 已移除 wms_pack_task 的 wave_scope 列');
},
};