根据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.service.DeviceService;
import com.isu.gaswellwatch.vo.DeviceHistoryVO; import com.isu.gaswellwatch.vo.DeviceHistoryVO;
import com.isu.gaswellwatch.vo.DeviceVO; import com.isu.gaswellwatch.vo.DeviceVO;
import com.isu.gaswellwatch.vo.GasStationVO;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.ParseException; import java.text.ParseException;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -32,6 +34,17 @@ public class DeviceController {
private final DeviceService deviceService; 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(defaultValue = "10") Integer pageSize,
@RequestParam(required = false) String gasWellName, @RequestParam(required = false) String gasWellName,
@RequestParam(required = false) String gasStationName, @RequestParam(required = false) String gasStationName,
@RequestParam(required = false) String mainPipe,
@RequestParam(required = false) Integer product, @RequestParam(required = false) Integer product,
@RequestParam Long deviceTypeId,@RequestParam Long blockId) { @RequestParam Long deviceTypeId, @RequestParam Long blockId) {
return Response.succeed(deviceService.page(currentPage, pageSize, gasWellName,gasStationName,deviceTypeId,blockId,product)); return Response.succeed(this.deviceService.page(currentPage, pageSize, gasWellName, gasStationName, mainPipe, deviceTypeId, blockId, product));
} }
/** /**
@ -50,18 +64,18 @@ public class DeviceController {
*/ */
@GetMapping(value = "/getDevice") @GetMapping(value = "/getDevice")
public Response<DeviceVO> getDevice(@RequestParam Long id) { public Response<DeviceVO> getDevice(@RequestParam Long id) {
return Response.succeed(deviceService.getDevice(id)); return Response.succeed(this.deviceService.getDevice(id));
} }
/** /**
*新增设备 * 新增设备
*/ */
@PostMapping(value = "/add") @PostMapping(value = "/add")
@OperationLog(description = "新增设备", type = LogType.ADD) @OperationLog(description = "新增设备", type = LogType.ADD)
public Response<String> add(@RequestBody @Valid DeviceCreateDTO deviceCreateDTO) { public Response<String> add(@RequestBody @Valid DeviceCreateDTO deviceCreateDTO) {
try { try {
deviceService.add(deviceCreateDTO); this.deviceService.add(deviceCreateDTO);
}catch (NumberFormatException e){ } catch (NumberFormatException e) {
throw new BusinessException("设备编号只能为纯数字格式"); throw new BusinessException("设备编号只能为纯数字格式");
} }
return Response.succeed(); return Response.succeed();
@ -73,7 +87,7 @@ public class DeviceController {
@PostMapping("/edit") @PostMapping("/edit")
@OperationLog(description = "修改设备", type = LogType.UPDATE) @OperationLog(description = "修改设备", type = LogType.UPDATE)
public Response<String> edit(@RequestBody @Valid DeviceEditDTO deviceEditDTO) { public Response<String> edit(@RequestBody @Valid DeviceEditDTO deviceEditDTO) {
deviceService.edit(deviceEditDTO); this.deviceService.edit(deviceEditDTO);
return Response.succeed(); return Response.succeed();
} }
@ -83,7 +97,7 @@ public class DeviceController {
@GetMapping("/delete") @GetMapping("/delete")
@OperationLog(description = "删除设备", type = LogType.DELETE) @OperationLog(description = "删除设备", type = LogType.DELETE)
public Response<String> delete(@RequestParam Long id) { public Response<String> delete(@RequestParam Long id) {
deviceService.delete(id); this.deviceService.delete(id);
return Response.succeed(); return Response.succeed();
} }
@ -91,8 +105,8 @@ public class DeviceController {
* 获取设备控制数据 * 获取设备控制数据
*/ */
@GetMapping("/getDeviceControlData") @GetMapping("/getDeviceControlData")
public Response<Map<String,String>> getDeviceControlData(@RequestParam Long deviceId) { public Response<Map<String, String>> getDeviceControlData(@RequestParam Long deviceId) {
return Response.succeed(deviceService.getDeviceControlData(deviceId)); return Response.succeed(this.deviceService.getDeviceControlData(deviceId));
} }
/** /**
@ -101,11 +115,11 @@ public class DeviceController {
@GetMapping("/getDeviceHistoryData") @GetMapping("/getDeviceHistoryData")
public Response<Page<DeviceHistoryVO>> getDeviceHistoryData(@RequestParam(defaultValue = "1") Integer currentPage, public Response<Page<DeviceHistoryVO>> getDeviceHistoryData(@RequestParam(defaultValue = "1") Integer currentPage,
@RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(required = false)String startTime, @RequestParam(required = false) String startTime,
@RequestParam (required = false)String endTime, @RequestParam(required = false) String endTime,
@RequestParam Long deviceId) { @RequestParam Long deviceId) {
try { 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) { } catch (ParseException e) {
throw new BusinessException("日期格式错误"); throw new BusinessException("日期格式错误");
} }
@ -117,11 +131,11 @@ public class DeviceController {
@GetMapping("/getDeviceLogData") @GetMapping("/getDeviceLogData")
public Response<Page<DeviceOptLog>> getDeviceLogData(@RequestParam(defaultValue = "1") Integer currentPage, public Response<Page<DeviceOptLog>> getDeviceLogData(@RequestParam(defaultValue = "1") Integer currentPage,
@RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(required = false)String startTime, @RequestParam(required = false) String startTime,
@RequestParam (required = false)String endTime, @RequestParam(required = false) String endTime,
@RequestParam Long deviceId) { @RequestParam Long deviceId) {
try { 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) { } catch (ParseException e) {
throw new BusinessException("日期格式错误"); throw new BusinessException("日期格式错误");
} }
@ -131,13 +145,13 @@ public class DeviceController {
* 设备历史数据导出 * 设备历史数据导出
*/ */
@GetMapping("/exportHistoryData") @GetMapping("/exportHistoryData")
@OperationLog(description = "设备历史数据导出",type = LogType.EXPORT) @OperationLog(description = "设备历史数据导出", type = LogType.EXPORT)
public void exportHistoryData(HttpServletResponse response, public void exportHistoryData(HttpServletResponse response,
@RequestParam Long deviceId, @RequestParam Long deviceId,
@RequestParam String startTime, @RequestParam String startTime,
@RequestParam String endTime) { @RequestParam String endTime) {
try{ try {
deviceService.exportHistoryData(response,deviceId, startTime, endTime); this.deviceService.exportHistoryData(response, deviceId, startTime, endTime);
} catch (ParseException e) { } catch (ParseException e) {
throw new BusinessException("日期格式错误"); throw new BusinessException("日期格式错误");
} }
@ -147,13 +161,12 @@ public class DeviceController {
* 设备开关状态数据导出 * 设备开关状态数据导出
*/ */
@GetMapping("/exportSwitchStatusData") @GetMapping("/exportSwitchStatusData")
@OperationLog(description = "设备开关状态数据导出",type = LogType.EXPORT) @OperationLog(description = "设备开关状态数据导出", type = LogType.EXPORT)
public void exportSwitchStatusData(HttpServletResponse response, public void exportSwitchStatusData(HttpServletResponse response,
@RequestParam String startTime, @RequestParam String startTime,
@RequestParam String endTime) { @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 @Repository
public interface DeviceDao extends BaseMapper<Device> { public interface DeviceDao extends BaseMapper<Device> {
List<String> queryGasStationList(String gasStationName);
Page<DeviceVO> page(Page<Object> page, Page<DeviceVO> page(Page<Object> page,
@Param("gasWellName") String gasWellName, @Param("gasWellName") String gasWellName,
@Param("gasStationName") String gasStationName, @Param("gasStationName") String gasStationName,
@Param("mainPipe") String mainPipe,
@Param("deviceTypeId") Long deviceTypeId, @Param("deviceTypeId") Long deviceTypeId,
@Param("blockId") Long blockId, @Param("blockId") Long blockId,
@Param("product") Integer product); @Param("product") Integer product);
@ -28,25 +31,25 @@ public interface DeviceDao extends BaseMapper<Device> {
DeviceVO getDeviceById(@Param("id") Long id); DeviceVO getDeviceById(@Param("id") Long id);
Page<DeviceHistoryVO> historyPage(Page<Object> objectPage, Page<DeviceHistoryVO> historyPage(Page<Object> objectPage,
@Param("startTime")Date startTime, @Param("startTime") Date startTime,
@Param("endTime")Date endTime, @Param("endTime") Date endTime,
@Param("deviceId") Long deviceId, @Param("deviceId") Long deviceId,
@Param("tableName") String tableName, @Param("tableName") String tableName,
@Param("deviceProduct") String deviceProduct); @Param("deviceProduct") String deviceProduct);
Page<DeviceOptLog> deviceOptLogPage(Page<DeviceOptLog> objectPage, Page<DeviceOptLog> deviceOptLogPage(Page<DeviceOptLog> objectPage,
@Param("startTime")Date startTime, @Param("startTime") Date startTime,
@Param("endTime")Date endTime, @Param("endTime") Date endTime,
@Param("deviceId") Long deviceId); @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> 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, List<DeviceHistoryVO> getDeviceHistoryData(@Param("startTime") Date startTime,
@Param("endTime")Date endTime, @Param("endTime") Date endTime,
@Param("deviceId") Long deviceId, @Param("deviceId") Long deviceId,
@Param("tableName") String tableName, @Param("tableName") String tableName,
@Param("deviceProduct") String deviceProduct); @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.entity.DeviceOptLog;
import com.isu.gaswellwatch.vo.DeviceHistoryVO; import com.isu.gaswellwatch.vo.DeviceHistoryVO;
import com.isu.gaswellwatch.vo.DeviceVO; import com.isu.gaswellwatch.vo.DeviceVO;
import com.isu.gaswellwatch.vo.GasStationVO;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.text.ParseException; import java.text.ParseException;
@ -16,7 +17,9 @@ import java.util.Map;
public interface DeviceService extends IService<Device> { 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); void add(DeviceCreateDTO deviceCreateDTO);
@ -26,7 +29,7 @@ public interface DeviceService extends IService<Device> {
DeviceVO getDevice(Long id); 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; 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> 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; 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.annotation.Resource;
import jakarta.servlet.ServletOutputStream; import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.RedisConnectionFailureException; import org.springframework.data.redis.RedisConnectionFailureException;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -35,10 +36,7 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service("deviceService") @Service("deviceService")
@ -66,8 +64,28 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
private UserService userService; private UserService userService;
@Override @Override
public Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId, Integer product) { public List<GasStationVO> queryGasStationList(String gasStationName) {
Page<DeviceVO> page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, deviceTypeId, blockId, product); 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(); List<DeviceVO> deviceVOList = page.getRecords();
// 从Redis获取设备运行数据 // 从Redis获取设备运行数据
if (CollectionUtil.isNotEmpty(deviceVOList)) { if (CollectionUtil.isNotEmpty(deviceVOList)) {
@ -82,6 +100,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
try { try {
for (DeviceVO deviceVO : deviceVOList) { for (DeviceVO deviceVO : deviceVOList) {
String deviceKey = PersistenceHandler.DEVICE_DATA_CACHE + deviceVO.getId(); 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"); Object casPressure = this.redisTemplate.opsForHash().get(deviceKey, "casPressure");
deviceVO.setCasPressure(casPressure == null ? "" : casPressure.toString()); 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"); Object voltage = this.redisTemplate.opsForHash().get(deviceKey, "batteryVoltage");
deviceVO.setVoltage(voltage == null ? "" : voltage.toString()); 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"); Object plugStatus = this.redisTemplate.opsForHash().get(deviceKey, "plugStatus");
if (plugStatus == null) { if (plugStatus == null) {
deviceVO.setPlugStatus(""); 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.DeviceService;
import com.isu.gaswellwatch.service.SummaryService; import com.isu.gaswellwatch.service.SummaryService;
import com.isu.gaswellwatch.utils.NumberScaleUtils;
import com.isu.gaswellwatch.vo.DeviceHistoryVO; import com.isu.gaswellwatch.vo.DeviceHistoryVO;
import com.isu.gaswellwatch.vo.DeviceVO; import com.isu.gaswellwatch.vo.DeviceVO;
import com.isu.gaswellwatch.vo.summary.*; import com.isu.gaswellwatch.vo.summary.*;
@ -112,15 +113,15 @@ public class SummaryServiceImpl implements SummaryService {
legendData.add("输压"); legendData.add("输压");
lineSummaryVO.setLegendData(legendData); lineSummaryVO.setLegendData(legendData);
List<String> oilPressureData = new ArrayList<>(); List<String> oilPressureData = new ArrayList<>(dataList.size());
List<String> casPressureData = new ArrayList<>(); List<String> casPressureData = new ArrayList<>(dataList.size());
List<String> prePressureData = new ArrayList<>(); List<String> prePressureData = new ArrayList<>(dataList.size());
for (DeviceHistoryVO deviceHistoryVO : dataList) { for (DeviceHistoryVO deviceHistoryVO : dataList) {
xAxisData.add(deviceHistoryVO.getCollectionTime()); xAxisData.add(deviceHistoryVO.getCollectionTime());
oilPressureData.add(StringUtils.isEmpty(deviceHistoryVO.getOilPressure()) ? "0" : deviceHistoryVO.getOilPressure()); oilPressureData.add(NumberScaleUtils.formatTwoScaleNullPositiveNumber(StringUtils.isEmpty(deviceHistoryVO.getOilPressure()) ? "0" : deviceHistoryVO.getOilPressure()));
casPressureData.add(StringUtils.isEmpty(deviceHistoryVO.getCasPressure()) ? "0" : deviceHistoryVO.getCasPressure()); casPressureData.add(NumberScaleUtils.formatTwoScaleNullPositiveNumber(StringUtils.isEmpty(deviceHistoryVO.getCasPressure()) ? "0" : deviceHistoryVO.getCasPressure()));
prePressureData.add(StringUtils.isEmpty(deviceHistoryVO.getPrePressure()) ? "0" : deviceHistoryVO.getPrePressure()); prePressureData.add(NumberScaleUtils.formatTwoScaleNullPositiveNumber(StringUtils.isEmpty(deviceHistoryVO.getPrePressure()) ? "0" : deviceHistoryVO.getPrePressure()));
} }
//设置x轴数据日期 //设置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; package com.isu.gaswellwatch.vo;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.isu.gaswellwatch.utils.NumberScaleUtils;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -82,5 +83,28 @@ public class DeviceHistoryVO extends Model<DeviceHistoryVO> {
*/ */
private String solarVoltage; 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.baomidou.mybatisplus.extension.activerecord.Model;
import com.isu.gaswellwatch.entity.Dictionary; import com.isu.gaswellwatch.entity.Dictionary;
import com.isu.gaswellwatch.entity.GasWell; import com.isu.gaswellwatch.entity.GasWell;
import com.isu.gaswellwatch.utils.NumberScaleUtils;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -10,7 +11,7 @@ import lombok.NoArgsConstructor;
/** /**
* 设备对象 Device * 设备对象 Device
* *
* @author scwsl * @author scwsl
* @date 2024-11-17 * @date 2024-11-17
*/ */
@ -18,62 +19,114 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class DeviceVO extends Model<DeviceVO> { public class DeviceVO extends Model<DeviceVO> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 主键 */ /**
* 主键
*/
private Long id; private Long id;
/** 设备类型 */ /**
* 设备类型
*/
private Dictionary deviceType; private Dictionary deviceType;
/** 设备编号 */ /**
* 设备编号
*/
private String code; private String code;
/** 集气站 */ /**
* 集气站
*/
private String gasStation; private String gasStation;
/** 设备品牌 */ /**
* 设备品牌
*/
private Dictionary product; private Dictionary product;
/** 网关通讯地址 */ /**
* 网关通讯地址
*/
private String gatewaySn; private String gatewaySn;
/** 描述 */ /**
* 描述
*/
private String details; private String details;
/** 所属气井 */ /**
* 所属气井
*/
private GasWell gasWell; private GasWell gasWell;
/** 创建时间 */ /**
* 创建时间
*/
private String createTime; private String createTime;
/** 更新时间 */ /**
* 更新时间
*/
private String updateTime; private String updateTime;
/** 油压 */ /**
* 油压
*/
private String oilPressure; private String oilPressure;
/** 套压 */ /**
* 套压
*/
private String casPressure; private String casPressure;
/** 输压 */ /**
* 输压
*/
private String prePressure; private String prePressure;
/** 设备状态 */ /**
* 设备状态
*/
private String online; private String online;
/** 生产模式 */ /**
* 生产模式
*/
private String runMode; private String runMode;
/** 柱塞状态 */ /**
* 柱塞状态
*/
private String plugStatus; private String plugStatus;
/** 生产状态 */ /**
* 生产状态
*/
private String wellStatus; private String wellStatus;
/** 电压 */ /**
* 电压
*/
private String voltage; 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"/> <result property="gasWell" column="gas_well"/>
</resultMap> </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 id="page" resultMap="DeviceVOMap">
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn, 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 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!='' "> <if test="gasStationName!=null and gasStationName!='' ">
and u.gas_station LIKE CONCAT('%',#{gasStationName},'%') and u.gas_station LIKE CONCAT('%',#{gasStationName},'%')
</if> </if>
<if test="mainPipe!=null and mainPipe!='' ">
and u.gas_station LIKE CONCAT('%(',#{mainPipe},')%')
</if>
<if test="deviceTypeId!=null and deviceTypeId!='' "> <if test="deviceTypeId!=null and deviceTypeId!='' ">
and u.device_type = #{deviceTypeId} and u.device_type = #{deviceTypeId}
</if> </if>
@ -167,9 +177,17 @@
<select id="getSwitchStatusData" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO"> <select id="getSwitchStatusData" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">
select t.collection_time select t.collection_time
<if test="deviceProduct!=null and deviceProduct=='knpc'">,t.well_status</if> <choose>
<if test="deviceProduct!=null and deviceProduct=='etc'">,t.solenoid_valve_status as wellStatus</if> <when test="deviceProduct!=null and deviceProduct=='knpc'">,t.well_status</when>
<if test="deviceProduct!=null and deviceProduct=='scss'">,t.first_solenoid_status as wellStatus</if> <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 from ${tableName} t
<where> <where>
t.device_id = #{deviceId} t.device_id = #{deviceId}