debug
This commit is contained in:
parent
ce0437814b
commit
6ba777ab8e
|
@ -223,4 +223,12 @@ public interface DeviceService
|
|||
* @return
|
||||
*/
|
||||
DeviceVO selectDevice(Long id, String sn, boolean scope, AreaJoinPermission permission);
|
||||
|
||||
/**
|
||||
* 条件更新
|
||||
* @param data
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
public int updateByQuerySimple(Device data, DeviceQuery query);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.bst.device.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -29,6 +30,7 @@ import com.ruoyi.common.utils.DateUtils;
|
|||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.iot.service.impl.DeviceOnlineStatus;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -478,6 +480,9 @@ public class DeviceServiceImpl implements DeviceService
|
|||
}
|
||||
Device data = new Device();
|
||||
data.setOnlineStatus(onlineStatus);
|
||||
if (DeviceOnlineStatus.ONLINE.getStatus().equals(onlineStatus)) {
|
||||
data.setLastTime(LocalDateTime.now());
|
||||
}
|
||||
DeviceQuery query = new DeviceQuery();
|
||||
query.setEqMac(mac);
|
||||
return deviceMapper.updateByQuerySimple(data, query);
|
||||
|
@ -609,5 +614,9 @@ public class DeviceServiceImpl implements DeviceService
|
|||
return this.selectOne(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByQuerySimple(Device data, DeviceQuery query) {
|
||||
return deviceMapper.updateByQuerySimple(data, query);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
|||
* @param device
|
||||
*/
|
||||
private void updateDeviceIot(DeviceVO device) {
|
||||
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK.getKey(), device.getMac(), 20L, TimeUnit.SECONDS, 1);
|
||||
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK, device.getMac(), 20L);
|
||||
if (lock) {
|
||||
int update = deviceIotService.updateIot(device);
|
||||
if (update != 1) {
|
||||
|
|
|
@ -291,7 +291,7 @@ public class IotServiceImpl implements IotService {
|
|||
redisCache.setCacheObject(this.getOnlineCacheKey(deviceName), status, 10, TimeUnit.SECONDS);
|
||||
|
||||
// 异步更新设备在线状态
|
||||
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK.getKey(), deviceName, 20L, TimeUnit.SECONDS, 1);
|
||||
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK, deviceName, 20L);
|
||||
if (lock ) {
|
||||
scheduledExecutorService.execute(() -> {
|
||||
int update = deviceService.updateOnlineStatusByMac(deviceName, status);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class DeviceTask {
|
|||
|
||||
Device data = new Device();
|
||||
data.setOnlineStatus(DeviceOnlineStatus.OFFLINE.getStatus());
|
||||
int update = deviceService.updateByQuery(data, query);
|
||||
int update = deviceService.updateByQuerySimple(data, query);
|
||||
log.info("更新了{}条离线的设备数据", update);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.ruoyi.web.bst;
|
||||
|
||||
import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
@ -8,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
|
||||
import com.ruoyi.bst.device.domain.DeviceVO;
|
||||
import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
||||
import com.ruoyi.bst.device.service.DeviceIotService;
|
||||
|
@ -18,8 +18,6 @@ import com.ruoyi.common.core.controller.BaseController;
|
|||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.enums.LogBizType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.iot.constants.IotConstants;
|
||||
|
||||
@RestController
|
||||
|
|
Loading…
Reference in New Issue
Block a user