增加区块查询过滤;增加维尔普斯气井状态检查逻辑

This commit is contained in:
wangshilong 2025-03-07 17:48:01 +08:00
parent d2c050780b
commit b1df896107
7 changed files with 50 additions and 21 deletions

View File

@ -41,8 +41,9 @@ public class DeviceController {
* @return * @return
*/ */
@GetMapping(value = "/gasStation") @GetMapping(value = "/gasStation")
public List<GasStationVO> queryGasStationList(@RequestParam String gasStationName) { public List<GasStationVO> queryGasStationList(@RequestParam Long blockId,
return this.deviceService.queryGasStationList(gasStationName); @RequestParam String gasStationName) {
return this.deviceService.queryGasStationList(blockId, gasStationName);
} }
/** /**

View File

@ -17,7 +17,7 @@ import java.util.List;
@Repository @Repository
public interface DeviceDao extends BaseMapper<Device> { public interface DeviceDao extends BaseMapper<Device> {
List<String> queryGasStationList(String gasStationName); List<String> queryGasStationList(Long blockId, String gasStationName);
Page<DeviceVO> page(Page<Object> page, Page<DeviceVO> page(Page<Object> page,
@Param("gasWellName") String gasWellName, @Param("gasWellName") String gasWellName,

View File

@ -21,10 +21,7 @@ import org.springframework.amqp.core.Message;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@Service @Service
@ -82,16 +79,16 @@ public class BusinessMessageHandlerListener implements BatchMessageListener {
} }
//根据设备ID获取设备的产品类型 //根据设备ID获取设备的产品类型
DeviceVO device = this.deviceService.getDevice(Long.valueOf(deviceId)); DeviceVO device = this.deviceService.getDevice(Long.valueOf(deviceId));
if(null == device){ if (null == device) {
continue; continue;
} }
//根据对应的产品类型用对应的气井开关字段获取开关状态(wellStatus,solenoidValveStatus,firstSolenoidStatus) //根据对应的产品类型用对应的气井开关字段获取开关状态(wellStatus,solenoidValveStatus,firstSolenoidStatus)
String wellStatusKey = getWellStatusKey(device); String wellStatusKey = getWellStatusKey(device);
//比对新旧数据看开关状态是否一致 //比对新旧数据看开关状态是否一致
if (oldObject.getString(wellStatusKey) != null && (!oldObject.getString(wellStatusKey).equals(newObject.getString(wellStatusKey)))) { if (Objects.nonNull(oldObject.getString(wellStatusKey)) && !Objects.equals(oldObject.getString(wellStatusKey), newObject.getString(wellStatusKey))) {
deviceWellStatusMap.put(Long.valueOf(deviceId), newObject.getInteger(wellStatusKey)); deviceWellStatusMap.put(Long.valueOf(deviceId), getWellStatusValue(device, newObject, wellStatusKey));
if(null==newObject.getInteger(wellStatusKey)){ if (Objects.isNull(newObject.getInteger(wellStatusKey))) {
continue; continue;
} }
//记录开关井状态及对应的套压油压数据 //记录开关井状态及对应的套压油压数据
@ -102,8 +99,8 @@ public class BusinessMessageHandlerListener implements BatchMessageListener {
switchStatusExport.setCasPressure(newObject.getString("casPressure")); switchStatusExport.setCasPressure(newObject.getString("casPressure"));
switchStatusExport.setOilPressure(newObject.getString("oilPressure")); switchStatusExport.setOilPressure(newObject.getString("oilPressure"));
switchStatusExport.setBlockId(device.getGasWell().getBlockId()); switchStatusExport.setBlockId(device.getGasWell().getBlockId());
if (newObject.getInteger(wellStatusKey)!=null){ if (newObject.getInteger(wellStatusKey) != null) {
switchStatusExport.setSwitchStatus(newObject.getInteger(wellStatusKey) == 1 ? "开井" : "关井"); switchStatusExport.setSwitchStatus(getWellStatusValue(device, newObject, wellStatusKey) == 1 ? "开井" : "关井");
} }
switchStatusExportList.add(switchStatusExport); switchStatusExportList.add(switchStatusExport);
} }
@ -175,7 +172,32 @@ public class BusinessMessageHandlerListener implements BatchMessageListener {
wellStatusKey = "solenoidValveStatus"; wellStatusKey = "solenoidValveStatus";
} else if (PersistenceHandler.SCSS_MODBUS_TYPE.equals(device.getProduct().getCode())) { } else if (PersistenceHandler.SCSS_MODBUS_TYPE.equals(device.getProduct().getCode())) {
wellStatusKey = "firstSolenoidStatus"; 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; 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;
}
} }

View File

@ -17,7 +17,7 @@ import java.util.Map;
public interface DeviceService extends IService<Device> { public interface DeviceService extends IService<Device> {
List<GasStationVO> queryGasStationList(String gasStationName); List<GasStationVO> queryGasStationList(Long blockId,String gasStationName);
Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, String mainPipe, Long deviceTypeId, Long blockId, Integer product); Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, String mainPipe, Long deviceTypeId, Long blockId, Integer product);

View File

@ -48,10 +48,7 @@ public class DeviceOptLogServiceImpl extends ServiceImpl<DeviceOptLogDao, Device
deviceOptLog.setGasStation(deviceVO.getGasStation()); deviceOptLog.setGasStation(deviceVO.getGasStation());
String content = ""; String content = "";
if ("device".equalsIgnoreCase(source)) { if ("device".equalsIgnoreCase(source)) {
content = content = isOpen == 1 ? "检测到气井开启" : "检测到气井关闭";
isOpen == 1 ? "检测到气井开启" : "检测到气井关闭";
deviceOptLog.setUsername("系统"); deviceOptLog.setUsername("系统");
deviceOptLog.setName("系统"); deviceOptLog.setName("系统");
} else { } else {
@ -68,5 +65,6 @@ public class DeviceOptLogServiceImpl extends ServiceImpl<DeviceOptLogDao, Device
public Page<DeviceOptLog> page(Page<DeviceOptLog> page, Date start, Date end, Long deviceId) { public Page<DeviceOptLog> page(Page<DeviceOptLog> page, Date start, Date end, Long deviceId) {
return this.deviceDao.deviceOptLogPage(page, start, end, deviceId); return this.deviceDao.deviceOptLogPage(page, start, end, deviceId);
} }
} }

View File

@ -64,8 +64,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
private UserService userService; private UserService userService;
@Override @Override
public List<GasStationVO> queryGasStationList(String gasStationName) { public List<GasStationVO> queryGasStationList(Long blockId, String gasStationName) {
List<String> gasStationList = this.deviceDao.queryGasStationList(gasStationName); List<String> gasStationList = this.deviceDao.queryGasStationList(blockId, gasStationName);
if (ObjectUtils.isEmpty(gasStationList)) { if (ObjectUtils.isEmpty(gasStationList)) {
return List.of(); return List.of();
} }

View File

@ -39,8 +39,16 @@
<select id="queryGasStationList" resultType="string"> <select id="queryGasStationList" resultType="string">
select u.gas_station select u.gas_station
from device u from device u
where u.gas_station LIKE CONCAT('%', #{gasStationName}, '%') <where>
<if test="gasStationName != null">
and u.gas_station LIKE CONCAT('%', #{gasStationName}, '%')
</if>
<if test="blockId != null">
and exists (select 1 from gas_well gw where gw.id = u.gas_well and gw.block_id = #{blockId})
</if>
</where>
order by u.id desc order by u.id desc
limit 10
</select> </select>
<select id="page" resultMap="DeviceVOMap"> <select id="page" resultMap="DeviceVOMap">