WMS_MAIN/database/migrations/20261005110000-add-title-and-seed-history-receiving-task.js
liufumingren 6ac3441109 feat: 收件任务体系(return_received_task)与退回权限调整
- 新增收件任务表 wms_return_received_task(自增 id 从 10000 起、批次号服务端自动生成 RT+日期+序号)
- 系统预设 id=1 历史收件;收件登记 wms_return_received 增加 return_received_task_id(缓存校验,未命中穿透建缓存)
- 任务接口:create/list/batchDelete/delete(有登记不可删、跨仓保护、has_register 筛选、register_count 统计)
- 移除 returnwaybill/returnReceived/returnUnpack 页面权限及角色组引用;权限标题「运单退回登记」改「未退登记」
2026-10-06 03:24:36 +08:00

49 lines
1.6 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';
/**
* 收件任务表补「标题」字段,并播种系统预设行(幂等)。
*
* - addColumn title(标题,NOT NULL 默认空串)
* - 幂等插入系统预设:id=1、warehouse_id=0、title='历史收件',
* 用于处理历史(旧流程)收货任务;batch_no 同步填 '历史收件',creator_id=0(系统)。
*
* 显式插入 id=1 不会影响 AUTO_INCREMENT=10000 的水位(1 < 10000)。
*/
const TABLE_NAME = 'wms_receiving_task';
module.exports = {
async up(queryInterface, Sequelize) {
const { STRING } = Sequelize;
const tableInfo = await queryInterface.describeTable(TABLE_NAME);
if (!tableInfo.title) {
await queryInterface.addColumn(TABLE_NAME, 'title', {
type: STRING(100),
allowNull: false,
defaultValue: '',
comment: '标题(任务名称,如系统预设「历史收件」)',
});
}
const { sequelize } = queryInterface;
const [ rows ] = await sequelize.query(
'SELECT id FROM `' + TABLE_NAME + '` WHERE id = 1 LIMIT 1'
);
if (!rows || rows.length === 0) {
await sequelize.query(
'INSERT INTO `' + TABLE_NAME + '` (id, batch_no, warehouse_id, creator_id, creator_name, title, created_at, updated_at) VALUES (1, :b, 0, 0, :c, :t, NOW(), NOW())',
{ replacements: { b: '历史收件', c: '系统', t: '历史收件' } }
);
}
},
async down(queryInterface) {
const { sequelize } = queryInterface;
await sequelize.query(
'DELETE FROM `' + TABLE_NAME + '` WHERE id = 1 AND warehouse_id = 0'
);
await queryInterface.removeColumn(TABLE_NAME, 'title');
},
};