fix:设备电话通知和告警,以及设备历史数据,增加设备有效期判断。

This commit is contained in:
tianyongbao
2026-04-20 09:44:25 +08:00
parent c7b74f6293
commit 7bb036c52c
4 changed files with 90 additions and 4 deletions

View File

@@ -0,0 +1,29 @@
package com.intc.tdengine.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
/**
* 设备到期信息Mapper查询MySQL主库
*
* @author intc
*/
@Repository
@Mapper
public interface DeviceExpireMapper {
/**
* 根据设备序列号查询服务到期时间
*
* @param serialNum 设备序列号
* @return 服务到期时间设备不存在时返回null
*/
@DS("master")
@InterceptorIgnore(tenantLine = "true")
Date getDeadTimeBySerialNum(@Param("serialNum") String serialNum);
}

View File

@@ -2,6 +2,7 @@ package com.intc.tdengine.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.intc.tdengine.domain.DeviceSensorData;
import com.intc.tdengine.mapper.DeviceExpireMapper;
import com.intc.tdengine.mapper.DeviceSensorDataMapper;
import com.intc.tdengine.service.IDeviceSensorDataService;
import jakarta.annotation.Resource;
@@ -9,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@@ -17,6 +19,9 @@ import java.util.List;
public class DeviceSensorDataService implements IDeviceSensorDataService {
@Resource
private DeviceSensorDataMapper deviceSensorDataMapper;
@Resource
private DeviceExpireMapper deviceExpireMapper;
/**
* 已创建的子表缓存(设备序列号)
@@ -203,6 +208,13 @@ public class DeviceSensorDataService implements IDeviceSensorDataService {
public List<DeviceSensorData> getHistoryDataList(String serialNum, String startTime, String endTime, Integer intervalType) {
List<DeviceSensorData> list = new ArrayList<>();
try {
// 检查设备是否已过期
Date deadTime = deviceExpireMapper.getDeadTimeBySerialNum(serialNum);
if (deadTime != null && deadTime.before(new Date())) {
log.info("设备已过期,不返回历史数据: serialNum={}, deadTime={}", serialNum, deadTime);
return list;
}
// 默认为原始数据
if (intervalType == null) {
intervalType = 1;