租户权限隔离接口修改

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

@ -148,7 +148,7 @@ public class DataScopeAspect {
StringBuilder sql = new StringBuilder();
Long tenantId = user.getTenantId();
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;

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

@ -9,6 +9,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
/**
@ -90,7 +91,11 @@ public class HwMonitorUnitAttributeController {
@GetMapping("/selectAttributeByUnitId")
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")

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

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

@ -94,6 +94,7 @@ public interface HwAlarmInfoMapper
* */
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<Long> selectUnitId();

@ -32,7 +32,7 @@ public interface HwDeviceMapper
/**
* 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
* */
@ -174,4 +174,6 @@ public interface HwDeviceMapper
List<HwDevice> getDeviceByModel(Long modelId);
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> selectsum();
//查询id与name的结果集
List<HwMonitorUnitVo> selectSceneNameById();
Integer selectSubSetNums(Long sceneId);
List<HwMonitorUnitVo> selectSceneNameById(Long tenantId);
Integer selectSubSetNums(@Param("tenantId") Long tenantId,@Param("sceneId")Long sceneId);
/**
*
* */
public List<HwMonitorUnit> selectLimitSubMonitorUnit(HwMonitorUnit hwMonitorUnit);
Integer selectReleatedDeviceIdNums(Long deviceCode);
Integer selectDeviceNums(Long sceneId);
Integer selectDeviceNums(@Param("sceneId")Long sceneId,@Param("tenantId")Long tenantId);
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.utils.DateUtils;
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.stereotype.Service;
import com.ruoyi.business.mapper.HwAlarmInfoMapper;
@ -50,6 +53,10 @@ public class HwAlarmInfoServiceImpl implements IHwAlarmInfoService {
@Override
@DataScope(tenantAlias = "hai")
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);
}

@ -13,6 +13,8 @@ import com.ruoyi.common.core.utils.RegexUtils;
import com.ruoyi.common.core.utils.StringUtils;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -116,6 +118,10 @@ public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService {
@DataScope(tenantAlias = "har")
public List<HwAlarmRule> selectHwAlarmRuleJoinList(HwAlarmRule hwAlarmRule) {
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);
}

@ -10,6 +10,8 @@ import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils;
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.stereotype.Service;
@ -61,6 +63,10 @@ public class HwAlarmTypeServiceImpl implements IHwAlarmTypeService {
@Override
@DataScope(tenantAlias = "hat")
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);
}

@ -20,6 +20,8 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils;
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.domain.TdField;
import com.ruoyi.tdengine.api.domain.TdSuperTableVo;
@ -375,6 +377,10 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
@Override
@DataScope(tenantAlias = "hdm")
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);
}
@ -440,6 +446,7 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
@Override
public List<HwDevice> getDeviceByModel(Long modelId) {
System.out.println(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.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.domain.*;
import io.swagger.models.auth.In;
@ -113,6 +114,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override
@DataScope(tenantAlias = "hd")
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);
}
@ -289,7 +294,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
*/
@Override
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;
if (list.size() > 10) {
for (int i = 9; i < list.size(); i++) {
@ -549,6 +557,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override
@DataScope(tenantAlias = "hd")
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);
}
@ -1359,6 +1371,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
list.addAll(list1);
}
}
Long modeId = hwDeviceMapper.selectModeIdByDeviceId(deviceIds);
Map<String, Object> mapName = new HashMap<String, Object>();
if (list.size()>0){
Set<String> strings = list.get(0).keySet();
@ -1366,7 +1379,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
list2.addAll(strings);
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);
}
list.add(mapName);
@ -1405,7 +1418,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
for (int i = 0; i < unitMap.size(); i++) {
List<TreeDeviceVo> list = new ArrayList<TreeDeviceVo>();
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));
}
}
@ -1556,21 +1569,26 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override
public JSONObject selectRedisFile(Long tenantId){
Object o = redisService.getCacheObject("file" + tenantId);
JSONObject array = new JSONObject(true);
array.put("content",o.toString());
String s = o.toString();
String[] split = s.split("},\\{");
String s2 = split[0].substring(1) + "}";
Map<String, Object> map = JSON.parseObject(s2,LinkedHashMap.class, Feature.OrderedField);
Map<Long, String> linkedMap = new LinkedHashMap<Long, String>();
Long along = 1l;
for (String key : map.keySet()){
linkedMap.put(along, key);
along++;
if (o == null){
return null;
}else {
JSONObject array = new JSONObject(true);
array.put("content",o.toString());
String s = o.toString();
String[] split = s.split("},\\{");
String s2 = split[0].substring(1) + "}";
Map<String, Object> map = JSON.parseObject(s2,LinkedHashMap.class, Feature.OrderedField);
Map<Long, String> linkedMap = new LinkedHashMap<Long, String>();
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.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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -363,6 +365,10 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
@Override
@DataScope(tenantAlias = "hef")
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);
}

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

@ -8,6 +8,9 @@ import com.ruoyi.business.mapper.HwMonitorUnitMapper;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils;
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.stereotype.Service;
import com.ruoyi.business.mapper.HwMonitorUnitTypeMapper;
@ -125,6 +128,9 @@ public class HwMonitorUnitTypeServiceImpl implements IHwMonitorUnitTypeService {
@Override
@DataScope(tenantAlias = "hmut")
public List<HwMonitorUnitType> selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getSysUser();
hwMonitorUnitType.setTenantId(user.getTenantId());
return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType);
}

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

@ -33,7 +33,7 @@ public class UnitExcelUtils {
int size = map1.keySet().size();
int cellIndex = 0;
Row row1 = unitId.createRow(row);
Row row2 = unitId.createRow(row + 1);
Row row2 = unitId.createRow(1);
for (cellIndex = 0;cellIndex < size;cellIndex++){
String key = list1.get(cellIndex).toString();
row1.createCell(cellIndex).setCellValue(key);
@ -43,16 +43,18 @@ public class UnitExcelUtils {
}else if (value instanceof Long){
row2.createCell(cellIndex).setCellValue((Long) map1.get(key));
}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 {
LinkedHashMap map1 = list3.get(row);
ArrayList list1 = new ArrayList<>(map1.keySet());
int size = map1.keySet().size();
int cellIndex = 0;
Row row1 = unitId.createRow(row);
Row row1 = unitId.createRow(row+1);
for (cellIndex = 0;cellIndex < size;cellIndex++){
String key = list1.get(cellIndex).toString();
Object value = map1.get(key);
@ -62,7 +64,10 @@ public class UnitExcelUtils {
row1.createCell(cellIndex).setCellValue((Long) map1.get(key));
}
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="deviceId != null "> and device_id = #{deviceId}</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="alarmLevelId != null "> and alarm_level_id = #{alarmLevelId}</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="alarmInfoField != null and alarmInfoField != ''"> and alarm_info_field = #{alarmInfoField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
order by alarm_info_id desc,hal.level_number desc
</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>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
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="typeStatus != null and typeStatus != ''"> and hat.type_status = #{typeStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
order by hat.scene_id,hat.alarm_type_id desc
</select>

@ -84,7 +84,7 @@ select a.device_mode_name,sum(a.sum) sum from (select
) a on
a.device_mode_id = b.device_mode_id
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 id="selectDeviceByDeviceModeByDeviceModeFunction" parameterType="Long" resultType="String">
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="onlineStatus != null and onlineStatus != ''"> and hd.online_status = #{onlineStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
</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="onlineStatus != null and onlineStatus != ''"> and hd.online_status = #{onlineStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
order by hd.device_id desc
</select>
@ -490,8 +490,8 @@ select a.device_mode_name,sum(a.sum) sum from (select
AND hd.device_status != 9
AND hd.monitor_unit_id = #{monitorUnitId}
</select>
<select id="selectFunctionNameByFunctionIdentifier" parameterType="String" resultType="String">
select distinct function_name from hw_device_mode_function where function_identifier = #{functionIdentifier}
<select id="selectFunctionNameByFunctionIdentifier" resultType="String">
select distinct function_name from hw_device_mode_function where function_identifier = #{functionIdentifier} and device_mode_id = #{modeId}
</select>
<select id="selectDeviceIfAlarm" parameterType="Long" resultType="Long">
select count(*) from
@ -501,5 +501,8 @@ select a.device_mode_name,sum(a.sum) sum from (select
select count(*) from
(select * from hw_alarm_info where device_id = #{deviceId} and handle_status = 0 and alarm_info_type = 4) as a
</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>

@ -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="deviceModeField != null and deviceModeField != ''"> and device_mode_field = #{deviceModeField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
order by device_mode_id desc
</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="deviceModeField != null and deviceModeField != ''"> and hdm.device_mode_field = #{deviceModeField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
order by hdm.device_mode_id desc
</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="deviceModeId != null "> and hef.device_mode_id = #{deviceModeId}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
order by hef.electronic_fence_id desc
</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
GROUP BY scene_id
</select>
<select id="selectSubSetNums" resultType="Integer">
<select id="selectSubSetNums" resultType="java.lang.Integer">
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)
<if test="tenantId != null "> and tenant_id = #{tenantId} </if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
</select>
<select id="selectDeviceNums" resultType="Integer">
select count(*) as sum from hw_device
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>
</select>
<!-- 通过场景分组,查询设备数量 todo 已解决 -->
@ -151,7 +153,7 @@
</select>
<!--查询id与name的结果集通过id与selectMonitorPercentage相连-->
<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>
<!-- 分页查询在impl实现分页-->
<select id="selectLimitSubMonitorUnit" resultMap="HwMonitorUnitResult">
@ -164,7 +166,7 @@
<select id="selectMonitorPercentage" resultMap="HwMonitorUnitVoResult">
select scene_id,count(*) as sum from (select monitor_unit_id,scene_id
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
</select>
<!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字-->
@ -296,7 +298,7 @@
<if test="preserveTime != null "> and hmu.preserve_time = #{preserveTime}</if>
<if test="monitorUnitStatus != null "> and hmu.monitor_unit_status = #{monitorUnitStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
order by hmu.tenant_id,hmu.parent_id
</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="unitTypeField != null and unitTypeField != ''"> and hmut.unit_type_field = #{unitTypeField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
-- ${params.tenantDataScope}
</where>
order by hmut.monitor_unit_type_id desc
</select>

Loading…
Cancel
Save