设备监控debug

This commit is contained in:
磷叶 2025-01-02 13:35:30 +08:00
parent 870e1ac431
commit 7c9acf2c54
13 changed files with 185 additions and 142 deletions

View File

@ -1,5 +1,5 @@
package com.ruoyi.iot.service.impl; package com.ruoyi.iot.service.impl;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.core.redis.enums.RedisLockKey; import com.ruoyi.common.core.redis.enums.RedisLockKey;
import com.ruoyi.common.utils.NumberUtils; import com.ruoyi.common.utils.NumberUtils;
@ -7,7 +7,10 @@ import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.iot.constants.ReceiveConstants; import com.ruoyi.iot.constants.ReceiveConstants;
import com.ruoyi.iot.domain.*; import com.ruoyi.iot.domain.Datapoint;
import com.ruoyi.iot.domain.HistoryDatastream;
import com.ruoyi.iot.domain.HistoryDeviceData;
import com.ruoyi.iot.domain.ReceiveMsg;
import com.ruoyi.iot.domain.response.CommandResponse; import com.ruoyi.iot.domain.response.CommandResponse;
import com.ruoyi.iot.enums.ReceiveType; import com.ruoyi.iot.enums.ReceiveType;
import com.ruoyi.iot.service.IotReceiveService; import com.ruoyi.iot.service.IotReceiveService;
@ -96,7 +99,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
return; return;
} }
// 拉取一下设备信息 // 拉取一下设备信息
deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(device);
// 查询 // 查询
} }

View File

@ -9,7 +9,6 @@ import com.ruoyi.ss.device.domain.vo.DeviceVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@ -224,4 +223,8 @@ public interface DeviceMapper
*/ */
int initTotalEle(@Param("deviceId") Long deviceId); int initTotalEle(@Param("deviceId") Long deviceId);
/**
* 查询ID列表
*/
List<Long> selectIds(@Param("query") DeviceQuery query);
} }

View File

@ -341,6 +341,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="selectIds" resultType="java.lang.Long">
select device_id
from sm_device sd
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertSmDevice" parameterType="Device" useGeneratedKeys="true" keyProperty="deviceId"> <insert id="insertSmDevice" parameterType="Device" useGeneratedKeys="true" keyProperty="deviceId">
<selectKey resultType="Long" order="AFTER" keyProperty="deviceId"> <selectKey resultType="Long" order="AFTER" keyProperty="deviceId">
select LAST_INSERT_ID() select LAST_INSERT_ID()
@ -631,6 +639,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</otherwise> </otherwise>
</choose> </choose>
</foreach> </foreach>
<foreach open="online_status1 = CASE device_id" collection="list" item="item" close="END,">
<choose>
<when test="item.onlineStatus1 != null">
WHEN #{item.deviceId} THEN #{item.onlineStatus1}
</when>
<otherwise>
WHEN #{item.deviceId} THEN `online_status1`
</otherwise>
</choose>
</foreach>
<foreach open="online_status2 = CASE device_id" collection="list" item="item" close="END,">
<choose>
<when test="item.onlineStatus2 != null">
WHEN #{item.deviceId} THEN #{item.onlineStatus2}
</when>
<otherwise>
WHEN #{item.deviceId} THEN `online_status2`
</otherwise>
</choose>
</foreach>
<foreach open="last_online_time = CASE device_id" collection="list" item="item" close="END,"> <foreach open="last_online_time = CASE device_id" collection="list" item="item" close="END,">
<choose> <choose>
<when test="item.lastOnlineTime != null"> <when test="item.lastOnlineTime != null">

View File

@ -1,7 +1,10 @@
package com.ruoyi.ss.device.service; package com.ruoyi.ss.device.service;
import com.ruoyi.iot.domain.response.CommandResponse; import com.ruoyi.iot.domain.response.CommandResponse;
import com.ruoyi.ss.device.domain.*; import com.ruoyi.ss.device.domain.Device;
import com.ruoyi.ss.device.domain.DeviceBO;
import com.ruoyi.ss.device.domain.DeviceCountVO;
import com.ruoyi.ss.device.domain.DeviceQuery;
import com.ruoyi.ss.device.domain.dto.DeviceBatchUpdateModelDTO; import com.ruoyi.ss.device.domain.dto.DeviceBatchUpdateModelDTO;
import com.ruoyi.ss.device.domain.dto.DeviceRegisterDTO; import com.ruoyi.ss.device.domain.dto.DeviceRegisterDTO;
import com.ruoyi.ss.device.domain.dto.DeviceWifiDTO; import com.ruoyi.ss.device.domain.dto.DeviceWifiDTO;
@ -112,16 +115,15 @@ public interface DeviceService
/** /**
* 拉取设备信息并保存到数据库 * 拉取设备信息并保存到数据库
* *
* @param deviceIds 设备id列表为空则查询所有 * @param deviceIds 设备id列表为空则查询所有
* @param onlineType
*/ */
void pullDeviceInfo(List<Long> deviceIds, String onlineType); void pullDeviceInfo(List<Long> deviceIds);
/** /**
* 拉取设备信息并保存到数据库 * 拉取设备信息并保存到数据库
*/ */
void pullDeviceInfoList(List<DeviceVO> list, String onlineType); void pullDeviceInfoList(List<DeviceVO> list);
/** /**
* 通过SN绑定设备 * 通过SN绑定设备
@ -290,7 +292,7 @@ public interface DeviceService
/** /**
* 刷新设备数据 * 刷新设备数据
*/ */
void pullDeviceInfo(Long deviceId, String onlineType); void pullDeviceInfo(Long deviceId);
/** /**
* 设备归零时长 * 设备归零时长
@ -338,7 +340,7 @@ public interface DeviceService
/** /**
* 拉取最新设备数据 * 拉取最新设备数据
*/ */
void pullDeviceInfo(DeviceVO device, String onlineType); void pullDeviceInfo(DeviceVO device);
/** /**
* 解绑代理商 * 解绑代理商

View File

@ -7,7 +7,10 @@ import com.ruoyi.common.core.redis.enums.RedisLockKey;
import com.ruoyi.common.enums.LoginType; import com.ruoyi.common.enums.LoginType;
import com.ruoyi.common.enums.UserType; import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.*; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.iot.domain.IotDeviceInfo; import com.ruoyi.iot.domain.IotDeviceInfo;
import com.ruoyi.iot.domain.response.CommandResponse; import com.ruoyi.iot.domain.response.CommandResponse;
@ -45,7 +48,6 @@ import com.ruoyi.ss.store.service.StoreService;
import com.ruoyi.ss.storeStaff.service.StoreStaffValidator; import com.ruoyi.ss.storeStaff.service.StoreStaffValidator;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery; import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus; import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO; import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
import com.ruoyi.ss.transactionBill.service.TransactionBillService; import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.domain.SmUserVO;
@ -366,7 +368,7 @@ public class DeviceServiceImpl implements DeviceService
@Override @Override
public int switchDevice(Long deviceId, boolean open, String reason) { public int switchDevice(Long deviceId, boolean open, String reason) {
DeviceVO device = selectById(deviceId); DeviceVO device = selectById(deviceId);
this.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); this.pullDeviceInfo(device);
return this.switchDevice(device, open ? DevicePowerStatus.ON : DevicePowerStatus.OFF, reason); return this.switchDevice(device, open ? DevicePowerStatus.ON : DevicePowerStatus.OFF, reason);
} }
@ -387,8 +389,8 @@ public class DeviceServiceImpl implements DeviceService
} }
@Override @Override
public void pullDeviceInfo(Long deviceId, String onlineType) { public void pullDeviceInfo(Long deviceId) {
pullDeviceInfo(Collections.singletonList(deviceId), onlineType); pullDeviceInfo(Collections.singletonList(deviceId));
} }
@Override @Override
@ -587,8 +589,8 @@ public class DeviceServiceImpl implements DeviceService
} }
@Override @Override
public void pullDeviceInfo(DeviceVO device, String onlineType) { public void pullDeviceInfo(DeviceVO device) {
this.pullDeviceInfoList(Collections.singletonList(device), onlineType); this.pullDeviceInfoList(Collections.singletonList(device));
} }
@Override @Override
@ -777,14 +779,8 @@ public class DeviceServiceImpl implements DeviceService
log.info("device list is empty"); log.info("device list is empty");
return; return;
} }
LocalDateTime now = LocalDateTime.now();
for (DeviceVO device : list) { for (DeviceVO device : list) {
String status = iotService.getOnlineStatus(device).getStatus(); this.setOnlineStatus(device, IotConstants.ONLINE_TYPE_COMMAND);
device.setOnlineStatus(status);
if (DeviceOnlineStatus.ONLINE.getStatus().equals(status)) {
device.setLastOnlineTime(now);
}
} }
int i = deviceMapper.batchUpdateOnlineStatus(list); int i = deviceMapper.batchUpdateOnlineStatus(list);
log.info("update count: {}", i); log.info("update count: {}", i);
@ -806,7 +802,7 @@ public class DeviceServiceImpl implements DeviceService
// 查询设备列表 // 查询设备列表
List<DeviceVO> deviceList = this.selectByIds(deviceIds); List<DeviceVO> deviceList = this.selectByIds(deviceIds);
// 拉取最新数据 // 拉取最新数据
this.pullDeviceInfoList(deviceList, IotConstants.ONLINE_TYPE_GET); this.pullDeviceInfoList(deviceList);
Integer result = transactionTemplate.execute(status -> { Integer result = transactionTemplate.execute(status -> {
// 关闭设备订单 // 关闭设备订单
@ -895,25 +891,23 @@ public class DeviceServiceImpl implements DeviceService
/** /**
* 拉取设备信息并保存到数据库 * 拉取设备信息并保存到数据库
* *
* @param deviceIds 设备id列表为空则查询所有 * @param deviceIds 设备id列表为空则查询所有
* @param onlineType
*/ */
@Override @Override
@SneakyThrows @SneakyThrows
public void pullDeviceInfo(List<Long> deviceIds, String onlineType) { public void pullDeviceInfo(List<Long> deviceIds) {
// 查询设备列表 // 查询设备列表
DeviceQuery dto = new DeviceQuery(); DeviceQuery dto = new DeviceQuery();
dto.setDeviceIds(deviceIds); dto.setDeviceIds(deviceIds);
List<DeviceVO> list = deviceMapper.selectSmDeviceList(dto); List<DeviceVO> list = deviceMapper.selectSmDeviceList(dto);
this.pullDeviceInfoList(list, onlineType); this.pullDeviceInfoList(list);
} }
@Override @Override
public void pullDeviceInfoList(List<DeviceVO> list, String onlineType) { public void pullDeviceInfoList(List<DeviceVO> list) {
if (CollectionUtils.isEmptyElement(list)) { if (CollectionUtils.isEmptyElement(list)) {
return; return;
} }
LocalDateTime now = LocalDateTime.now();
// 拼接正在使用中的订单数量 // 拼接正在使用中的订单数量
deviceAssembler.assembleUsingBillCount(list); deviceAssembler.assembleUsingBillCount(list);
@ -992,23 +986,28 @@ public class DeviceServiceImpl implements DeviceService
// 异步更新设备信息 // 异步更新设备信息
for (DeviceVO device : list) { for (DeviceVO device : list) {
scheduledExecutorService.schedule(() -> { scheduledExecutorService.schedule(() -> {
// 是否在线 // 获取并设置在线状态
String onlineStatus1 = iotService.getOnlineStatus(device.getMac(), device.getProductId(), onlineType).getStatus(); this.setOnlineStatus(device, IotConstants.ONLINE_TYPE_COMMAND);
String onlineStatus2 = iotService.getOnlineStatus(device.getMac2(), device.getProductId(), onlineType).getStatus();
device.setOnlineStatus1(onlineStatus1);
device.setOnlineStatus2(onlineStatus2);
if (DeviceOnlineStatus.ONLINE.getStatus().equals(onlineStatus1) || DeviceOnlineStatus.ONLINE.getStatus().equals(onlineStatus2)) {
device.setOnlineStatus(DeviceOnlineStatus.ONLINE.getStatus());
device.setLastOnlineTime(now);
} else {
device.setOnlineStatus(DeviceOnlineStatus.OFFLINE.getStatus());
}
// 更新数据库 // 更新数据库
this.updateIotInfo(device); this.updateIotInfo(device);
}, 0, TimeUnit.SECONDS); }, 0, TimeUnit.SECONDS);
} }
} }
private void setOnlineStatus(DeviceVO device, String onlineType) {
// 是否在线
String onlineStatus1 = iotService.getOnlineStatus(device.getMac(), device.getProductId(), onlineType).getStatus();
String onlineStatus2 = iotService.getOnlineStatus(device.getMac2(), device.getProductId(), onlineType).getStatus();
device.setOnlineStatus1(onlineStatus1);
device.setOnlineStatus2(onlineStatus2);
if (DeviceOnlineStatus.ONLINE.getStatus().equals(onlineStatus1) || DeviceOnlineStatus.ONLINE.getStatus().equals(onlineStatus2)) {
device.setOnlineStatus(DeviceOnlineStatus.ONLINE.getStatus());
device.setLastOnlineTime(LocalDateTime.now());
} else {
device.setOnlineStatus(DeviceOnlineStatus.OFFLINE.getStatus());
}
}
/** /**
* 更新物联网信息 * 更新物联网信息
*/ */
@ -1026,6 +1025,8 @@ public class DeviceServiceImpl implements DeviceService
data.setSurplusEle(device.getSurplusEle()); data.setSurplusEle(device.getSurplusEle());
data.setStatus(device.getStatus()); data.setStatus(device.getStatus());
data.setOnlineStatus(device.getOnlineStatus()); data.setOnlineStatus(device.getOnlineStatus());
data.setOnlineStatus1(device.getOnlineStatus1());
data.setOnlineStatus2(device.getOnlineStatus2());
data.setLastOnlineTime(device.getLastOnlineTime()); data.setLastOnlineTime(device.getLastOnlineTime());
return deviceMapper.updateSmDevice(data); return deviceMapper.updateSmDevice(data);
} }
@ -1039,7 +1040,7 @@ public class DeviceServiceImpl implements DeviceService
private void pullDeviceInfoAsync(List<Long> deviceIds, long delay, TimeUnit unit) { private void pullDeviceInfoAsync(List<Long> deviceIds, long delay, TimeUnit unit) {
scheduledExecutorService.schedule(() -> { scheduledExecutorService.schedule(() -> {
log.info("异步拉取设备信息 start"); log.info("异步拉取设备信息 start");
this.pullDeviceInfo(deviceIds, IotConstants.ONLINE_TYPE_GET); this.pullDeviceInfo(deviceIds);
log.info("异步拉取设备信息 end"); log.info("异步拉取设备信息 end");
}, delay, unit); }, delay, unit);
} }
@ -1137,7 +1138,7 @@ public class DeviceServiceImpl implements DeviceService
DeviceVO device = deviceMapper.selectSmDeviceByDeviceId(deviceId); DeviceVO device = deviceMapper.selectSmDeviceByDeviceId(deviceId);
ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在"); ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在");
// 拉取最新设备信息 // 拉取最新设备信息
pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); pullDeviceInfo(device);
Integer result = transactionTemplate.execute(status -> { Integer result = transactionTemplate.execute(status -> {
// 修改设备信息 // 修改设备信息
@ -1226,7 +1227,7 @@ public class DeviceServiceImpl implements DeviceService
return 0; return 0;
} }
// 拉取设备信息 // 拉取设备信息
this.pullDeviceInfo(deviceId, IotConstants.ONLINE_TYPE_GET); this.pullDeviceInfo(deviceId);
return deviceMapper.initTotalEle(deviceId); return deviceMapper.initTotalEle(deviceId);
} }
@ -1314,51 +1315,58 @@ public class DeviceServiceImpl implements DeviceService
/** /**
* 监控设备信息并对设备进行校准 * 监控设备信息并对设备进行校准
* FIXME 存在问题数据量大时处理较慢会造成数据不一致导致频繁关闭设备
* 应该考虑实时获取设备数据采用同步方式进行校准
* 或者考虑有针对性的对设备进行校准
*/ */
@Override @Override
public void monitor(List<Long> deviceIds) { public void monitor(List<Long> deviceIds) {
// DeviceQuery query = new DeviceQuery(); // 若不为空则查询所有设备
// query.setDeviceIds(deviceIds); if (CollectionUtils.isEmpty(deviceIds)) {
// List<DeviceVO> deviceList = this.selectSmDeviceList(query); DeviceQuery query = new DeviceQuery();
// if (CollectionUtils.isEmptyElement(deviceList)) { query.setDeviceIds(deviceIds);
// return; deviceIds = this.selectIds(query);
// } }
// this.pullDeviceInfoList(deviceList, IotConstants.ONLINE_TYPE_GET); if (CollectionUtils.isEmptyElement(deviceIds)) {
// return;
// for (DeviceVO device : deviceList) { }
// try {
// scheduledExecutorService.schedule(() -> { for (Long deviceId : deviceIds) {
// // 若物联网设备的时长或者电量小于当前设备数据库的值则执行一次同步开启 try {
// // 一般情况下物联网设备的值会大于或等于当前数据库的值 scheduledExecutorService.schedule(() -> {
// long deviceSeconds = device.getRemainTime() == null ? 0 : device.getRemainTime().longValue(); // 获取设备最新信息
// if (device.getSurplusSecondsDb() > deviceSeconds) { DeviceVO device = selectById(deviceId);
// this.syncTime(device.getDeviceId(), LocalDateTime.now(), "设备监控-同步时长"); pullDeviceInfo(device);
// }
// if (device.getSurplusEleDb().compareTo(device.getSurplusEle()) > 0) { // 若物联网设备的时长或者电量小于当前设备数据库的值则执行一次同步开启
// this.syncEle(device.getDeviceId(), "设备监控-同步电量"); // 一般情况下物联网设备的值会大于或等于当前数据库的值
// } long deviceSeconds = device.getRemainTime() == null ? 0 : device.getRemainTime().longValue();
// if (device.getSurplusSecondsDb() > deviceSeconds) {
// // 若当前设备数据库的时长并且电量<=0且在这之后用户没有发open命令则执行一次同步关闭 this.syncTime(device.getDeviceId(), LocalDateTime.now(), "设备监控-同步时长");
// boolean hasOpen = DeviceUserOperaType.OPEN.getType().equals(device.getUserOperaType()); // 是否开启过 }
// LocalDateTime lastOperaTime = device.getUserOperaTime(); // 上次开启的时间 if (device.getSurplusEleDb().compareTo(device.getSurplusEle()) > 0) {
// BigDecimal lastOperaEle = device.getUserOperaEle(); // 上次开启的总用电量 this.syncEle(device.getDeviceId(), "设备监控-同步电量");
// }
// boolean hasOpenAfterExpireTime = hasOpen && lastOperaTime != null && lastOperaTime.isAfter(device.getExpireTime()); // 是否在时间结束后开启
// boolean hasTime = device.getSurplusSecondsDb() > 0; // 剩余时间 // 若当前设备数据库的时长并且电量<=0且在这之后用户没有发open命令则执行一次同步关闭
// boolean hasOpenAfterExpireEle = hasOpen && lastOperaEle != null && lastOperaEle.compareTo(device.getExpireEle()) > 0; // 是否在结束电量后开启 boolean hasOpen = DeviceUserOperaType.OPEN.getType().equals(device.getUserOperaType()); // 是否开启过
// boolean hasEle = device.getSurplusEleDb().compareTo(BigDecimal.ZERO) > 0; // 剩余电量 LocalDateTime lastOperaTime = device.getUserOperaTime(); // 上次开启的时间
// if (!hasTime && !hasEle && !hasOpenAfterExpireTime && !hasOpenAfterExpireEle) { BigDecimal lastOperaEle = device.getUserOperaEle(); // 上次开启的总用电量
// this.switchDevice(device, DevicePowerStatus.OFF, "设备监控-发现异常未关闭设备");
// } boolean hasOpenAfterExpireTime = hasOpen && lastOperaTime != null && lastOperaTime.isAfter(device.getExpireTime()); // 是否在时间结束后开启
// },0, TimeUnit.SECONDS); boolean hasTime = device.getSurplusSecondsDb() > 0; // 剩余时间
// boolean hasOpenAfterExpireEle = hasOpen && lastOperaEle != null && lastOperaEle.compareTo(device.getExpireEle()) > 0; // 是否在结束电量后开启
// } catch (Exception e) { boolean hasEle = device.getSurplusEleDb().compareTo(BigDecimal.ZERO) > 0; // 剩余电量
// log.error("监控设备{}出错:{}", device.getDeviceNo(), e.getMessage()); if (!hasTime && !hasEle && !hasOpenAfterExpireTime && !hasOpenAfterExpireEle) {
// } this.switchDevice(device, DevicePowerStatus.OFF, "设备监控-发现异常未关闭设备");
// } }
},0, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("监控设备id={}出错:{}", deviceId, e.getMessage());
}
}
}
private List<Long> selectIds(DeviceQuery query) {
return deviceMapper.selectIds(query);
} }
/** /**

View File

@ -1,6 +1,5 @@
package com.ruoyi.ss.transactionBill.service.impl; package com.ruoyi.ss.transactionBill.service.impl;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.iot.service.IotService; import com.ruoyi.iot.service.IotService;
@ -50,7 +49,7 @@ public class RechargeDepositAfterPay implements AfterPay {
DeviceVO device = deviceService.selectById(bill.getDeviceId()); DeviceVO device = deviceService.selectById(bill.getDeviceId());
ServiceUtil.assertion(device == null, "设备不存在"); ServiceUtil.assertion(device == null, "设备不存在");
deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(device);
Integer result = transactionTemplate.execute(status -> { Integer result = transactionTemplate.execute(status -> {
// 修改订单信息 // 修改订单信息

View File

@ -1,13 +1,10 @@
package com.ruoyi.ss.transactionBill.service.impl; package com.ruoyi.ss.transactionBill.service.impl;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.bonus.domain.BonusVO; import com.ruoyi.ss.bonus.domain.BonusVO;
import com.ruoyi.ss.bonus.domain.enums.BonusArrivalType; import com.ruoyi.ss.bonus.domain.enums.BonusArrivalType;
import com.ruoyi.ss.bonus.service.BonusService; import com.ruoyi.ss.bonus.service.BonusService;
import com.ruoyi.ss.device.domain.vo.DeviceIotResultVO;
import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.payBill.domain.PayBillVO; import com.ruoyi.ss.payBill.domain.PayBillVO;
@ -101,7 +98,7 @@ public class RechargePayHandler implements AfterPay, AfterRefund {
// 设备信息 // 设备信息
DeviceVO device = bo.getDevice(); DeviceVO device = bo.getDevice();
deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(device);
List<BonusVO> bonusList = bill.getBonusList(); List<BonusVO> bonusList = bill.getBonusList();

View File

@ -1,7 +1,6 @@
package com.ruoyi.ss.transactionBill.service.impl; package com.ruoyi.ss.transactionBill.service.impl;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
@ -19,7 +18,10 @@ import com.ruoyi.ss.store.service.StoreService;
import com.ruoyi.ss.suit.domain.SuitVO; import com.ruoyi.ss.suit.domain.SuitVO;
import com.ruoyi.ss.suit.service.SuitAssembler; import com.ruoyi.ss.suit.service.SuitAssembler;
import com.ruoyi.ss.suit.service.SuitService; import com.ruoyi.ss.suit.service.SuitService;
import com.ruoyi.ss.transactionBill.domain.bo.*; import com.ruoyi.ss.transactionBill.domain.bo.EndUseBO;
import com.ruoyi.ss.transactionBill.domain.bo.RechargeBO;
import com.ruoyi.ss.transactionBill.domain.bo.RechargePayDepositBO;
import com.ruoyi.ss.transactionBill.domain.bo.WithdrawBO;
import com.ruoyi.ss.transactionBill.domain.dto.*; import com.ruoyi.ss.transactionBill.domain.dto.*;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO; import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
import com.ruoyi.ss.transactionBill.service.TransactionBillConverter; import com.ruoyi.ss.transactionBill.service.TransactionBillConverter;
@ -192,7 +194,7 @@ public class TransactionBillConverterImpl implements TransactionBillConverter {
bo.setTotalEle(dto.getTotalEle()); bo.setTotalEle(dto.getTotalEle());
if (order != null) { if (order != null) {
DeviceVO device = deviceService.selectById(order.getDeviceId()); DeviceVO device = deviceService.selectById(order.getDeviceId());
deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(device);
bo.setDevice(device); bo.setDevice(device);
} }
return bo; return bo;

View File

@ -3,14 +3,18 @@ package com.ruoyi.ss.transactionBill.service.impl;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.core.redis.enums.RedisLockKey; import com.ruoyi.common.core.redis.enums.RedisLockKey;
import com.ruoyi.common.enums.ServiceCode; import com.ruoyi.common.enums.ServiceCode;
import com.ruoyi.common.enums.WithdrawServiceType; import com.ruoyi.common.enums.WithdrawServiceType;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.*; import com.ruoyi.common.pay.wx.service.WxPayService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.SnowFlakeUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.dashboard.domain.vo.BillCountVo;
import com.ruoyi.iot.domain.response.CommandResponse; import com.ruoyi.iot.domain.response.CommandResponse;
import com.ruoyi.iot.service.IotService; import com.ruoyi.iot.service.IotService;
import com.ruoyi.ss.account.domain.AccountVO; import com.ruoyi.ss.account.domain.AccountVO;
@ -23,7 +27,6 @@ import com.ruoyi.ss.bonus.service.BonusConverter;
import com.ruoyi.ss.bonus.service.BonusService; import com.ruoyi.ss.bonus.service.BonusService;
import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO; import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO;
import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService; import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService;
import com.ruoyi.dashboard.domain.vo.BillCountVo;
import com.ruoyi.ss.device.domain.enums.DevicePowerStatus; import com.ruoyi.ss.device.domain.enums.DevicePowerStatus;
import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.device.service.DeviceService;
@ -49,10 +52,16 @@ import com.ruoyi.ss.suit.domain.enums.SuitFeeType;
import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit; import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit;
import com.ruoyi.ss.transactionBill.domain.TransactionBill; import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery; import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.bo.*; import com.ruoyi.ss.transactionBill.domain.bo.EndUseBO;
import com.ruoyi.ss.transactionBill.domain.bo.RechargeBO;
import com.ruoyi.ss.transactionBill.domain.bo.RechargePayDepositBO;
import com.ruoyi.ss.transactionBill.domain.bo.WithdrawBO;
import com.ruoyi.ss.transactionBill.domain.dto.*; import com.ruoyi.ss.transactionBill.domain.dto.*;
import com.ruoyi.ss.transactionBill.domain.vo.*;
import com.ruoyi.ss.transactionBill.domain.enums.*; import com.ruoyi.ss.transactionBill.domain.enums.*;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionAmountVO;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionDailyAmountVO;
import com.ruoyi.ss.transactionBill.domain.vo.UserWithdrawServiceVO;
import com.ruoyi.ss.transactionBill.mapper.TransactionBillMapper; import com.ruoyi.ss.transactionBill.mapper.TransactionBillMapper;
import com.ruoyi.ss.transactionBill.service.*; import com.ruoyi.ss.transactionBill.service.*;
import com.ruoyi.ss.transfer.domain.TransferVO; import com.ruoyi.ss.transfer.domain.TransferVO;
@ -61,7 +70,6 @@ import com.ruoyi.ss.transfer.service.TransferConverter;
import com.ruoyi.ss.transfer.service.TransferService; import com.ruoyi.ss.transfer.service.TransferService;
import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.domain.SmUserVO;
import com.ruoyi.ss.user.service.ISmUserService; import com.ruoyi.ss.user.service.ISmUserService;
import com.ruoyi.common.pay.wx.service.WxPayService;
import com.ruoyi.system.domain.enums.config.ConfigKey; import com.ruoyi.system.domain.enums.config.ConfigKey;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.task.bill.BillDelayedManager; import com.ruoyi.task.bill.BillDelayedManager;
@ -261,7 +269,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
ServiceUtil.assertion(!redisLock.lock(RedisLockKey.ADD_RECHARGE_ORDER, deviceId), "当前使用该设备人数较多,请稍后再试"); ServiceUtil.assertion(!redisLock.lock(RedisLockKey.ADD_RECHARGE_ORDER, deviceId), "当前使用该设备人数较多,请稍后再试");
try { try {
// 拉取设备信息 // 拉取设备信息
deviceService.pullDeviceInfo(bo.getDevice().getDeviceId(), IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(bo.getDevice().getDeviceId());
// 生成订单 // 生成订单
TransactionBill order = parseToOrder(bo); TransactionBill order = parseToOrder(bo);
@ -865,7 +873,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
// 获取最新设备信息 // 获取最新设备信息
DeviceVO device = deviceService.selectById(bill.getDeviceId()); DeviceVO device = deviceService.selectById(bill.getDeviceId());
deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(device);
// 充值设备 // 充值设备
Boolean iotResult = transactionTemplate.execute(status -> { Boolean iotResult = transactionTemplate.execute(status -> {
@ -1138,7 +1146,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
// 计量收费则获取最新的设备信息 // 计量收费则获取最新的设备信息
if(SuitFeeType.COUNT.getType().equals(bill.getSuitFeeType()) || SuitFeeType.TIMING_COUNT.getType().equals(bill.getSuitFeeType())) { if(SuitFeeType.COUNT.getType().equals(bill.getSuitFeeType()) || SuitFeeType.TIMING_COUNT.getType().equals(bill.getSuitFeeType())) {
DeviceVO device = deviceService.selectById(bill.getDeviceId()); DeviceVO device = deviceService.selectById(bill.getDeviceId());
deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(device);
totalEle = this.calcTotalEle(device, totalEle); totalEle = this.calcTotalEle(device, totalEle);
} }
@ -1539,7 +1547,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(bill.getStatus()), "订单尚未充值成功", 10004); ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(bill.getStatus()), "订单尚未充值成功", 10004);
// 拉取设备信息 // 拉取设备信息
deviceService.pullDeviceInfo(bill.getDeviceId(), IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(bill.getDeviceId());
Integer execute = transactionTemplate.execute(status -> { Integer execute = transactionTemplate.execute(status -> {
// 更新设备充值状态 // 更新设备充值状态
@ -1823,7 +1831,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
DeviceVO device = deviceService.selectById(bill.getDeviceId()); DeviceVO device = deviceService.selectById(bill.getDeviceId());
ServiceUtil.assertion(device == null, "设备不存在"); ServiceUtil.assertion(device == null, "设备不存在");
ServiceUtil.assertion(StringUtils.isAllBlank(device.getMac(), device.getMac2()), "设备MAC为空请联系管理员处理"); ServiceUtil.assertion(StringUtils.isAllBlank(device.getMac(), device.getMac2()), "设备MAC为空请联系管理员处理");
deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(device);
// 开启 // 开启
if (open) { if (open) {

View File

@ -1,6 +1,5 @@
package com.ruoyi.web.controller.app; package com.ruoyi.web.controller.app;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
@ -75,7 +74,7 @@ public class AppDeviceAdminController extends BaseController {
return error("上报数据失败"); return error("上报数据失败");
} }
Threads.sleep(3000); Threads.sleep(3000);
deviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfo(device);
return success(device); return success(device);
} }

View File

@ -2,7 +2,6 @@ package com.ruoyi.web.controller.app;
import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.JsonViewProfile; import com.ruoyi.common.core.domain.JsonViewProfile;
@ -13,18 +12,18 @@ import com.ruoyi.common.enums.OperatorType;
import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.ss.device.domain.DeviceView;
import com.ruoyi.ss.device.domain.Device; import com.ruoyi.ss.device.domain.Device;
import com.ruoyi.ss.device.domain.DeviceBO; import com.ruoyi.ss.device.domain.DeviceBO;
import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.domain.DeviceQuery;
import com.ruoyi.ss.device.domain.DeviceView;
import com.ruoyi.ss.device.domain.dto.DeviceRegisterDTO; import com.ruoyi.ss.device.domain.dto.DeviceRegisterDTO;
import com.ruoyi.ss.device.domain.dto.DeviceWifiDTO; import com.ruoyi.ss.device.domain.dto.DeviceWifiDTO;
import com.ruoyi.ss.device.domain.enums.DevicePowerStatus; import com.ruoyi.ss.device.domain.enums.DevicePowerStatus;
import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.device.service.DeviceAssembler; import com.ruoyi.ss.device.service.DeviceAssembler;
import com.ruoyi.ss.device.service.DeviceConverter; import com.ruoyi.ss.device.service.DeviceConverter;
import com.ruoyi.ss.device.service.DeviceValidator;
import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.device.service.DeviceValidator;
import com.ruoyi.ss.meterReadingRecord.domain.SmMeterReadingRecordQuery; import com.ruoyi.ss.meterReadingRecord.domain.SmMeterReadingRecordQuery;
import com.ruoyi.ss.meterReadingRecord.service.ISmMeterReadingRecordService; import com.ruoyi.ss.meterReadingRecord.service.ISmMeterReadingRecordService;
import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit; import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit;
@ -97,7 +96,7 @@ public class AppDeviceController extends BaseController {
startOrderBy(); startOrderBy();
smDevice.setUserId(getUserId()); smDevice.setUserId(getUserId());
List<DeviceVO> list = smDeviceService.selectSmDeviceList(smDevice); List<DeviceVO> list = smDeviceService.selectSmDeviceList(smDevice);
smDeviceService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_GET); smDeviceService.pullDeviceInfoList(list);
deviceAssembler.assembleRealServiceRate(list); deviceAssembler.assembleRealServiceRate(list);
return getDataTable(list); return getDataTable(list);
} }
@ -109,7 +108,7 @@ public class AppDeviceController extends BaseController {
startPage(); startPage();
query.setStoreId(storeId); query.setStoreId(storeId);
List<DeviceVO> list = smDeviceService.selectSmDeviceList(query); List<DeviceVO> list = smDeviceService.selectSmDeviceList(query);
smDeviceService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_GET); smDeviceService.pullDeviceInfoList(list);
deviceAssembler.assembleBusinessTime(list); // 店铺营业时间 deviceAssembler.assembleBusinessTime(list); // 店铺营业时间
return getDataTable(list); return getDataTable(list);
} }
@ -140,7 +139,7 @@ public class AppDeviceController extends BaseController {
ServiceUtil.assertion(!device.getAllowSwitch(), "您无权操作此设备"); ServiceUtil.assertion(!device.getAllowSwitch(), "您无权操作此设备");
// 获取最新数据 // 获取最新数据
smDeviceService.pullDeviceInfo(device, IotConstants.ONLINE_TYPE_GET); smDeviceService.pullDeviceInfo(device);
DevicePowerStatus powerStatus = DevicePowerStatus.parse(status); DevicePowerStatus powerStatus = DevicePowerStatus.parse(status);
return toAjax(smDeviceService.switchDevice(device, powerStatus, "商户开关设备")); return toAjax(smDeviceService.switchDevice(device, powerStatus, "商户开关设备"));
@ -216,9 +215,8 @@ public class AppDeviceController extends BaseController {
@ApiOperation("刷新设备信息") @ApiOperation("刷新设备信息")
@GetMapping("/{deviceId}/refreshIot") @GetMapping("/{deviceId}/refreshIot")
public AjaxResult syncIot(@PathVariable @ApiParam("设备id") Long deviceId, public AjaxResult syncIot(@PathVariable @ApiParam("设备id") Long deviceId) {
@RequestParam(required = false, defaultValue = IotConstants.ONLINE_TYPE_GET) String onlineType) { smDeviceService.pullDeviceInfo(deviceId);
smDeviceService.pullDeviceInfo(deviceId, onlineType);
return success(); return success();
} }
@ -226,8 +224,7 @@ public class AppDeviceController extends BaseController {
@GetMapping("/v2/refreshIot") @GetMapping("/v2/refreshIot")
public AjaxResult syncIotBySn(@RequestParam(required = false) Long deviceId, public AjaxResult syncIotBySn(@RequestParam(required = false) Long deviceId,
@RequestParam(required = false) String deviceNo, @RequestParam(required = false) String deviceNo,
@RequestParam(required = false) String mac, @RequestParam(required = false) String mac) {
@RequestParam(required = false, defaultValue = IotConstants.ONLINE_TYPE_GET) String onlineType) {
DeviceVO device = null; DeviceVO device = null;
if (deviceId != null) { if (deviceId != null) {
device = smDeviceService.selectById(deviceId); device = smDeviceService.selectById(deviceId);
@ -238,7 +235,7 @@ public class AppDeviceController extends BaseController {
} else { } else {
return error("设备ID、SN、MAC必须传入其中一个"); return error("设备ID、SN、MAC必须传入其中一个");
} }
smDeviceService.pullDeviceInfo(device, onlineType); smDeviceService.pullDeviceInfo(device);
return success(device); return success(device);
} }

View File

@ -1,34 +1,32 @@
package com.ruoyi.web.controller.ss; package com.ruoyi.web.controller.ss;
import java.math.BigDecimal; import com.ruoyi.common.annotation.Log;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.constant.IotConstants; 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.ValidGroup; import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ss.device.domain.DeviceBO; import com.ruoyi.ss.device.domain.DeviceBO;
import com.ruoyi.ss.device.domain.dto.DeviceBatchUpdateModelDTO;
import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.domain.DeviceQuery;
import com.ruoyi.ss.device.domain.dto.DeviceBatchUpdateModelDTO;
import com.ruoyi.ss.device.domain.dto.DeviceWifiDTO; import com.ruoyi.ss.device.domain.dto.DeviceWifiDTO;
import com.ruoyi.ss.device.domain.vo.DeviceIotResultVO;
import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.device.service.DeviceAssembler; import com.ruoyi.ss.device.service.DeviceAssembler;
import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit; import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.AjaxResult; import java.math.BigDecimal;
import com.ruoyi.common.enums.BusinessType; import java.util.Arrays;
import com.ruoyi.ss.device.service.DeviceService; import java.util.List;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/** /**
* 设备Controller * 设备Controller
@ -53,7 +51,7 @@ public class SmDeviceController extends BaseController
{ {
startPage(); startPage();
List<DeviceVO> list = deviceService.selectSmDeviceList(smDevice); List<DeviceVO> list = deviceService.selectSmDeviceList(smDevice);
deviceService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfoList(list);
deviceAssembler.assembleRealServiceRate(list); deviceAssembler.assembleRealServiceRate(list);
return getDataTable(list); return getDataTable(list);
} }
@ -144,7 +142,7 @@ public class SmDeviceController extends BaseController
@GetMapping("/{deviceId}/refreshIot") @GetMapping("/{deviceId}/refreshIot")
public AjaxResult syncIot(@PathVariable @ApiParam("设备id") Long deviceId, public AjaxResult syncIot(@PathVariable @ApiParam("设备id") Long deviceId,
@RequestParam(required = false, defaultValue = IotConstants.ONLINE_TYPE_GET) String onlineType) { @RequestParam(required = false, defaultValue = IotConstants.ONLINE_TYPE_GET) String onlineType) {
deviceService.pullDeviceInfo(deviceId, onlineType); deviceService.pullDeviceInfo(deviceId);
return success(); return success();
} }

View File

@ -1,6 +1,5 @@
package com.ruoyi.web.controller.staff; package com.ruoyi.web.controller.staff;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.domain.DeviceQuery;
@ -38,7 +37,7 @@ public class StaffDeviceController extends BaseController {
query.setStaffUserId(getUserId()); query.setStaffUserId(getUserId());
query.setStaffPermission(StoreStaffPermissions.DEVICE_VIEW.getCode()); query.setStaffPermission(StoreStaffPermissions.DEVICE_VIEW.getCode());
List<DeviceVO> list = deviceService.selectStaffDeviceList(query); List<DeviceVO> list = deviceService.selectStaffDeviceList(query);
deviceService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_GET); deviceService.pullDeviceInfoList(list);
return getDataTable(list); return getDataTable(list);
} }