WMS_MAIN/app/model/inbound_direct_log.js
liufumingren 478ad2ab0d 1
2026-07-03 16:10:46 +08:00

167 lines
4.0 KiB
JavaScript
Raw Permalink 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, INTEGER, BIGINT, ENUM, DATE } = app.Sequelize;
const InboundDirectLog = app.model.define('wms_inbound_direct_log', {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
comment: '主键ID',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID',
},
store_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '货主ID',
},
stock_id: {
type: BIGINT(20),
allowNull: false,
comment: '商品SKU ID,关联 wms_stock_warehouse.id',
},
quantity: {
type: INTEGER(12),
allowNull: false,
comment: '入库数量',
},
inbound_type: {
type: ENUM('import', 'pda'),
allowNull: false,
comment: '入库方式:import-导入入库 pda-PDA入库',
},
entry_order_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '关联入库单ID(可选),关联 wms_entry_order.id',
},
entry_order_code: {
type: STRING(50),
allowNull: true,
comment: '入库单号(冗余,方便查询)',
},
entry_item_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '入库明细ID',
},
receiving_detail_id: {
type: INTEGER,
allowNull: true,
comment: '收货明细ID,绑定收货时使用',
},
status: {
type: ENUM('pending', 'committed', 'released'),
allowNull: true,
comment: '绑定状态:pending=待提交 committed=已提交 released=已释放,非绑定模式为NULL',
},
remark: {
type: STRING(500),
allowNull: true,
comment: '备注(如导入文件名、PDA操作备注等)',
},
space_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
defaultValue: null,
comment: '存放库位ID,关联 wms_location_space.id',
},
operator_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '操作人ID',
},
operator_name: {
type: STRING(50),
allowNull: true,
comment: '操作人名称',
},
created_at: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
updated_at: {
type: DATE,
allowNull: true,
comment: '更新时间',
},
deleted_at: {
type: DATE,
allowNull: true,
comment: '软删除时间',
},
}, {
tableName: 'wms_inbound_direct_log',
comment: '非收货单途径入库直接记录表(导入/PDA入库)',
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
paranoid: true,
deletedAt: 'deleted_at',
indexes: [
{
name: 'idx_warehouse_id',
fields: [ 'warehouse_id' ],
},
{
name: 'idx_stock_id',
fields: [ 'stock_id' ],
},
{
name: 'idx_inbound_type',
fields: [ 'inbound_type' ],
},
{
name: 'idx_entry_order_id',
fields: [ 'entry_order_id' ],
},
{
name: 'idx_created_at',
fields: [ 'created_at' ],
},
{
name: 'idx_entry_item_id',
fields: [ 'entry_item_id' ],
},
{
name: 'idx_receiving_detail_id',
fields: [ 'receiving_detail_id' ],
},
{
name: 'idx_status',
fields: [ 'status' ],
},
{
name: 'uk_entry_receiving_binding',
unique: true,
fields: [ 'entry_item_id', 'receiving_detail_id', 'status' ],
},
],
});
// 关联关系
InboundDirectLog.associate = function() {
const { InboundDirectLog, EntryItems, ReceivingDetail } = app.model;
// 关联入库明细
InboundDirectLog.belongsTo(EntryItems, {
foreignKey: 'entry_item_id',
as: 'entryItem',
});
// 关联收货明细
InboundDirectLog.belongsTo(ReceivingDetail, {
foreignKey: 'receiving_detail_id',
as: 'receivingDetail',
});
};
return InboundDirectLog;
};