fix: 设备最后上数时间,新增字段,接口调用,小程序显示。
This commit is contained in:
@@ -77,4 +77,14 @@ public interface DeviceSensorDataMapper {
|
||||
@Param("endTime") String endTime,
|
||||
@Param("intervalType") Integer intervalType);
|
||||
|
||||
/**
|
||||
* 查询设备最新上数时间
|
||||
*
|
||||
* @param serialNum 设备序列号
|
||||
* @return 最新传感器数据
|
||||
*/
|
||||
@DS("taos")
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
DeviceSensorData getLatestReportTime(@Param("serialNum") String serialNum);
|
||||
|
||||
}
|
||||
|
||||
@@ -38,4 +38,12 @@ public interface IDeviceSensorDataService {
|
||||
* @return 设备传感器数据列表
|
||||
*/
|
||||
public List<DeviceSensorData> getHistoryDataList(String serialNum, String startTime, String endTime, Integer intervalType);
|
||||
|
||||
/**
|
||||
* 查询设备最新上数时间
|
||||
*
|
||||
* @param serialNum 设备序列号
|
||||
* @return 最新上数时间字符串,格式 yyyy-MM-dd HH:mm:ss;无数据时返回 null
|
||||
*/
|
||||
String getLatestReportTime(String serialNum);
|
||||
}
|
||||
|
||||
@@ -256,6 +256,30 @@ public class DeviceSensorDataService implements IDeviceSensorDataService {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备最新上数时间
|
||||
*/
|
||||
@Override
|
||||
public String getLatestReportTime(String serialNum) {
|
||||
if (serialNum == null || serialNum.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Integer exists = deviceSensorDataMapper.checkTableExists(serialNum);
|
||||
if (exists == null || exists == 0) {
|
||||
return null;
|
||||
}
|
||||
DeviceSensorData latest = deviceSensorDataMapper.getLatestReportTime(serialNum);
|
||||
if (latest == null) {
|
||||
return null;
|
||||
}
|
||||
return latest.getCreateTime() != null ? latest.getCreateTime() : latest.getTime();
|
||||
} catch (Exception e) {
|
||||
log.warn("查询设备最新上数时间失败: serialNum={}, error={}", serialNum, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取间隔类型描述
|
||||
|
||||
Reference in New Issue
Block a user