租户权限隔离接口修改

breach-zhy
马雪伟 4 weeks ago
parent a160d64054
commit 7c0da83250

@ -148,7 +148,7 @@ public class DataScopeAspect {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
Long tenantId = user.getTenantId(); Long tenantId = user.getTenantId();
if (!tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { if (!tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) {
sql.append(StringUtils.format(" OR {}.tenant_id = {} ", tenantAlias, tenantId)); sql.append(StringUtils.format(" AND tenant_id = {} ", tenantId));
} }
return sql; return sql;

@ -470,36 +470,44 @@ public class HwMonitorPlatformController extends BaseController {
List<LinkedHashMap> excelMap = new ArrayList<LinkedHashMap>(); List<LinkedHashMap> excelMap = new ArrayList<LinkedHashMap>();
LinkedHashMap attributeMap = new LinkedHashMap(); LinkedHashMap attributeMap = new LinkedHashMap();
for (HwMonitorUnitAttribute attribute : attributes) { for (HwMonitorUnitAttribute attribute : attributes) {
attributeMap.put(attribute.getAttributeName(),attribute.getAttributeValue()); if (attribute!=null){
attributeMap.put(attribute.getAttributeName(),attribute.getAttributeValue());
}
} }
for (AlarmInfoExportVo alarmInfo : list2) { for (AlarmInfoExportVo alarmInfo : list2) {
LinkedHashMap voMap = new LinkedHashMap<>(); LinkedHashMap voMap = new LinkedHashMap<>();
Class<AlarmInfoExportVo> clazz = AlarmInfoExportVo.class; Class<AlarmInfoExportVo> clazz = AlarmInfoExportVo.class;
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
Excel annotation = field.getAnnotation(Excel.class); Excel annotation = field.getAnnotation(Excel.class);
String name = annotation.name(); String name = annotation.name();
field.setAccessible(true); System.out.println(name);
if (field.getName().equals("alarmInfoId")){ field.setAccessible(true);
Long alarmInfoId =(Long)field.get(alarmInfo); if (field.getName().equals("alarmInfoId")){
voMap.put(name,alarmInfoId); System.out.println(field);
}else { // Long alarmInfoId =(Long)field.get(alarmInfo);
String value = null; Long alarmInfoId = alarmInfo.getAlarmInfoId();
if (field.get(alarmInfo)!=null){ System.out.println(alarmInfoId);
value = field.get(alarmInfo).toString(); voMap.put(name,alarmInfoId);
}else {
String value = null;
if (field.get(alarmInfo)!=null){
value = field.get(alarmInfo).toString();
}
voMap.put(name,value);
} }
voMap.put(name,value);
}
}
voMap.putAll(attributeMap);
excelMap.add(voMap);
} }
voMap.putAll(attributeMap); if (CollectionUtil.isNotEmpty(excelMap)){
excelMap.add(voMap); map.put(unitId,excelMap);
} }
if (CollectionUtil.isNotEmpty(excelMap)){
map.put(unitId,excelMap);
} }
}
UnitExcelUtils unitExcelUtils = new UnitExcelUtils(); UnitExcelUtils unitExcelUtils = new UnitExcelUtils();
unitExcelUtils.exportAlarmInfos(response,map); unitExcelUtils.exportAlarmInfos(response,map);
// List<AlarmInfoExportVo> alarmInfoExportVos = hwAlarmInfoService.selectAlarmInfoExport(startTime,endTime); // List<AlarmInfoExportVo> alarmInfoExportVos = hwAlarmInfoService.selectAlarmInfoExport(startTime,endTime);
@ -524,7 +532,7 @@ public class HwMonitorPlatformController extends BaseController {
{ {
JSONObject o = hwDeviceService.selectRedisFile(tenantId); JSONObject o = hwDeviceService.selectRedisFile(tenantId);
if (!o.equals(null)&&!o.equals("")){ if (o!=null){
return o; return o;
} }

@ -9,6 +9,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -90,7 +91,11 @@ public class HwMonitorUnitAttributeController {
@GetMapping("/selectAttributeByUnitId") @GetMapping("/selectAttributeByUnitId")
public AjaxResult selectAttributeByUnitId(Long monitorUnitId){ public AjaxResult selectAttributeByUnitId(Long monitorUnitId){
return AjaxResult.success(hwMonitorUnitAttributeService.selectAttributeByUnitId(monitorUnitId)); List<HwMonitorUnitAttribute> attributes = hwMonitorUnitAttributeService.selectAttributeByUnitId(monitorUnitId);
if (attributes.size()==0){
return AjaxResult.success(Collections.emptyList());
}
return AjaxResult.success(attributes);
} }
@PostMapping("/updateAttributeByUniitId") @PostMapping("/updateAttributeByUniitId")

@ -114,7 +114,7 @@ public class HwTenantController extends BaseController
return toAjax(hwTenantService.deleteHwTenantByTenantIds(tenantIds)); return toAjax(hwTenantService.deleteHwTenantByTenantIds(tenantIds));
} }
@RequiresPermissions("business:tenant:getAliArea")
@GetMapping("/getAliArea") @GetMapping("/getAliArea")
public AjaxResult getAliArea(Long areaCode) public AjaxResult getAliArea(Long areaCode)
{ {

@ -40,53 +40,53 @@ public class AlarmInfoExportVo {
@Excel(name = "报警区域") @Excel(name = "报警区域")
private String areaName; private String areaName;
public Long getAlarmInfoId() { // public Long getAlarmInfoId() {
return alarmInfoId; // return alarmInfoId;
} // }
//
public void setAlarmInfoId(Long alarmInfoId) { // public void setAlarmInfoId(Long alarmInfoId) {
this.alarmInfoId = alarmInfoId; // this.alarmInfoId = alarmInfoId;
} // }
//
public String getAreaName() { // public String getAreaName() {
return areaName; // return areaName;
} // }
//
public void setAreaName(String areaName) { // public void setAreaName(String areaName) {
this.areaName = areaName; // this.areaName = areaName;
} // }
//
public String getMonitorUnitName() { // public String getMonitorUnitName() {
return monitorUnitName; // return monitorUnitName;
} // }
//
public void setMonitorUnitName(String monitorUnitName) { // public void setMonitorUnitName(String monitorUnitName) {
this.monitorUnitName = monitorUnitName; // this.monitorUnitName = monitorUnitName;
} // }
//
public String getAlarmLevelName() { // public String getAlarmLevelName() {
return alarmLevelName; // return alarmLevelName;
} // }
//
public void setAlarmLevelName(String alarmLevelName) { // public void setAlarmLevelName(String alarmLevelName) {
this.alarmLevelName = alarmLevelName; // this.alarmLevelName = alarmLevelName;
} // }
//
public String getAlarmTypeName() { // public String getAlarmTypeName() {
return alarmTypeName; // return alarmTypeName;
} // }
//
public void setAlarmTypeName(String alarmTypeName) { // public void setAlarmTypeName(String alarmTypeName) {
this.alarmTypeName = alarmTypeName; // this.alarmTypeName = alarmTypeName;
} // }
//
public String getAlarmTime() { // public String getAlarmTime() {
return alarmTime; // return alarmTime;
} // }
//
public void setAlarmTime(String alarmTime) { // public void setAlarmTime(String alarmTime) {
this.alarmTime = alarmTime; // this.alarmTime = alarmTime;
} // }
// public String getMonitor_unit_id() { // public String getMonitor_unit_id() {
// return monitor_unit_id; // return monitor_unit_id;
@ -112,14 +112,14 @@ public class AlarmInfoExportVo {
// this.monitor_unit_type_name = monitor_unit_type_name; // this.monitor_unit_type_name = monitor_unit_type_name;
// } // }
@Override // @Override
public String toString() { // public String toString() {
return "AlarmInfoExportVo{" + // return "AlarmInfoExportVo{" +
"alarmInfoId=" + alarmInfoId + // "alarmInfoId=" + alarmInfoId +
", monitorUnitName='" + monitorUnitName + '\'' + // ", monitorUnitName='" + monitorUnitName + '\'' +
", alarmLevelName='" + alarmLevelName + '\'' + // ", alarmLevelName='" + alarmLevelName + '\'' +
", alarmTypeName='" + alarmTypeName + '\'' + // ", alarmTypeName='" + alarmTypeName + '\'' +
", alarmTime='" + alarmTime + '\'' + // ", alarmTime='" + alarmTime + '\'' +
'}'; // '}';
} // }
} }

@ -94,6 +94,7 @@ public interface HwAlarmInfoMapper
* */ * */
public int updateHwAlarmInfoAllByDevice(HwAlarmInfo hwAlarmInfo); public int updateHwAlarmInfoAllByDevice(HwAlarmInfo hwAlarmInfo);
// List<AlarmInfoExportVo> selectAlarmInfoExport1(@Param("monitorUnitId")Long monitorUnitId);
List<AlarmInfoExportVo> selectAlarmInfoExport1(@Param("monitorUnitId")Long monitorUnitId,@Param("startTime") Date startTime, @Param("endTime") Date endTime); List<AlarmInfoExportVo> selectAlarmInfoExport1(@Param("monitorUnitId")Long monitorUnitId,@Param("startTime") Date startTime, @Param("endTime") Date endTime);
List<Long> selectUnitId(); List<Long> selectUnitId();

@ -32,7 +32,7 @@ public interface HwDeviceMapper
/** /**
* 3. * 3.
* */ * */
public List<DeviceModeVo> selectDeviceModeNameVo(); public List<DeviceModeVo> selectDeviceModeNameVo(Long tenantId);
/** /**
* *
* *
@ -165,7 +165,7 @@ public interface HwDeviceMapper
/** /**
* *
* */ * */
String selectFunctionNameByFunctionIdentifier(String functionIdentifier); String selectFunctionNameByFunctionIdentifier(@Param("functionIdentifier") String functionIdentifier,@Param("modeId") Long modeId);
/** /**
* id * id
* */ * */
@ -174,4 +174,6 @@ public interface HwDeviceMapper
List<HwDevice> getDeviceByModel(Long modelId); List<HwDevice> getDeviceByModel(Long modelId);
Long selectDeviceIfAlarmElectronFence(Long deviceId); Long selectDeviceIfAlarmElectronFence(Long deviceId);
Long selectModeIdByDeviceId(String deviceId);
} }

@ -27,22 +27,22 @@ public interface HwMonitorUnitMapper
/** /**
* () * ()
* */ * */
public List<HwMonitorUnitVo> selectMonitorPercentage(); public List<HwMonitorUnitVo> selectMonitorPercentage(Long tenantId);
/** /**
* *
* */ * */
public List<AllNumsVo> selectAllNums(); public List<AllNumsVo> selectAllNums();
public List<AllNumsVo> selectsum(); public List<AllNumsVo> selectsum();
//查询id与name的结果集 //查询id与name的结果集
List<HwMonitorUnitVo> selectSceneNameById(); List<HwMonitorUnitVo> selectSceneNameById(Long tenantId);
Integer selectSubSetNums(Long sceneId); Integer selectSubSetNums(@Param("tenantId") Long tenantId,@Param("sceneId")Long sceneId);
/** /**
* *
* */ * */
public List<HwMonitorUnit> selectLimitSubMonitorUnit(HwMonitorUnit hwMonitorUnit); public List<HwMonitorUnit> selectLimitSubMonitorUnit(HwMonitorUnit hwMonitorUnit);
Integer selectReleatedDeviceIdNums(Long deviceCode); Integer selectReleatedDeviceIdNums(Long deviceCode);
Integer selectDeviceNums(Long sceneId); Integer selectDeviceNums(@Param("sceneId")Long sceneId,@Param("tenantId")Long tenantId);
Integer selectSubDeviceSum(Long sceneId); Integer selectSubDeviceSum(Long sceneId);
/** /**

@ -10,6 +10,9 @@ import com.ruoyi.business.mapper.HwAlarmTypeMapper;
import com.ruoyi.common.core.constant.HwDictConstants; import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwAlarmInfoMapper; import com.ruoyi.business.mapper.HwAlarmInfoMapper;
@ -50,6 +53,10 @@ public class HwAlarmInfoServiceImpl implements IHwAlarmInfoService {
@Override @Override
@DataScope(tenantAlias = "hai") @DataScope(tenantAlias = "hai")
public List<HwAlarmInfo> selectHwAlarmInfoList(HwAlarmInfo hwAlarmInfo) { public List<HwAlarmInfo> selectHwAlarmInfoList(HwAlarmInfo hwAlarmInfo) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
hwAlarmInfo.setTenantId(tenantId);
return hwAlarmInfoMapper.selectHwAlarmInfoList(hwAlarmInfo); return hwAlarmInfoMapper.selectHwAlarmInfoList(hwAlarmInfo);
} }

@ -13,6 +13,8 @@ import com.ruoyi.common.core.utils.RegexUtils;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -116,6 +118,10 @@ public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService {
@DataScope(tenantAlias = "har") @DataScope(tenantAlias = "har")
public List<HwAlarmRule> selectHwAlarmRuleJoinList(HwAlarmRule hwAlarmRule) { public List<HwAlarmRule> selectHwAlarmRuleJoinList(HwAlarmRule hwAlarmRule) {
hwAlarmRule.setRuleType(HwDictConstants.ALARM_RULE_RULE_TYPE_DEVICE); hwAlarmRule.setRuleType(HwDictConstants.ALARM_RULE_RULE_TYPE_DEVICE);
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
hwAlarmRule.setTenantId(tenantId);
return hwAlarmRuleMapper.selectHwAlarmRuleJoinList(hwAlarmRule); return hwAlarmRuleMapper.selectHwAlarmRuleJoinList(hwAlarmRule);
} }

@ -10,6 +10,8 @@ import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -61,6 +63,10 @@ public class HwAlarmTypeServiceImpl implements IHwAlarmTypeService {
@Override @Override
@DataScope(tenantAlias = "hat") @DataScope(tenantAlias = "hat")
public List<HwAlarmType> selectHwAlarmTypeJoinList(HwAlarmType hwAlarmType) { public List<HwAlarmType> selectHwAlarmTypeJoinList(HwAlarmType hwAlarmType) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
hwAlarmType.setTenantId(tenantId);
return hwAlarmTypeMapper.selectHwAlarmTypeJoinList(hwAlarmType); return hwAlarmTypeMapper.selectHwAlarmTypeJoinList(hwAlarmType);
} }

@ -20,6 +20,8 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.RemoteConfigService; import com.ruoyi.system.api.RemoteConfigService;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import com.ruoyi.tdengine.api.RemoteTdEngineService; import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.TdField; import com.ruoyi.tdengine.api.domain.TdField;
import com.ruoyi.tdengine.api.domain.TdSuperTableVo; import com.ruoyi.tdengine.api.domain.TdSuperTableVo;
@ -375,6 +377,10 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
@Override @Override
@DataScope(tenantAlias = "hdm") @DataScope(tenantAlias = "hdm")
public List<HwDeviceMode> selectHwDeviceModeJoinList(HwDeviceMode hwDeviceMode) { public List<HwDeviceMode> selectHwDeviceModeJoinList(HwDeviceMode hwDeviceMode) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
hwDeviceMode.setTenantId(tenantId);
return hwDeviceModeMapper.selectHwDeviceModeJoinList(hwDeviceMode); return hwDeviceModeMapper.selectHwDeviceModeJoinList(hwDeviceMode);
} }
@ -440,6 +446,7 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
@Override @Override
public List<HwDevice> getDeviceByModel(Long modelId) { public List<HwDevice> getDeviceByModel(Long modelId) {
System.out.println(hwDeviceMapper.getDeviceByModel(modelId));
return hwDeviceMapper.getDeviceByModel(modelId); return hwDeviceMapper.getDeviceByModel(modelId);
} }

@ -23,6 +23,7 @@ import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import com.ruoyi.tdengine.api.RemoteTdEngineService; import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.*; import com.ruoyi.tdengine.api.domain.*;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
@ -113,6 +114,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override @Override
@DataScope(tenantAlias = "hd") @DataScope(tenantAlias = "hd")
public List<HwDevice> selectHwDeviceList(HwDevice hwDevice) { public List<HwDevice> selectHwDeviceList(HwDevice hwDevice) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
hwDevice.setTenantId(tenantId);
return hwDeviceMapper.selectHwDeviceList(hwDevice); return hwDeviceMapper.selectHwDeviceList(hwDevice);
} }
@ -289,7 +294,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
*/ */
@Override @Override
public List<DeviceModeVo> selectDeviceModeNameVo() { public List<DeviceModeVo> selectDeviceModeNameVo() {
List<DeviceModeVo> list = hwDeviceMapper.selectDeviceModeNameVo(); LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
List<DeviceModeVo> list = hwDeviceMapper.selectDeviceModeNameVo(tenantId);
Integer value = 0; Integer value = 0;
if (list.size() > 10) { if (list.size() > 10) {
for (int i = 9; i < list.size(); i++) { for (int i = 9; i < list.size(); i++) {
@ -549,6 +557,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override @Override
@DataScope(tenantAlias = "hd") @DataScope(tenantAlias = "hd")
public List<HwDevice> selectHwDeviceJoinList(HwDevice hwDevice) { public List<HwDevice> selectHwDeviceJoinList(HwDevice hwDevice) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
hwDevice.setTenantId(tenantId);
return hwDeviceMapper.selectHwDeviceJoinList(hwDevice); return hwDeviceMapper.selectHwDeviceJoinList(hwDevice);
} }
@ -1359,6 +1371,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
list.addAll(list1); list.addAll(list1);
} }
} }
Long modeId = hwDeviceMapper.selectModeIdByDeviceId(deviceIds);
Map<String, Object> mapName = new HashMap<String, Object>(); Map<String, Object> mapName = new HashMap<String, Object>();
if (list.size()>0){ if (list.size()>0){
Set<String> strings = list.get(0).keySet(); Set<String> strings = list.get(0).keySet();
@ -1366,7 +1379,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
list2.addAll(strings); list2.addAll(strings);
for (int i = 0; i < list2.size(); i++) { for (int i = 0; i < list2.size(); i++) {
//查询类型的字段名 //查询类型的字段名
String s = hwDeviceMapper.selectFunctionNameByFunctionIdentifier(list2.get(i)); String s = hwDeviceMapper.selectFunctionNameByFunctionIdentifier(list2.get(i),modeId);
mapName.put(list2.get(i),s); mapName.put(list2.get(i),s);
} }
list.add(mapName); list.add(mapName);
@ -1405,7 +1418,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
for (int i = 0; i < unitMap.size(); i++) { for (int i = 0; i < unitMap.size(); i++) {
List<TreeDeviceVo> list = new ArrayList<TreeDeviceVo>(); List<TreeDeviceVo> list = new ArrayList<TreeDeviceVo>();
for (int j = 0; j < deviceMap.size(); j++) { for (int j = 0; j < deviceMap.size(); j++) {
if (unitMap.get(i).getVoId() == deviceMap.get(j).getParentId()) { if (unitMap.get(i).getVoId().longValue() == deviceMap.get(j).getParentId().longValue()) {
list.add(deviceMap.get(j)); list.add(deviceMap.get(j));
} }
} }
@ -1556,21 +1569,26 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override @Override
public JSONObject selectRedisFile(Long tenantId){ public JSONObject selectRedisFile(Long tenantId){
Object o = redisService.getCacheObject("file" + tenantId); Object o = redisService.getCacheObject("file" + tenantId);
JSONObject array = new JSONObject(true); if (o == null){
array.put("content",o.toString()); return null;
}else {
String s = o.toString(); JSONObject array = new JSONObject(true);
String[] split = s.split("},\\{"); array.put("content",o.toString());
String s2 = split[0].substring(1) + "}";
Map<String, Object> map = JSON.parseObject(s2,LinkedHashMap.class, Feature.OrderedField); String s = o.toString();
Map<Long, String> linkedMap = new LinkedHashMap<Long, String>(); String[] split = s.split("},\\{");
Long along = 1l; String s2 = split[0].substring(1) + "}";
for (String key : map.keySet()){ Map<String, Object> map = JSON.parseObject(s2,LinkedHashMap.class, Feature.OrderedField);
linkedMap.put(along, key); Map<Long, String> linkedMap = new LinkedHashMap<Long, String>();
along++; Long along = 1l;
for (String key : map.keySet()){
linkedMap.put(along, key);
along++;
}
array.put("Header",linkedMap);
return array;
} }
array.put("Header",linkedMap);
return array;
} }
/** /**

@ -18,6 +18,8 @@ import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -363,6 +365,10 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
@Override @Override
@DataScope(tenantAlias = "hef") @DataScope(tenantAlias = "hef")
public List<HwElectronicFence> selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence) { public List<HwElectronicFence> selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
hwElectronicFence.setTenantId(tenantId);
return hwElectronicFenceMapper.selectHwElectronicFenceJoinList(hwElectronicFence); return hwElectronicFenceMapper.selectHwElectronicFenceJoinList(hwElectronicFence);
} }

@ -7,6 +7,7 @@ import com.ruoyi.business.domain.VO.*;
import com.ruoyi.business.mapper.HwAlarmInfoMapper; import com.ruoyi.business.mapper.HwAlarmInfoMapper;
import com.ruoyi.business.mapper.HwDeviceMapper; import com.ruoyi.business.mapper.HwDeviceMapper;
import com.ruoyi.business.mapper.HwElectronicFenceMapper; import com.ruoyi.business.mapper.HwElectronicFenceMapper;
import com.ruoyi.business.mapper.HwMonitorUnitMapper; import com.ruoyi.business.mapper.HwMonitorUnitMapper;
import com.ruoyi.business.service.IHwMonitorUnitService; import com.ruoyi.business.service.IHwMonitorUnitService;
import com.ruoyi.common.core.constant.HwDictConstants; import com.ruoyi.common.core.constant.HwDictConstants;
@ -15,6 +16,9 @@ import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.NumberUtils; import com.ruoyi.common.core.utils.NumberUtils;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import com.ruoyi.tdengine.api.RemoteTdEngineService; import com.ruoyi.tdengine.api.RemoteTdEngineService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -71,8 +75,11 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService {
// Integer value = monitorUnitMap.get(key); // Integer value = monitorUnitMap.get(key);
// System.out.println(key+"\t"+value); // System.out.println(key+"\t"+value);
// } // }
List<HwMonitorUnitVo> list = hwMonitorUnitMapper.selectMonitorPercentage(); LoginUser loginUser = SecurityUtils.getLoginUser();
List<HwMonitorUnitVo> hwScenes = hwMonitorUnitMapper.selectSceneNameById(); SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
List<HwMonitorUnitVo> list = hwMonitorUnitMapper.selectMonitorPercentage(tenantId);
List<HwMonitorUnitVo> hwScenes = hwMonitorUnitMapper.selectSceneNameById(tenantId);
list.stream().forEach(l -> { list.stream().forEach(l -> {
for (int i = 0; i < hwScenes.size(); i++) { for (int i = 0; i < hwScenes.size(); i++) {
if (l.getSceneId().equals(hwScenes.get(i).getSceneId())) { if (l.getSceneId().equals(hwScenes.get(i).getSceneId())) {
@ -125,12 +132,15 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService {
//获取总的设备数量与监控单元数量(标准场景使用) //获取总的设备数量与监控单元数量(标准场景使用)
@Override @Override
public AllNumsVo selectAllNums(Long sceneId) { public AllNumsVo selectAllNums(Long sceneId) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
//监控单元数量 //监控单元数量
Integer monitor = hwMonitorUnitMapper.selectSubSetNums(sceneId) == null ? 0 Integer monitor = hwMonitorUnitMapper.selectSubSetNums(tenantId,sceneId) == null ? 0
: hwMonitorUnitMapper.selectSubSetNums(sceneId); : hwMonitorUnitMapper.selectSubSetNums(tenantId,sceneId);
//查询设备数量(子设备和直连设备),不包括网关 //查询设备数量(子设备和直连设备),不包括网关
Integer integer = hwMonitorUnitMapper.selectDeviceNums(sceneId) == null ? 0 Integer integer = hwMonitorUnitMapper.selectDeviceNums(sceneId,tenantId) == null ? 0
: hwMonitorUnitMapper.selectDeviceNums(sceneId); : hwMonitorUnitMapper.selectDeviceNums(sceneId,tenantId);
//查询信标设备数量 //查询信标设备数量
Integer beaconNums = hwMonitorUnitMapper.selectBeaconDeviceNums(sceneId) ==null ? 0 Integer beaconNums = hwMonitorUnitMapper.selectBeaconDeviceNums(sceneId) ==null ? 0
:hwMonitorUnitMapper.selectBeaconDeviceNums(sceneId); :hwMonitorUnitMapper.selectBeaconDeviceNums(sceneId);
@ -428,6 +438,10 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService {
@DataScope(tenantAlias = "hmu") @DataScope(tenantAlias = "hmu")
public List<HwMonitorUnit> selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit) { public List<HwMonitorUnit> selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit) {
hwMonitorUnit.setMonitorUnitStatus(HwDictConstants.MONITOR_UNIT_STATUS_NORMAL); hwMonitorUnit.setMonitorUnitStatus(HwDictConstants.MONITOR_UNIT_STATUS_NORMAL);
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
hwMonitorUnit.setTenantId(tenantId);
return hwMonitorUnitMapper.selectHwMonitorUnitJoinList(hwMonitorUnit); return hwMonitorUnitMapper.selectHwMonitorUnitJoinList(hwMonitorUnit);
} }

@ -8,6 +8,9 @@ import com.ruoyi.business.mapper.HwMonitorUnitMapper;
import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwMonitorUnitTypeMapper; import com.ruoyi.business.mapper.HwMonitorUnitTypeMapper;
@ -125,6 +128,9 @@ public class HwMonitorUnitTypeServiceImpl implements IHwMonitorUnitTypeService {
@Override @Override
@DataScope(tenantAlias = "hmut") @DataScope(tenantAlias = "hmut")
public List<HwMonitorUnitType> selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType) { public List<HwMonitorUnitType> selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getSysUser();
hwMonitorUnitType.setTenantId(user.getTenantId());
return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType); return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType);
} }

@ -249,6 +249,9 @@ public class HwSceneServiceImpl implements IHwSceneService {
* @date 2023-09-26 18:19 * @date 2023-09-26 18:19
*/ */
private void updateDefaultFlag(HwScene hwScene) { private void updateDefaultFlag(HwScene hwScene) {
if (hwScene.getDefaultFlag() == null){
hwScene.setDefaultFlag("0");
}
if (hwScene.getDefaultFlag().equals(HwDictConstants.SCENE_DEFAULT_FLAG_YES)) { if (hwScene.getDefaultFlag().equals(HwDictConstants.SCENE_DEFAULT_FLAG_YES)) {
HwScene queryScene = new HwScene(); HwScene queryScene = new HwScene();
queryScene.setTenantId(hwScene.getTenantId()); queryScene.setTenantId(hwScene.getTenantId());

@ -33,7 +33,7 @@ public class UnitExcelUtils {
int size = map1.keySet().size(); int size = map1.keySet().size();
int cellIndex = 0; int cellIndex = 0;
Row row1 = unitId.createRow(row); Row row1 = unitId.createRow(row);
Row row2 = unitId.createRow(row + 1); Row row2 = unitId.createRow(1);
for (cellIndex = 0;cellIndex < size;cellIndex++){ for (cellIndex = 0;cellIndex < size;cellIndex++){
String key = list1.get(cellIndex).toString(); String key = list1.get(cellIndex).toString();
row1.createCell(cellIndex).setCellValue(key); row1.createCell(cellIndex).setCellValue(key);
@ -43,16 +43,18 @@ public class UnitExcelUtils {
}else if (value instanceof Long){ }else if (value instanceof Long){
row2.createCell(cellIndex).setCellValue((Long) map1.get(key)); row2.createCell(cellIndex).setCellValue((Long) map1.get(key));
}else if(value instanceof Date){ }else if(value instanceof Date){
row2.createCell(cellIndex).setCellValue((Date) map.get(key)); row2.createCell(cellIndex).setCellValue((Date) map1.get(key));
}else {
row2.createCell(cellIndex).setCellValue("");
} }
} }
}else { }else {
LinkedHashMap map1 = list3.get(row); LinkedHashMap map1 = list3.get(row);
ArrayList list1 = new ArrayList<>(map1.keySet()); ArrayList list1 = new ArrayList<>(map1.keySet());
int size = map1.keySet().size(); int size = map1.keySet().size();
int cellIndex = 0; int cellIndex = 0;
Row row1 = unitId.createRow(row); Row row1 = unitId.createRow(row+1);
for (cellIndex = 0;cellIndex < size;cellIndex++){ for (cellIndex = 0;cellIndex < size;cellIndex++){
String key = list1.get(cellIndex).toString(); String key = list1.get(cellIndex).toString();
Object value = map1.get(key); Object value = map1.get(key);
@ -62,7 +64,10 @@ public class UnitExcelUtils {
row1.createCell(cellIndex).setCellValue((Long) map1.get(key)); row1.createCell(cellIndex).setCellValue((Long) map1.get(key));
} }
else if(value instanceof Date){ else if(value instanceof Date){
row1.createCell(cellIndex).setCellValue((Date) map.get(key)); row1.createCell(cellIndex).setCellValue((Date) map1.get(key));
}
else {
row1.createCell(cellIndex).setCellValue("");
} }
} }
} }

@ -106,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alarmReleatedId != null "> and alarm_releated_id = #{alarmReleatedId}</if> <if test="alarmReleatedId != null "> and alarm_releated_id = #{alarmReleatedId}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if> <if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="monitorUnitId != null "> and monitor_unit_id = #{monitorUnitId}</if> <if test="monitorUnitId != null "> and monitor_unit_id = #{monitorUnitId}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if> <if test="tenantId != null "> and hai.tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and hai.scene_id = #{sceneId}</if> <if test="sceneId != null "> and hai.scene_id = #{sceneId}</if>
<if test="alarmLevelId != null "> and alarm_level_id = #{alarmLevelId}</if> <if test="alarmLevelId != null "> and alarm_level_id = #{alarmLevelId}</if>
<if test="alarmTypeId != null "> and alarm_type_id = #{alarmTypeId}</if> <if test="alarmTypeId != null "> and alarm_type_id = #{alarmTypeId}</if>
@ -119,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alarmTime != null "> and alarm_time = #{alarmTime}</if> <if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>
<if test="alarmInfoField != null and alarmInfoField != ''"> and alarm_info_field = #{alarmInfoField}</if> <if test="alarmInfoField != null and alarmInfoField != ''"> and alarm_info_field = #{alarmInfoField}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by alarm_info_id desc,hal.level_number desc order by alarm_info_id desc,hal.level_number desc
</select> </select>

@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alarmRuleField != null and alarmRuleField != ''"> and har.alarm_rule_field = #{alarmRuleField}</if> <if test="alarmRuleField != null and alarmRuleField != ''"> and har.alarm_rule_field = #{alarmRuleField}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by har.alarm_rule_id desc order by har.alarm_rule_id desc

@ -131,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="handleMode != null and handleMode != ''"> and hat.handle_mode = #{handleMode}</if> <if test="handleMode != null and handleMode != ''"> and hat.handle_mode = #{handleMode}</if>
<if test="typeStatus != null and typeStatus != ''"> and hat.type_status = #{typeStatus}</if> <if test="typeStatus != null and typeStatus != ''"> and hat.type_status = #{typeStatus}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by hat.scene_id,hat.alarm_type_id desc order by hat.scene_id,hat.alarm_type_id desc
</select> </select>

@ -84,7 +84,7 @@ select a.device_mode_name,sum(a.sum) sum from (select
) a on ) a on
a.device_mode_id = b.device_mode_id a.device_mode_id = b.device_mode_id
left join hw_scene c on left join hw_scene c on
b.scene_id = c.scene_id) a group by a.device_mode_name b.scene_id = c.scene_id where b.tenant_id = #{tenantId}) a group by a.device_mode_name
</select> </select>
<select id="selectDeviceByDeviceModeByDeviceModeFunction" parameterType="Long" resultType="String"> <select id="selectDeviceByDeviceModeByDeviceModeFunction" parameterType="Long" resultType="String">
select count(*) from hw_device_mode_function where device_mode_id = select count(*) from hw_device_mode_function where device_mode_id =
@ -174,7 +174,7 @@ select a.device_mode_name,sum(a.sum) sum from (select
<if test="tenantId != null "> and hd.tenant_id = #{tenantId}</if> <if test="tenantId != null "> and hd.tenant_id = #{tenantId}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and hd.online_status = #{onlineStatus}</if> <if test="onlineStatus != null and onlineStatus != ''"> and hd.online_status = #{onlineStatus}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
</select> </select>
@ -343,7 +343,7 @@ select a.device_mode_name,sum(a.sum) sum from (select
<if test="releatedDeviceId != null "> and hd.releated_device_id = #{releatedDeviceId}</if> <if test="releatedDeviceId != null "> and hd.releated_device_id = #{releatedDeviceId}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and hd.online_status = #{onlineStatus}</if> <if test="onlineStatus != null and onlineStatus != ''"> and hd.online_status = #{onlineStatus}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by hd.device_id desc order by hd.device_id desc
</select> </select>
@ -490,8 +490,8 @@ select a.device_mode_name,sum(a.sum) sum from (select
AND hd.device_status != 9 AND hd.device_status != 9
AND hd.monitor_unit_id = #{monitorUnitId} AND hd.monitor_unit_id = #{monitorUnitId}
</select> </select>
<select id="selectFunctionNameByFunctionIdentifier" parameterType="String" resultType="String"> <select id="selectFunctionNameByFunctionIdentifier" resultType="String">
select distinct function_name from hw_device_mode_function where function_identifier = #{functionIdentifier} select distinct function_name from hw_device_mode_function where function_identifier = #{functionIdentifier} and device_mode_id = #{modeId}
</select> </select>
<select id="selectDeviceIfAlarm" parameterType="Long" resultType="Long"> <select id="selectDeviceIfAlarm" parameterType="Long" resultType="Long">
select count(*) from select count(*) from
@ -501,5 +501,8 @@ select a.device_mode_name,sum(a.sum) sum from (select
select count(*) from select count(*) from
(select * from hw_alarm_info where device_id = #{deviceId} and handle_status = 0 and alarm_info_type = 4) as a (select * from hw_alarm_info where device_id = #{deviceId} and handle_status = 0 and alarm_info_type = 4) as a
</select> </select>
<select id="selectModeIdByDeviceId" resultType="java.lang.Long" parameterType="java.lang.String">
select device_mode_id from hw_device where device_id = #{deviceId}
</select>
</mapper> </mapper>

@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and data_verify_level = #{dataVerifyLevel}</if> <if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and data_verify_level = #{dataVerifyLevel}</if>
<if test="deviceModeField != null and deviceModeField != ''"> and device_mode_field = #{deviceModeField}</if> <if test="deviceModeField != null and deviceModeField != ''"> and device_mode_field = #{deviceModeField}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by device_mode_id desc order by device_mode_id desc
</select> </select>
@ -323,7 +323,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and hdm.data_verify_level = #{dataVerifyLevel}</if> <if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and hdm.data_verify_level = #{dataVerifyLevel}</if>
<if test="deviceModeField != null and deviceModeField != ''"> and hdm.device_mode_field = #{deviceModeField}</if> <if test="deviceModeField != null and deviceModeField != ''"> and hdm.device_mode_field = #{deviceModeField}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by hdm.device_mode_id desc order by hdm.device_mode_id desc
</select> </select>

@ -282,7 +282,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deviceId != null "> and hef.device_id = #{deviceId}</if> <if test="deviceId != null "> and hef.device_id = #{deviceId}</if>
<if test="deviceModeId != null "> and hef.device_mode_id = #{deviceModeId}</if> <if test="deviceModeId != null "> and hef.device_mode_id = #{deviceModeId}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by hef.electronic_fence_id desc order by hef.electronic_fence_id desc
</select> </select>

@ -116,14 +116,16 @@
where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null))as temp where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id GROUP BY scene_id
</select> </select>
<select id="selectSubSetNums" resultType="Integer"> <select id="selectSubSetNums" resultType="java.lang.Integer">
select count(*)from hw_monitor_unit select count(*)from hw_monitor_unit
where monitor_unit_status='1' and monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null) where monitor_unit_status='1' and monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null)
<if test="tenantId != null "> and tenant_id = #{tenantId} </if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if> <if test="sceneId != null "> and scene_id = #{sceneId}</if>
</select> </select>
<select id="selectDeviceNums" resultType="Integer"> <select id="selectDeviceNums" resultType="Integer">
select count(*) as sum from hw_device select count(*) as sum from hw_device
where device_status = '1' and (device_type='2' or device_type='3') where device_status = '1' and (device_type='2' or device_type='3')
<if test="tenantId != null and sceneId!=0">and tenant_id = #{tenantId}</if>
<if test="sceneId != null and sceneId!=0"> and scene_id = #{sceneId}</if> <if test="sceneId != null and sceneId!=0"> and scene_id = #{sceneId}</if>
</select> </select>
<!-- 通过场景分组,查询设备数量 todo 已解决 --> <!-- 通过场景分组,查询设备数量 todo 已解决 -->
@ -151,7 +153,7 @@
</select> </select>
<!--查询id与name的结果集通过id与selectMonitorPercentage相连--> <!--查询id与name的结果集通过id与selectMonitorPercentage相连-->
<select id="selectSceneNameById" resultMap="HwMonitorUnitVoResult"> <select id="selectSceneNameById" resultMap="HwMonitorUnitVoResult">
select scene_id,scene_name from hw_scene select scene_id,scene_name from hw_scene where tenant_id = #{tenantId} and scene_status != '9'
</select> </select>
<!-- 分页查询在impl实现分页--> <!-- 分页查询在impl实现分页-->
<select id="selectLimitSubMonitorUnit" resultMap="HwMonitorUnitResult"> <select id="selectLimitSubMonitorUnit" resultMap="HwMonitorUnitResult">
@ -164,7 +166,7 @@
<select id="selectMonitorPercentage" resultMap="HwMonitorUnitVoResult"> <select id="selectMonitorPercentage" resultMap="HwMonitorUnitVoResult">
select scene_id,count(*) as sum from (select monitor_unit_id,scene_id select scene_id,count(*) as sum from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp (select parent_id from hw_monitor_unit where parent_id is not null) and tenant_id = #{tenantId})as temp
GROUP BY scene_id order by sum desc GROUP BY scene_id order by sum desc
</select> </select>
<!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字--> <!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字-->
@ -296,7 +298,7 @@
<if test="preserveTime != null "> and hmu.preserve_time = #{preserveTime}</if> <if test="preserveTime != null "> and hmu.preserve_time = #{preserveTime}</if>
<if test="monitorUnitStatus != null "> and hmu.monitor_unit_status = #{monitorUnitStatus}</if> <if test="monitorUnitStatus != null "> and hmu.monitor_unit_status = #{monitorUnitStatus}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by hmu.tenant_id,hmu.parent_id order by hmu.tenant_id,hmu.parent_id
</select> </select>

@ -131,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="unitTypeIcon != null and unitTypeIcon != ''"> and hmut.unit_type_icon = #{unitTypeIcon}</if> <if test="unitTypeIcon != null and unitTypeIcon != ''"> and hmut.unit_type_icon = #{unitTypeIcon}</if>
<if test="unitTypeField != null and unitTypeField != ''"> and hmut.unit_type_field = #{unitTypeField}</if> <if test="unitTypeField != null and unitTypeField != ''"> and hmut.unit_type_field = #{unitTypeField}</if>
<!-- 租户数据范围过滤 --> <!-- 租户数据范围过滤 -->
${params.tenantDataScope} -- ${params.tenantDataScope}
</where> </where>
order by hmut.monitor_unit_type_id desc order by hmut.monitor_unit_type_id desc
</select> </select>

Loading…
Cancel
Save