From 02be2303cab044a6cba2979da646afffbb9fe113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Wed, 4 Dec 2024 15:14:55 +0800 Subject: [PATCH] =?UTF-8?q?debug:=E8=AE=BE=E5=A4=87=E5=BD=92=E9=9B=B6?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E7=94=B5=E9=87=8F=E6=9C=AA=E5=BD=92=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ss/device/service/impl/DeviceServiceImpl.java | 12 ++++++------ .../service/impl/TransactionBillConverterImpl.java | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java index 6cad08ce..30316a8d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java @@ -473,7 +473,7 @@ public class DeviceServiceImpl implements DeviceService Integer result = transactionTemplate.execute(status -> { // 更新剩余电量 - int update = this.resetUpdateDbEle(device.getDeviceId()); + int update = this.resetUpdateDbEle(device.getDeviceId(), device.getTotalElectriQuantity()); ServiceUtil.assertion(update != 1, "更新剩余电量失败"); // 直接设置电量为0 @@ -518,10 +518,11 @@ public class DeviceServiceImpl implements DeviceService } } - private int resetUpdateDbEle(Long deviceId) { + private int resetUpdateDbEle(Long deviceId, BigDecimal expireEle) { Device data = new Device(); data.setDeviceId(deviceId); data.setSurplusEle(BigDecimal.ZERO); + data.setExpireEle(expireEle); return deviceMapper.updateSmDevice(data); } @@ -529,6 +530,7 @@ public class DeviceServiceImpl implements DeviceService public int resetEle(Long deviceId, boolean required) { // 获取设备信息 DeviceVO device = selectById(deviceId); + this.pullDeviceInfo(device); return resetEle(device, required); } @@ -570,9 +572,9 @@ public class DeviceServiceImpl implements DeviceService return 0; } // 拉取设备信息 - pullDeviceInfo(deviceId); DeviceVO device = selectById(deviceId); + pullDeviceInfo(device); ServiceUtil.assertion(device == null, "设备不存在"); // 尝试关闭该设备未结束的所有订单 @@ -1259,12 +1261,10 @@ public class DeviceServiceImpl implements DeviceService // 修改设备信息 int timeUpdate = this.resetUpdateDbTime(deviceId); ServiceUtil.assertion(timeUpdate != 1, "修改设备时间失败"); - int eleUpdate = this.resetUpdateDbEle(deviceId); + int eleUpdate = this.resetUpdateDbEle(deviceId, device.getTotalElectriQuantity()); ServiceUtil.assertion(eleUpdate != 1, "修改设备电量失败"); // 发送命令 -// int reset = iotService.setTimeAndEle(device, 0L, BigDecimal.ZERO); -// ServiceUtil.assertion(reset != 1, "归零失败"); CommandResponse res1 = iotService.setTime(device, 0L); ServiceUtil.assertion(!res1.isSuccess(), "设备时长归零失败:" + res1.getMsg()); try { diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillConverterImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillConverterImpl.java index 8acd9f66..044e45b9 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillConverterImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillConverterImpl.java @@ -195,8 +195,9 @@ public class TransactionBillConverterImpl implements TransactionBillConverter { bo.setOrder(order); bo.setTotalEle(dto.getTotalEle()); if (order != null) { - deviceService.pullDeviceInfo(order.getDeviceId()); - bo.setDevice(deviceService.selectById(order.getDeviceId())); + DeviceVO device = deviceService.selectById(order.getDeviceId()); + deviceService.pullDeviceInfo(device); + bo.setDevice(device); } return bo; }