diff --git a/src/main/java/com/isu/gaswellwatch/modbus/data/decode/impl/weps/WepsRemainingLocalTimeDecodeHandler.java b/src/main/java/com/isu/gaswellwatch/modbus/data/decode/impl/weps/WepsRemainingLocalTimeDecodeHandler.java index 4443bad..67186a9 100644 --- a/src/main/java/com/isu/gaswellwatch/modbus/data/decode/impl/weps/WepsRemainingLocalTimeDecodeHandler.java +++ b/src/main/java/com/isu/gaswellwatch/modbus/data/decode/impl/weps/WepsRemainingLocalTimeDecodeHandler.java @@ -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); diff --git a/src/main/java/com/isu/gaswellwatch/vo/DeviceVO.java b/src/main/java/com/isu/gaswellwatch/vo/DeviceVO.java index 04430c6..339039a 100644 --- a/src/main/java/com/isu/gaswellwatch/vo/DeviceVO.java +++ b/src/main/java/com/isu/gaswellwatch/vo/DeviceVO.java @@ -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 { 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; + } + } diff --git a/src/main/resources/sql/CREATE_MI_WEPS_PLUG.sql b/src/main/resources/sql/CREATE_MI_WEPS_PLUG.sql index fcead1c..3eb737f 100644 --- a/src/main/resources/sql/CREATE_MI_WEPS_PLUG.sql +++ b/src/main/resources/sql/CREATE_MI_WEPS_PLUG.sql @@ -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', diff --git a/src/main/resources/sql/CREATE_WEPS_PLUG.sql b/src/main/resources/sql/CREATE_WEPS_PLUG.sql index 63a54eb..e36f9a0 100644 --- a/src/main/resources/sql/CREATE_WEPS_PLUG.sql +++ b/src/main/resources/sql/CREATE_WEPS_PLUG.sql @@ -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, diff --git a/src/test/java/com/isu/gaswellwatch/MIWrpsDecodeTest.java b/src/test/java/com/isu/gaswellwatch/MIWrpsDecodeTest.java index 825a508..5b73bab 100644 --- a/src/test/java/com/isu/gaswellwatch/MIWrpsDecodeTest.java +++ b/src/test/java/com/isu/gaswellwatch/MIWrpsDecodeTest.java @@ -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));