mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-10 18:40:33 +08:00
后端TDengine统计分类数量
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ruoyi.iot.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.iot.domain.ProductAuthorize;
|
import com.ruoyi.iot.domain.ProductAuthorize;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品授权码Mapper接口
|
* 产品授权码Mapper接口
|
||||||
@@ -9,6 +10,7 @@ import com.ruoyi.iot.domain.ProductAuthorize;
|
|||||||
* @author kami
|
* @author kami
|
||||||
* @date 2022-04-11
|
* @date 2022-04-11
|
||||||
*/
|
*/
|
||||||
|
@Repository
|
||||||
public interface ProductAuthorizeMapper
|
public interface ProductAuthorizeMapper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -59,6 +61,14 @@ public interface ProductAuthorizeMapper
|
|||||||
*/
|
*/
|
||||||
public int deleteProductAuthorizeByAuthorizeIds(Long[] authorizeIds);
|
public int deleteProductAuthorizeByAuthorizeIds(Long[] authorizeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过产品ID批量删除产品授权码
|
||||||
|
*
|
||||||
|
* @param productIds 产品ID数组
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteProductAuthorizeByProductIds(Long[] productIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量新增产品授权码
|
* 批量新增产品授权码
|
||||||
* @param list
|
* @param list
|
||||||
|
@@ -757,12 +757,15 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
public int deleteDeviceByDeviceIds(Long[] deviceIds) throws SchedulerException {
|
public int deleteDeviceByDeviceIds(Long[] deviceIds) throws SchedulerException {
|
||||||
// 删除设备分组
|
// 删除设备分组
|
||||||
deviceMapper.deleteDeviceGroupByDeviceIds(deviceIds);
|
deviceMapper.deleteDeviceGroupByDeviceIds(deviceIds);
|
||||||
// 删除设备日志
|
// TODO 删除设备日志 td里面删除
|
||||||
deviceLogMapper.deleteDeviceLogByDeviceIds(deviceIds);
|
deviceLogMapper.deleteDeviceLogByDeviceIds(deviceIds);
|
||||||
|
// TODO 删除设备告警记录
|
||||||
|
|
||||||
// 删除定时任务
|
// 删除定时任务
|
||||||
deviceJobService.deleteJobByDeviceIds(deviceIds);
|
deviceJobService.deleteJobByDeviceIds(deviceIds);
|
||||||
|
// 删除设备用户
|
||||||
// TODO 删除设备用户
|
deviceUserMapper.deleteDeviceUserByDeviceIds(deviceIds);
|
||||||
|
// 删除设备
|
||||||
return deviceMapper.deleteDeviceByDeviceIds(deviceIds);
|
return deviceMapper.deleteDeviceByDeviceIds(deviceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.iot.domain.Product;
|
import com.ruoyi.iot.domain.Product;
|
||||||
|
import com.ruoyi.iot.mapper.ProductAuthorizeMapper;
|
||||||
import com.ruoyi.iot.mapper.ProductMapper;
|
import com.ruoyi.iot.mapper.ProductMapper;
|
||||||
import com.ruoyi.iot.model.ChangeProductStatusModel;
|
import com.ruoyi.iot.model.ChangeProductStatusModel;
|
||||||
import com.ruoyi.iot.model.IdAndName;
|
import com.ruoyi.iot.model.IdAndName;
|
||||||
@@ -32,6 +33,9 @@ public class ProductServiceImpl implements IProductService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ProductMapper productMapper;
|
private ProductMapper productMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProductAuthorizeMapper productAuthorizeMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@@ -185,6 +189,8 @@ public class ProductServiceImpl implements IProductService
|
|||||||
}
|
}
|
||||||
// 删除产品物模型
|
// 删除产品物模型
|
||||||
productMapper.deleteProductThingsModelByProductIds(productIds);
|
productMapper.deleteProductThingsModelByProductIds(productIds);
|
||||||
|
// 删除产品的授权码
|
||||||
|
productAuthorizeMapper.deleteProductAuthorizeByProductIds(productIds);
|
||||||
// 删除产品
|
// 删除产品
|
||||||
if(productMapper.deleteProductByProductIds(productIds)>0){
|
if(productMapper.deleteProductByProductIds(productIds)>0){
|
||||||
return AjaxResult.success("删除成功");
|
return AjaxResult.success("删除成功");
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.iot.tdengine.dao;
|
package com.ruoyi.iot.tdengine.dao;
|
||||||
|
|
||||||
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.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -11,7 +12,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @package com.ruoyi.mysql.mysql.tdengine
|
* @package com.ruoyi.mysql.mysql.tdengine
|
||||||
* 类名: DatabaseMapper
|
* 类名: DatabaseMapper
|
||||||
* 描述: TODO
|
|
||||||
* 时间: 2022/5/16,0016 1:27
|
* 时间: 2022/5/16,0016 1:27
|
||||||
* 开发人: wxy
|
* 开发人: wxy
|
||||||
*/
|
*/
|
||||||
@@ -27,6 +27,8 @@ public interface TDDeviceLogDAO {
|
|||||||
|
|
||||||
int save(@Param("database") String database,@Param("device") DeviceLog deviceLog);
|
int save(@Param("database") String database,@Param("device") DeviceLog deviceLog);
|
||||||
|
|
||||||
|
DeviceStatistic selectCategoryLogCount(@Param("database") String database);
|
||||||
|
|
||||||
List<DeviceLog> selectSTable(String database,DeviceLog deviceLog);
|
List<DeviceLog> selectSTable(String database,DeviceLog deviceLog);
|
||||||
|
|
||||||
int delete(String dbName, DeviceLog deviceLog);
|
int delete(String dbName, DeviceLog deviceLog);
|
||||||
|
@@ -24,7 +24,6 @@ import java.util.Properties;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 类名: ApplicationStarted
|
* 类名: ApplicationStarted
|
||||||
* 描述: TODO
|
|
||||||
* 时间: 2022/5/18,0018 1:41
|
* 时间: 2022/5/18,0018 1:41
|
||||||
* 开发人: wxy
|
* 开发人: wxy
|
||||||
*/
|
*/
|
||||||
|
@@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 类名: DeviceLogServiceImpl
|
* 类名: DeviceLogServiceImpl
|
||||||
* 描述: TODO
|
|
||||||
* 时间: 2022/5/19,0019 18:09
|
* 时间: 2022/5/19,0019 18:09
|
||||||
* 开发人: wxy
|
* 开发人: wxy
|
||||||
*/
|
*/
|
||||||
|
@@ -27,17 +27,28 @@ public class MySqlLogServiceImpl implements ILogService {
|
|||||||
return deviceLogMapper.insertDeviceLog(deviceLog);
|
return deviceLogMapper.insertDeviceLog(deviceLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设备属性、功能、事件和监测数据总数 **/
|
/***
|
||||||
|
* 设备属性、功能、事件和监测数据总数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DeviceStatistic selectCategoryLogCount(){
|
public DeviceStatistic selectCategoryLogCount(){
|
||||||
return deviceLogMapper.selectCategoryLogCount();
|
return deviceLogMapper.selectCategoryLogCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 日志列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog) {
|
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog) {
|
||||||
return deviceLogMapper.selectDeviceLogList(deviceLog);
|
return deviceLogMapper.selectDeviceLogList(deviceLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 监测数据列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<MonitorModel> selectMonitorList(DeviceLog deviceLog) {
|
public List<MonitorModel> selectMonitorList(DeviceLog deviceLog) {
|
||||||
return deviceLogMapper.selectMonitorList(deviceLog);
|
return deviceLogMapper.selectMonitorList(deviceLog);
|
||||||
|
@@ -46,8 +46,7 @@ public class TdengineLogServiceImpl implements ILogService {
|
|||||||
/** 设备属性、功能、事件和监测数据总数 **/
|
/** 设备属性、功能、事件和监测数据总数 **/
|
||||||
@Override
|
@Override
|
||||||
public DeviceStatistic selectCategoryLogCount(){
|
public DeviceStatistic selectCategoryLogCount(){
|
||||||
// return tdDeviceLogDAO.save(dbName,new DeviceLog());
|
return tdDeviceLogDAO.selectCategoryLogCount(dbName);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -111,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteDeviceUserByDeviceIds" parameterType="String">
|
<delete id="deleteDeviceUserByDeviceIds" parameterType="String">
|
||||||
delete from iot_device_user where is_owner !=1 and device_id in
|
delete from iot_device_user where device_id in
|
||||||
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
|
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
|
||||||
#{deviceId}
|
#{deviceId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
@@ -120,4 +120,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{authorizeId}
|
#{authorizeId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteProductAuthorizeByProductIds" parameterType="String">
|
||||||
|
delete from iot_product_authorize where product_id in
|
||||||
|
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{productId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
@@ -76,6 +76,16 @@
|
|||||||
order by ts desc
|
order by ts desc
|
||||||
</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 ${database}.device_log
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="save" parameterType="com.ruoyi.iot.domain.DeviceLog">
|
<insert id="save" parameterType="com.ruoyi.iot.domain.DeviceLog">
|
||||||
INSERT INTO ${database}.device_${device.serialNumber} USING device_log
|
INSERT INTO ${database}.device_${device.serialNumber} USING device_log
|
||||||
TAGS (#{device.deviceId},#{device.deviceName},#{device.serialNumber})
|
TAGS (#{device.deviceId},#{device.deviceName},#{device.serialNumber})
|
||||||
|
Reference in New Issue
Block a user