WMS_MAIN/app/model/camera.js
liufumingren b485f8e9f1 feat(camera): 新增摄像头/录制模块 (camera/camera_server/pack_task_video)
- 新增 model: camera, camera_server

- 新增 services: camera, cameraServer (systemMethods + systems)

- 新增 pack_task_video 表及录制状态管理

- 7 条迁移: 建表→设备字段→端口拆分→状态枚举
2026-07-27 03:46:51 +08:00

116 lines
2.7 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 } = app.Sequelize;
const Camera = app.model.define('camera', {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
comment: '主键ID',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID',
},
server_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '所属录像服务器ID,关联 wms_camera_server.id',
},
channel_id: {
type: INTEGER.UNSIGNED,
allowNull: false,
comment: '通道编号(DVR/NVR 上的物理通道号)',
},
channel_name: {
type: STRING(100),
allowNull: true,
comment: '通道原始名称',
},
ip: {
type: STRING(50),
allowNull: true,
comment: '摄像头IP地址',
},
port: {
type: INTEGER.UNSIGNED,
allowNull: true,
comment: 'SDK管理端口(通常2020/8000)',
},
model: {
type: STRING(100),
allowNull: true,
comment: '摄像头型号',
},
serial_number: {
type: STRING(100),
allowNull: true,
comment: '摄像头序列号',
},
stream_type: {
type: STRING(20),
allowNull: true,
comment: '码流类型(auto/main/sub)',
},
custom_name: {
type: STRING(100),
allowNull: true,
comment: '自定义摄像头名称',
},
status: {
type: TINYINT,
allowNull: false,
defaultValue: 1,
comment: '状态:0-禁用 1-启用',
},
remark: {
type: STRING(500),
allowNull: true,
comment: '备注',
},
created_at: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
updated_at: {
type: DATE,
allowNull: false,
comment: '更新时间',
},
deleted_at: {
type: DATE,
allowNull: true,
comment: '软删除时间',
},
}, {
tableName: 'wms_camera',
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
paranoid: true,
deletedAt: 'deleted_at',
comment: '摄像头表',
indexes: [
{ name: 'idx_warehouse_id', fields: ['warehouse_id'] },
{ name: 'idx_server_id', fields: ['server_id'] },
{ name: 'uk_server_channel', unique: true, fields: ['server_id', 'channel_id', 'deleted_at'] },
{ name: 'idx_status', fields: ['status'] },
{ name: 'idx_deleted_at', fields: ['deleted_at'] },
],
});
Camera.associate = () => {
app.model.Camera.belongsTo(app.model.CameraServer, {
foreignKey: 'server_id',
targetKey: 'id',
as: 'server',
});
};
return Camera;
};