fix:设备电话通知和告警,以及设备历史数据,增加设备有效期判断。
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.intc.tdengine.mapper.DeviceExpireMapper">
|
||||
|
||||
<select id="getDeadTimeBySerialNum" resultType="java.util.Date">
|
||||
SELECT dead_time FROM aqu_device WHERE serial_num = #{serialNum} LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user