packServer/backend/app/model/workstation.js
liufumingren f8aa4c4899 feat(工作台): 成员扫码登入、面单摄像头与虚拟通道
- 工作台成员扫码登入:workstation_login_records 记录谁在什么时候登入/下线了哪台工作台,
  超时(团购 1h / 散单 30min)由 schedule/workstation_idle_offline 自动下线;
  运单查询的 packers 取当时的登入成员
- 面单摄像头识别:workstation_cameras.is_label_camera + service/label_scan 下发本机该跑的识别配置,
  设备端(桌面端 LabelScan 工作线程)按配置做面单识别并上报
- 虚拟通道 CAM-<工作台id>:工作台没接扫码枪时,面单摄像头那一路顶替扫码枪上报,records 规则按 ws_type 区分
- 桌面端:新增 LabelScanMonitor/LabelScanWorker/ScanDeviceKind 与面单预览页,扫描通道支持改名,静默窗口 5s

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-29 17:19:24 +08:00

49 lines
2.9 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';
/**
* 工作台表模型(workstations)
*
* 一个工作台:绑定若干摄像头(workstation_cameras)+ 若干扫码通道(workstation_scan_channels)。
* `code` 是业务编号(如「1号工作台」),同一用户下唯一。
*/
module.exports = (app) => {
const { BIGINT, STRING, TINYINT, INTEGER, DATE } = app.Sequelize;
const Workstation = app.model.define('workstation', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
subjectId: { type: BIGINT.UNSIGNED, comment: '所属主体 subjects.id' },
userId: { type: BIGINT.UNSIGNED, comment: '创建人 users.id' },
code: { type: STRING(64), allowNull: false, comment: '工作台编号' },
name: { type: STRING(64), allowNull: false, defaultValue: '', comment: '工作台名称' }, /** 1 散单工作台 2 团购工作台 */
wsType: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '工作台类型' },
/** 录制范围(团购以扫码时间为基准,散单以任务结束时间为基准) */
recordBeforeSec: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 60, comment: '录制范围:触发点之前秒数' },
recordAfterSec: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 60, comment: '录制范围:触发点之后秒数' },
recordMaxSec: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 240, comment: '最大录制时长(秒);团购无此限制,固定存 0' }, status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '状态:1启用 0停用' },
/** 扫码上报时刷新;配合 idleTimeoutSec 触发自动下线 */
lastActiveAt: { type: DATE, comment: '最后活跃时间(扫码上报时刷新)' },
idleTimeoutSec: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 1800, comment: '多少秒不活跃自动下线所有成员(团购 3600 / 散单 1800)' },
remark: { type: STRING(255), comment: '备注' },
// ↓ 合成画面画布(默认 1920×1080)
canvasWidth: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 1920, comment: '合成画布宽' },
canvasHeight: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 1080, comment: '合成画布高' },
}, {
tableName: 'workstations',
paranoid: true,
comment: '工作台表',
});
Workstation.associate = function() {
app.model.Workstation.belongsTo(app.model.User, { foreignKey: 'user_id', as: 'user' });
app.model.Workstation.hasMany(app.model.WorkstationCamera, { foreignKey: 'workstation_id', as: 'cameraLinks' });
app.model.Workstation.hasMany(app.model.WorkstationScanChannel, { foreignKey: 'workstation_id', as: 'scanChannelLinks' });
app.model.Workstation.hasMany(app.model.WorkstationLoginRecord, { foreignKey: 'workstation_id', as: 'loginRecords' });
};
return Workstation;
};