WEPS时间类型入库逻辑调整

This commit is contained in:
wangshilong 2025-03-02 18:42:12 +08:00
parent c03c3a70ba
commit 694fdb0a1e
5 changed files with 60 additions and 38 deletions

View File

@ -4,7 +4,6 @@ import cn.hutool.core.map.MapUtil;
import com.isu.gaswellwatch.modbus.data.ModbusMessage;
import com.isu.gaswellwatch.modbus.data.decode.DecodeHandler;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.stereotype.Component;
import java.util.Map;
@ -35,10 +34,10 @@ public class WepsRemainingLocalTimeDecodeHandler implements DecodeHandler {
minuteSecond = StringUtils.leftPad(minuteSecond, 4, '0');
dayHour = StringUtils.leftPad(dayHour, 4, '0');
long daySeconds = TimeUnit.DAYS.toSeconds(NumberUtils.createLong(StringUtils.substring(dayHour, 0, 2)));
long hourSeconds = TimeUnit.HOURS.toSeconds(NumberUtils.createLong(StringUtils.substring(dayHour, 2)));
long minuteSeconds = TimeUnit.HOURS.toSeconds(NumberUtils.createLong(StringUtils.substring(minuteSecond, 0, 2)));
long seconds = TimeUnit.HOURS.toSeconds(NumberUtils.createLong(StringUtils.substring(minuteSecond, 2)));
long daySeconds = TimeUnit.DAYS.toSeconds(Long.valueOf(StringUtils.substring(dayHour, 0, 2)));
long hourSeconds = TimeUnit.HOURS.toSeconds(Long.valueOf(StringUtils.substring(dayHour, 2)));
long minuteSeconds = TimeUnit.HOURS.toSeconds(Long.valueOf(StringUtils.substring(minuteSecond, 0, 2)));
long seconds = TimeUnit.HOURS.toSeconds(Long.valueOf(StringUtils.substring(minuteSecond, 2)));
long totalSeconds = daySeconds + hourSeconds + minuteSeconds + seconds;
long hours = TimeUnit.SECONDS.toHours(totalSeconds);

View File

@ -8,6 +8,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
/**
* 设备对象 Device
@ -129,4 +130,26 @@ public class DeviceVO extends Model<DeviceVO> {
this.voltage = NumberScaleUtils.formatTwoScalePositiveNumber(voltage);
}
public String getGasStationName() {
if (StringUtils.isBlank(this.gasStation)) {
return this.gasStation;
}
if (StringUtils.contains(this.gasStation, "(")
&& StringUtils.contains(this.gasStation, ")")) {
return StringUtils.substring(this.gasStation, 0, StringUtils.indexOf(this.gasStation, "("));
}
return this.gasStation;
}
public String getMainPipe() {
if (StringUtils.isBlank(this.gasStation)) {
return this.gasStation;
}
if (StringUtils.contains(this.gasStation, "(")
&& StringUtils.contains(this.gasStation, ")")) {
return StringUtils.substringBetween(this.gasStation, "(", ")");
}
return null;
}
}

View File

@ -8,7 +8,7 @@ CREATE TABLE `$TableName$`
`report_status` int NULL DEFAULT NULL COMMENT '报表状态 - 0:无报表数据; 1:有分钟记录; 2:有小时记录; 3:有日志记录; 4:有生产记录',
`current_status` int NULL DEFAULT NULL COMMENT '当前状态 - 0:关井; 1:上升; 2:续流; 3:停机',
`current_time` datetime NULL DEFAULT NULL COMMENT '当前时间 - "控制器时间。示例0x4830:0x0211:0x0924:0x2013。结果2013-09-24 11:48:30"',
`remaining_time` varchar(10) NULL DEFAULT NULL COMMENT '剩余时间 - "组合后时间格式:天.小时:分钟:秒。示例0x0930:0x0001。结果0.1:09:30"',
`remaining_time` varchar(20) NULL DEFAULT NULL COMMENT '剩余时间 - "组合后时间格式:天.小时:分钟:秒。示例0x0930:0x0001。结果0.1:09:30"',
`current_status_0x` varchar(10) NULL DEFAULT NULL COMMENT '当前状态0x - 0x8000:关井0x8001:上升0x8002:续流0x8003:停机',
`oil_pressure` decimal(12, 4) NULL DEFAULT NULL COMMENT '油压 - 单位MPa',
`oil_pressure_temperature` decimal(12, 4) NULL DEFAULT NULL COMMENT '油压表测量温度 - 单位:℃',
@ -28,31 +28,31 @@ CREATE TABLE `$TableName$`
`oil_and_cas_data_collection_interval` int NULL DEFAULT NULL COMMENT '油、套压数据采集间隔 - 0每5秒采样1每10秒采样2每15秒采样3每30秒采样4每1秒采样5每2秒采样6每3秒采样7每4秒采样',
`store_data_interval_on_open_well` int NULL DEFAULT NULL COMMENT '数据存储间隔(开井期间) - 0每1分钟存储1每5分钟存储2每10分钟存储3每15分钟存储4每30秒存储5每15秒存储6每5秒存储',
`store_data_interval_on_close_well` int NULL DEFAULT NULL COMMENT '数据存储间隔(关井期间) - 0每1分钟存储1每5分钟存储2每10分钟存储3每15分钟存储4每30秒存储5每15秒存储6每5秒存储',
`communication_power_threshold` decimal(12, 4) NULL DEFAULT NULL COMMENT '通信电量门限 - Zigbee通讯使用',
`communication_power_threshold` int NULL DEFAULT NULL COMMENT '通信电量门限 - Zigbee通讯使用',
`reserve1` int NULL DEFAULT NULL COMMENT '保留 - Zigbee通讯使用',
`start_time_of_daytime` int NULL DEFAULT NULL COMMENT '白天起始时间 - Zigbee通讯使用',
`end_time_of_daytime` int NULL DEFAULT NULL COMMENT '白天结束时间 - Zigbee通讯使用',
`control_work_time` int NULL DEFAULT NULL COMMENT '控制器工作状态 - 0生产模式1常开模式2常关模式',
`produce_mode` int NULL DEFAULT NULL COMMENT '生产制度设置 - 0定时开关井1时间优化模式2压力微升模式3压力回升模式4压力跌落模式',
`plunger_rise_time` varchar(10) NULL DEFAULT NULL COMMENT '上升时间 - 单位:秒',
`dangerous_rise_time` varchar(10) NULL DEFAULT NULL COMMENT '危险上升时间 - 单位:秒',
`too_fast_rise_time` varchar(10) NULL DEFAULT NULL COMMENT '过快上升时间 - 单位:秒',
`too_slow_rise_time` varchar(10) NULL DEFAULT NULL COMMENT '过缓上升时间 - 单位:秒',
`plunger_rise_time` varchar(20) NULL DEFAULT NULL COMMENT '上升时间 - 单位:秒',
`dangerous_rise_time` varchar(20) NULL DEFAULT NULL COMMENT '危险上升时间 - 单位:秒',
`too_fast_rise_time` varchar(20) NULL DEFAULT NULL COMMENT '过快上升时间 - 单位:秒',
`too_slow_rise_time` varchar(20) NULL DEFAULT NULL COMMENT '过缓上升时间 - 单位:秒',
`too_fast_count` int NULL DEFAULT NULL COMMENT '过快次数',
`too_fast_raise_open_well_time` varchar(10) NULL DEFAULT NULL COMMENT '过快增加开井时间 - 单位:秒',
`too_fast_lower_close_well_time` varchar(10) NULL DEFAULT NULL COMMENT '过快减少关井时间 - 单位:秒',
`too_slow_lower_open_well_time` varchar(10) NULL DEFAULT NULL COMMENT '过缓减少开井时间 - 单位:秒',
`too_slow_raise_close_well_time` varchar(10) NULL DEFAULT NULL COMMENT '过缓增加关井时间 - 单位:秒',
`check_stability_time` varchar(10) NULL DEFAULT NULL COMMENT '检测稳定时间 - 单位:秒',
`min_close_well_time` varchar(10) NULL DEFAULT NULL COMMENT '最小关井时间 - 单位:秒',
`max_close_well_time` varchar(10) NULL DEFAULT NULL COMMENT '最大关井时间 - 单位:秒',
`well_close_time_not_reached_duration` varchar(10) NULL DEFAULT NULL COMMENT '未到达关井时间 - 单位:秒',
`min_open_well_time` varchar(10) NULL DEFAULT NULL COMMENT '最小开井时间 - 单位:秒',
`max_open_well_time` varchar(10) NULL DEFAULT NULL COMMENT '最大开井时间 - 单位:秒',
`after_flow_time` varchar(10) NULL DEFAULT NULL COMMENT '续流时间 - 单位:秒',
`not_reached_flow_time` varchar(10) NULL DEFAULT NULL COMMENT '未到续流时间 - 单位:秒',
`close_time` varchar(10) NULL DEFAULT NULL COMMENT '关井时间 - 单位:秒',
`open_time` varchar(10) NULL DEFAULT NULL COMMENT '开井时间 - 单位:秒',
`too_fast_raise_open_well_time` varchar(20) NULL DEFAULT NULL COMMENT '过快增加开井时间 - 单位:秒',
`too_fast_lower_close_well_time` varchar(20) NULL DEFAULT NULL COMMENT '过快减少关井时间 - 单位:秒',
`too_slow_lower_open_well_time` varchar(20) NULL DEFAULT NULL COMMENT '过缓减少开井时间 - 单位:秒',
`too_slow_raise_close_well_time` varchar(20) NULL DEFAULT NULL COMMENT '过缓增加关井时间 - 单位:秒',
`check_stability_time` varchar(20) NULL DEFAULT NULL COMMENT '检测稳定时间 - 单位:秒',
`min_close_well_time` varchar(20) NULL DEFAULT NULL COMMENT '最小关井时间 - 单位:秒',
`max_close_well_time` varchar(20) NULL DEFAULT NULL COMMENT '最大关井时间 - 单位:秒',
`well_close_time_not_reached_duration` varchar(20) NULL DEFAULT NULL COMMENT '未到达关井时间 - 单位:秒',
`min_open_well_time` varchar(20) NULL DEFAULT NULL COMMENT '最小开井时间 - 单位:秒',
`max_open_well_time` varchar(20) NULL DEFAULT NULL COMMENT '最大开井时间 - 单位:秒',
`after_flow_time` varchar(20) NULL DEFAULT NULL COMMENT '续流时间 - 单位:秒',
`not_reached_flow_time` varchar(20) NULL DEFAULT NULL COMMENT '未到续流时间 - 单位:秒',
`close_time` varchar(20) NULL DEFAULT NULL COMMENT '关井时间 - 单位:秒',
`open_time` varchar(20) NULL DEFAULT NULL COMMENT '开井时间 - 单位:秒',
`open_pressure` decimal(12, 4) NULL DEFAULT NULL COMMENT '开井压力 - 单位MPa',
`close_pressure` decimal(12, 4) NULL DEFAULT NULL COMMENT '关井压力 - 单位MPa',
`little_rise_pressure` decimal(12, 4) NULL DEFAULT NULL COMMENT '微升压力 - 单位MPa',

View File

@ -9,8 +9,8 @@ CREATE TABLE `$TableName$`
`oil_pressure` decimal(10, 2) NULL DEFAULT NULL COMMENT '油压MPa-3表示现场仪表通信故障',
`alarm` int NULL DEFAULT NULL COMMENT '报警信息1高压集气压力低2低压集气压力高3是柱塞危险上升4 柱塞快速上升次数超过设定值',
`solenoid_valve_status` int NULL DEFAULT NULL COMMENT '电磁阀状态0-未知1-关状态2-开状态;',
`open_well_remaining_time` varchar(10) NULL DEFAULT NULL COMMENT '定时开井剩余时间;分钟',
`close_well_remaining_time` varchar(10) NULL DEFAULT NULL COMMENT '定时关井剩余时间;分钟',
`open_well_remaining_time` varchar(20) NULL DEFAULT NULL COMMENT '定时开井剩余时间;分钟',
`close_well_remaining_time` varchar(20) NULL DEFAULT NULL COMMENT '定时关井剩余时间;分钟',
`plug_arrival_status` int NULL DEFAULT NULL COMMENT '柱塞到达信号0-未到达1-到达;',
`plug_too_fast_count` int NULL DEFAULT NULL COMMENT '柱塞过快次数;次',
`plug_rising_speed` int NULL DEFAULT NULL COMMENT '柱塞上升速度;米/分钟',
@ -24,17 +24,17 @@ CREATE TABLE `$TableName$`
`high_pressure_protection` decimal(10, 2) NULL DEFAULT NULL COMMENT '高压保护压力MPa低压集气方式 高压保护设置;',
`low_pressure_protection` decimal(10, 2) NULL DEFAULT NULL COMMENT '低压保护压力MPa高压集气方式 低压保护设置;',
`too_fast_count` int NULL DEFAULT NULL COMMENT '过快次数设置;次',
`dangerous_rise_time` varchar(10) NULL DEFAULT NULL COMMENT '危险上升时间HH:mm:ss',
`too_fast_rise_time` varchar(10) NULL DEFAULT NULL COMMENT '过快上升时间HH:mm:ss',
`open_well_time` varchar NULL DEFAULT NULL COMMENT '开井时间设置分钟HH:mm',
`close_well_time` varchar NULL DEFAULT NULL COMMENT '关井时间设置分钟HH:mm',
`dangerous_rise_time` varchar(20) NULL DEFAULT NULL COMMENT '危险上升时间HH:mm:ss',
`too_fast_rise_time` varchar(20) NULL DEFAULT NULL COMMENT '过快上升时间HH:mm:ss',
`open_well_time` varchar(20) NULL DEFAULT NULL COMMENT '开井时间设置分钟HH:mm',
`close_well_time` varchar(20) NULL DEFAULT NULL COMMENT '关井时间设置分钟HH:mm',
`open_well_cas_pressure` decimal(10, 2) NULL DEFAULT NULL COMMENT '套压开井压力MPa压力优化微升模式',
`little_rise_cas_pressure` decimal(10, 2) NULL DEFAULT NULL COMMENT '套压微升压力MPa压力优化微升模式',
`check_stability_time` varchar(10) NULL DEFAULT NULL COMMENT '检测稳定时间HH:mm:ss',
`min_close_well_time` varchar(10) NULL DEFAULT NULL COMMENT '最小关井时间分钟HH:mm',
`max_close_well_time` varchar(10) NULL DEFAULT NULL COMMENT '最大关井时间分钟HH:mm',
`min_open_well_time` varchar(10) NULL DEFAULT NULL COMMENT '最小开井时间分钟HH:mm',
`max_open_well_time` varchar(10) NULL DEFAULT NULL COMMENT '最大开井时间分钟HH:mm',
`check_stability_time` varchar(20) NULL DEFAULT NULL COMMENT '检测稳定时间HH:mm:ss',
`min_close_well_time` varchar(20) NULL DEFAULT NULL COMMENT '最小关井时间分钟HH:mm',
`max_close_well_time` varchar(20) NULL DEFAULT NULL COMMENT '最大关井时间分钟HH:mm',
`min_open_well_time` varchar(20) NULL DEFAULT NULL COMMENT '最小开井时间分钟HH:mm',
`max_open_well_time` varchar(20) NULL DEFAULT NULL COMMENT '最大开井时间分钟HH:mm',
`well_depth` int NULL DEFAULT NULL COMMENT '气井深度;米',
`produce_mode` int NULL DEFAULT NULL COMMENT '生产制度1-常开2-常关3-柱塞气举',
PRIMARY KEY (`id`) USING BTREE,

View File

@ -25,7 +25,7 @@ import java.util.concurrent.locks.LockSupport;
@ActiveProfiles("test")
public class MIWrpsDecodeTest {
private String message10301 = "564D2E53352E31352E34315831/50002/10301/1740200010000/1740200016203/01032C0003000000E0553106120222202500000000800358C0411E27B13F46AACB411ED507408C000042C80000000071B2";
private String message10301 = "564D2E53352E31352E34315831/50002/10301/1740200010000/1740200016203/01032C0004000000FB32330017030220251C290113800020C93FDE08B73FFE5AD5405D78EE406A000042C80E004844D8C3";
private String message10302 = "564D2E53352E31352E34315831/50002/10302/1740197640001/1740197646124/01038E00000CE9000100010A8C00FA028A0064D5CB2D353531342D583100310000000000000000000000000000000000000000000000000000000041C800010007001900020000070800000000D960FFFEFEFE2300FEFEFFFEEEFF00C41000000E08000007580000022000001C2000001C0000A000BAFEE770002002580000A000FEFE0000000000006B0000000000000046D5";
@Resource(name = "stringRedisTemplate")
@ -45,7 +45,7 @@ public class MIWrpsDecodeTest {
Mockito.doReturn("/modbus/collect/0").when(testMessageProperties).getConsumerQueue();
Assertions.assertDoesNotThrow(() -> this.dynamicRabbitListener.getComposeListener().onMessage(testMessage10301));
Assertions.assertDoesNotThrow(() -> this.dynamicRabbitListener.getComposeListener().onMessage(testMessage10302));
// Assertions.assertDoesNotThrow(() -> this.dynamicRabbitListener.getComposeListener().onMessage(testMessage10302));
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(2));