mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 17:05:55 +08:00
多租户的测试调整
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.iot.mapper;
|
||||
|
||||
import com.ruoyi.iot.domain.Device;
|
||||
import com.ruoyi.iot.domain.DeviceLog;
|
||||
import com.ruoyi.iot.model.DeviceStatistic;
|
||||
import com.ruoyi.iot.model.MonitorModel;
|
||||
@@ -30,7 +31,7 @@ public interface DeviceLogMapper
|
||||
*
|
||||
* @return 设备日志
|
||||
*/
|
||||
public DeviceStatistic selectCategoryLogCount();
|
||||
public DeviceStatistic selectCategoryLogCount(Device device);
|
||||
|
||||
/**
|
||||
* 查询设备日志列表
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface DeviceMapper
|
||||
*
|
||||
* @return 设备
|
||||
*/
|
||||
public DeviceStatistic selectDeviceProductAlertCount();
|
||||
public DeviceStatistic selectDeviceProductAlertCount(Device device);
|
||||
|
||||
/**
|
||||
* 根据设备编号查询设备
|
||||
|
||||
@@ -12,79 +12,79 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
public class DeviceStatistic
|
||||
{
|
||||
/** 设备数量 **/
|
||||
private Long deviceCount;
|
||||
private int deviceCount;
|
||||
|
||||
/** 产品数量 **/
|
||||
private Long productCount;
|
||||
private int productCount;
|
||||
|
||||
/** 告警 **/
|
||||
private Long alertCount;
|
||||
private int alertCount;
|
||||
|
||||
/** 属性上报 **/
|
||||
private Long propertyCount;
|
||||
private int propertyCount;
|
||||
|
||||
/** 功能上报 **/
|
||||
private Long functionCount;
|
||||
private int functionCount;
|
||||
|
||||
/** 事件上报 **/
|
||||
private Long eventCount;
|
||||
private int eventCount;
|
||||
|
||||
/** 监测数据上报 **/
|
||||
private Long monitorCount;
|
||||
private int monitorCount;
|
||||
|
||||
public Long getMonitorCount() {
|
||||
public int getMonitorCount() {
|
||||
return monitorCount;
|
||||
}
|
||||
|
||||
public void setMonitorCount(Long monitorCount) {
|
||||
public void setMonitorCount(int monitorCount) {
|
||||
this.monitorCount = monitorCount;
|
||||
}
|
||||
|
||||
public Long getDeviceCount() {
|
||||
public int getDeviceCount() {
|
||||
return deviceCount;
|
||||
}
|
||||
|
||||
public void setDeviceCount(Long deviceCount) {
|
||||
public void setDeviceCount(int deviceCount) {
|
||||
this.deviceCount = deviceCount;
|
||||
}
|
||||
|
||||
public Long getProductCount() {
|
||||
public int getProductCount() {
|
||||
return productCount;
|
||||
}
|
||||
|
||||
public void setProductCount(Long productCount) {
|
||||
public void setProductCount(int productCount) {
|
||||
this.productCount = productCount;
|
||||
}
|
||||
|
||||
public Long getAlertCount() {
|
||||
public int getAlertCount() {
|
||||
return alertCount;
|
||||
}
|
||||
|
||||
public void setAlertCount(Long alertCount) {
|
||||
public void setAlertCount(int alertCount) {
|
||||
this.alertCount = alertCount;
|
||||
}
|
||||
|
||||
public Long getPropertyCount() {
|
||||
public int getPropertyCount() {
|
||||
return propertyCount;
|
||||
}
|
||||
|
||||
public void setPropertyCount(Long propertyCount) {
|
||||
public void setPropertyCount(int propertyCount) {
|
||||
this.propertyCount = propertyCount;
|
||||
}
|
||||
|
||||
public Long getFunctionCount() {
|
||||
public int getFunctionCount() {
|
||||
return functionCount;
|
||||
}
|
||||
|
||||
public void setFunctionCount(Long functionCount) {
|
||||
public void setFunctionCount(int functionCount) {
|
||||
this.functionCount = functionCount;
|
||||
}
|
||||
|
||||
public Long getEventCount() {
|
||||
public int getEventCount() {
|
||||
return eventCount;
|
||||
}
|
||||
|
||||
public void setEventCount(Long eventCount) {
|
||||
public void setEventCount(int eventCount) {
|
||||
this.eventCount = eventCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,10 +98,29 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
*/
|
||||
@Override
|
||||
public DeviceStatistic selectDeviceStatistic() {
|
||||
Device device=new Device();
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
for(int i=0;i<roles.size();i++){
|
||||
if(roles.get(i).getRoleKey().equals("tenant")){
|
||||
// 租户查看产品下所有设备
|
||||
device.setTenantId(user.getUserId());
|
||||
}else if (roles.get(i).getRoleKey().equals("general")){
|
||||
// 用户查看自己设备
|
||||
device.setUserId(user.getUserId());
|
||||
}
|
||||
}
|
||||
// 获取设备、产品和告警数量
|
||||
DeviceStatistic statistic=deviceMapper.selectDeviceProductAlertCount();
|
||||
DeviceStatistic statistic=deviceMapper.selectDeviceProductAlertCount(device);
|
||||
if(statistic==null){
|
||||
statistic=new DeviceStatistic();
|
||||
return statistic;
|
||||
}
|
||||
// 获取属性、功能和事件
|
||||
DeviceStatistic thingsCount=logService.selectCategoryLogCount();
|
||||
DeviceStatistic thingsCount=logService.selectCategoryLogCount(device);
|
||||
if(thingsCount==null){
|
||||
return statistic;
|
||||
}
|
||||
// 组合属性、功能、事件和监测数据
|
||||
statistic.setPropertyCount(thingsCount.getPropertyCount());
|
||||
statistic.setFunctionCount(thingsCount.getFunctionCount());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.iot.tdengine.dao;
|
||||
|
||||
import com.ruoyi.iot.domain.Device;
|
||||
import com.ruoyi.iot.domain.DeviceLog;
|
||||
import com.ruoyi.iot.model.DeviceStatistic;
|
||||
import com.ruoyi.iot.model.MonitorModel;
|
||||
@@ -27,7 +28,7 @@ public interface TDDeviceLogDAO {
|
||||
|
||||
int save(@Param("database") String database,@Param("device") DeviceLog deviceLog);
|
||||
|
||||
DeviceStatistic selectCategoryLogCount(@Param("database") String database);
|
||||
DeviceStatistic selectCategoryLogCount(@Param("database") String database, Device device);
|
||||
|
||||
List<DeviceLog> selectSTable(String database,DeviceLog deviceLog);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.iot.tdengine.service;
|
||||
|
||||
import com.ruoyi.iot.domain.Device;
|
||||
import com.ruoyi.iot.domain.DeviceLog;
|
||||
|
||||
import com.ruoyi.iot.model.DeviceStatistic;
|
||||
@@ -25,7 +26,7 @@ public interface ILogService {
|
||||
int deleteDeviceLogByDeviceId(Long deviceId);
|
||||
|
||||
/** 设备属性、功能、事件总数 **/
|
||||
DeviceStatistic selectCategoryLogCount();
|
||||
DeviceStatistic selectCategoryLogCount(Device device);
|
||||
|
||||
/** 查询物模型日志列表 **/
|
||||
List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.iot.tdengine.service.impl;
|
||||
|
||||
import com.ruoyi.iot.domain.Device;
|
||||
import com.ruoyi.iot.domain.DeviceLog;
|
||||
import com.ruoyi.iot.model.DeviceStatistic;
|
||||
import com.ruoyi.iot.tdengine.service.ILogService;
|
||||
@@ -45,8 +46,8 @@ public class MySqlLogServiceImpl implements ILogService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DeviceStatistic selectCategoryLogCount(){
|
||||
return deviceLogMapper.selectCategoryLogCount();
|
||||
public DeviceStatistic selectCategoryLogCount(Device device){
|
||||
return deviceLogMapper.selectCategoryLogCount(device);
|
||||
}
|
||||
|
||||
/***
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.iot.tdengine.service.impl;
|
||||
|
||||
import com.ruoyi.iot.domain.Device;
|
||||
import com.ruoyi.iot.domain.DeviceLog;
|
||||
import com.ruoyi.iot.model.DeviceStatistic;
|
||||
import com.ruoyi.iot.tdengine.service.ILogService;
|
||||
@@ -61,8 +62,8 @@ public class TdengineLogServiceImpl implements ILogService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DeviceStatistic selectCategoryLogCount(){
|
||||
return tdDeviceLogDAO.selectCategoryLogCount(dbName);
|
||||
public DeviceStatistic selectCategoryLogCount(Device device){
|
||||
return tdDeviceLogDAO.selectCategoryLogCount(dbName,device);
|
||||
}
|
||||
|
||||
/***
|
||||
|
||||
Reference in New Issue
Block a user