From f41dcc7468de9caff0cf003c8d48652d1b6b3c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E9=9B=AA=E4=BC=9F?= Date: Thu, 24 Oct 2024 14:41:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BAsheet=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E4=B8=89=E7=BA=A7=E9=A1=B5=E9=9D=A2=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E8=AE=B0=E5=BD=95=E5=BE=97=E5=8F=82=E6=95=B0=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HwMonitorPlatformController.java | 6 +++--- .../business/domain/VO/AlarmInfoExportVo.java | 4 ++-- .../mapper/HwDeviceModeFunctionMapper.java | 4 ++++ .../business/service/impl/HwDeviceServiceImpl.java | 14 +++++++++++++- .../com/ruoyi/business/utils/UnitExcelUtils.java | 6 +++--- .../mapper/business/HwAlarmInfoMapper.xml | 4 ++-- .../mapper/business/HwDeviceModeFunctionMapper.xml | 5 ++++- .../ruoyi/system/controller/SysDeptController.java | 3 ++- .../ruoyi/system/controller/SysPostController.java | 2 ++ .../ruoyi/system/controller/SysRoleController.java | 5 ++++- .../ruoyi/system/controller/SysUserController.java | 3 +++ .../system/service/impl/SysDeptServiceImpl.java | 4 ++++ .../system/service/impl/SysUserServiceImpl.java | 5 +++++ .../main/resources/mapper/system/SysDeptMapper.xml | 8 ++++---- .../main/resources/mapper/system/SysPostMapper.xml | 5 +++-- .../main/resources/mapper/system/SysRoleMapper.xml | 4 ++-- .../main/resources/mapper/system/SysUserMapper.xml | 6 +++--- 17 files changed, 63 insertions(+), 25 deletions(-) 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 aa18e70..9cfa02e 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 @@ -462,11 +462,11 @@ public class HwMonitorPlatformController extends BaseController { @RequiresPermissions("business:monitor:alarm") public void AlarmInfosExport(HttpServletResponse response,Date startTime,Date endTime) throws IOException, NoSuchFieldException, IllegalAccessException { List list1 = hwAlarmInfoService.selectUnitId(); - HashMap> map = new HashMap<>(); + HashMap> map = new HashMap<>(); for (Long unitId : list1) { List list2 = hwAlarmInfoService.selectAlarmInfoExport1(unitId,startTime,endTime); List attributes = hwMonitorUnitAttributeService.selectAttributes(unitId); - + HwMonitorUnit hwMonitorUnit = hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(unitId); List excelMap = new ArrayList(); LinkedHashMap attributeMap = new LinkedHashMap(); for (HwMonitorUnitAttribute attribute : attributes) { @@ -502,7 +502,7 @@ public class HwMonitorPlatformController extends BaseController { excelMap.add(voMap); } if (CollectionUtil.isNotEmpty(excelMap)){ - map.put(unitId,excelMap); + map.put(hwMonitorUnit.getMonitorUnitName(),excelMap); } } 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 8f214a2..d247fcb 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 @@ -19,8 +19,8 @@ public class AlarmInfoExportVo { @Excel(name = "报警位置") private String monitorUnitName; - @Excel(name = "报警级别名称") - private String alarmLevelName; +// @Excel(name = "报警级别名称") +// private String alarmLevelName; @Excel(name = "报警类型名称") private String alarmTypeName; diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeFunctionMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeFunctionMapper.java index 4a94095..0f20a08 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeFunctionMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeFunctionMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.business.mapper; import java.util.List; import com.ruoyi.business.domain.HwDeviceModeFunction; +import org.apache.ibatis.annotations.Param; /** * 设备模型功能Mapper接口 @@ -58,4 +59,7 @@ public interface HwDeviceModeFunctionMapper * @return 结果 */ public int deleteHwDeviceModeFunctionByModeFunctionIds(Long[] modeFunctionIds); + + String selectUbitByIdAndName(@Param("dataFunctionIdentifier") String dataFunctionIdentifier,@Param("modeId") Long modeId); + } 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 ec3105a..8a8775a 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 @@ -535,8 +535,20 @@ public class HwDeviceServiceImpl implements IHwDeviceService { Set functionIdentifiers = deviceLatestDataMap.keySet(); for (String dataFunctionIdentifier : functionIdentifiers) { if (functionIndentifierNameMap.get(dataFunctionIdentifier) != null) { + String unit; + if (dataFunctionIdentifier.equals("value1")){ + unit = hwDevieModeFunctionMapper.selectUbitByIdAndName("value",hwDevice.getDeviceModeId()); + }else { + unit = hwDevieModeFunctionMapper.selectUbitByIdAndName(dataFunctionIdentifier,hwDevice.getDeviceModeId()); + } + Object value; + if (unit == null){ + value = deviceLatestDataMap.get(dataFunctionIdentifier); + }else { + value = deviceLatestDataMap.get(dataFunctionIdentifier) + unit; + } ddValueMap.put(functionIndentifierNameMap.get(dataFunctionIdentifier), - deviceLatestDataMap.get(dataFunctionIdentifier)); + value); } } }); 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 5a2288b..069cc07 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 @@ -20,11 +20,11 @@ public class UnitExcelUtils { @Autowired private HwAlarmInfoMapper hwAlarmInfoMapper; - public void exportAlarmInfos(HttpServletResponse response, HashMap> map) throws IOException { + public void exportAlarmInfos(HttpServletResponse response, HashMap> map) throws IOException { Workbook bk = new XSSFWorkbook(); - for (Long aLong : map.keySet()) { + for (String aLong : map.keySet()) { List list3 = map.get(aLong); - Sheet unitId = bk.createSheet(aLong.toString()); + Sheet unitId = bk.createSheet(aLong); int row = 0; for (row = 0;row < list3.size();row++){ if (row == 0){ 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 d9af348..16d2c2a 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 @@ -135,7 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and alarm_releated_id = #{alarmReleatedId} and device_id = #{deviceId} and monitor_unit_id = #{monitorUnitId} - and hai.tenant_id = #{tenantId} + and hai.tenant_id = #{tenantId} and hai.scene_id = #{sceneId} and alarm_level_id = #{alarmLevelId} and alarm_type_id = #{alarmTypeId} @@ -295,7 +295,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select hai.monitor_unit_id,hai.alarm_info_id, hai.alarm_time, hmu.monitor_unit_name, - hal.alarm_level_name, +-- hal.alarm_level_name, hat.alarm_type_name, ha.area_name, -- hmu.monitor_unit_id, diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeFunctionMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeFunctionMapper.xml index b24d576..fd3fc50 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeFunctionMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeFunctionMapper.xml @@ -61,7 +61,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where mode_function_id = #{modeFunctionId} - + + insert into hw_device_mode_function diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java index 2722bf4..a4245b0 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java @@ -51,8 +51,9 @@ public class SysDeptController extends BaseController { @RequiresPermissions("system:dept:list") @GetMapping("/list") public AjaxResult list(SysDept dept) { - List depts = deptService.selectDeptList(dept); Long tenantId = SecurityUtils.getTenantId(); + dept.setTenantId(tenantId); + List depts = deptService.selectDeptList(dept); if (tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { depts.forEach(d -> { if (!d.getTenantId().equals(tenantId)) { diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java index ad93749..34d70d1 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java @@ -52,6 +52,8 @@ public class SysPostController extends BaseController @GetMapping("/list") public TableDataInfo list(SysPost post) { + Long tenantId = SecurityUtils.getTenantId(); + post.setTenantId(tenantId); startPage(); List list = postService.selectPostList(post); return getDataTable(list); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java index db2cc0b..7d3d1e1 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java @@ -52,9 +52,12 @@ public class SysRoleController extends BaseController @GetMapping("/list") public TableDataInfo list(SysRole role) { + Long tenantId = SecurityUtils.getTenantId(); + role.setTenantId(tenantId); startPage(); + List list = roleService.selectRoleList(role); - Long tenantId = SecurityUtils.getTenantId(); + if(tenantId.equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)){ list.forEach(r->{ if(!r.getTenantId().equals(tenantId)){ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java index 33b7145..377f7e6 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java @@ -164,6 +164,9 @@ public class SysUserController extends BaseController { public AjaxResult getAddedInfo(@PathVariable(value = "tenantId", required = false) Long tenantId) { userService.checkUserDataScope(null); AjaxResult ajax = AjaxResult.success(); + if (tenantId==null){ + tenantId = SecurityUtils.getLoginUser().getSysUser().getTenantId(); + } SysRole querySysRole = new SysRole(); querySysRole.setTenantId(tenantId); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 1d33a75..fb1a785 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; +import com.ruoyi.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.core.constant.UserConstants; @@ -44,6 +45,9 @@ public class SysDeptServiceImpl implements ISysDeptService { @Override @DataScope(deptAlias = "d", tenantAlias = "d") public List selectDeptList(SysDept dept) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + Long tenantId = loginUser.getSysUser().getTenantId(); + dept.setTenantId(tenantId); return deptMapper.selectDeptList(dept); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 5660356..ea4d054 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.stream.Collectors; import javax.validation.Validator; +import com.ruoyi.system.api.model.LoginUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -70,6 +71,10 @@ public class SysUserServiceImpl implements ISysUserService { @Override @DataScope(deptAlias = "d", userAlias = "u", tenantAlias = "u") public List selectUserList(SysUser user) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + Long tenantId = sysUser.getTenantId(); + user.setTenantId(tenantId); return userMapper.selectUserList(user); } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index e9f0bf6..72e5f4f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -44,13 +44,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND d.status = #{status} - + AND d.tenant_id = #{tenantId} - ${params.dataScope} - - ${params.tenantDataScope} + + + order by d.parent_id, d.order_num diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml index 112d0bf..f8d9bf7 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml @@ -27,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index f076d09..cc5a4da 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -54,13 +54,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') - + AND r.tenant_id = #{tenantId} ${params.dataScope} - ${params.tenantDataScope} +-- ${params.tenantDataScope} order by r.tenant_id,r.role_sort diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 1bfbda1..ab911aa 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -66,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND u.user_id = #{userId} - + AND u.tenant_id = #{tenantId} @@ -88,9 +88,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) )) - ${params.dataScope} +-- ${params.dataScope} - ${params.tenantDataScope} +-- ${params.tenantDataScope}