From 156e36c26d0f9fbae18b2fe2131e5d26e8757b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Wed, 18 Sep 2024 09:33:05 +0800 Subject: [PATCH] =?UTF-8?q?debug:=E5=BD=92=E9=9B=B6=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E7=8A=B6=E6=80=81=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DeviceServiceImpl.java | 62 +++++++++---------- .../impl/TransactionBillServiceImpl.java | 2 +- 2 files changed, 32 insertions(+), 32 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 0a4f4cff..599e7afd 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 @@ -519,25 +519,25 @@ public class DeviceServiceImpl implements DeviceService DeviceVO device = selectSmDeviceByDeviceId(deviceId); ServiceUtil.assertion(device == null, "设备不存在"); - Integer result = transactionTemplate.execute(status -> { - // 关闭该设备未结束的所有订单 - TransactionBillQuery query = new TransactionBillQuery(); - query.setStatusList(TransactionBillStatus.canClose()); - query.setDeviceId(device.getDeviceId()); - query.setIsFinished(false); // 未结束的订单都会被关闭 - query.setSuitFeeTypes(SuitFeeType.rechargeCountList()); - List billList = transactionBillService.selectSmTransactionBillList(query); + // 尝试关闭该设备未结束的所有订单 + TransactionBillQuery query = new TransactionBillQuery(); + query.setStatusList(TransactionBillStatus.canClose()); + query.setDeviceId(device.getDeviceId()); + query.setIsFinished(false); // 未结束的订单都会被关闭 + query.setSuitFeeTypes(SuitFeeType.rechargeCountList()); + List billList = transactionBillService.selectSmTransactionBillList(query); + try { int closeCount = transactionBillService.batchCloseBillByDevice(billList, false, device); - ServiceUtil.assertion(closeCount != billList.size(), "关闭订单失败"); + ServiceUtil.assertion(closeCount != billList.size(), "关闭订单失败:closeCount =" + closeCount); + } catch (Exception e) { + log.error("关闭订单失败:{}" , e.getMessage()); + } - // 发送命令 - int reset = this.resetEle(device, true); - ServiceUtil.assertion(reset != 1, "设备电量归零失败"); + // 发送命令 + int reset = this.resetEle(device, true); + ServiceUtil.assertion(reset != 1, "设备电量归零失败"); - return reset; - }); - - return result == null ? 0 : result; + return reset; } @@ -856,23 +856,23 @@ public class DeviceServiceImpl implements DeviceService ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在"); ServiceUtil.assertion(!UserUtil.hasFrontUser(device.getUserId()), "您不是该设备的商户,无法进行该操作"); - transactionTemplate.execute(status -> { - // 关闭该设备未结束的所有订单 - TransactionBillQuery query = new TransactionBillQuery(); - query.setStatusList(TransactionBillStatus.canClose()); - query.setDeviceId(device.getDeviceId()); - query.setIsFinished(false); // 未结束的订单都会被关闭 - query.setSuitFeeTypes(SuitFeeType.rechargeTimeList()); - List billList = transactionBillService.selectSmTransactionBillList(query); + // 尝试关闭该设备未结束的所有订单 + TransactionBillQuery query = new TransactionBillQuery(); + query.setStatusList(TransactionBillStatus.canClose()); + query.setDeviceId(device.getDeviceId()); + query.setIsFinished(false); // 未结束的订单都会被关闭 + query.setSuitFeeTypes(SuitFeeType.rechargeTimeList()); + List billList = transactionBillService.selectSmTransactionBillList(query); + try { int closeCount = transactionBillService.batchCloseBillByDevice(billList, false, device); - ServiceUtil.assertion(closeCount != billList.size(), "关闭订单失败"); + ServiceUtil.assertion(closeCount != billList.size(), "关闭订单失败:closeCount =" + closeCount); + } catch (Exception e) { + log.error("关闭订单失败: {}", e.getMessage()); + } - // 发送命令 - int reset = this.resetTime(device, true); - ServiceUtil.assertion(reset != 1, "归零失败"); - - return reset; - }); + // 发送命令 + int reset = this.resetTime(device, true); + ServiceUtil.assertion(reset != 1, "归零失败"); return true; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java index 47fbc77d..2a250d48 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java @@ -1537,7 +1537,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After for (TransactionBillVO bill : billList) { bo.setOrder(bill); int end = this.endUse(bo, withDevice); - ServiceUtil.assertion(end != 1, "关闭订单失败"); + ServiceUtil.assertion(end != 1, "关闭订单失败:" + bill.getBillNo()); sum += end; }