From 03878c137cd705ee08f19e4b4428413119096243 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: Fri, 3 Jan 2025 15:23:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=85=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IotReceiveServiceImpl.java | 38 +++--- .../ss/device/service/DeviceService.java | 14 +- .../service/impl/DeviceServiceImpl.java | 124 +++++++++--------- .../service/impl/RechargeDepositAfterPay.java | 2 +- .../service/impl/RechargePayHandler.java | 2 +- .../impl/TransactionBillConverterImpl.java | 2 +- .../impl/TransactionBillServiceImpl.java | 36 ++--- .../app/AppDeviceAdminController.java | 3 +- .../controller/app/AppDeviceController.java | 11 +- .../web/controller/ss/SmDeviceController.java | 4 +- .../staff/StaffDeviceController.java | 3 +- 11 files changed, 107 insertions(+), 132 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/service/impl/IotReceiveServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/iot/service/impl/IotReceiveServiceImpl.java index 5d719828..53d97a2a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/iot/service/impl/IotReceiveServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/service/impl/IotReceiveServiceImpl.java @@ -4,7 +4,6 @@ import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.core.redis.enums.RedisLockKey; import com.ruoyi.common.utils.NumberUtils; import com.ruoyi.common.utils.ServiceUtil; -import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.iot.constants.ReceiveConstants; import com.ruoyi.iot.domain.Datapoint; @@ -15,7 +14,6 @@ import com.ruoyi.iot.domain.response.CommandResponse; import com.ruoyi.iot.enums.ReceiveType; import com.ruoyi.iot.service.IotReceiveService; import com.ruoyi.iot.service.IotService; -import com.ruoyi.ss.device.domain.enums.DevicePowerStatus; import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.transactionBill.service.TransactionAssembler; @@ -71,8 +69,8 @@ public class IotReceiveServiceImpl implements IotReceiveService { } // 开关状态 else if (ReceiveConstants.DS_S.equals(msg.getDsId())) { - // 同步订单状态 - this.syncOrderStatus(msg); + // 同步订单状态 已经改为轮询,无需再做 +// this.syncOrderStatus(msg); } } // 生命周期 @@ -84,22 +82,22 @@ public class IotReceiveServiceImpl implements IotReceiveService { * 当开关状态为关闭,则同步订单状态 */ private void syncOrderStatus(ReceiveMsg msg) { - if (msg == null || StringUtils.isBlank(msg.getDevName())) { - return; - } - // 开关不是断电状态,则忽略 - if (!DevicePowerStatus.OFF.getStatus().equals(msg.getValue())) { - return; - } - log.info("{} 开关状态为 {}", msg.getDevName(), msg.getValue()); - - DeviceVO device = deviceService.selectByAnyMac(msg.getDevName()); - if (device == null) { - log.error("设备:{} 不存在", msg.getDevName()); - return; - } - // 拉取一下设备信息 - deviceService.pullDeviceInfo(device); +// if (msg == null || StringUtils.isBlank(msg.getDevName())) { +// return; +// } +// // 开关不是断电状态,则忽略 +// if (!DevicePowerStatus.OFF.getStatus().equals(msg.getValue())) { +// return; +// } +// log.info("{} 开关状态为 {}", msg.getDevName(), msg.getValue()); +// +// DeviceVO device = deviceService.selectByAnyMac(msg.getDevName()); +// if (device == null) { +// log.error("设备:{} 不存在", msg.getDevName()); +// return; +// } +// // 拉取一下设备信息 +// deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_COMMAND); // 查询 } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java index bfce4e02..8275f12b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java @@ -114,16 +114,8 @@ public interface DeviceService /** * 拉取设备信息,并保存到数据库 - * - * @param deviceIds 设备id列表(为空则查询所有) */ - void pullDeviceInfo(List deviceIds); - - - /** - * 拉取设备信息,并保存到数据库 - */ - void pullDeviceInfoList(List list); + void pullDeviceInfoList(List list, String onlineType); /** * 通过SN绑定设备 @@ -292,7 +284,7 @@ public interface DeviceService /** * 刷新设备数据 */ - void pullDeviceInfo(Long deviceId); + void pullDeviceInfo(Long deviceId, String onlineType); /** * 设备归零时长 @@ -340,7 +332,7 @@ public interface DeviceService /** * 拉取最新设备数据 */ - void pullDeviceInfo(DeviceVO device); + void pullDeviceInfo(DeviceVO device, String onlineType); /** * 解绑代理商 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 14d1f918..91ea0201 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 @@ -41,7 +41,6 @@ import com.ruoyi.ss.deviceSuit.service.DeviceSuitService; import com.ruoyi.ss.model.domain.SmModelVO; import com.ruoyi.ss.model.domain.enums.ModelTag; import com.ruoyi.ss.model.service.ModelService; -import com.ruoyi.ss.record.time.domain.RecordTime; import com.ruoyi.ss.record.time.domain.enums.RecordTimeType; import com.ruoyi.ss.record.time.service.IRecordTimeService; import com.ruoyi.ss.record.time.service.RecordTimeConverter; @@ -55,7 +54,6 @@ import com.ruoyi.ss.transactionBill.service.TransactionBillService; import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.ISmUserService; import com.ruoyi.ss.user.service.UserValidator; -import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -369,8 +367,14 @@ public class DeviceServiceImpl implements DeviceService */ @Override public int switchDevice(Long deviceId, boolean open, String reason) { + if (deviceId == null) { + return 0; + } DeviceVO device = selectById(deviceId); - this.pullDeviceInfo(device); + if (device == null) { + return 0; + } + this.pullDeviceInfo(device, null); return this.switchDevice(device, open ? DevicePowerStatus.ON : DevicePowerStatus.OFF, reason); } @@ -391,8 +395,9 @@ public class DeviceServiceImpl implements DeviceService } @Override - public void pullDeviceInfo(Long deviceId) { - pullDeviceInfo(Collections.singletonList(deviceId)); + public void pullDeviceInfo(Long deviceId, String onlineType) { + DeviceVO device = selectById(deviceId); + pullDeviceInfo(device, onlineType); } @Override @@ -418,9 +423,9 @@ public class DeviceServiceImpl implements DeviceService }); // 归零记录 - if (result != null && result == 1 ) { - this.resetRecord(device, RecordTimeType.TIME, reason); - } +// if (result != null && result == 1 ) { +// this.resetRecord(device, RecordTimeType.TIME, reason); +// } return result == null ? 0 : result; } @@ -459,31 +464,37 @@ public class DeviceServiceImpl implements DeviceService }); // 归零记录 - if (result != null && result == 1 ) { - this.resetRecord(device, RecordTimeType.ELE, reason); - } +// if (result != null && result == 1 ) { +// this.resetRecord(device, RecordTimeType.ELE, reason); +// } return result == null ? 0 : result; } private void resetRecord(DeviceVO device, RecordTimeType type, String reason) { - // 电量 - if (RecordTimeType.ELE.equals(type)) { - int amount = device.getSurplusEle().negate().intValue(); - RecordTime record = recordTimeConverter.toRecordTime(device.getDeviceId(), amount, reason, RecordTimeType.ELE.getType()); - scheduledExecutorService.schedule(() -> { - recordTimeService.insertRecordTime(record); - }, 0, TimeUnit.SECONDS); - } - // 时长 - else if (RecordTimeType.TIME.equals(type)) { - Duration duration = Duration.between(LocalDateTime.now(), device.getExpireTime()); - long seconds = duration.getSeconds() > 0 ? duration.getSeconds() : 0; - RecordTime record = recordTimeConverter.toRecordTime(device.getDeviceId(), -seconds, reason, RecordTimeType.TIME.getType()); - scheduledExecutorService.schedule(() -> { - recordTimeService.insertRecordTime(record); - }, 0, TimeUnit.SECONDS); - } +// // 电量 +// if (RecordTimeType.ELE.equals(type)) { +// int amount = device.getSurplusEle().negate().intValue(); +// RecordTime record = recordTimeConverter.toRecordTime(device.getDeviceId(), amount, reason, RecordTimeType.ELE.getType()); +// scheduledExecutorService.schedule(() -> { +// recordTimeService.insertRecordTime(record); +// }, 0, TimeUnit.SECONDS); +// } +// // 时长 +// else if (RecordTimeType.TIME.equals(type)) { +// LocalDateTime expireTime = device.getExpireTime(); +// long seconds = 0; +// if (expireTime != null) { +// Duration duration = Duration.between(LocalDateTime.now(), expireTime); +// seconds = duration.getSeconds() > 0 ? duration.getSeconds() : 0; +// } +// if (seconds > 0) { +// RecordTime record = recordTimeConverter.toRecordTime(device.getDeviceId(), -seconds, reason, RecordTimeType.TIME.getType()); +// scheduledExecutorService.schedule(() -> { +// recordTimeService.insertRecordTime(record); +// }, 0, TimeUnit.SECONDS); +// } +// } } private int resetUpdateDbEle(Long deviceId, BigDecimal expireEle) { @@ -591,8 +602,8 @@ public class DeviceServiceImpl implements DeviceService } @Override - public void pullDeviceInfo(DeviceVO device) { - this.pullDeviceInfoList(Collections.singletonList(device)); + public void pullDeviceInfo(DeviceVO device, String onlineType) { + this.pullDeviceInfoList(Collections.singletonList(device), onlineType); } @Override @@ -739,7 +750,7 @@ public class DeviceServiceImpl implements DeviceService // 成功后拉取设备信息 boolean success = result != null && result == 1; if (success) { - this.pullDeviceInfoAsync(Collections.singletonList(deviceId), 3, TimeUnit.SECONDS); + this.pullDeviceInfoAsync(device, 3, TimeUnit.SECONDS); } return success; @@ -804,7 +815,7 @@ public class DeviceServiceImpl implements DeviceService // 查询设备列表 List deviceList = this.selectByIds(deviceIds); // 拉取最新数据 - this.pullDeviceInfoList(deviceList); + this.pullDeviceInfoList(deviceList, null); Integer result = transactionTemplate.execute(status -> { // 关闭设备订单 @@ -890,23 +901,8 @@ public class DeviceServiceImpl implements DeviceService return result == null ? 0 : result; } - /** - * 拉取设备信息,并保存到数据库 - * - * @param deviceIds 设备id列表(为空则查询所有) - */ @Override - @SneakyThrows - public void pullDeviceInfo(List deviceIds) { - // 查询设备列表 - DeviceQuery dto = new DeviceQuery(); - dto.setDeviceIds(deviceIds); - List list = deviceMapper.selectSmDeviceList(dto); - this.pullDeviceInfoList(list); - } - - @Override - public void pullDeviceInfoList(List list) { + public void pullDeviceInfoList(List list, String onlineType) { if (CollectionUtils.isEmptyElement(list)) { return; } @@ -988,8 +984,10 @@ public class DeviceServiceImpl implements DeviceService // 异步更新设备信息 for (DeviceVO device : list) { scheduledExecutorService.schedule(() -> { - // 获取并设置在线状态 - this.setOnlineStatus(device, IotConstants.ONLINE_TYPE_COMMAND); + if (StringUtils.hasText(onlineType)) { + // 获取并设置在线状态 + this.setOnlineStatus(device, onlineType); + } // 更新数据库 this.updateIotInfo(device); }, 0, TimeUnit.SECONDS); @@ -1035,14 +1033,14 @@ public class DeviceServiceImpl implements DeviceService /** * 异步延迟执行拉取设备信息 - * @param deviceIds 设备id列表 + * @param device 设备id列表 * @param delay 延迟时间 * @param unit 时间单位 */ - private void pullDeviceInfoAsync(List deviceIds, long delay, TimeUnit unit) { + private void pullDeviceInfoAsync(DeviceVO device, long delay, TimeUnit unit) { scheduledExecutorService.schedule(() -> { log.info("异步拉取设备信息 start"); - this.pullDeviceInfo(deviceIds); + this.pullDeviceInfo(device, null); log.info("异步拉取设备信息 end"); }, delay, unit); } @@ -1140,7 +1138,10 @@ public class DeviceServiceImpl implements DeviceService DeviceVO device = deviceMapper.selectSmDeviceByDeviceId(deviceId); ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在"); // 拉取最新设备信息 - pullDeviceInfo(device); + pullDeviceInfo(device, null); + + // 关闭未完成订单 + this.closeNotFinishedBill(device, totalEle); Integer result = transactionTemplate.execute(status -> { // 修改设备信息 @@ -1157,9 +1158,6 @@ public class DeviceServiceImpl implements DeviceService int update = deviceMapper.updateSmDevice(data); ServiceUtil.assertion(update != 1, "更新设备%s信息失败", device.getDeviceNo()); - // 关闭未完成订单 - this.closeNotFinishedBill(device, totalEle); - // 发送命令 if (withTime) { // this.resetTime(device, false, reason); // 重置时长 @@ -1192,10 +1190,10 @@ public class DeviceServiceImpl implements DeviceService return 1; }); - if (result != null && result == 1) { - this.resetRecord(device, RecordTimeType.TIME, reason); - this.resetRecord(device, RecordTimeType.ELE, reason); - } +// if (result != null && result == 1) { +// this.resetRecord(device, RecordTimeType.TIME, reason); +// this.resetRecord(device, RecordTimeType.ELE, reason); +// } return result == null ? 0 : result; } @@ -1229,7 +1227,7 @@ public class DeviceServiceImpl implements DeviceService return 0; } // 拉取设备信息 - this.pullDeviceInfo(deviceId); + this.pullDeviceInfo(deviceId, null); return deviceMapper.initTotalEle(deviceId); } @@ -1336,7 +1334,7 @@ public class DeviceServiceImpl implements DeviceService scheduledExecutorService.schedule(() -> { // 获取设备最新信息 DeviceVO device = selectById(deviceId); - pullDeviceInfo(device); + pullDeviceInfo(device, null); // 若物联网设备的时长或者电量小于当前设备数据库的值,则执行一次同步(开启) // 一般情况下,物联网设备的值会大于或等于当前数据库的值 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/RechargeDepositAfterPay.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/RechargeDepositAfterPay.java index a8b5334f..afa03334 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/RechargeDepositAfterPay.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/RechargeDepositAfterPay.java @@ -49,7 +49,7 @@ public class RechargeDepositAfterPay implements AfterPay { DeviceVO device = deviceService.selectById(bill.getDeviceId()); ServiceUtil.assertion(device == null, "设备不存在"); - deviceService.pullDeviceInfo(device); + deviceService.pullDeviceInfo(device, null); Integer result = transactionTemplate.execute(status -> { // 修改订单信息 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/RechargePayHandler.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/RechargePayHandler.java index 1e1132c4..2f2f82d1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/RechargePayHandler.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/RechargePayHandler.java @@ -94,7 +94,7 @@ public class RechargePayHandler implements AfterPay, AfterRefund { // 设备信息 DeviceVO device = bo.getDevice(); - deviceService.pullDeviceInfo(device); + deviceService.pullDeviceInfo(device, null); List bonusList = bill.getBonusList(); 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 ee306d8f..6353cc71 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 @@ -194,7 +194,7 @@ public class TransactionBillConverterImpl implements TransactionBillConverter { bo.setTotalEle(dto.getTotalEle()); if (order != null) { DeviceVO device = deviceService.selectById(order.getDeviceId()); - deviceService.pullDeviceInfo(device); + deviceService.pullDeviceInfo(device, null); bo.setDevice(device); } return bo; 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 94f11fd1..378e2d92 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 @@ -269,7 +269,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After ServiceUtil.assertion(!redisLock.lock(RedisLockKey.ADD_RECHARGE_ORDER, deviceId), "当前使用该设备人数较多,请稍后再试"); try { // 拉取设备信息 - deviceService.pullDeviceInfo(bo.getDevice().getDeviceId()); + deviceService.pullDeviceInfo(bo.getDevice().getDeviceId(), null); // 生成订单 TransactionBill order = parseToOrder(bo); @@ -866,7 +866,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After // 获取最新设备信息 DeviceVO device = deviceService.selectById(bill.getDeviceId()); - deviceService.pullDeviceInfo(device); + deviceService.pullDeviceInfo(device, null); // 充值设备 Boolean iotResult = transactionTemplate.execute(status -> { @@ -1143,7 +1143,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After // 计量收费,则获取最新的设备信息 if(SuitFeeType.COUNT.getType().equals(bill.getSuitFeeType()) || SuitFeeType.TIMING_COUNT.getType().equals(bill.getSuitFeeType())) { DeviceVO device = deviceService.selectById(bill.getDeviceId()); - deviceService.pullDeviceInfo(device); + deviceService.pullDeviceInfo(device, null); totalEle = this.calcTotalEle(device, totalEle); } @@ -1541,30 +1541,14 @@ public class TransactionBillServiceImpl implements TransactionBillService, After public boolean bluetoothRechargeSuccess(String billNo) { TransactionBillVO bill = selectSmTransactionBillByBillNo(billNo); ServiceUtil.assertion(bill == null, "订单不存在", 10001); - ServiceUtil.assertion(!TransactionBillType.RECHARGE.getType().equals(bill.getType()), "该订单不是充值订单", 10002); - ServiceUtil.assertion(TransactionBillDeviceRechargeStatus.SUCCESS.getStatus().equals(bill.getDeviceRechargeStatus()), "设备已充值成功,请勿重复充值", 10003); - ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(bill.getStatus()), "订单尚未充值成功", 10004); - // 拉取设备信息 - deviceService.pullDeviceInfo(bill.getDeviceId()); + // 更新设备充值状态 + TransactionBill data = new TransactionBill(); + data.setDeviceRechargeStatus(TransactionBillDeviceRechargeStatus.SUCCESS.getStatus()); + data.setOpenMsg("蓝牙充值成功"); + data.setBillId(bill.getBillId()); - Integer execute = transactionTemplate.execute(status -> { - // 更新设备充值状态 - TransactionBill data = new TransactionBill(); - data.setDeviceRechargeStatus(TransactionBillDeviceRechargeStatus.SUCCESS.getStatus()); - data.setOpenMsg("蓝牙充值成功"); - TransactionBillQuery query = new TransactionBillQuery(); - query.setBillId(bill.getBillId()); - query.setType(TransactionBillType.RECHARGE.getType()); - query.setDeviceRechargeStatus(TransactionBillDeviceRechargeStatus.BLUETOOTH.getStatus()); - query.setStatus(TransactionBillStatus.SUCCESS.getStatus()); - int result = this.updateByQuery(data, query); - ServiceUtil.assertion( result != 1, "蓝牙充值回调失败,设备状态已发生改变"); - - return result; - }); - - return execute != null && execute == 1; + return this.updateSmTransactionBill(data) == 1; } @Override @@ -1830,7 +1814,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After DeviceVO device = deviceService.selectById(bill.getDeviceId()); ServiceUtil.assertion(device == null, "设备不存在"); ServiceUtil.assertion(StringUtils.isAllBlank(device.getMac(), device.getMac2()), "设备MAC为空,请联系管理员处理"); - deviceService.pullDeviceInfo(device); + deviceService.pullDeviceInfo(device, null); // 开启 if (open) { diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceAdminController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceAdminController.java index 6af07019..69717fa8 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceAdminController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceAdminController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.app; +import com.ruoyi.common.constant.IotConstants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.StringUtils; @@ -74,7 +75,7 @@ public class AppDeviceAdminController extends BaseController { return error("上报数据失败"); } Threads.sleep(3000); - deviceService.pullDeviceInfo(device); + deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_COMMAND); return success(device); } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java index 9facd709..122efe8a 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java @@ -2,6 +2,7 @@ package com.ruoyi.web.controller.app; import com.fasterxml.jackson.annotation.JsonView; import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.IotConstants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.JsonViewProfile; @@ -96,7 +97,7 @@ public class AppDeviceController extends BaseController { startOrderBy(); smDevice.setUserId(getUserId()); List list = smDeviceService.selectSmDeviceList(smDevice); - smDeviceService.pullDeviceInfoList(list); + smDeviceService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_COMMAND); deviceAssembler.assembleRealServiceRate(list); return getDataTable(list); } @@ -108,7 +109,7 @@ public class AppDeviceController extends BaseController { startPage(); query.setStoreId(storeId); List list = smDeviceService.selectSmDeviceList(query); - smDeviceService.pullDeviceInfoList(list); + smDeviceService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_COMMAND); deviceAssembler.assembleBusinessTime(list); // 店铺营业时间 return getDataTable(list); } @@ -139,7 +140,7 @@ public class AppDeviceController extends BaseController { ServiceUtil.assertion(!device.getAllowSwitch(), "您无权操作此设备"); // 获取最新数据 - smDeviceService.pullDeviceInfo(device); + smDeviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_COMMAND); DevicePowerStatus powerStatus = DevicePowerStatus.parse(status); return toAjax(smDeviceService.switchDevice(device, powerStatus, "商户开关设备")); @@ -216,7 +217,7 @@ public class AppDeviceController extends BaseController { @ApiOperation("刷新设备信息") @GetMapping("/{deviceId}/refreshIot") public AjaxResult syncIot(@PathVariable @ApiParam("设备id") Long deviceId) { - smDeviceService.pullDeviceInfo(deviceId); + smDeviceService.pullDeviceInfo(deviceId, IotConstants.ONLINE_TYPE_COMMAND); return success(); } @@ -235,7 +236,7 @@ public class AppDeviceController extends BaseController { } else { return error("设备ID、SN、MAC必须传入其中一个"); } - smDeviceService.pullDeviceInfo(device); + smDeviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_COMMAND); return success(device); } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java index b87c895f..105ce13d 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java @@ -51,7 +51,7 @@ public class SmDeviceController extends BaseController { startPage(); List list = deviceService.selectSmDeviceList(smDevice); - deviceService.pullDeviceInfoList(list); + deviceService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_COMMAND); deviceAssembler.assembleRealServiceRate(list); return getDataTable(list); } @@ -142,7 +142,7 @@ public class SmDeviceController extends BaseController @GetMapping("/{deviceId}/refreshIot") public AjaxResult syncIot(@PathVariable @ApiParam("设备id") Long deviceId, @RequestParam(required = false, defaultValue = IotConstants.ONLINE_TYPE_GET) String onlineType) { - deviceService.pullDeviceInfo(deviceId); + deviceService.pullDeviceInfo(deviceId, IotConstants.ONLINE_TYPE_COMMAND); return success(); } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDeviceController.java index 74052bb4..dd6aad1d 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDeviceController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.staff; +import com.ruoyi.common.constant.IotConstants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.ss.device.domain.DeviceQuery; @@ -37,7 +38,7 @@ public class StaffDeviceController extends BaseController { query.setStaffUserId(getUserId()); query.setStaffPermission(StoreStaffPermissions.DEVICE_VIEW.getCode()); List list = deviceService.selectStaffDeviceList(query); - deviceService.pullDeviceInfoList(list); + deviceService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_COMMAND); return getDataTable(list); }