Files
MES/yawei-mes/.sql/2026-03-06_v2.0.004_周启威_8Multi报工、设备状态修改.sql
2026-04-02 10:39:03 +08:00

29 lines
1.9 KiB
SQL
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.

-- ============================================================
-- v2.0.004 8Multi di_reg 报工 & 设备状态修改
-- 作者:周启威
-- 日期2026-03-06
-- ============================================================
-- 1. device_data 新增 di_reg 字段(存储每次上报的原始值)
ALTER TABLE `device_data`
ADD COLUMN `di_reg` INT DEFAULT NULL COMMENT '输入寄存器(0-7报工/8-15设备状态)';
-- 2. 新增 di_reg 触发动作日志表
CREATE TABLE `device_di_reg_log` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键',
`device_id` BIGINT NOT NULL COMMENT '设备ID(关联device.id)',
`device_no` INT NOT NULL COMMENT '设备号(device.device_no)',
`di_reg` INT NOT NULL COMMENT 'di_reg原始值(0-15)',
`action_type` VARCHAR(16) NOT NULL COMMENT '动作类型: REPORT=报工 / STATUS=设备状态',
`process_sort` INT DEFAULT NULL COMMENT '工序顺序(REPORT时有效, = di_reg + 1)',
`cn_reg_new` INT DEFAULT NULL COMMENT '新设备状态值(STATUS时有效, = di_reg - 8)',
`affected_count` INT DEFAULT 0 COMMENT '本次实际处理的工单数量(REPORT时)',
`work_order_ids` VARCHAR(512) DEFAULT NULL COMMENT '本次处理的工单ID列表,逗号分隔(REPORT时)',
`trigger_time` DATETIME NOT NULL COMMENT '触发时间',
`remark` VARCHAR(512) DEFAULT NULL COMMENT '备注',
`del_flag` CHAR(1) NOT NULL DEFAULT '0' COMMENT '删除标志(0正常/1删除)',
PRIMARY KEY (`id`),
KEY `idx_device_id_time` (`device_id`, `trigger_time`),
KEY `idx_action_type_time` (`action_type`, `trigger_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='8Multi di_reg触发动作日志表';