ALTER TABLE `commands`
    MODIFY COLUMN `ref_type` varchar(20) NOT NULL COMMENT '引用类型，DEVICE:设备；DEVICE_PRODUCT_CODE:设备类型' AFTER `id`;

ALTER TABLE `command_points`
    DROP COLUMN `device_id`;

update commands
set ref_type = 'DEVICE_PRODUCT_CODE',
    ref_id   = 4
where ref_type = 'DEVICE'
  and ref_id = 1;
update commands
set ref_type = 'DEVICE_PRODUCT_CODE',
    ref_id   = 6
where ref_type = 'DEVICE'
  and ref_id = 2;


INSERT INTO `commands` (`id`, `ref_type`, `ref_id`, `name`, `code`, `type`, `collection_frequency`, `command`,
                        `start_address`, `message_length`, `details`)
VALUES (10201, 'DEVICE_PRODUCT_CODE', 5, '线圈寄存器02', 'COIL_REGISTER_02', 'COLLECTION', 30, '010200140004 ', 20, 26,
        '');
INSERT INTO `commands` (`id`, `ref_type`, `ref_id`, `name`, `code`, `type`, `collection_frequency`, `command`,
                        `start_address`, `message_length`, `details`)
VALUES (10202, 'DEVICE_PRODUCT_CODE', 5, '输入寄存器04', 'INPUT_REGISTER_04', 'COLLECTION', 30, '0104000A001A', 10, 114,
        '');
INSERT INTO `commands` (`id`, `ref_type`, `ref_id`, `name`, `code`, `type`, `collection_frequency`, `command`,
                        `start_address`, `message_length`, `details`)
VALUES (10203, 'DEVICE_PRODUCT_CODE', 5, '输入寄存器03', 'INPUT_REGISTER_03', 'COLLECTION', 30, '0103006A002A', 106,
        178, '');

INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12001, 10201, 'solenoidValveAClosedPlungerNotReached', '电磁阀A关闭,柱塞未到达', '', 20, 1, NULL, NULL, '', '');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12002, 10201, 'solenoidValveAOpenedPlungerNotReached', '电磁阀A开启,柱塞未到达', '', 21, 1, NULL, NULL, '', '');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12003, 10201, 'solenoidValveAClosedPlungerReached', '电磁阀A关闭,柱塞到达', '', 28, 1, NULL, NULL, '', '');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12004, 10201, 'solenoidValveAOpenedPlungerReached', '电磁阀A开启,柱塞到达', '', 29, 1, NULL, NULL, '', '');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12005, 10202, 'controllerCurrentStatus', '控制器当前状态', '', 10, 1, NULL, NULL, '', '');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12006, 10202, 'currentStatusRemainingTime', '当前状态剩余时间', '', 11, 3, NULL, NULL, '%s:%s:%s',
        'stringTime');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12007, 10202, 'currentStatusStartTime', '当前状态开始时间', '', 14, 6, NULL, NULL, '%s-%s-%s %s:%s:%s',
        'localDateTime');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12008, 10202, 'casPressure', '套压', '', 32, 1, 10.00, 1, '', 'factor');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12009, 10202, 'oilPressure', '油压', '', 35, 1, 10.00, 1, '', 'factor');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12010, 10203, 'plungerRiseTime', '柱塞上升时间', '', 106, 3, NULL, NULL, '%s:%s:%s', 'stringTime');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12011, 10203, 'arrivalSensorDelayTime', '到达传感器延时时间', '', 139, 3, NULL, NULL, '%s:%s:%s', 'stringTime');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12012, 10203, 'wellShutInTime', '关井时间', '', 142, 3, NULL, NULL, '%s:%s:%s', 'stringTime');
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
                              `precision`, `format`, `decode_name`)
VALUES (12013, 10203, 'afterFlowTime', '续流时间', '', 145, 3, NULL, NULL, '%s:%s:%s', 'stringTime');

