TDengine测试和优化

This commit is contained in:
kerwincui
2022-06-18 23:14:43 +08:00
parent 452c5a5903
commit 381ff00ea4
12 changed files with 159 additions and 167 deletions

View File

@@ -84,11 +84,10 @@ public interface DeviceLogMapper
/**
* 根据设备Ids批量删除设备日志
*
* @param deviceId 需要删除的数据设备Id
* @param deviceNumber 需要删除的数据设备Id
* @return 结果
*/
public int deleteDeviceLogByDeviceId(Long deviceId);
public int deleteDeviceLogByDeviceNumber(String deviceNumber);
// List<DeviceLog> selectLogList(Long deviceId,String serialNumber,Long isMonitor,Long logType, Date beginDate, Date endDate);
}

View File

@@ -18,25 +18,25 @@ public class DeviceStatistic
private int productCount;
/** 告警 **/
private int alertCount;
private long alertCount;
/** 属性上报 **/
private int propertyCount;
private long propertyCount;
/** 功能上报 **/
private int functionCount;
private long functionCount;
/** 事件上报 **/
private int eventCount;
private long eventCount;
/** 监测数据上报 **/
private int monitorCount;
private long monitorCount;
public int getMonitorCount() {
public long getMonitorCount() {
return monitorCount;
}
public void setMonitorCount(int monitorCount) {
public void setMonitorCount(long monitorCount) {
this.monitorCount = monitorCount;
}
@@ -56,35 +56,35 @@ public class DeviceStatistic
this.productCount = productCount;
}
public int getAlertCount() {
public long getAlertCount() {
return alertCount;
}
public void setAlertCount(int alertCount) {
public void setAlertCount(long alertCount) {
this.alertCount = alertCount;
}
public int getPropertyCount() {
public long getPropertyCount() {
return propertyCount;
}
public void setPropertyCount(int propertyCount) {
public void setPropertyCount(long propertyCount) {
this.propertyCount = propertyCount;
}
public int getFunctionCount() {
public long getFunctionCount() {
return functionCount;
}
public void setFunctionCount(int functionCount) {
public void setFunctionCount(long functionCount) {
this.functionCount = functionCount;
}
public int getEventCount() {
public long getEventCount() {
return eventCount;
}
public void setEventCount(int eventCount) {
public void setEventCount(long eventCount) {
this.eventCount = eventCount;
}
}

View File

@@ -70,10 +70,10 @@ public interface IDeviceLogService
public int deleteDeviceLogByLogId(Long logId);
/**
* 根据设备ID批量删除设备日志
* 根据设备编号批量删除设备日志
*
* @param deviceId 需要删除的设备日志ID
* @param deviceNumber 需要删除的设备日志ID
* @return 结果
*/
public int deleteDeviceLogByDeviceId(Long deviceId);
public int deleteDeviceLogByDeviceNumber(String deviceNumber);
}

View File

@@ -101,13 +101,13 @@ public class DeviceLogServiceImpl implements IDeviceLogService
/**
* 根据设备Ids批量删除设备日志
*
* @param deviceId 需要删除数据的设备Ids
* @param deviceNumber 需要删除数据的设备Ids
* @return 结果
*/
@Override
public int deleteDeviceLogByDeviceId(Long deviceId)
public int deleteDeviceLogByDeviceNumber(String deviceNumber)
{
return deviceLogMapper.deleteDeviceLogByDeviceId(deviceId);
return deviceLogMapper.deleteDeviceLogByDeviceNumber(deviceNumber);
}
/**

View File

@@ -234,7 +234,7 @@ public class DeviceServiceImpl implements IDeviceService {
deviceLog.setLogValue(input.getThingsModelValueRemarkItem().get(i).getValue());
deviceLog.setRemark(input.getThingsModelValueRemarkItem().get(i).getRemark());
deviceLog.setIdentity(input.getThingsModelValueRemarkItem().get(i).getId());
deviceLog.setIsMonitor(valueList.get(k).getIsMonitor());
deviceLog.setIsMonitor(valueList.get(k).getIsMonitor()==null ? 0:valueList.get(k).getIsMonitor());
deviceLog.setLogType(type);
deviceLog.setUserId(deviceThings.getUserId());
deviceLog.setUserName(deviceThings.getUserName());
@@ -244,7 +244,6 @@ public class DeviceServiceImpl implements IDeviceService {
// 1=影子模式2=在线模式3=其他
deviceLog.setMode(isShadow?1:2);
logService.saveDeviceLog(deviceLog);
break;
}
}
@@ -885,7 +884,7 @@ public class DeviceServiceImpl implements IDeviceService {
// 删除定时任务
deviceJobService.deleteJobByDeviceIds(new Long[]{deviceId});
// 批量删除设备日志
logService.deleteDeviceLogByDeviceId(deviceId);
logService.deleteDeviceLogByDeviceNumber(device.getSerialNumber());
// TODO 删除设备告警记录
// 删除设备

View File

@@ -19,28 +19,55 @@ import java.util.List;
@Repository
public interface TDDeviceLogDAO {
/***
* 创建数据库
*/
int createDB( String database);
/***
* 创建超级表
*/
int createSTable(String database);
int createTable(String database,String deviceId);
/***
* 新增设备日志
*/
int save(@Param("database") String database,@Param("device") DeviceLog deviceLog);
DeviceStatistic selectCategoryLogCount(@Param("database") String database, Device device);
/***
* 设备属性数据总数
*/
Long selectPropertyLogCount(@Param("database") String database,@Param("device") Device device);
List<DeviceLog> selectSTable(String database,DeviceLog deviceLog);
/***
* 设备功能数据总数
*/
Long selectFunctionLogCount(@Param("database") String database,@Param("device") Device device);
int delete(String dbName, DeviceLog deviceLog);
/***
* 设备事件数据总数
*/
Long selectEventLogCount(@Param("database") String database,@Param("device") Device device);
int deleteDeviceLogByDeviceId(String dbName,Long deviceId);
// List<DeviceLog> selectLogListByPage(String dbName, Integer pageSize, Integer pageNum, String deviceNum, Date beginDate, Date endDate);
List<DeviceLog> selectLogList(String dbName, Long deviceId, String serialNumber, Long isMonitor, Long logType, Date beginDate, Date endDate);
/***
* 设备监测数据总数
*/
Long selectMonitorLogCount(@Param("database") String database,@Param("device") Device device);
/***
* 监测数据列表
*/
List<MonitorModel> selectMonitorList(@Param("database") String database, @Param("device") DeviceLog deviceLog);
/***
* 日志列表
*/
List<DeviceLog> selectDeviceLogList(@Param("database") String database,@Param("device") DeviceLog deviceLog);
/***
* 根据设备ID删除设备日志
*/
int deleteDeviceLogByDeviceNumber(@Param("database")String dbName,@Param("serialNumber") String serialNumber);
}

View File

@@ -70,10 +70,9 @@ public class ApplicationStarted implements ApplicationRunner {
createDatabase();
//创建数据库表
deviceLogMapper.createSTable(dbName);
System.out.println("完成超级表的创建");
LOGGER.info("完成超级表的创建");
} catch (Exception e) {
LOGGER.info("错误",e.getMessage());
LOGGER.error("错误",e.getMessage());
e.printStackTrace();
}

View File

@@ -22,8 +22,8 @@ public interface ILogService {
/** 保存设备日志 **/
int saveDeviceLog(DeviceLog deviceLog);
/** 根据设备ID删除设备日志 **/
int deleteDeviceLogByDeviceId(Long deviceId);
/** 根据设备编号删除设备日志 **/
int deleteDeviceLogByDeviceNumber(String deviceNumber);
/** 设备属性、功能、事件总数 **/
DeviceStatistic selectCategoryLogCount(Device device);

View File

@@ -38,8 +38,8 @@ public class MySqlLogServiceImpl implements ILogService {
* @return
*/
@Override
public int deleteDeviceLogByDeviceId(Long deviceId) {
return deviceLogMapper.deleteDeviceLogByDeviceId(deviceId);
public int deleteDeviceLogByDeviceNumber(String deviceNumber) {
return deviceLogMapper.deleteDeviceLogByDeviceNumber(deviceNumber);
}
/***

View File

@@ -48,22 +48,22 @@ public class TdengineLogServiceImpl implements ILogService {
return tdDeviceLogDAO.save(dbName,deviceLog);
}
/***
* 根据设备ID删除设备日志
* @return
*/
@Override
public int deleteDeviceLogByDeviceId(Long deviceId) {
return tdDeviceLogDAO.deleteDeviceLogByDeviceId(dbName,deviceId);
}
/***
* 设备属性、功能、事件和监测数据总数
* @return
*/
@Override
public DeviceStatistic selectCategoryLogCount(Device device){
return tdDeviceLogDAO.selectCategoryLogCount(dbName,device);
DeviceStatistic statistic=new DeviceStatistic();
Long property=tdDeviceLogDAO.selectPropertyLogCount(dbName,device);
Long function=tdDeviceLogDAO.selectFunctionLogCount(dbName,device);
Long event=tdDeviceLogDAO.selectEventLogCount(dbName,device);
Long monitor=tdDeviceLogDAO.selectMonitorLogCount(dbName,device);
statistic.setPropertyCount(property==null?0:property);
statistic.setFunctionCount(function==null?0:function);
statistic.setEventCount(event==null?0:event);
statistic.setMonitorCount(monitor==null?0:monitor);
return statistic;
}
/***
@@ -86,4 +86,13 @@ public class TdengineLogServiceImpl implements ILogService {
}
return tdDeviceLogDAO.selectMonitorList(dbName,deviceLog);
}
/***
* 根据设备ID删除设备日志
* @return
*/
@Override
public int deleteDeviceLogByDeviceNumber(String deviceNumber) {
return tdDeviceLogDAO.deleteDeviceLogByDeviceNumber(dbName,deviceNumber);
}
}