diff --git a/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java b/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java index fcd0a66..98ef0b6 100644 --- a/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java +++ b/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java @@ -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; diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java index 9898c44..aa18e70 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java @@ -470,36 +470,44 @@ public class HwMonitorPlatformController extends BaseController { List excelMap = new ArrayList(); 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 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 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 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; } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitAttributeController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitAttributeController.java index 880a5e1..3ad6ddf 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitAttributeController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitAttributeController.java @@ -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 attributes = hwMonitorUnitAttributeService.selectAttributeByUnitId(monitorUnitId); + if (attributes.size()==0){ + return AjaxResult.success(Collections.emptyList()); + } + return AjaxResult.success(attributes); } @PostMapping("/updateAttributeByUniitId") diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java index e70c5da..b5ea021 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java @@ -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) { diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/AlarmInfoExportVo.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/AlarmInfoExportVo.java index 701ff24..8f214a2 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/AlarmInfoExportVo.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/AlarmInfoExportVo.java @@ -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 + '\'' + +// '}'; +// } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwAlarmInfoMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwAlarmInfoMapper.java index 190821f..8b21758 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwAlarmInfoMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwAlarmInfoMapper.java @@ -94,6 +94,7 @@ public interface HwAlarmInfoMapper * */ public int updateHwAlarmInfoAllByDevice(HwAlarmInfo hwAlarmInfo); +// List selectAlarmInfoExport1(@Param("monitorUnitId")Long monitorUnitId); List selectAlarmInfoExport1(@Param("monitorUnitId")Long monitorUnitId,@Param("startTime") Date startTime, @Param("endTime") Date endTime); List selectUnitId(); diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java index ea5a5bd..266a9e4 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java @@ -32,7 +32,7 @@ public interface HwDeviceMapper /** * 查询3. 设备各类型占所有设备数量百分比饼状图(左下角) * */ - public List selectDeviceModeNameVo(); + public List 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 getDeviceByModel(Long modelId); Long selectDeviceIfAlarmElectronFence(Long deviceId); + + Long selectModeIdByDeviceId(String deviceId); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitMapper.java index fbd88be..4bb5cc0 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitMapper.java @@ -27,22 +27,22 @@ public interface HwMonitorUnitMapper /** * 查询区域数量站场景区总数百分比(左上角) * */ - public List selectMonitorPercentage(); + public List selectMonitorPercentage(Long tenantId); /** *  展示总的设备数量和总的监控单元数量(最低级的监控单元) * */ public List selectAllNums(); public List selectsum(); //查询id与name的结果集 - List selectSceneNameById(); - Integer selectSubSetNums(Long sceneId); + List selectSceneNameById(Long tenantId); + Integer selectSubSetNums(@Param("tenantId") Long tenantId,@Param("sceneId")Long sceneId); /** * 分页获取最子集监控单元列表 * */ public List 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); /** diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmInfoServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmInfoServiceImpl.java index bb13a37..c456d93 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmInfoServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmInfoServiceImpl.java @@ -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 selectHwAlarmInfoList(HwAlarmInfo hwAlarmInfo) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + Long tenantId = sysUser.getTenantId(); + hwAlarmInfo.setTenantId(tenantId); return hwAlarmInfoMapper.selectHwAlarmInfoList(hwAlarmInfo); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmRuleServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmRuleServiceImpl.java index 5eccf36..f576e9f 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmRuleServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmRuleServiceImpl.java @@ -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 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); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmTypeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmTypeServiceImpl.java index 13b72ee..5b3b16b 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmTypeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmTypeServiceImpl.java @@ -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 selectHwAlarmTypeJoinList(HwAlarmType hwAlarmType) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + Long tenantId = sysUser.getTenantId(); + hwAlarmType.setTenantId(tenantId); return hwAlarmTypeMapper.selectHwAlarmTypeJoinList(hwAlarmType); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java index 06849ed..79b50f8 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java @@ -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 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 getDeviceByModel(Long modelId) { + System.out.println(hwDeviceMapper.getDeviceByModel(modelId)); return hwDeviceMapper.getDeviceByModel(modelId); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index e51b95c..82bf466 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -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 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 selectDeviceModeNameVo() { - List list = hwDeviceMapper.selectDeviceModeNameVo(); + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + Long tenantId = sysUser.getTenantId(); + List 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 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 mapName = new HashMap(); if (list.size()>0){ Set 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 list = new ArrayList(); 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 map = JSON.parseObject(s2,LinkedHashMap.class, Feature.OrderedField); - Map linkedMap = new LinkedHashMap(); - 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 map = JSON.parseObject(s2,LinkedHashMap.class, Feature.OrderedField); + Map linkedMap = new LinkedHashMap(); + 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; + } /** diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java index 2f5c81e..f19b47e 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java @@ -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 selectHwElectronicFenceJoinList(HwElectronicFence hwElectronicFence) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + Long tenantId = sysUser.getTenantId(); + hwElectronicFence.setTenantId(tenantId); return hwElectronicFenceMapper.selectHwElectronicFenceJoinList(hwElectronicFence); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java index fab7896..c603d5f 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java @@ -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 list = hwMonitorUnitMapper.selectMonitorPercentage(); - List hwScenes = hwMonitorUnitMapper.selectSceneNameById(); + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + Long tenantId = sysUser.getTenantId(); + List list = hwMonitorUnitMapper.selectMonitorPercentage(tenantId); + List 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 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); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitTypeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitTypeServiceImpl.java index 16e8c46..a36a5fb 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitTypeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitTypeServiceImpl.java @@ -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 selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + hwMonitorUnitType.setTenantId(user.getTenantId()); return hwMonitorUnitTypeMapper.selectHwMonitorUnitTypeJoinList(hwMonitorUnitType); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java index ea99200..8b27011 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java @@ -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()); diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/utils/UnitExcelUtils.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/utils/UnitExcelUtils.java index 34d1e0f..5a2288b 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/utils/UnitExcelUtils.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/utils/UnitExcelUtils.java @@ -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(""); } } } diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml index 1137e9d..1d6d60d 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml @@ -106,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and alarm_releated_id = #{alarmReleatedId} and device_id = #{deviceId} and monitor_unit_id = #{monitorUnitId} - and tenant_id = #{tenantId} + and hai.tenant_id = #{tenantId} and hai.scene_id = #{sceneId} and alarm_level_id = #{alarmLevelId} and alarm_type_id = #{alarmTypeId} @@ -119,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and alarm_time = #{alarmTime} and alarm_info_field = #{alarmInfoField} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by alarm_info_id desc,hal.level_number desc diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmRuleMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmRuleMapper.xml index 34933d5..f95c305 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmRuleMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmRuleMapper.xml @@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and har.alarm_rule_field = #{alarmRuleField} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by har.alarm_rule_id desc diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmTypeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmTypeMapper.xml index 63f117f..623d7e1 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmTypeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmTypeMapper.xml @@ -131,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and hat.handle_mode = #{handleMode} and hat.type_status = #{typeStatus} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by hat.scene_id,hat.alarm_type_id desc diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml index d237899..ae709ae 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml @@ -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 @@ -343,7 +343,7 @@ select a.device_mode_name,sum(a.sum) sum from (select and hd.releated_device_id = #{releatedDeviceId} and hd.online_status = #{onlineStatus} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by hd.device_id desc @@ -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 distinct function_name from hw_device_mode_function where function_identifier = #{functionIdentifier} and device_mode_id = #{modeId} + diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml index a2b5d53..107d0d6 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml @@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and data_verify_level = #{dataVerifyLevel} and device_mode_field = #{deviceModeField} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by device_mode_id desc @@ -323,7 +323,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and hdm.data_verify_level = #{dataVerifyLevel} and hdm.device_mode_field = #{deviceModeField} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by hdm.device_mode_id desc diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwElectronicFenceMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwElectronicFenceMapper.xml index 192a59c..656e5f5 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwElectronicFenceMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwElectronicFenceMapper.xml @@ -282,7 +282,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and hef.device_id = #{deviceId} and hef.device_mode_id = #{deviceModeId} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by hef.electronic_fence_id desc diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml index 713f9ea..e82325a 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitMapper.xml @@ -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 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) + and tenant_id = #{tenantId} and scene_id = #{sceneId} @@ -151,7 +153,7 @@ 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 @@ -296,7 +298,7 @@ and hmu.preserve_time = #{preserveTime} and hmu.monitor_unit_status = #{monitorUnitStatus} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by hmu.tenant_id,hmu.parent_id diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml index b299da3..2ac5268 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwMonitorUnitTypeMapper.xml @@ -131,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and hmut.unit_type_icon = #{unitTypeIcon} and hmut.unit_type_field = #{unitTypeField} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by hmut.monitor_unit_type_id desc