WMS_MAIN/database/migrations/20260908120000-add-recheck-start-time-to-wms-wave-batch.js
liufumingren 68dbf65c77 feat: 波次复核开始时间回写与统计/防覆盖修复
- 波次策略列表 order.wave.waveStrategyList 成功响应新增 info.order_count(当前查询条件下全部策略命中订单去重总数,新增 getWaveStrategyMatchedOrderCountTotal,与行级统计同口径,统计失败安全降级为 0)

- 拣货任务 wms_wave_pick_task.finish_time 防覆盖:两处写入改为 CASE WHEN finish_time IS NULL,只记第一次

- 波次复核开始时间:新增迁移 20260908120000(wms_wave_batch 新增 recheck_start_time 字段,已在开发/生产执行)、模型字段同步、scanOrder 各成功分支首次回写(新增 markWaveRecheckStart,仅 IS NULL 时写入,回写失败不影响扫描主流程)

- 同步 methods/system.json 与 methods/changes/system.json 接口文档及变更记录(docMeta.version 更新至 0.3.101)

- 新增 recheckOrder-scanOrder-recheckStartTime HTTP 行为验证脚本与验证报告
2026-09-08 16:36:57 +08:00

72 lines
2.7 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_wave_batch 增加复核开始时间字段。
*
* 背景:
* 复核扫描接口 order.recheckOrder.scanOrder 首次成功加载某波次的复核视图时,
* 需要记录该波次的复核开始时间用于统计与审计;此前波次表仅有复核完成时间
* (check_time,校验时间),缺少复核开始时间,二者语义不同不可复用。
*
* 变更:
* 1. wms_wave_batch 新增 recheck_start_time:DATETIME,可空、无默认值,复核开始时间。
* 2. 不回填任何历史数据(对既有数据零影响,仅后续首次扫描时写入)。
* 3. 模型定义同步更新(app/model/wave_batch.js)。
*
* 幂等:字段已存在则跳过;回滚时字段不存在则跳过。
*/
const TABLE_NAME = 'wms_wave_batch';
const COLUMN_NAME = 'recheck_start_time';
const FILE_TAG = '[20260908120000-add-recheck-start-time-to-wms-wave-batch]';
/**
* 获取表字段定义。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
* @param {string} tableName 表名。
* @return {Promise<Object>} 字段定义对象。
*/
const getTableColumns = async (queryInterface, tableName) => {
return queryInterface.describeTable(tableName);
};
module.exports = {
/**
* 正向迁移:为波次表补充复核开始时间字段(字段已存在则跳过)。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
* @param {typeof import('sequelize')} Sequelize Sequelize 类型集合。
* @return {Promise<void>} 无返回值。
*/
up: async (queryInterface, Sequelize) => {
const columnsBefore = await getTableColumns(queryInterface, TABLE_NAME);
if (!columnsBefore[COLUMN_NAME]) {
await queryInterface.addColumn(TABLE_NAME, COLUMN_NAME, {
type: Sequelize.DATE,
allowNull: true,
comment: '复核开始时间',
after: 'check_result',
});
console.log(`${FILE_TAG} up: added column ${COLUMN_NAME} on ${TABLE_NAME}`);
} else {
console.log(`${FILE_TAG} up: skip, column ${COLUMN_NAME} already exists on ${TABLE_NAME}`);
}
},
/**
* 回滚迁移:若复核开始时间字段存在则删除。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
* @return {Promise<void>} 无返回值。
*/
down: async queryInterface => {
const columnsBefore = await getTableColumns(queryInterface, TABLE_NAME);
if (columnsBefore[COLUMN_NAME]) {
await queryInterface.removeColumn(TABLE_NAME, COLUMN_NAME);
console.log(`${FILE_TAG} down: removed column ${COLUMN_NAME} on ${TABLE_NAME}`);
} else {
console.log(`${FILE_TAG} down: skip, column ${COLUMN_NAME} not exists on ${TABLE_NAME}`);
}
},
};