WMS_MAIN/app/model/pack_task.js
liufumingren 5b3180ff34 feat(workbench): 新增工作台/打包台模块 (workbench/pack_task)
- 新增 model: workbench, pack_task, pack_task_packer

- 新增 systemMethods: workbench (finishPack/sendWeight/操作日志)

- systems/workbench 扩展: 波次订单ID获取、打包操作日志白名单

- 10 条迁移: 建表→扩展→权限→重构
2026-07-27 03:46:37 +08:00

165 lines
4.0 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';
module.exports = app => {
const { STRING, BIGINT, INTEGER, DATE, TINYINT, TEXT, JSON: JSON_TYPE } = app.Sequelize;
const PackTask = app.model.define('pack_task', {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
comment: '主键ID',
},
order_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '订单ID',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
defaultValue: 0,
comment: '仓库ID',
},
workbench_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '工作台ID,关联 wms_workbench.id',
},
wave_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
defaultValue: 0,
comment: '波次ID',
},
wave_no: {
type: STRING(50),
allowNull: true,
comment: '波次号',
},
waybill_code: {
type: STRING(50),
allowNull: true,
comment: '运单号',
},
pack_quantity: {
type: INTEGER.UNSIGNED,
allowNull: true,
defaultValue: 0,
comment: '打包数量(件数)',
},
item_quantity: {
type: INTEGER.UNSIGNED,
allowNull: true,
defaultValue: 0,
comment: '商品总数量',
},
sku_count: {
type: INTEGER.UNSIGNED,
allowNull: true,
defaultValue: 0,
comment: '商品种类数(SKU数)',
},
pack_mode: {
type: TINYINT.UNSIGNED,
allowNull: false,
defaultValue: 1,
comment: '打包模式:1=散单 2=团购',
},
status: {
type: TINYINT.UNSIGNED,
allowNull: false,
defaultValue: 0,
comment: '任务状态:0=待处理 1=打包中 2=已完成 3=异常',
},
start_time: {
type: DATE,
allowNull: true,
comment: '开始打包时间',
},
end_time: {
type: DATE,
allowNull: true,
comment: '结束打包时间',
},
operator_text: {
type: TEXT,
allowNull: true,
comment: '作业人员(自由文本,如多人逗号分隔)',
},
device_ids: {
type: JSON_TYPE,
allowNull: true,
comment: '设备ID列表,如 [1,2,3]',
},
remark: {
type: STRING(500),
allowNull: true,
comment: '备注',
},
meta: {
type: JSON_TYPE,
allowNull: true,
comment: '扩展信息JSON',
},
create_time: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
update_time: {
type: DATE,
allowNull: false,
comment: '更新时间',
},
deleted_at: {
type: DATE,
allowNull: true,
comment: '删除时间',
},
}, {
tableName: 'wms_pack_task',
timestamps: true,
createdAt: 'create_time',
updatedAt: 'update_time',
paranoid: true,
deletedAt: 'deleted_at',
comment: '打包任务表(含作业记录)',
indexes: [
{ name: 'idx_order_id', fields: [ 'order_id' ] },
{ name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] },
{ name: 'idx_workbench_id', fields: [ 'workbench_id' ] },
{ name: 'idx_wave_id', fields: [ 'wave_id' ] },
{ name: 'idx_waybill_code', fields: [ 'waybill_code' ] },
{ name: 'idx_pack_mode_status', fields: [ 'pack_mode', 'status' ] },
{ name: 'idx_start_time', fields: [ 'start_time' ] },
{ name: 'idx_status', fields: [ 'status' ] },
],
});
PackTask.associate = () => {
app.model.PackTask.belongsTo(app.model.Workbench, {
foreignKey: 'workbench_id',
targetKey: 'id',
as: 'workbench',
});
app.model.PackTask.hasMany(app.model.PackTaskVideo, {
foreignKey: 'pack_task_id',
sourceKey: 'id',
as: 'videos',
});
app.model.PackTask.hasMany(app.model.PackTaskPacker, {
foreignKey: 'pack_task_id',
sourceKey: 'id',
as: 'packers',
});
app.model.PackTask.hasMany(app.model.OrderExpress, {
foreignKey: 'order_id',
sourceKey: 'order_id',
as: 'expresses',
});
};
return PackTask;
};