mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
设备统计接口
This commit is contained in:
@@ -107,6 +107,17 @@ public class DeviceController extends BaseController
|
|||||||
return AjaxResult.success(deviceService.selectDeviceByDeviceId(deviceId));
|
return AjaxResult.success(deviceService.selectDeviceByDeviceId(deviceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备统计信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:device:query')")
|
||||||
|
@GetMapping(value = "/statistic")
|
||||||
|
@ApiOperation("获取设备统计信息")
|
||||||
|
public AjaxResult getDeviceStatistic()
|
||||||
|
{
|
||||||
|
return AjaxResult.success(deviceService.selectDeviceStatistic());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备详细信息
|
* 获取设备详细信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.iot.mapper;
|
package com.ruoyi.iot.mapper;
|
||||||
|
|
||||||
import com.ruoyi.iot.domain.DeviceLog;
|
import com.ruoyi.iot.domain.DeviceLog;
|
||||||
|
import com.ruoyi.iot.model.DeviceStatistic;
|
||||||
import com.ruoyi.iot.model.MonitorModel;
|
import com.ruoyi.iot.model.MonitorModel;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -24,6 +25,13 @@ public interface DeviceLogMapper
|
|||||||
*/
|
*/
|
||||||
public DeviceLog selectDeviceLogByLogId(Long logId);
|
public DeviceLog selectDeviceLogByLogId(Long logId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询日志分类总数
|
||||||
|
*
|
||||||
|
* @return 设备日志
|
||||||
|
*/
|
||||||
|
public DeviceStatistic selectCategoryLogCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备日志列表
|
* 查询设备日志列表
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.ruoyi.iot.mapper;
|
package com.ruoyi.iot.mapper;
|
||||||
|
|
||||||
import com.ruoyi.iot.domain.Device;
|
import com.ruoyi.iot.domain.Device;
|
||||||
import com.ruoyi.iot.model.AuthenticateInputModel;
|
import com.ruoyi.iot.model.*;
|
||||||
import com.ruoyi.iot.model.DeviceAllShortOutput;
|
|
||||||
import com.ruoyi.iot.model.ProductAuthenticateModel;
|
|
||||||
import com.ruoyi.iot.model.DeviceShortOutput;
|
|
||||||
import com.ruoyi.iot.model.ThingsModels.ThingsModelValuesInput;
|
import com.ruoyi.iot.model.ThingsModels.ThingsModelValuesInput;
|
||||||
import com.ruoyi.iot.model.ThingsModels.ThingsModelValuesOutput;
|
import com.ruoyi.iot.model.ThingsModels.ThingsModelValuesOutput;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -28,6 +25,13 @@ public interface DeviceMapper
|
|||||||
*/
|
*/
|
||||||
public Device selectDeviceByDeviceId(Long deviceId);
|
public Device selectDeviceByDeviceId(Long deviceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备和产品总数
|
||||||
|
*
|
||||||
|
* @return 设备
|
||||||
|
*/
|
||||||
|
public DeviceStatistic selectDeviceProductAlertCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备编号查询设备
|
* 根据设备编号查询设备
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package com.ruoyi.iot.model;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id和name
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
public class DeviceStatistic
|
||||||
|
{
|
||||||
|
/** 设备数量 **/
|
||||||
|
private Long deviceCount;
|
||||||
|
|
||||||
|
/** 产品数量 **/
|
||||||
|
private Long productCount;
|
||||||
|
|
||||||
|
/** 告警 **/
|
||||||
|
private Long alertCount;
|
||||||
|
|
||||||
|
/** 属性上报 **/
|
||||||
|
private Long propertyCount;
|
||||||
|
|
||||||
|
/** 功能上报 **/
|
||||||
|
private Long functionCount;
|
||||||
|
|
||||||
|
/** 事件上报 **/
|
||||||
|
private Long eventCount;
|
||||||
|
|
||||||
|
/** 监测数据上报 **/
|
||||||
|
private Long monitorCount;
|
||||||
|
|
||||||
|
public Long getMonitorCount() {
|
||||||
|
return monitorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMonitorCount(Long monitorCount) {
|
||||||
|
this.monitorCount = monitorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDeviceCount() {
|
||||||
|
return deviceCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceCount(Long deviceCount) {
|
||||||
|
this.deviceCount = deviceCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProductCount() {
|
||||||
|
return productCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductCount(Long productCount) {
|
||||||
|
this.productCount = productCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getAlertCount() {
|
||||||
|
return alertCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlertCount(Long alertCount) {
|
||||||
|
this.alertCount = alertCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPropertyCount() {
|
||||||
|
return propertyCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPropertyCount(Long propertyCount) {
|
||||||
|
this.propertyCount = propertyCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getFunctionCount() {
|
||||||
|
return functionCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFunctionCount(Long functionCount) {
|
||||||
|
this.functionCount = functionCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getEventCount() {
|
||||||
|
return eventCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventCount(Long eventCount) {
|
||||||
|
this.eventCount = eventCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,13 @@ public interface IDeviceService
|
|||||||
*/
|
*/
|
||||||
public Device selectDeviceByDeviceId(Long deviceId);
|
public Device selectDeviceByDeviceId(Long deviceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备统计信息
|
||||||
|
*
|
||||||
|
* @return 设备
|
||||||
|
*/
|
||||||
|
public DeviceStatistic selectDeviceStatistic();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备编号查询设备
|
* 根据设备编号查询设备
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ public class DeviceLogServiceImpl implements IDeviceLogService
|
|||||||
@Override
|
@Override
|
||||||
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog)
|
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog)
|
||||||
{
|
{
|
||||||
// deviceLogMapper.selectDeviceLogList(deviceLog);
|
|
||||||
return logService.selectDeviceLogList(deviceLog);
|
return logService.selectDeviceLogList(deviceLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +59,6 @@ public class DeviceLogServiceImpl implements IDeviceLogService
|
|||||||
@Override
|
@Override
|
||||||
public List<MonitorModel> selectMonitorList(DeviceLog deviceLog)
|
public List<MonitorModel> selectMonitorList(DeviceLog deviceLog)
|
||||||
{
|
{
|
||||||
// return deviceLogMapper.selectMonitorList(deviceLog);
|
|
||||||
return logService.selectMonitorList(deviceLog);
|
return logService.selectMonitorList(deviceLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +72,6 @@ public class DeviceLogServiceImpl implements IDeviceLogService
|
|||||||
public int insertDeviceLog(DeviceLog deviceLog)
|
public int insertDeviceLog(DeviceLog deviceLog)
|
||||||
{
|
{
|
||||||
deviceLog.setCreateTime(DateUtils.getNowDate());
|
deviceLog.setCreateTime(DateUtils.getNowDate());
|
||||||
// return deviceLogMapper.insertDeviceLog(deviceLog);
|
|
||||||
return logService.saveDeviceLog(deviceLog);
|
return logService.saveDeviceLog(deviceLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,25 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
return deviceMapper.selectDeviceByDeviceId(deviceId);
|
return deviceMapper.selectDeviceByDeviceId(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备统计信息
|
||||||
|
*
|
||||||
|
* @return 设备
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DeviceStatistic selectDeviceStatistic() {
|
||||||
|
// 获取设备、产品和告警数量
|
||||||
|
DeviceStatistic statistic=deviceMapper.selectDeviceProductAlertCount();
|
||||||
|
// 获取属性、功能和事件
|
||||||
|
DeviceStatistic thingsCount=logService.selectCategoryLogCount();
|
||||||
|
// 组合属性、功能、事件和监测数据
|
||||||
|
statistic.setPropertyCount(thingsCount.getPropertyCount());
|
||||||
|
statistic.setFunctionCount(thingsCount.getFunctionCount());
|
||||||
|
statistic.setEventCount(thingsCount.getEventCount());
|
||||||
|
statistic.setMonitorCount(thingsCount.getMonitorCount());
|
||||||
|
return statistic;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备编号查询设备
|
* 根据设备编号查询设备
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ruoyi.iot.tdengine.service;
|
|||||||
|
|
||||||
import com.ruoyi.iot.domain.DeviceLog;
|
import com.ruoyi.iot.domain.DeviceLog;
|
||||||
|
|
||||||
|
import com.ruoyi.iot.model.DeviceStatistic;
|
||||||
import com.ruoyi.iot.model.MonitorModel;
|
import com.ruoyi.iot.model.MonitorModel;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -19,7 +20,12 @@ public interface ILogService {
|
|||||||
|
|
||||||
int saveDeviceLog(DeviceLog deviceLog);
|
int saveDeviceLog(DeviceLog deviceLog);
|
||||||
|
|
||||||
|
/** 设备属性、功能、事件总数 **/
|
||||||
|
DeviceStatistic selectCategoryLogCount();
|
||||||
|
|
||||||
|
/** 查询物模型日志列表 **/
|
||||||
List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog);
|
List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog);
|
||||||
|
|
||||||
|
/** 查询监测数据列表 **/
|
||||||
List<MonitorModel> selectMonitorList(DeviceLog deviceLog);
|
List<MonitorModel> selectMonitorList(DeviceLog deviceLog);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.iot.tdengine.service.impl;
|
package com.ruoyi.iot.tdengine.service.impl;
|
||||||
|
|
||||||
import com.ruoyi.iot.domain.DeviceLog;
|
import com.ruoyi.iot.domain.DeviceLog;
|
||||||
|
import com.ruoyi.iot.model.DeviceStatistic;
|
||||||
import com.ruoyi.iot.tdengine.service.ILogService;
|
import com.ruoyi.iot.tdengine.service.ILogService;
|
||||||
import com.ruoyi.iot.mapper.DeviceLogMapper;
|
import com.ruoyi.iot.mapper.DeviceLogMapper;
|
||||||
import com.ruoyi.iot.model.MonitorModel;
|
import com.ruoyi.iot.model.MonitorModel;
|
||||||
@@ -20,11 +21,18 @@ public class MySqlLogServiceImpl implements ILogService {
|
|||||||
public MySqlLogServiceImpl(DeviceLogMapper _deviceLogMapper){
|
public MySqlLogServiceImpl(DeviceLogMapper _deviceLogMapper){
|
||||||
this.deviceLogMapper=_deviceLogMapper;
|
this.deviceLogMapper=_deviceLogMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int saveDeviceLog(DeviceLog deviceLog) {
|
public int saveDeviceLog(DeviceLog deviceLog) {
|
||||||
return deviceLogMapper.insertDeviceLog(deviceLog);
|
return deviceLogMapper.insertDeviceLog(deviceLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 设备属性、功能、事件和监测数据总数 **/
|
||||||
|
@Override
|
||||||
|
public DeviceStatistic selectCategoryLogCount(){
|
||||||
|
return deviceLogMapper.selectCategoryLogCount();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog) {
|
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog) {
|
||||||
return deviceLogMapper.selectDeviceLogList(deviceLog);
|
return deviceLogMapper.selectDeviceLogList(deviceLog);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.iot.tdengine.service.impl;
|
package com.ruoyi.iot.tdengine.service.impl;
|
||||||
|
|
||||||
import com.ruoyi.iot.domain.DeviceLog;
|
import com.ruoyi.iot.domain.DeviceLog;
|
||||||
|
import com.ruoyi.iot.model.DeviceStatistic;
|
||||||
import com.ruoyi.iot.tdengine.service.ILogService;
|
import com.ruoyi.iot.tdengine.service.ILogService;
|
||||||
import com.ruoyi.iot.model.MonitorModel;
|
import com.ruoyi.iot.model.MonitorModel;
|
||||||
import com.ruoyi.iot.tdengine.config.TDengineConfig;
|
import com.ruoyi.iot.tdengine.config.TDengineConfig;
|
||||||
@@ -42,6 +43,13 @@ public class TdengineLogServiceImpl implements ILogService {
|
|||||||
return tdDeviceLogDAO.save(dbName,deviceLog);
|
return tdDeviceLogDAO.save(dbName,deviceLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 设备属性、功能、事件和监测数据总数 **/
|
||||||
|
@Override
|
||||||
|
public DeviceStatistic selectCategoryLogCount(){
|
||||||
|
// return tdDeviceLogDAO.save(dbName,new DeviceLog());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog) {
|
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog) {
|
||||||
return tdDeviceLogDAO.selectDeviceLogList(dbName,deviceLog);
|
return tdDeviceLogDAO.selectDeviceLogList(dbName,deviceLog);
|
||||||
|
|||||||
@@ -53,6 +53,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="selectDeviceLogVo"/>
|
<include refid="selectDeviceLogVo"/>
|
||||||
where log_id = #{logId}
|
where log_id = #{logId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCategoryLogCount" parameterType="Long" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
||||||
|
SELECT
|
||||||
|
(select count(log_id) from iot_device_log where log_type=1) as propertyCount,
|
||||||
|
(select count(log_id) from iot_device_log where log_type=2) as functionCount,
|
||||||
|
(select count(log_id) from iot_device_log where log_type=3) as eventCount,
|
||||||
|
(select count(log_id) from iot_device_log where log_type=1 and is_monitor=1) as monitorCount
|
||||||
|
from iot_device_log
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertDeviceLog" parameterType="com.ruoyi.iot.domain.DeviceLog" useGeneratedKeys="true" keyProperty="logId">
|
<insert id="insertDeviceLog" parameterType="com.ruoyi.iot.domain.DeviceLog" useGeneratedKeys="true" keyProperty="logId">
|
||||||
insert into iot_device_log
|
insert into iot_device_log
|
||||||
|
|||||||
@@ -192,6 +192,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where device_id = #{deviceId}
|
where device_id = #{deviceId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDeviceProductAlertCount" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
||||||
|
SELECT count(device_id) as deviceCount,
|
||||||
|
(select count(product_id) from iot_product) as productCount,
|
||||||
|
(select count(alert_log_id) from iot_alert_log) as alertCount
|
||||||
|
from iot_device
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectProductAuthenticate" parameterType="com.ruoyi.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
|
<select id="selectProductAuthenticate" parameterType="com.ruoyi.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
|
||||||
SELECT p.mqtt_password,p.mqtt_account, p.mqtt_secret,p.is_authorize,p.product_id,p.product_name,p.vertificate_method,p.STATUS as product_status,d.device_id,d.device_name,d.STATUS,d.serial_number
|
SELECT p.mqtt_password,p.mqtt_account, p.mqtt_secret,p.is_authorize,p.product_id,p.product_name,p.vertificate_method,p.STATUS as product_status,d.device_id,d.device_name,d.STATUS,d.serial_number
|
||||||
FROM iot_product p
|
FROM iot_product p
|
||||||
|
|||||||
Reference in New Issue
Block a user