添加ETC入库
This commit is contained in:
parent
16fd5e522a
commit
af5612a785
|
@ -1,11 +1,7 @@
|
|||
package com.isu.gaswellwatch.modbus.data.impl;
|
||||
|
||||
import com.isu.gaswellwatch.config.SnowflakeConfig;
|
||||
import com.isu.gaswellwatch.modbus.data.PersistenceHandler;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.PreparedStatementCallback;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -22,13 +18,6 @@ import java.util.Objects;
|
|||
@Component(PersistenceHandler.ETC_MODBUS_TYPE)
|
||||
public class EtcPersistenceHandler extends AbstractPersistenceHandler {
|
||||
|
||||
@Resource
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
@Resource
|
||||
private SnowflakeConfig snowflakeConfig;
|
||||
@Resource(name = "stringRedisTemplate")
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public void createTable(String tableName, Long deviceId) {
|
||||
this.createTable("sql/CREATE_ETC.sql", tableName, deviceId);
|
||||
|
@ -49,55 +38,19 @@ public class EtcPersistenceHandler extends AbstractPersistenceHandler {
|
|||
EtcPersistenceHandler.this.setValue(ps, newRow, 2, "deviceId", Types.BIGINT);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 3, "collectionTime", Types.TIMESTAMP);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 4, "receiveTime", Types.TIMESTAMP);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 5, "deviceTime", Types.TIMESTAMP);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 6, "runMode", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 7, "wellStatus", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 8, "plugStatus", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 9, "statusOpenTime", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 10, "statusCloseTime", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 11, "oilPressure", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 5, "solenoidValveAClosedPlungerNotReached", Types.TIMESTAMP);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 6, "solenoidValveAOpenedPlungerNotReached", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 7, "solenoidValveAClosedPlungerReached", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 8, "solenoidValveAOpenedPlungerReached", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 9, "controllerCurrentStatus", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 10, "currentStatusRemainingTime", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 11, "currentStatusStartTime", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 12, "casPressure", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 13, "prePressure", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 14, "pipePressure", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 15, "liquidLevel", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 16, "temperature", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 17, "humidity", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 18, "opmode", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 19, "timer1", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 20, "timer2", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 21, "timer1Open", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 22, "timer1Close", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 23, "timer2Open", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 24, "timer2Close", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 25, "timingOpen", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 26, "timingClose", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 27, "timingCelay", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 28, "presource", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 29, "pressureOpen", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 30, "pressureClose", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 31, "triggerType", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 32, "stabilityTime", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 33, "maxOpenWell", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 34, "maxCloseWell", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 35, "minOpenWell", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 36, "minCloseWell", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 37, "presproTect", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 38, "presproSource", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 39, "openWellLimitMax", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 40, "openWellLimitMin", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 41, "plugInitStatus", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 42, "plugSustainTime", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 43, "plugCloseTime", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 44, "tpInitStatus", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 45, "tpOpenSource", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 46, "tpOpenTrigger", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 47, "tpOpenPressure", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 48, "tpOpenTime", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 49, "tpCloseSource", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 50, "tpCloseTrigger", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 51, "tpClosePressure", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 52, "tpCloseTime", Types.VARCHAR);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 53, "tpStabilityTime", Types.INTEGER);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 13, "oilPressure", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 13, "plungerRiseTime", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 13, "arrivalSensorDelayTime", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 13, "wellShutInTime", Types.DECIMAL);
|
||||
EtcPersistenceHandler.this.setValue(ps, newRow, 13, "afterFlowTime", Types.DECIMAL);
|
||||
return ps.executeUpdate();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package com.isu.gaswellwatch.modbus.data.impl;
|
||||
|
||||
import com.isu.gaswellwatch.config.SnowflakeConfig;
|
||||
import com.isu.gaswellwatch.modbus.data.PersistenceHandler;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.PreparedStatementCallback;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -22,13 +18,6 @@ import java.util.Objects;
|
|||
@Component(PersistenceHandler.SCSS_MODBUS_TYPE)
|
||||
public class ScssPersistenceHandler extends AbstractPersistenceHandler {
|
||||
|
||||
@Resource
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
@Resource
|
||||
private SnowflakeConfig snowflakeConfig;
|
||||
@Resource(name = "stringRedisTemplate")
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public void createTable(String tableName, Long deviceId) {
|
||||
this.createTable("sql/CREATE_SCSS.sql", tableName, deviceId);
|
||||
|
|
|
@ -14,3 +14,60 @@ 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');
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
CREATE TABLE `$TableName$`
|
||||
(
|
||||
`id` bigint NOT NULL COMMENT '主键',
|
||||
`device_id` int NOT NULL COMMENT '设备标识',
|
||||
`created_time` datetime NOT NULL COMMENT '数据落库时间',
|
||||
`collection_time` datetime NOT NULL COMMENT '采集指令下发时间',
|
||||
`receive_time` datetime NOT NULL COMMENT '接收到数据时间',
|
||||
`solenoid_valve_a_closed_plunger_not_reached` int NULL DEFAULT NULL COMMENT '电磁阀A关闭,柱塞未到达',
|
||||
`solenoid_valve_a_opened_plunger_not_reached` int NULL DEFAULT NULL COMMENT '电磁阀A开启,柱塞未到达',
|
||||
`solenoid_valve_a_closed_plunger_reached` int NULL DEFAULT NULL COMMENT '电磁阀A关闭,柱塞到达',
|
||||
`solenoid_valve_a_opened_plunger_reached` int NULL DEFAULT NULL COMMENT '电磁阀A开启,柱塞到达',
|
||||
`controller_current_status` int NULL DEFAULT NULL COMMENT '控制器当前状态',
|
||||
`current_status_remaining_time` varchar(10) NULL DEFAULT NULL COMMENT '当前状态剩余时间',
|
||||
`current_status_start_time` datetime NULL DEFAULT NULL COMMENT '当前状态开始时间',
|
||||
`cas_pressure` decimal(10, 1) NULL DEFAULT NULL COMMENT '套压',
|
||||
`oil_pressure` decimal(10, 1) NULL DEFAULT NULL COMMENT '油压',
|
||||
`plunger_rise_time` varchar(10) NULL DEFAULT NULL COMMENT '柱塞上升时间',
|
||||
`arrival_sensor_delay_time` varchar(10) NULL DEFAULT NULL COMMENT '到达传感器延时时间',
|
||||
`well_shut_in_time` varchar(10) NULL DEFAULT NULL COMMENT '关井时间',
|
||||
`after_flow_time` varchar(10) NULL DEFAULT NULL COMMENT '续流时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `udx_device_create_time` (`device_id` ASC, `collection_time` ASC) USING BTREE COMMENT '设备采集数据唯一键'
|
||||
) ENGINE = InnoDB COMMENT = '设备ID:$DeviceId$的采集数据'
|
|
@ -0,0 +1,21 @@
|
|||
INSERT INTO `$TableName$` (`id`, `device_id`, `created_time`, `collection_time`, `receive_time`,
|
||||
`solenoid_valve_a_closed_plunger_not_reached`, `solenoid_valve_a_opened_plunger_not_reached`,
|
||||
`solenoid_valve_a_closed_plunger_reached`, `solenoid_valve_a_opened_plunger_reached`,
|
||||
`controller_current_status`, `current_status_remaining_time`, `current_status_start_time`,
|
||||
`cas_pressure`, `oil_pressure`, `plunger_rise_time`, `arrival_sensor_delay_time`,
|
||||
`well_shut_in_time`, `after_flow_time`)
|
||||
VALUES (?, ?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE receive_time=VALUES(receive_time),
|
||||
solenoid_valve_a_closed_plunger_not_reached=VALUES(solenoid_valve_a_closed_plunger_not_reached),
|
||||
solenoid_valve_a_opened_plunger_not_reached=VALUES(solenoid_valve_a_opened_plunger_not_reached),
|
||||
solenoid_valve_a_closed_plunger_reached=VALUES(solenoid_valve_a_closed_plunger_reached),
|
||||
solenoid_valve_a_opened_plunger_reached=VALUES(solenoid_valve_a_opened_plunger_reached),
|
||||
controller_current_status=VALUES(controller_current_status),
|
||||
current_status_remaining_time=VALUES(current_status_remaining_time),
|
||||
current_status_start_time=VALUES(current_status_start_time),
|
||||
cas_pressure=VALUES(cas_pressure),
|
||||
oil_pressure=VALUES(oil_pressure),
|
||||
plunger_rise_time=VALUES(plunger_rise_time),
|
||||
arrival_sensor_delay_time=VALUES(arrival_sensor_delay_time),
|
||||
well_shut_in_time=VALUES(well_shut_in_time),
|
||||
after_flow_time=VALUES(after_flow_time)
|
Loading…
Reference in New Issue