From b1df896107401b6d54fec955834764088002762c Mon Sep 17 00:00:00 2001 From: wangshilong Date: Fri, 7 Mar 2025 17:48:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8C=BA=E5=9D=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=BF=87=E6=BB=A4=EF=BC=9B=E5=A2=9E=E5=8A=A0=E7=BB=B4?= =?UTF-8?q?=E5=B0=94=E6=99=AE=E6=96=AF=E6=B0=94=E4=BA=95=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DeviceController.java | 5 ++- .../com/isu/gaswellwatch/dao/DeviceDao.java | 2 +- .../BusinessMessageHandlerListener.java | 42 ++++++++++++++----- .../gaswellwatch/service/DeviceService.java | 2 +- .../service/impl/DeviceOptLogServiceImpl.java | 6 +-- .../service/impl/DeviceServiceImpl.java | 4 +- src/main/resources/mapper/DeviceDao.xml | 10 ++++- 7 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java b/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java index b5dd7c3..6887b99 100644 --- a/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java +++ b/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java @@ -41,8 +41,9 @@ public class DeviceController { * @return */ @GetMapping(value = "/gasStation") - public List queryGasStationList(@RequestParam String gasStationName) { - return this.deviceService.queryGasStationList(gasStationName); + public List queryGasStationList(@RequestParam Long blockId, + @RequestParam String gasStationName) { + return this.deviceService.queryGasStationList(blockId, gasStationName); } /** diff --git a/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java b/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java index e9f958e..d05e087 100644 --- a/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java +++ b/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java @@ -17,7 +17,7 @@ import java.util.List; @Repository public interface DeviceDao extends BaseMapper { - List queryGasStationList(String gasStationName); + List queryGasStationList(Long blockId, String gasStationName); Page page(Page page, @Param("gasWellName") String gasWellName, diff --git a/src/main/java/com/isu/gaswellwatch/modbus/data/listener/BusinessMessageHandlerListener.java b/src/main/java/com/isu/gaswellwatch/modbus/data/listener/BusinessMessageHandlerListener.java index f2cb74f..87bef4a 100755 --- a/src/main/java/com/isu/gaswellwatch/modbus/data/listener/BusinessMessageHandlerListener.java +++ b/src/main/java/com/isu/gaswellwatch/modbus/data/listener/BusinessMessageHandlerListener.java @@ -21,10 +21,7 @@ import org.springframework.amqp.core.Message; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Slf4j @Service @@ -82,16 +79,16 @@ public class BusinessMessageHandlerListener implements BatchMessageListener { } //根据设备ID获取设备的产品类型 DeviceVO device = this.deviceService.getDevice(Long.valueOf(deviceId)); - if(null == device){ + if (null == device) { continue; } //根据对应的产品类型,用对应的气井开关字段获取开关状态(wellStatus,solenoidValveStatus,firstSolenoidStatus) String wellStatusKey = getWellStatusKey(device); //比对新旧数据,看开关状态是否一致 - if (oldObject.getString(wellStatusKey) != null && (!oldObject.getString(wellStatusKey).equals(newObject.getString(wellStatusKey)))) { - deviceWellStatusMap.put(Long.valueOf(deviceId), newObject.getInteger(wellStatusKey)); + if (Objects.nonNull(oldObject.getString(wellStatusKey)) && !Objects.equals(oldObject.getString(wellStatusKey), newObject.getString(wellStatusKey))) { + deviceWellStatusMap.put(Long.valueOf(deviceId), getWellStatusValue(device, newObject, wellStatusKey)); - if(null==newObject.getInteger(wellStatusKey)){ + if (Objects.isNull(newObject.getInteger(wellStatusKey))) { continue; } //记录开关井状态及对应的套压油压数据 @@ -102,8 +99,8 @@ public class BusinessMessageHandlerListener implements BatchMessageListener { switchStatusExport.setCasPressure(newObject.getString("casPressure")); switchStatusExport.setOilPressure(newObject.getString("oilPressure")); switchStatusExport.setBlockId(device.getGasWell().getBlockId()); - if (newObject.getInteger(wellStatusKey)!=null){ - switchStatusExport.setSwitchStatus(newObject.getInteger(wellStatusKey) == 1 ? "开井" : "关井"); + if (newObject.getInteger(wellStatusKey) != null) { + switchStatusExport.setSwitchStatus(getWellStatusValue(device, newObject, wellStatusKey) == 1 ? "开井" : "关井"); } switchStatusExportList.add(switchStatusExport); } @@ -175,7 +172,32 @@ public class BusinessMessageHandlerListener implements BatchMessageListener { wellStatusKey = "solenoidValveStatus"; } else if (PersistenceHandler.SCSS_MODBUS_TYPE.equals(device.getProduct().getCode())) { wellStatusKey = "firstSolenoidStatus"; + } else if (PersistenceHandler.WEPS_PLUG_MODBUS_TYPE.equals(device.getProduct().getCode())) { + wellStatusKey = "solenoidValveStatus"; + } else if (PersistenceHandler.MI_WEPS_PLUG_MODBUS_TYPE.equals(device.getProduct().getCode())) { + wellStatusKey = "currentStatus"; } return wellStatusKey; } + + private static Integer getWellStatusValue(DeviceVO device, JSONObject newObject, String wellStatusKey) { + Integer wellStatus = newObject.getInteger(wellStatusKey); + if (PersistenceHandler.WEPS_PLUG_MODBUS_TYPE.equals(device.getProduct().getCode())) { + if (Objects.equals(wellStatus, 1)) { + wellStatus = 0; + } else if (Objects.equals(wellStatus, 2)) { + wellStatus = 1; + } else { + wellStatus = null; + } + } else if (PersistenceHandler.MI_WEPS_PLUG_MODBUS_TYPE.equals(device.getProduct().getCode())) { + if (Objects.equals(wellStatus, 0)) { + wellStatus = 0; + } else { + wellStatus = 1; + } + } + return wellStatus; + } + } diff --git a/src/main/java/com/isu/gaswellwatch/service/DeviceService.java b/src/main/java/com/isu/gaswellwatch/service/DeviceService.java index aa60d92..3fe9244 100644 --- a/src/main/java/com/isu/gaswellwatch/service/DeviceService.java +++ b/src/main/java/com/isu/gaswellwatch/service/DeviceService.java @@ -17,7 +17,7 @@ import java.util.Map; public interface DeviceService extends IService { - List queryGasStationList(String gasStationName); + List queryGasStationList(Long blockId,String gasStationName); Page page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, String mainPipe, Long deviceTypeId, Long blockId, Integer product); diff --git a/src/main/java/com/isu/gaswellwatch/service/impl/DeviceOptLogServiceImpl.java b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceOptLogServiceImpl.java index e1c0ad0..cf5f6e2 100644 --- a/src/main/java/com/isu/gaswellwatch/service/impl/DeviceOptLogServiceImpl.java +++ b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceOptLogServiceImpl.java @@ -48,10 +48,7 @@ public class DeviceOptLogServiceImpl extends ServiceImpl page(Page page, Date start, Date end, Long deviceId) { return this.deviceDao.deviceOptLogPage(page, start, end, deviceId); } + } diff --git a/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java index 8806dbf..2e0fea1 100644 --- a/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java @@ -64,8 +64,8 @@ public class DeviceServiceImpl extends ServiceImpl implements private UserService userService; @Override - public List queryGasStationList(String gasStationName) { - List gasStationList = this.deviceDao.queryGasStationList(gasStationName); + public List queryGasStationList(Long blockId, String gasStationName) { + List gasStationList = this.deviceDao.queryGasStationList(blockId, gasStationName); if (ObjectUtils.isEmpty(gasStationList)) { return List.of(); } diff --git a/src/main/resources/mapper/DeviceDao.xml b/src/main/resources/mapper/DeviceDao.xml index 88e57f2..720d15c 100644 --- a/src/main/resources/mapper/DeviceDao.xml +++ b/src/main/resources/mapper/DeviceDao.xml @@ -39,8 +39,16 @@