同时推送新旧两条数据

This commit is contained in:
wangshilong 2024-11-26 15:51:47 +08:00
parent 803f3248f3
commit 16fd5e522a
24 changed files with 318 additions and 283 deletions

View File

@ -14,7 +14,7 @@ import java.util.Objects;
* 网关标识/设备标识/命令标识/采集下发时间/采集数据接收时间/采集数据体
* 4B454E454E4731343030303030333538/1/10000/1732365690000/1732365691000/01042C07D000010003000C002B0029000300010000001A0018003303CD002300080DAC0DAC0000000000000959091DF066
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/24 10:11
*/
@Getter

View File

@ -1,22 +1,11 @@
package com.isu.gaswellwatch.modbus.data;
import cn.hutool.core.map.MapUtil;
import org.apache.commons.io.IOUtils;
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Map;
import java.util.Objects;
/**
* 数据持久化处理器
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/23 11:53
*/
public interface PersistenceHandler {
@ -30,25 +19,6 @@ public interface PersistenceHandler {
void createTable(String tableName, Long deviceId);
Map<String, Object> insert(String tableName, String cacheKey);
default void setValue(PreparedStatement ps, Map<String, Object> row, int index, String key, int sqlType) throws SQLException {
String value = MapUtil.getStr(row, key);
if (Objects.isNull(value)) {
ps.setNull(index, sqlType);
} else {
ps.setObject(index, value);
}
}
static String getResource(String classPath) {
try {
File file = ResourceUtils.getFile("classpath:" + classPath);
return IOUtils.toString(new FileInputStream(file), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Map<String, Map<String, Object>> insert(String tableName, String cacheKey);
}

View File

@ -28,7 +28,7 @@ import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/23 11:55
*/
@Slf4j
@ -94,9 +94,9 @@ public class Redis2DBPersistenceService {
|| StringUtils.isBlank(MapUtil.getStr(existsTableList.get(0), "TABLE_NAME"))) {
persistenceHandler.createTable(tableName, deviceId);
}
Map<String, Object> rowData = persistenceHandler.insert(tableName, cacheKey);
if (ObjectUtils.isNotEmpty(rowData)) {
String rowDataJson = JSONUtil.toJsonStr(rowData);
Map<String, Map<String, Object>> changeData = persistenceHandler.insert(tableName, cacheKey);
if (ObjectUtils.isNotEmpty(changeData)) {
String rowDataJson = JSONUtil.toJsonStr(changeData);
String queueName = String.format(Queues.DEVICE_EVENTS, deviceId);
try {
log.debug("推设备最新落库数据到MQ({}): {}", queueName, rowDataJson);

View File

@ -9,7 +9,7 @@ import java.util.Map;
/**
* Modbus 数据解析器
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/23 11:20
*/
public interface DecodeHandler {

View File

@ -7,7 +7,7 @@ import java.util.Collection;
import java.util.Map;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/25 16:31
*/
public class ComposeDecodeHandler implements DecodeHandler {

View File

@ -19,7 +19,7 @@ import java.util.Map;
* <li>例如输入值2580系数(factor)100精度(precision)2输出值2580 * 100 = 258000</li>
* </ul>
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/24 21:23
*/
@Component(FactorDecodeHandler.NAME + DecodeHandler.DECODE_NAME)

View File

@ -9,7 +9,7 @@ import java.util.Map;
/**
* 高低位4字节解析器
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/25 16:36
*/
@Component(HighLowBinDecodeHandler.NAME + DecodeHandler.DECODE_NAME)

View File

@ -11,7 +11,7 @@ import java.util.Map;
/**
* 本地日期类型解析器
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/25 11:51
*/
@Component(LocalDateDecodeHandler.NAME + DecodeHandler.DECODE_NAME)

View File

@ -11,7 +11,7 @@ import java.util.Map;
/**
* 本地日期时间类型解析器
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/24 21:34
*/
@Component(LocalDateTimeDecodeHandler.NAME + DecodeHandler.DECODE_NAME)

View File

@ -11,7 +11,7 @@ import java.util.Map;
/**
* 本地时间类型解析器
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/25 11:58
*/
@Component(LocalTimeDecodeHandler.NAME + DecodeHandler.DECODE_NAME)

View File

@ -10,7 +10,7 @@ import java.util.Map;
/**
* 有符号整数转换
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/25 16:24
*/
@Component(SignedNumberDecodeHandler.NAME + DecodeHandler.DECODE_NAME)

View File

@ -11,7 +11,7 @@ import java.util.Map;
/**
* 本地日期时间类型解析器
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/24 21:34
*/
@Component(SimpleLocalDateTimeDecodeHandler.NAME + DecodeHandler.DECODE_NAME)

View File

@ -13,7 +13,7 @@ import java.util.stream.Collectors;
* 时间类型解析器
* 支持解析999:59:59, 实际使用中请不要转为LocalTime
*
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/24 21:38
*/
@Component(StringTimeDecodeHandler.NAME + DecodeHandler.DECODE_NAME)

View File

@ -0,0 +1,67 @@
package com.isu.gaswellwatch.modbus.data.impl;
import cn.hutool.core.map.MapUtil;
import com.isu.gaswellwatch.config.SnowflakeConfig;
import com.isu.gaswellwatch.modbus.data.PersistenceHandler;
import jakarta.annotation.Resource;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Map;
import java.util.Objects;
/**
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/26 15:42
*/
public abstract class AbstractPersistenceHandler implements PersistenceHandler {
@Resource
protected JdbcTemplate jdbcTemplate;
@Resource
protected SnowflakeConfig snowflakeConfig;
@Resource(name = "stringRedisTemplate")
protected RedisTemplate redisTemplate;
protected void createTable(String filePath, String tableName, Long deviceId) {
String createTableSQL = this.getResource(filePath);
createTableSQL = StringUtils.replace(createTableSQL, "$TableName$", tableName);
createTableSQL = StringUtils.replace(createTableSQL, "$DeviceId$", String.valueOf(deviceId));
this.jdbcTemplate.execute(createTableSQL);
}
protected Map<String, Object> getLastRow(String tableName) {
return this.jdbcTemplate.queryForList("SELECT * FROM " + tableName + " ORDER BY ID DESC LIMIT 1")
.stream()
.findFirst()
.orElse(null);
}
protected void setValue(PreparedStatement ps, Map<String, Object> row, int index, String key, int sqlType) throws SQLException {
String value = MapUtil.getStr(row, key);
if (Objects.isNull(value)) {
ps.setNull(index, sqlType);
} else {
ps.setObject(index, value);
}
}
protected String getResource(String classPath) {
try {
File file = ResourceUtils.getFile("classpath:" + classPath);
return IOUtils.toString(new FileInputStream(file), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -13,13 +13,14 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Map;
import java.util.Objects;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/24 17:33
*/
@Component(PersistenceHandler.ETC_MODBUS_TYPE)
public class EtcPersistenceHandler implements PersistenceHandler {
public class EtcPersistenceHandler extends AbstractPersistenceHandler {
@Resource
private JdbcTemplate jdbcTemplate;
@ -30,78 +31,79 @@ public class EtcPersistenceHandler implements PersistenceHandler {
@Override
public void createTable(String tableName, Long deviceId) {
String createTableSQL = PersistenceHandler.getResource("sql/CREATE_ETC.sql");
createTableSQL = StringUtils.replace(createTableSQL, "$TableName$", tableName);
createTableSQL = StringUtils.replace(createTableSQL, "$DeviceId$", String.valueOf(deviceId));
this.jdbcTemplate.execute(createTableSQL);
this.createTable("sql/CREATE_ETC.sql", tableName, deviceId);
}
@Override
public Map<String, Object> insert(String tableName, String cacheKey) {
String insertTableSQL = PersistenceHandler.getResource("sql/INSERT_ETC.sql");
public Map<String, Map<String, Object>> insert(String tableName, String cacheKey) {
String insertTableSQL = this.getResource("sql/INSERT_ETC.sql");
insertTableSQL = StringUtils.replace(insertTableSQL, "$TableName$", tableName);
Map<String, Object> row = this.redisTemplate.opsForHash().entries(cacheKey);
Map<String, Object> oldRow = this.getLastRow(tableName);
Map<String, Object> newRow = this.redisTemplate.opsForHash().entries(cacheKey);
this.jdbcTemplate.execute(insertTableSQL, new PreparedStatementCallback<Object>() {
@Override
public Object doInPreparedStatement(PreparedStatement ps) throws SQLException {
ps.setLong(1, EtcPersistenceHandler.this.snowflakeConfig.snowflakeId());
EtcPersistenceHandler.this.setValue(ps, row, 2, "deviceId", Types.BIGINT);
EtcPersistenceHandler.this.setValue(ps, row, 3, "collectionTime", Types.TIMESTAMP);
EtcPersistenceHandler.this.setValue(ps, row, 4, "receiveTime", Types.TIMESTAMP);
EtcPersistenceHandler.this.setValue(ps, row, 5, "deviceTime", Types.TIMESTAMP);
EtcPersistenceHandler.this.setValue(ps, row, 6, "runMode", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 7, "wellStatus", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 8, "plugStatus", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 9, "statusOpenTime", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 10, "statusCloseTime", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 11, "oilPressure", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 12, "casPressure", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 13, "prePressure", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 14, "pipePressure", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 15, "liquidLevel", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 16, "temperature", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 17, "humidity", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 18, "opmode", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 19, "timer1", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 20, "timer2", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 21, "timer1Open", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 22, "timer1Close", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 23, "timer2Open", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 24, "timer2Close", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 25, "timingOpen", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 26, "timingClose", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 27, "timingCelay", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 28, "presource", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 29, "pressureOpen", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 30, "pressureClose", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 31, "triggerType", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 32, "stabilityTime", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 33, "maxOpenWell", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 34, "maxCloseWell", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 35, "minOpenWell", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 36, "minCloseWell", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 37, "presproTect", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 38, "presproSource", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 39, "openWellLimitMax", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 40, "openWellLimitMin", Types.DECIMAL);
EtcPersistenceHandler.this.setValue(ps, row, 41, "plugInitStatus", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 42, "plugSustainTime", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 43, "plugCloseTime", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 44, "tpInitStatus", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 45, "tpOpenSource", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 46, "tpOpenTrigger", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 47, "tpOpenPressure", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 48, "tpOpenTime", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 49, "tpCloseSource", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 50, "tpCloseTrigger", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 51, "tpClosePressure", Types.INTEGER);
EtcPersistenceHandler.this.setValue(ps, row, 52, "tpCloseTime", Types.VARCHAR);
EtcPersistenceHandler.this.setValue(ps, row, 53, "tpStabilityTime", Types.INTEGER);
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, 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);
return ps.executeUpdate();
}
});
return row;
if (Objects.isNull(oldRow)) {
return Map.of("new", newRow);
}
return Map.of("new", newRow, "old", oldRow);
}
}

View File

@ -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;
@ -13,95 +9,90 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Map;
import java.util.Objects;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/24 17:33
*/
@Component(PersistenceHandler.KNPCV1_MODBUS_TYPE)
public class Knpcv1PersistenceHandler implements PersistenceHandler {
@Resource
private JdbcTemplate jdbcTemplate;
@Resource
private SnowflakeConfig snowflakeConfig;
@Resource(name = "stringRedisTemplate")
private RedisTemplate redisTemplate;
public class Knpcv1PersistenceHandler extends AbstractPersistenceHandler {
@Override
public void createTable(String tableName, Long deviceId) {
String createTableSQL = PersistenceHandler.getResource("sql/CREATE_KNPCV1.sql");
createTableSQL = StringUtils.replace(createTableSQL, "$TableName$", tableName);
createTableSQL = StringUtils.replace(createTableSQL, "$DeviceId$", String.valueOf(deviceId));
this.jdbcTemplate.execute(createTableSQL);
this.createTable("sql/CREATE_KNPCV1.sql", tableName, deviceId);
}
@Override
public Map<String, Object> insert(String tableName, String cacheKey) {
String insertTableSQL = PersistenceHandler.getResource("sql/INSERT_KNPCV1.sql");
public Map<String, Map<String, Object>> insert(String tableName, String cacheKey) {
String insertTableSQL = this.getResource("sql/INSERT_KNPCV1.sql");
insertTableSQL = StringUtils.replace(insertTableSQL, "$TableName$", tableName);
Map<String, Object> row = this.redisTemplate.opsForHash().entries(cacheKey);
Map<String, Object> oldRow = this.getLastRow(tableName);
Map<String, Object> newRow = this.redisTemplate.opsForHash().entries(cacheKey);
this.jdbcTemplate.execute(insertTableSQL, new PreparedStatementCallback<Object>() {
@Override
public Object doInPreparedStatement(PreparedStatement ps) throws SQLException {
ps.setLong(1, Knpcv1PersistenceHandler.this.snowflakeConfig.snowflakeId());
Knpcv1PersistenceHandler.this.setValue(ps, row, 2, "deviceId", Types.BIGINT);
Knpcv1PersistenceHandler.this.setValue(ps, row, 3, "collectionTime", Types.TIMESTAMP);
Knpcv1PersistenceHandler.this.setValue(ps, row, 4, "receiveTime", Types.TIMESTAMP);
Knpcv1PersistenceHandler.this.setValue(ps, row, 5, "deviceTime", Types.TIMESTAMP);
Knpcv1PersistenceHandler.this.setValue(ps, row, 6, "runMode", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 7, "wellStatus", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 8, "plugStatus", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 9, "statusOpenTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 10, "statusCloseTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 11, "oilPressure", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 12, "casPressure", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 13, "prePressure", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 14, "pipePressure", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 15, "liquidLevel", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 16, "temperature", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 17, "humidity", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 18, "opmode", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 19, "timer1", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 20, "timer2", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 21, "timer1Open", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 22, "timer1Close", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 23, "timer2Open", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 24, "timer2Close", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 25, "timingOpen", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 26, "timingClose", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 27, "timingCelay", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 28, "presource", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 29, "pressureOpen", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 30, "pressureClose", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 31, "triggerType", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 32, "stabilityTime", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 33, "maxOpenWell", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 34, "maxCloseWell", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 35, "minOpenWell", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 36, "minCloseWell", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 37, "presproTect", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 38, "presproSource", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 39, "openWellLimitMax", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 40, "openWellLimitMin", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, row, 41, "plugInitStatus", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 42, "plugSustainTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 43, "plugCloseTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 44, "tpInitStatus", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 45, "tpOpenSource", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 46, "tpOpenTrigger", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 47, "tpOpenPressure", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 48, "tpOpenTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 49, "tpCloseSource", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 50, "tpCloseTrigger", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 51, "tpClosePressure", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, row, 52, "tpCloseTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, row, 53, "tpStabilityTime", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 2, "deviceId", Types.BIGINT);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 3, "collectionTime", Types.TIMESTAMP);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 4, "receiveTime", Types.TIMESTAMP);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 5, "deviceTime", Types.TIMESTAMP);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 6, "runMode", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 7, "wellStatus", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 8, "plugStatus", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 9, "statusOpenTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 10, "statusCloseTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 11, "oilPressure", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 12, "casPressure", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 13, "prePressure", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 14, "pipePressure", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 15, "liquidLevel", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 16, "temperature", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 17, "humidity", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 18, "opmode", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 19, "timer1", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 20, "timer2", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 21, "timer1Open", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 22, "timer1Close", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 23, "timer2Open", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 24, "timer2Close", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 25, "timingOpen", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 26, "timingClose", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 27, "timingCelay", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 28, "presource", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 29, "pressureOpen", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 30, "pressureClose", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 31, "triggerType", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 32, "stabilityTime", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 33, "maxOpenWell", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 34, "maxCloseWell", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 35, "minOpenWell", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 36, "minCloseWell", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 37, "presproTect", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 38, "presproSource", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 39, "openWellLimitMax", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 40, "openWellLimitMin", Types.DECIMAL);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 41, "plugInitStatus", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 42, "plugSustainTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 43, "plugCloseTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 44, "tpInitStatus", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 45, "tpOpenSource", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 46, "tpOpenTrigger", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 47, "tpOpenPressure", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 48, "tpOpenTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 49, "tpCloseSource", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 50, "tpCloseTrigger", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 51, "tpClosePressure", Types.INTEGER);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 52, "tpCloseTime", Types.VARCHAR);
Knpcv1PersistenceHandler.this.setValue(ps, newRow, 53, "tpStabilityTime", Types.INTEGER);
return ps.executeUpdate();
}
});
return row;
if (Objects.isNull(oldRow)) {
return Map.of("new", newRow);
}
return Map.of("new", newRow, "old", oldRow);
}
}

View File

@ -13,13 +13,14 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Map;
import java.util.Objects;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/24 17:33
*/
@Component(PersistenceHandler.SCSS_MODBUS_TYPE)
public class ScssPersistenceHandler implements PersistenceHandler {
public class ScssPersistenceHandler extends AbstractPersistenceHandler {
@Resource
private JdbcTemplate jdbcTemplate;
@ -30,110 +31,111 @@ public class ScssPersistenceHandler implements PersistenceHandler {
@Override
public void createTable(String tableName, Long deviceId) {
String createTableSQL = PersistenceHandler.getResource("sql/CREATE_SCSS.sql");
createTableSQL = StringUtils.replace(createTableSQL, "$TableName$", tableName);
createTableSQL = StringUtils.replace(createTableSQL, "$DeviceId$", String.valueOf(deviceId));
this.jdbcTemplate.execute(createTableSQL);
this.createTable("sql/CREATE_SCSS.sql", tableName, deviceId);
}
@Override
public Map<String, Object> insert(String tableName, String cacheKey) {
String insertTableSQL = PersistenceHandler.getResource("sql/INSERT_SCSS.sql");
public Map<String, Map<String, Object>> insert(String tableName, String cacheKey) {
String insertTableSQL = this.getResource("sql/INSERT_SCSS.sql");
insertTableSQL = StringUtils.replace(insertTableSQL, "$TableName$", tableName);
Map<String, Object> row = this.redisTemplate.opsForHash().entries(cacheKey);
Map<String, Object> oldRow = this.getLastRow(tableName);
Map<String, Object> newRow = this.redisTemplate.opsForHash().entries(cacheKey);
this.jdbcTemplate.execute(insertTableSQL, new PreparedStatementCallback<Object>() {
@Override
public Object doInPreparedStatement(PreparedStatement ps) throws SQLException {
ps.setLong(1, ScssPersistenceHandler.this.snowflakeConfig.snowflakeId());
ScssPersistenceHandler.this.setValue(ps, row, 2, "deviceId", Types.BIGINT);
ScssPersistenceHandler.this.setValue(ps, row, 3, "collectionTime", Types.TIMESTAMP);
ScssPersistenceHandler.this.setValue(ps, row, 4, "receiveTime", Types.TIMESTAMP);
ScssPersistenceHandler.this.setValue(ps, row, 5, "casPressure", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, row, 6, "oilPressure", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, row, 7, "firstSolenoidStatus", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 8, "batteryVoltage", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, row, 9, "solarVoltage", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, row, 10, "remainingTimeAction", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 11, "secondSolenoidStatus", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 12, "preTransmission", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 13, "internetTraffic", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 14, "loadFactor", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 15, "dataTime", Types.TIMESTAMP);
ScssPersistenceHandler.this.setValue(ps, row, 16, "showDelay", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 17, "openWellSamplingInterval", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 18, "closeWellSamplingInterval", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 19, "ctlModel", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 20, "minPressure", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 21, "maxPressure", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 22, "pressureMinVoltage", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 23, "pressureMaxVoltage", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 24, "oilMin", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 25, "oliMax", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 26, "oilMinVoltage", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 27, "oilMaxVoltage", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 28, "inputPressureMinValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 29, "inputPressureMaxValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 30, "inputVoltageMinValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 31, "inputVoltageMaxValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 32, "flowRateMinValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 33, "flowRateMaxValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 34, "flowVoltageMinValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 35, "flowVoltageMaxValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 36, "continuousSamplingIntervalDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 37, "sensorSignalEffectiveLevel", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 38, "pressureCompensationPolarityFlag", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 39, "pressureCompensationValueSetting", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 40, "oilPressureCompensationPolarityFlag", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 41, "oilPressureCompensationValueSetting", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 42, "inputPressureCompensationPolarityFlag", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 43, "inputPressureCompensationValueSetting", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 44, "flowCompensationPolarityFlag", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 45, "flowCompensationValueSetting", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 46, "wellOpenTimeTimestamp", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 47, "wellOpenPressureValue", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, row, 48, "wellOpenOilPressureValue", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, row, 49, "wellOpenLoadFactorPresets", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, row, 50, "wellCloseTimeTimestamp", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 51, "wellClosePressureValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 52, "wellCloseOilPressureValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 53, "wellCloseFlowValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 54, "minWellOpenTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 55, "maxWellOpenTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 56, "minWellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 57, "maxWellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 58, "pressureStabilizationDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 59, "flowStabilizationDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 60, "loadFactorStabilizationDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 61, "plungerDelayDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 62, "plungerRiseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 63, "continuosFlowDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 64, "wellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 65, "wellCloseTimeNotReachedDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 66, "wellCloseNotReachedCountValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 67, "plungerDelayDurationRepeat", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 68, "targetTimeTimestamp", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 69, "targetTimeRangeValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 70, "continuosFlowIncreaseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 71, "continuosFlowDecreaseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 72, "wellCloseIncreaseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 73, "wellCloseDecreaseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 74, "minWellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 75, "maxWellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 76, "minContinuosFlowTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 77, "maxContinuosFlowTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 78, "minWellOpenTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 79, "maxWellOpenTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 80, "wellOpenPressureValueAtOpen", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 81, "wellOpenOilPressureValueAtOpen", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 82, "wellOpenLoadFactorPresetsAtOpen", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 83, "wellClosePressureValueAtClose", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 84, "wellCloseOilPressureValueAtClose", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, row, 85, "wellCloseFlowValueAtClose", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 2, "deviceId", Types.BIGINT);
ScssPersistenceHandler.this.setValue(ps, newRow, 3, "collectionTime", Types.TIMESTAMP);
ScssPersistenceHandler.this.setValue(ps, newRow, 4, "receiveTime", Types.TIMESTAMP);
ScssPersistenceHandler.this.setValue(ps, newRow, 5, "casPressure", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, newRow, 6, "oilPressure", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, newRow, 7, "firstSolenoidStatus", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 8, "batteryVoltage", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, newRow, 9, "solarVoltage", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, newRow, 10, "remainingTimeAction", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 11, "secondSolenoidStatus", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 12, "preTransmission", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 13, "internetTraffic", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 14, "loadFactor", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 15, "dataTime", Types.TIMESTAMP);
ScssPersistenceHandler.this.setValue(ps, newRow, 16, "showDelay", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 17, "openWellSamplingInterval", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 18, "closeWellSamplingInterval", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 19, "ctlModel", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 20, "minPressure", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 21, "maxPressure", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 22, "pressureMinVoltage", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 23, "pressureMaxVoltage", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 24, "oilMin", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 25, "oliMax", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 26, "oilMinVoltage", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 27, "oilMaxVoltage", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 28, "inputPressureMinValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 29, "inputPressureMaxValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 30, "inputVoltageMinValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 31, "inputVoltageMaxValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 32, "flowRateMinValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 33, "flowRateMaxValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 34, "flowVoltageMinValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 35, "flowVoltageMaxValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 36, "continuousSamplingIntervalDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 37, "sensorSignalEffectiveLevel", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 38, "pressureCompensationPolarityFlag", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 39, "pressureCompensationValueSetting", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 40, "oilPressureCompensationPolarityFlag", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 41, "oilPressureCompensationValueSetting", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 42, "inputPressureCompensationPolarityFlag", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 43, "inputPressureCompensationValueSetting", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 44, "flowCompensationPolarityFlag", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 45, "flowCompensationValueSetting", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 46, "wellOpenTimeTimestamp", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 47, "wellOpenPressureValue", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, newRow, 48, "wellOpenOilPressureValue", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, newRow, 49, "wellOpenLoadFactorPresets", Types.DECIMAL);
ScssPersistenceHandler.this.setValue(ps, newRow, 50, "wellCloseTimeTimestamp", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 51, "wellClosePressureValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 52, "wellCloseOilPressureValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 53, "wellCloseFlowValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 54, "minWellOpenTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 55, "maxWellOpenTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 56, "minWellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 57, "maxWellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 58, "pressureStabilizationDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 59, "flowStabilizationDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 60, "loadFactorStabilizationDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 61, "plungerDelayDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 62, "plungerRiseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 63, "continuosFlowDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 64, "wellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 65, "wellCloseTimeNotReachedDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 66, "wellCloseNotReachedCountValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 67, "plungerDelayDurationRepeat", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 68, "targetTimeTimestamp", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 69, "targetTimeRangeValue", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 70, "continuosFlowIncreaseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 71, "continuosFlowDecreaseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 72, "wellCloseIncreaseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 73, "wellCloseDecreaseDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 74, "minWellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 75, "maxWellCloseTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 76, "minContinuosFlowTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 77, "maxContinuosFlowTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 78, "minWellOpenTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 79, "maxWellOpenTimeDuration", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 80, "wellOpenPressureValueAtOpen", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 81, "wellOpenOilPressureValueAtOpen", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 82, "wellOpenLoadFactorPresetsAtOpen", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 83, "wellClosePressureValueAtClose", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 84, "wellCloseOilPressureValueAtClose", Types.INTEGER);
ScssPersistenceHandler.this.setValue(ps, newRow, 85, "wellCloseFlowValueAtClose", Types.INTEGER);
return ps.executeUpdate();
}
});
return row;
if (Objects.isNull(oldRow)) {
return Map.of("new", newRow);
}
return Map.of("new", newRow, "old", oldRow);
}
}

View File

@ -8,7 +8,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/23 0:51
*/
public class ComposeModbusMessageListener implements BatchMessageListener {

View File

@ -1,7 +1,7 @@
package com.isu.gaswellwatch.modbus.data.listener;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/23 0:32
*/

View File

@ -16,7 +16,7 @@ import java.nio.file.StandardOpenOption;
import java.util.List;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/23 0:47
*/
@Slf4j

View File

@ -32,7 +32,7 @@ import java.time.ZoneOffset;
import java.util.*;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/23 0:43
*/
@Slf4j

View File

@ -1,7 +1,7 @@
package com.isu.gaswellwatch.modbus.data.listener;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/26 12:37
*/
public final class Queues {

View File

@ -3,7 +3,7 @@ package com.isu.gaswellwatch.utils;
import java.util.Objects;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/25 16:07
*/
public class ReverseComplementCodeUtils {

View File

@ -5,10 +5,11 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import java.io.Serial;
import java.io.Serializable;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/15 21:07
*/
@Getter
@ -16,6 +17,8 @@ import java.io.Serializable;
@SuperBuilder
@NoArgsConstructor
public class PageQuery implements Serializable {
@Serial
private static final long serialVersionUID = 5208411501118143553L;
private Integer currentPage;
private Integer pageSize;
}