根据Excel内容修改BUG

This commit is contained in:
wangshilong 2025-02-28 00:20:47 +08:00
parent 1a82fdd52d
commit ce8cd2402c
10 changed files with 307 additions and 76 deletions

View File

@ -11,12 +11,14 @@ import com.isu.gaswellwatch.exception.BusinessException;
import com.isu.gaswellwatch.service.DeviceService;
import com.isu.gaswellwatch.vo.DeviceHistoryVO;
import com.isu.gaswellwatch.vo.DeviceVO;
import com.isu.gaswellwatch.vo.GasStationVO;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
/**
@ -32,6 +34,17 @@ public class DeviceController {
private final DeviceService deviceService;
/**
* 查询气井列表
*
* @param gasStationName
* @return
*/
@GetMapping(value = "/gasStation")
public List<GasStationVO> queryGasStationList(@RequestParam String gasStationName) {
return this.deviceService.queryGasStationList(gasStationName);
}
/**
* 查询设备列表
*/
@ -40,9 +53,10 @@ public class DeviceController {
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(required = false) String gasWellName,
@RequestParam(required = false) String gasStationName,
@RequestParam(required = false) String mainPipe,
@RequestParam(required = false) Integer product,
@RequestParam Long deviceTypeId,@RequestParam Long blockId) {
return Response.succeed(deviceService.page(currentPage, pageSize, gasWellName,gasStationName,deviceTypeId,blockId,product));
@RequestParam Long deviceTypeId, @RequestParam Long blockId) {
return Response.succeed(this.deviceService.page(currentPage, pageSize, gasWellName, gasStationName, mainPipe, deviceTypeId, blockId, product));
}
/**
@ -50,18 +64,18 @@ public class DeviceController {
*/
@GetMapping(value = "/getDevice")
public Response<DeviceVO> getDevice(@RequestParam Long id) {
return Response.succeed(deviceService.getDevice(id));
return Response.succeed(this.deviceService.getDevice(id));
}
/**
*新增设备
* 新增设备
*/
@PostMapping(value = "/add")
@OperationLog(description = "新增设备", type = LogType.ADD)
public Response<String> add(@RequestBody @Valid DeviceCreateDTO deviceCreateDTO) {
try {
deviceService.add(deviceCreateDTO);
}catch (NumberFormatException e){
this.deviceService.add(deviceCreateDTO);
} catch (NumberFormatException e) {
throw new BusinessException("设备编号只能为纯数字格式");
}
return Response.succeed();
@ -73,7 +87,7 @@ public class DeviceController {
@PostMapping("/edit")
@OperationLog(description = "修改设备", type = LogType.UPDATE)
public Response<String> edit(@RequestBody @Valid DeviceEditDTO deviceEditDTO) {
deviceService.edit(deviceEditDTO);
this.deviceService.edit(deviceEditDTO);
return Response.succeed();
}
@ -83,7 +97,7 @@ public class DeviceController {
@GetMapping("/delete")
@OperationLog(description = "删除设备", type = LogType.DELETE)
public Response<String> delete(@RequestParam Long id) {
deviceService.delete(id);
this.deviceService.delete(id);
return Response.succeed();
}
@ -91,8 +105,8 @@ public class DeviceController {
* 获取设备控制数据
*/
@GetMapping("/getDeviceControlData")
public Response<Map<String,String>> getDeviceControlData(@RequestParam Long deviceId) {
return Response.succeed(deviceService.getDeviceControlData(deviceId));
public Response<Map<String, String>> getDeviceControlData(@RequestParam Long deviceId) {
return Response.succeed(this.deviceService.getDeviceControlData(deviceId));
}
/**
@ -101,11 +115,11 @@ public class DeviceController {
@GetMapping("/getDeviceHistoryData")
public Response<Page<DeviceHistoryVO>> getDeviceHistoryData(@RequestParam(defaultValue = "1") Integer currentPage,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(required = false)String startTime,
@RequestParam (required = false)String endTime,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime,
@RequestParam Long deviceId) {
try {
return Response.succeed(deviceService.getDeviceHistoryData(currentPage,pageSize,startTime,endTime,deviceId));
return Response.succeed(this.deviceService.getDeviceHistoryData(currentPage, pageSize, startTime, endTime, deviceId));
} catch (ParseException e) {
throw new BusinessException("日期格式错误");
}
@ -117,11 +131,11 @@ public class DeviceController {
@GetMapping("/getDeviceLogData")
public Response<Page<DeviceOptLog>> getDeviceLogData(@RequestParam(defaultValue = "1") Integer currentPage,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(required = false)String startTime,
@RequestParam (required = false)String endTime,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime,
@RequestParam Long deviceId) {
try {
return Response.succeed(deviceService.getDeviceLogData(currentPage,pageSize,startTime,endTime,deviceId));
return Response.succeed(this.deviceService.getDeviceLogData(currentPage, pageSize, startTime, endTime, deviceId));
} catch (ParseException e) {
throw new BusinessException("日期格式错误");
}
@ -131,13 +145,13 @@ public class DeviceController {
* 设备历史数据导出
*/
@GetMapping("/exportHistoryData")
@OperationLog(description = "设备历史数据导出",type = LogType.EXPORT)
@OperationLog(description = "设备历史数据导出", type = LogType.EXPORT)
public void exportHistoryData(HttpServletResponse response,
@RequestParam Long deviceId,
@RequestParam String startTime,
@RequestParam String endTime) {
try{
deviceService.exportHistoryData(response,deviceId, startTime, endTime);
try {
this.deviceService.exportHistoryData(response, deviceId, startTime, endTime);
} catch (ParseException e) {
throw new BusinessException("日期格式错误");
}
@ -147,13 +161,12 @@ public class DeviceController {
* 设备开关状态数据导出
*/
@GetMapping("/exportSwitchStatusData")
@OperationLog(description = "设备开关状态数据导出",type = LogType.EXPORT)
@OperationLog(description = "设备开关状态数据导出", type = LogType.EXPORT)
public void exportSwitchStatusData(HttpServletResponse response,
@RequestParam String startTime,
@RequestParam String endTime) {
deviceService.exportSwitchStatusData(response, startTime, endTime);
this.deviceService.exportSwitchStatusData(response, startTime, endTime);
}
}

View File

@ -17,9 +17,12 @@ import java.util.List;
@Repository
public interface DeviceDao extends BaseMapper<Device> {
List<String> queryGasStationList(String gasStationName);
Page<DeviceVO> page(Page<Object> page,
@Param("gasWellName") String gasWellName,
@Param("gasStationName") String gasStationName,
@Param("mainPipe") String mainPipe,
@Param("deviceTypeId") Long deviceTypeId,
@Param("blockId") Long blockId,
@Param("product") Integer product);
@ -28,25 +31,25 @@ public interface DeviceDao extends BaseMapper<Device> {
DeviceVO getDeviceById(@Param("id") Long id);
Page<DeviceHistoryVO> historyPage(Page<Object> objectPage,
@Param("startTime")Date startTime,
@Param("endTime")Date endTime,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("deviceId") Long deviceId,
@Param("tableName") String tableName,
@Param("deviceProduct") String deviceProduct);
Page<DeviceOptLog> deviceOptLogPage(Page<DeviceOptLog> objectPage,
@Param("startTime")Date startTime,
@Param("endTime")Date endTime,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("deviceId") Long deviceId);
List<DeviceVO> getDeviceVOByIds(@Param("idList")List<Long> deviceIdList);
List<DeviceVO> getDeviceVOByIds(@Param("idList") List<Long> deviceIdList);
List<DeviceHistoryVO> getPressureChartData(Long deviceId, String startTime, String endTime, String tableName);
List<DeviceHistoryVO> getSwitchStatusData(Long deviceId, String startTime, String endTime, String tableName,String deviceProduct);
List<DeviceHistoryVO> getSwitchStatusData(Long deviceId, String startTime, String endTime, String tableName, String deviceProduct);
List<DeviceHistoryVO> getDeviceHistoryData(@Param("startTime")Date startTime,
@Param("endTime")Date endTime,
List<DeviceHistoryVO> getDeviceHistoryData(@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("deviceId") Long deviceId,
@Param("tableName") String tableName,
@Param("deviceProduct") String deviceProduct);

View File

@ -8,6 +8,7 @@ import com.isu.gaswellwatch.entity.Device;
import com.isu.gaswellwatch.entity.DeviceOptLog;
import com.isu.gaswellwatch.vo.DeviceHistoryVO;
import com.isu.gaswellwatch.vo.DeviceVO;
import com.isu.gaswellwatch.vo.GasStationVO;
import jakarta.servlet.http.HttpServletResponse;
import java.text.ParseException;
@ -16,7 +17,9 @@ import java.util.Map;
public interface DeviceService extends IService<Device> {
Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId, Integer product);
List<GasStationVO> queryGasStationList(String gasStationName);
Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, String mainPipe, Long deviceTypeId, Long blockId, Integer product);
void add(DeviceCreateDTO deviceCreateDTO);
@ -26,7 +29,7 @@ public interface DeviceService extends IService<Device> {
DeviceVO getDevice(Long id);
Map<String,String> getDeviceControlData(Long deviceId);
Map<String, String> getDeviceControlData(Long deviceId);
Page<DeviceHistoryVO> getDeviceHistoryData(Integer currentPage, Integer pageSize, String startTime, String endTime, Long deviceId) throws ParseException;
@ -36,7 +39,7 @@ public interface DeviceService extends IService<Device> {
List<DeviceHistoryVO> getPressureChartData(Long deviceId, String startTime, String endTime);
List<DeviceHistoryVO> getSwitchStatusData(Long deviceId, String startTime, String endTime,String deviceProduct);
List<DeviceHistoryVO> getSwitchStatusData(Long deviceId, String startTime, String endTime, String deviceProduct);
void exportHistoryData(HttpServletResponse response, Long deviceId, String startTime, String endTime) throws ParseException;

View File

@ -25,6 +25,7 @@ import com.isu.gaswellwatch.vo.*;
import jakarta.annotation.Resource;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.RedisConnectionFailureException;
import org.springframework.data.redis.core.RedisTemplate;
@ -35,10 +36,7 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
@Service("deviceService")
@ -66,8 +64,28 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
private UserService userService;
@Override
public Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId, Integer product) {
Page<DeviceVO> page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, deviceTypeId, blockId, product);
public List<GasStationVO> queryGasStationList(String gasStationName) {
List<String> gasStationList = this.deviceDao.queryGasStationList(gasStationName);
if (ObjectUtils.isEmpty(gasStationList)) {
return List.of();
}
Map<String, GasStationVO> gasStationMap = new LinkedHashMap<>();
gasStationList.forEach(name -> {
if (StringUtils.contains(name, "(") && StringUtils.contains(name, ")")) {
GasStationVO vo = gasStationMap.computeIfAbsent(StringUtils.substring(name, 0, StringUtils.indexOf(name, "(")),
k -> GasStationVO.builder().name(k).pipes(new HashSet<>()).build());
vo.getPipes().add(StringUtils.substringBetween(name, "(", ")"));
} else {
gasStationMap.computeIfAbsent(name,
k -> GasStationVO.builder().name(k).pipes(new HashSet<>()).build());
}
});
return new ArrayList<>(gasStationMap.values());
}
@Override
public Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, String mainPipe, Long deviceTypeId, Long blockId, Integer product) {
Page<DeviceVO> page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, mainPipe, deviceTypeId, blockId, product);
List<DeviceVO> deviceVOList = page.getRecords();
// 从Redis获取设备运行数据
if (CollectionUtil.isNotEmpty(deviceVOList)) {
@ -82,6 +100,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
try {
for (DeviceVO deviceVO : deviceVOList) {
String deviceKey = PersistenceHandler.DEVICE_DATA_CACHE + deviceVO.getId();
Object online = this.redisTemplate.opsForHash().get(deviceKey, "online");
deviceVO.setOnline(online == null ? "" : online.toString());
if (!StringUtils.equalsIgnoreCase("true", deviceVO.getOnline())) {
continue;
}
Object casPressure = this.redisTemplate.opsForHash().get(deviceKey, "casPressure");
deviceVO.setCasPressure(casPressure == null ? "" : casPressure.toString());
@ -94,9 +119,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
Object voltage = this.redisTemplate.opsForHash().get(deviceKey, "batteryVoltage");
deviceVO.setVoltage(voltage == null ? "" : voltage.toString());
Object online = this.redisTemplate.opsForHash().get(deviceKey, "online");
deviceVO.setOnline(online == null ? "" : online.toString());
Object plugStatus = this.redisTemplate.opsForHash().get(deviceKey, "plugStatus");
if (plugStatus == null) {
deviceVO.setPlugStatus("");

View File

@ -2,6 +2,7 @@ package com.isu.gaswellwatch.service.impl;
import com.isu.gaswellwatch.service.DeviceService;
import com.isu.gaswellwatch.service.SummaryService;
import com.isu.gaswellwatch.utils.NumberScaleUtils;
import com.isu.gaswellwatch.vo.DeviceHistoryVO;
import com.isu.gaswellwatch.vo.DeviceVO;
import com.isu.gaswellwatch.vo.summary.*;
@ -112,15 +113,15 @@ public class SummaryServiceImpl implements SummaryService {
legendData.add("输压");
lineSummaryVO.setLegendData(legendData);
List<String> oilPressureData = new ArrayList<>();
List<String> casPressureData = new ArrayList<>();
List<String> prePressureData = new ArrayList<>();
List<String> oilPressureData = new ArrayList<>(dataList.size());
List<String> casPressureData = new ArrayList<>(dataList.size());
List<String> prePressureData = new ArrayList<>(dataList.size());
for (DeviceHistoryVO deviceHistoryVO : dataList) {
xAxisData.add(deviceHistoryVO.getCollectionTime());
oilPressureData.add(StringUtils.isEmpty(deviceHistoryVO.getOilPressure()) ? "0" : deviceHistoryVO.getOilPressure());
casPressureData.add(StringUtils.isEmpty(deviceHistoryVO.getCasPressure()) ? "0" : deviceHistoryVO.getCasPressure());
prePressureData.add(StringUtils.isEmpty(deviceHistoryVO.getPrePressure()) ? "0" : deviceHistoryVO.getPrePressure());
oilPressureData.add(NumberScaleUtils.formatTwoScaleNullPositiveNumber(StringUtils.isEmpty(deviceHistoryVO.getOilPressure()) ? "0" : deviceHistoryVO.getOilPressure()));
casPressureData.add(NumberScaleUtils.formatTwoScaleNullPositiveNumber(StringUtils.isEmpty(deviceHistoryVO.getCasPressure()) ? "0" : deviceHistoryVO.getCasPressure()));
prePressureData.add(NumberScaleUtils.formatTwoScaleNullPositiveNumber(StringUtils.isEmpty(deviceHistoryVO.getPrePressure()) ? "0" : deviceHistoryVO.getPrePressure()));
}
//设置x轴数据日期

View File

@ -0,0 +1,51 @@
package com.isu.gaswellwatch.utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Optional;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* 2025/2/27 22:57
*/
public class NumberScaleUtils {
public static String formatTwoScalePositiveNumber(String number) {
return formatPositiveNumber(number, 2);
}
public static String formatPositiveNumber(String number, int scale) {
if (StringUtils.isNotBlank(number) && NumberUtils.isCreatable(number)) {
return Optional.of(number).map(value -> {
BigDecimal decimal = NumberUtils.createBigDecimal(value).setScale(scale, RoundingMode.HALF_UP);
if (BigDecimal.ZERO.compareTo(decimal) > 0) {
return "--";
}
return decimal.toString();
}).orElse(null);
}
return number;
}
public static String formatTwoScaleNullPositiveNumber(String number) {
return formatNullPositiveNumber(number, 2);
}
public static String formatNullPositiveNumber(String number, int scale) {
if (StringUtils.isNotBlank(number) && NumberUtils.isCreatable(number)) {
return Optional.of(number).map(value -> {
BigDecimal decimal = NumberUtils.createBigDecimal(value).setScale(scale, RoundingMode.HALF_UP);
if (BigDecimal.ZERO.compareTo(decimal) > 0) {
return null;
}
return decimal.toString();
}).orElse(null);
}
return number;
}
}

View File

@ -1,6 +1,7 @@
package com.isu.gaswellwatch.vo;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.isu.gaswellwatch.utils.NumberScaleUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -82,5 +83,28 @@ public class DeviceHistoryVO extends Model<DeviceHistoryVO> {
*/
private String solarVoltage;
public void setOilPressure(String oilPressure) {
this.oilPressure = NumberScaleUtils.formatTwoScalePositiveNumber(oilPressure);
}
public void setPrePressure(String prePressure) {
this.prePressure = NumberScaleUtils.formatTwoScalePositiveNumber(prePressure);
}
public void setCasPressure(String casPressure) {
this.casPressure = NumberScaleUtils.formatTwoScalePositiveNumber(casPressure);
}
public void setTemperature(String temperature) {
this.temperature = NumberScaleUtils.formatTwoScalePositiveNumber(temperature);
}
public void setHumidity(String humidity) {
this.humidity = NumberScaleUtils.formatTwoScalePositiveNumber(humidity);
}
public void setSolarVoltage(String solarVoltage) {
this.solarVoltage = NumberScaleUtils.formatTwoScalePositiveNumber(solarVoltage);
}
}

View File

@ -3,6 +3,7 @@ package com.isu.gaswellwatch.vo;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.isu.gaswellwatch.entity.Dictionary;
import com.isu.gaswellwatch.entity.GasWell;
import com.isu.gaswellwatch.utils.NumberScaleUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -22,58 +23,110 @@ public class DeviceVO extends Model<DeviceVO> {
private static final long serialVersionUID = 1L;
/** 主键 */
/**
* 主键
*/
private Long id;
/** 设备类型 */
/**
* 设备类型
*/
private Dictionary deviceType;
/** 设备编号 */
/**
* 设备编号
*/
private String code;
/** 集气站 */
/**
* 集气站
*/
private String gasStation;
/** 设备品牌 */
/**
* 设备品牌
*/
private Dictionary product;
/** 网关通讯地址 */
/**
* 网关通讯地址
*/
private String gatewaySn;
/** 描述 */
/**
* 描述
*/
private String details;
/** 所属气井 */
/**
* 所属气井
*/
private GasWell gasWell;
/** 创建时间 */
/**
* 创建时间
*/
private String createTime;
/** 更新时间 */
/**
* 更新时间
*/
private String updateTime;
/** 油压 */
/**
* 油压
*/
private String oilPressure;
/** 套压 */
/**
* 套压
*/
private String casPressure;
/** 输压 */
/**
* 输压
*/
private String prePressure;
/** 设备状态 */
/**
* 设备状态
*/
private String online;
/** 生产模式 */
/**
* 生产模式
*/
private String runMode;
/** 柱塞状态 */
/**
* 柱塞状态
*/
private String plugStatus;
/** 生产状态 */
/**
* 生产状态
*/
private String wellStatus;
/** 电压 */
/**
* 电压
*/
private String voltage;
public void setOilPressure(String oilPressure) {
this.oilPressure = NumberScaleUtils.formatTwoScalePositiveNumber(oilPressure);
}
public void setCasPressure(String casPressure) {
this.casPressure = NumberScaleUtils.formatTwoScalePositiveNumber(casPressure);
}
public void setPrePressure(String prePressure) {
this.prePressure = NumberScaleUtils.formatTwoScalePositiveNumber(prePressure);
}
public void setVoltage(String voltage) {
this.voltage = NumberScaleUtils.formatTwoScalePositiveNumber(voltage);
}
}

View File

@ -0,0 +1,43 @@
package com.isu.gaswellwatch.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.math.NumberUtils;
import java.io.Serial;
import java.io.Serializable;
import java.util.Collection;
import java.util.Comparator;
import java.util.stream.Collectors;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* 2025/2/27 23:20
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public class GasStationVO implements Serializable {
@Serial
private static final long serialVersionUID = 573191480595821294L;
private String name;
@JsonIgnore
private Collection<String> pipes;
public Collection<String> getMainPipes() {
if (ObjectUtils.isEmpty(this.pipes)) {
return this.pipes;
}
return this.pipes.stream().sorted(Comparator.comparingInt(NumberUtils::createInteger)).collect(Collectors.toList());
}
}

View File

@ -36,6 +36,13 @@
<result property="gasWell" column="gas_well"/>
</resultMap>
<select id="queryGasStationList" resultType="string">
select u.gas_station
from device u
where u.gas_station LIKE CONCAT('%', #{gasStationName}, '%')
order by u.id desc
</select>
<select id="page" resultMap="DeviceVOMap">
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn,
u.gas_well, u.details, u.create_time, u.update_time,g.name as gasWellName,g.id as gasWellId
@ -47,6 +54,9 @@
<if test="gasStationName!=null and gasStationName!='' ">
and u.gas_station LIKE CONCAT('%',#{gasStationName},'%')
</if>
<if test="mainPipe!=null and mainPipe!='' ">
and u.gas_station LIKE CONCAT('%(',#{mainPipe},')%')
</if>
<if test="deviceTypeId!=null and deviceTypeId!='' ">
and u.device_type = #{deviceTypeId}
</if>
@ -167,9 +177,17 @@
<select id="getSwitchStatusData" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">
select t.collection_time
<if test="deviceProduct!=null and deviceProduct=='knpc'">,t.well_status</if>
<if test="deviceProduct!=null and deviceProduct=='etc'">,t.solenoid_valve_status as wellStatus</if>
<if test="deviceProduct!=null and deviceProduct=='scss'">,t.first_solenoid_status as wellStatus</if>
<choose>
<when test="deviceProduct!=null and deviceProduct=='knpc'">,t.well_status</when>
<when test="deviceProduct!=null and deviceProduct=='etc'">,t.solenoid_valve_status as wellStatus</when>
<when test="deviceProduct!=null and deviceProduct=='scss'">,t.first_solenoid_status as wellStatus</when>
<when test="deviceProduct!=null and deviceProduct=='weps_plug'">
,case t.solenoid_valve_status when 2 then 1 when 1 then 0 else null end as wellStatus
</when>
<when test="deviceProduct!=null and deviceProduct=='mi_weps_plug'">
,case t.current_status when 0 then 0 else 1 end as wellStatus
</when>
</choose>
from ${tableName} t
<where>
t.device_id = #{deviceId}