Commit 6376ac76 by YG8999

网关上报信息验证日志最新时间范围改为配置文件设置

网关设备状态验证最新上报时间范围改为配置文件设置
parent ef7991f7
......@@ -215,4 +215,7 @@ dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
order:
allow-refund-time: 3600
\ No newline at end of file
allow-refund-time: 3600
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
\ No newline at end of file
......@@ -213,4 +213,6 @@ dianping:
#订单
order:
allow-refund-time: 3600
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
......@@ -6,6 +6,7 @@ import java.util.List;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import share.common.enums.DeviceStatusEnum;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,6 +27,9 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
@Autowired
private DeviceGatewayMapper deviceGatewayMapper;
@Value("${mqtt.device-gateway-last-report-time}")
private Integer deviceGatewayLastReportTime;
/**
* 查询设备网关信息
*
......@@ -110,7 +114,7 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
list.stream().forEach(gateway -> {
Date lastReportDate = gateway.getLastReportDate();
// 网关上报(最近10分钟内没有上报数据,网关设备离线)
Date startDate = DateUtil.offsetMinute(DateUtil.date(), -10);
Date startDate = DateUtil.offsetMinute(DateUtil.date(), deviceGatewayLastReportTime);
if (lastReportDate != null && lastReportDate.compareTo(startDate) > 0) {
gateway.setStatus(DeviceStatusEnum.DEVICE_ONLINE.getCode());
} else {
......
......@@ -8,6 +8,7 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import share.common.constant.MqttConstants;
import share.common.enums.*;
......@@ -48,6 +49,8 @@ public class MqttxServiceImpl implements MqttxService {
private DeviceLogMapper deviceLogMapper;
@Autowired
private DeviceStatusLogService deviceStatusLogService;
@Value("${mqtt.device-op-last-time}")
private Integer deviceOpLastTime;
/**
* 清除网关锁id列表
......@@ -557,7 +560,7 @@ public class MqttxServiceImpl implements MqttxService {
Map<String, Device> map = deviceList.stream()
.collect(Collectors.toMap(Device::getDevId, Function.identity()));
// 设备操作日志(最近3分钟内的最新操作日志)
Date startDate = DateUtil.offsetMinute(DateUtil.date(), -5);
Date startDate = DateUtil.offsetMinute(DateUtil.date(), deviceOpLastTime);
List<DeviceLog> deviceLogList = deviceLogMapper.selectListByMaxId(devIds, startDate);
// 将List转换为Map
Map<String, DeviceLog> deviceLogMap = deviceLogList.stream()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment