181 lines
4.7 KiB
JavaScript
181 lines
4.7 KiB
JavaScript
'use strict';
|
||
|
||
module.exports = app => {
|
||
const { BIGINT, STRING, JSON, ENUM, TEXT, DATE, INTEGER } = app.Sequelize;
|
||
const PrintRecord = app.model.define('PrintRecord', {
|
||
id: {
|
||
type: BIGINT.UNSIGNED,
|
||
autoIncrement: true,
|
||
primaryKey: true,
|
||
comment: '主键ID',
|
||
},
|
||
warehouse_id: {
|
||
type: BIGINT.UNSIGNED,
|
||
allowNull: false,
|
||
comment: '仓库ID',
|
||
},
|
||
computer_id: {
|
||
type: BIGINT.UNSIGNED,
|
||
allowNull: false,
|
||
comment: '电脑ID',
|
||
},
|
||
printer: {
|
||
type: STRING(100),
|
||
allowNull: false,
|
||
comment: '打印机名称/标识',
|
||
},
|
||
type: {
|
||
type: STRING(50),
|
||
allowNull: false,
|
||
comment: '打印类型',
|
||
},
|
||
data: {
|
||
type: JSON,
|
||
allowNull: true,
|
||
comment: '打印数据(JSON格式)',
|
||
},
|
||
status: {
|
||
type: ENUM('pending', 'sent', 'success', 'failed'),
|
||
allowNull: false,
|
||
defaultValue: 'pending',
|
||
comment: '打印状态:pending-待发送,sent-已发送,success-打印成功,failed-打印失败',
|
||
},
|
||
send_status: {
|
||
type: STRING(32),
|
||
allowNull: false,
|
||
defaultValue: 'pending',
|
||
comment: '发送状态',
|
||
},
|
||
print_status: {
|
||
type: STRING(32),
|
||
allowNull: false,
|
||
defaultValue: 'unknown',
|
||
comment: '打印状态',
|
||
},
|
||
retry_count: {
|
||
type: INTEGER,
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '已重试次数',
|
||
},
|
||
max_retry_count: {
|
||
type: INTEGER,
|
||
allowNull: false,
|
||
defaultValue: 3,
|
||
comment: '最大重试次数',
|
||
},
|
||
next_retry_at: {
|
||
type: DATE,
|
||
allowNull: true,
|
||
comment: '下次重试时间',
|
||
},
|
||
last_retry_at: {
|
||
type: DATE,
|
||
allowNull: true,
|
||
comment: '最后重试时间',
|
||
},
|
||
fail_code: {
|
||
type: STRING(64),
|
||
allowNull: true,
|
||
comment: '失败编码',
|
||
},
|
||
retry_of_print_id: {
|
||
type: BIGINT.UNSIGNED,
|
||
allowNull: true,
|
||
comment: '补偿来源打印记录ID',
|
||
},
|
||
error_message: {
|
||
type: TEXT,
|
||
allowNull: true,
|
||
comment: '错误信息',
|
||
},
|
||
print_task_code: {
|
||
type: TEXT,
|
||
allowNull: true,
|
||
comment: '自定义打印任务编码,多个编码以逗号分隔',
|
||
},
|
||
request_code: {
|
||
type: STRING(128),
|
||
allowNull: true,
|
||
comment: '请求参数码',
|
||
},
|
||
wave_id: {
|
||
type: BIGINT.UNSIGNED,
|
||
allowNull: true,
|
||
comment: '波次ID',
|
||
},
|
||
wave_no: {
|
||
type: STRING(64),
|
||
allowNull: true,
|
||
comment: '波次号',
|
||
},
|
||
platform_code: {
|
||
type: STRING(32),
|
||
allowNull: true,
|
||
comment: '平台编码',
|
||
},
|
||
platform_name: {
|
||
type: STRING(64),
|
||
allowNull: true,
|
||
comment: '平台名称',
|
||
},
|
||
sys_logistics_code: {
|
||
type: STRING(32),
|
||
allowNull: true,
|
||
comment: '系统快递编码',
|
||
},
|
||
sys_logistics_name: {
|
||
type: STRING(64),
|
||
allowNull: true,
|
||
comment: '系统快递名称',
|
||
},
|
||
sent_time: {
|
||
type: DATE,
|
||
allowNull: true,
|
||
comment: '发送时间',
|
||
},
|
||
print_time: {
|
||
type: DATE,
|
||
allowNull: true,
|
||
comment: '打印完成时间',
|
||
},
|
||
created_at: {
|
||
type: DATE,
|
||
allowNull: false,
|
||
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
|
||
comment: '创建时间',
|
||
},
|
||
updated_at: {
|
||
type: DATE,
|
||
allowNull: false,
|
||
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
|
||
comment: '更新时间',
|
||
},
|
||
}, {
|
||
tableName: 'wms_print_record',
|
||
freezeTableName: true,
|
||
underscored: false,
|
||
timestamps: false,
|
||
indexes: [
|
||
{ name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] },
|
||
{ name: 'idx_computer_id', fields: [ 'computer_id' ] },
|
||
{ name: 'idx_status', fields: [ 'status' ] },
|
||
{ name: 'idx_created_at', fields: [ 'created_at' ] },
|
||
{ name: 'idx_sent_time', fields: [ 'sent_time' ] },
|
||
{ name: 'idx_send_status', fields: [ 'send_status' ] },
|
||
{ name: 'idx_print_status', fields: [ 'print_status' ] },
|
||
{ name: 'idx_next_retry_at', fields: [ 'next_retry_at' ] },
|
||
{ name: 'idx_retry_of_print_id', fields: [ 'retry_of_print_id' ] },
|
||
{ name: 'idx_print_status_next_retry', fields: [ 'print_status', 'next_retry_at' ] },
|
||
{ name: 'idx_request_code', fields: [ 'request_code' ] },
|
||
{ name: 'idx_wave_id', fields: [ 'wave_id' ] },
|
||
{ name: 'idx_platform_code', fields: [ 'platform_code' ] },
|
||
{ name: 'idx_sys_logistics_code', fields: [ 'sys_logistics_code' ] },
|
||
{ name: 'idx_wave_platform_status', fields: [ 'wave_id', 'platform_code', 'status' ] },
|
||
],
|
||
comment: '打印记录表',
|
||
});
|
||
|
||
return PrintRecord;
|
||
};
|