From ce8cd2402c1929813eb3d041bc11cf90cb835819 Mon Sep 17 00:00:00 2001 From: wangshilong Date: Fri, 28 Feb 2025 00:20:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AEExcel=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DeviceController.java | 67 +++++++------ .../com/isu/gaswellwatch/dao/DeviceDao.java | 19 ++-- .../gaswellwatch/service/DeviceService.java | 9 +- .../service/impl/DeviceServiceImpl.java | 40 ++++++-- .../service/impl/SummaryServiceImpl.java | 13 +-- .../gaswellwatch/utils/NumberScaleUtils.java | 51 ++++++++++ .../isu/gaswellwatch/vo/DeviceHistoryVO.java | 24 +++++ .../com/isu/gaswellwatch/vo/DeviceVO.java | 93 +++++++++++++++---- .../com/isu/gaswellwatch/vo/GasStationVO.java | 43 +++++++++ src/main/resources/mapper/DeviceDao.xml | 24 ++++- 10 files changed, 307 insertions(+), 76 deletions(-) create mode 100644 src/main/java/com/isu/gaswellwatch/utils/NumberScaleUtils.java create mode 100644 src/main/java/com/isu/gaswellwatch/vo/GasStationVO.java diff --git a/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java b/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java index ce5efc9..b5dd7c3 100644 --- a/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java +++ b/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java @@ -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 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 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 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 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 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> getDeviceControlData(@RequestParam Long deviceId) { - return Response.succeed(deviceService.getDeviceControlData(deviceId)); + public Response> getDeviceControlData(@RequestParam Long deviceId) { + return Response.succeed(this.deviceService.getDeviceControlData(deviceId)); } /** @@ -101,11 +115,11 @@ public class DeviceController { @GetMapping("/getDeviceHistoryData") public Response> 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> 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); + @RequestParam Long deviceId, + @RequestParam String startTime, + @RequestParam String 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); + @RequestParam String startTime, + @RequestParam String endTime) { + this.deviceService.exportSwitchStatusData(response, startTime, endTime); } - } diff --git a/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java b/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java index 7b8b3ce..d1f49d5 100644 --- a/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java +++ b/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java @@ -17,9 +17,12 @@ import java.util.List; @Repository public interface DeviceDao extends BaseMapper { + List queryGasStationList(String gasStationName); + Page page(Page 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 { DeviceVO getDeviceById(@Param("id") Long id); Page historyPage(Page 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 deviceOptLogPage(Page objectPage, - @Param("startTime")Date startTime, - @Param("endTime")Date endTime, + @Param("startTime") Date startTime, + @Param("endTime") Date endTime, @Param("deviceId") Long deviceId); - List getDeviceVOByIds(@Param("idList")List deviceIdList); + List getDeviceVOByIds(@Param("idList") List deviceIdList); List getPressureChartData(Long deviceId, String startTime, String endTime, String tableName); - List getSwitchStatusData(Long deviceId, String startTime, String endTime, String tableName,String deviceProduct); + List getSwitchStatusData(Long deviceId, String startTime, String endTime, String tableName, String deviceProduct); - List getDeviceHistoryData(@Param("startTime")Date startTime, - @Param("endTime")Date endTime, + List getDeviceHistoryData(@Param("startTime") Date startTime, + @Param("endTime") Date endTime, @Param("deviceId") Long deviceId, @Param("tableName") String tableName, @Param("deviceProduct") String deviceProduct); diff --git a/src/main/java/com/isu/gaswellwatch/service/DeviceService.java b/src/main/java/com/isu/gaswellwatch/service/DeviceService.java index 23b3078..bc173fc 100644 --- a/src/main/java/com/isu/gaswellwatch/service/DeviceService.java +++ b/src/main/java/com/isu/gaswellwatch/service/DeviceService.java @@ -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 { - Page page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId, Integer product); + List queryGasStationList(String gasStationName); + + Page 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 { DeviceVO getDevice(Long id); - Map getDeviceControlData(Long deviceId); + Map getDeviceControlData(Long deviceId); Page getDeviceHistoryData(Integer currentPage, Integer pageSize, String startTime, String endTime, Long deviceId) throws ParseException; @@ -36,7 +39,7 @@ public interface DeviceService extends IService { List getPressureChartData(Long deviceId, String startTime, String endTime); - List getSwitchStatusData(Long deviceId, String startTime, String endTime,String deviceProduct); + List getSwitchStatusData(Long deviceId, String startTime, String endTime, String deviceProduct); void exportHistoryData(HttpServletResponse response, Long deviceId, String startTime, String endTime) throws ParseException; 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 18ba0f7..6cdcb9e 100644 --- a/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java @@ -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 implements private UserService userService; @Override - public Page page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId, Integer product) { - Page page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, deviceTypeId, blockId, product); + public List queryGasStationList(String gasStationName) { + List gasStationList = this.deviceDao.queryGasStationList(gasStationName); + if (ObjectUtils.isEmpty(gasStationList)) { + return List.of(); + } + Map 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 page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, String mainPipe, Long deviceTypeId, Long blockId, Integer product) { + Page page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, mainPipe, deviceTypeId, blockId, product); List deviceVOList = page.getRecords(); // 从Redis获取设备运行数据 if (CollectionUtil.isNotEmpty(deviceVOList)) { @@ -82,6 +100,13 @@ public class DeviceServiceImpl extends ServiceImpl 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 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(""); diff --git a/src/main/java/com/isu/gaswellwatch/service/impl/SummaryServiceImpl.java b/src/main/java/com/isu/gaswellwatch/service/impl/SummaryServiceImpl.java index ed6a5a9..404be94 100644 --- a/src/main/java/com/isu/gaswellwatch/service/impl/SummaryServiceImpl.java +++ b/src/main/java/com/isu/gaswellwatch/service/impl/SummaryServiceImpl.java @@ -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 oilPressureData = new ArrayList<>(); - List casPressureData = new ArrayList<>(); - List prePressureData = new ArrayList<>(); + List oilPressureData = new ArrayList<>(dataList.size()); + List casPressureData = new ArrayList<>(dataList.size()); + List 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轴数据(日期) diff --git a/src/main/java/com/isu/gaswellwatch/utils/NumberScaleUtils.java b/src/main/java/com/isu/gaswellwatch/utils/NumberScaleUtils.java new file mode 100644 index 0000000..c65ed2f --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/utils/NumberScaleUtils.java @@ -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 王仕龙 + * 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; + } + +} diff --git a/src/main/java/com/isu/gaswellwatch/vo/DeviceHistoryVO.java b/src/main/java/com/isu/gaswellwatch/vo/DeviceHistoryVO.java index 794137b..e5784f3 100644 --- a/src/main/java/com/isu/gaswellwatch/vo/DeviceHistoryVO.java +++ b/src/main/java/com/isu/gaswellwatch/vo/DeviceHistoryVO.java @@ -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 { */ 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); + } } diff --git a/src/main/java/com/isu/gaswellwatch/vo/DeviceVO.java b/src/main/java/com/isu/gaswellwatch/vo/DeviceVO.java index 0ee62ed..04430c6 100644 --- a/src/main/java/com/isu/gaswellwatch/vo/DeviceVO.java +++ b/src/main/java/com/isu/gaswellwatch/vo/DeviceVO.java @@ -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; @@ -10,7 +11,7 @@ import lombok.NoArgsConstructor; /** * 设备对象 Device - * + * * @author scwsl * @date 2024-11-17 */ @@ -18,62 +19,114 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor -public class DeviceVO extends Model { +public class DeviceVO extends Model { 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); + } + } diff --git a/src/main/java/com/isu/gaswellwatch/vo/GasStationVO.java b/src/main/java/com/isu/gaswellwatch/vo/GasStationVO.java new file mode 100644 index 0000000..29cda2d --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/vo/GasStationVO.java @@ -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 王仕龙 + * 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 pipes; + + public Collection getMainPipes() { + if (ObjectUtils.isEmpty(this.pipes)) { + return this.pipes; + } + return this.pipes.stream().sorted(Comparator.comparingInt(NumberUtils::createInteger)).collect(Collectors.toList()); + } + +} diff --git a/src/main/resources/mapper/DeviceDao.xml b/src/main/resources/mapper/DeviceDao.xml index 9947d8b..a0a68da 100644 --- a/src/main/resources/mapper/DeviceDao.xml +++ b/src/main/resources/mapper/DeviceDao.xml @@ -36,6 +36,13 @@ + + select t.collection_time - ,t.well_status - ,t.solenoid_valve_status as wellStatus - ,t.first_solenoid_status as wellStatus + + ,t.well_status + ,t.solenoid_valve_status as wellStatus + ,t.first_solenoid_status as wellStatus + + ,case t.solenoid_valve_status when 2 then 1 when 1 then 0 else null end as wellStatus + + + ,case t.current_status when 0 then 0 else 1 end as wellStatus + + from ${tableName} t t.device_id = #{deviceId}