change - 首页监控单元统计添加角色权限

main
wenjy 3 years ago
parent ef2a05dd41
commit 45de52146f

@ -3,8 +3,11 @@ package com.ruoyi.web.controller.iot;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.dto.*; import com.ruoyi.system.domain.dto.*;
import com.ruoyi.system.service.*; import com.ruoyi.system.service.*;
@ -40,6 +43,9 @@ public class IndexController {
@Autowired private IRecordAlarmService recordAlarmService; @Autowired private IRecordAlarmService recordAlarmService;
@Autowired
private ISysRoleService iSysRoleService;
@GetMapping() @GetMapping()
public String index() { public String index() {
return "iot-ui/index"; return "iot-ui/index";
@ -57,16 +63,26 @@ public class IndexController {
public String getMonitorUnitCharts() { public String getMonitorUnitCharts() {
try { try {
List<BaseMonitorunitInfoDto> result = new ArrayList<BaseMonitorunitInfoDto>(); List<BaseMonitorunitInfoDto> result = new ArrayList<BaseMonitorunitInfoDto>();
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtoList = new ArrayList<BaseMonitorunitInfoDto>();
List<BaseMonitorunitType> baseMonitorunitTypes = List<BaseMonitorunitType> baseMonitorunitTypes =
baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
for (SysRole sysRole : sysRoles) {
//
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
}
baseMonitorunitTypes.forEach( baseMonitorunitTypes.forEach(
x -> { x -> {
List<BaseMonitorunitInfoDto> collect = List<BaseMonitorunitInfoDto> collect =
baseMonitorunitInfoDtos.stream() baseMonitorunitInfoDtoList.stream()
.filter( .filter(
y -> y ->
!y.getParentId().isEmpty() !y.getParentId().isEmpty()

@ -58,6 +58,8 @@ public class BaseMonitorunitInfo extends TreeEntity
private String monitorunitImage; private String monitorunitImage;
private Long roleId;
public void setObjId(Long objId) public void setObjId(Long objId)
{ {
this.objId = objId; this.objId = objId;
@ -129,6 +131,14 @@ public class BaseMonitorunitInfo extends TreeEntity
this.monitorunitImage = monitorunitImage; this.monitorunitImage = monitorunitImage;
} }
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -37,6 +37,16 @@ public interface BaseMonitorunitInfoMapper
*/ */
public List<BaseMonitorunitInfoDto> selectBaseMonitorunitInfoDtoList(BaseMonitorunitInfo baseMonitorunitInfo); public List<BaseMonitorunitInfoDto> selectBaseMonitorunitInfoDtoList(BaseMonitorunitInfo baseMonitorunitInfo);
/**
*
* @author WenJY
* @date 2022-05-15 11:28
* @param baseMonitorunitInfo
* @return java.util.List<com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto>
*/
public List<BaseMonitorunitInfoDto> selectBaseMonitorunitInfoDtoListByRoleId(BaseMonitorunitInfo baseMonitorunitInfo);
/** /**
* *
* *

@ -61,6 +61,11 @@ public class BaseMonitorunitInfoServiceImpl implements IBaseMonitorunitInfoServi
@Override @Override
public List<BaseMonitorunitInfoDto> selectBaseMonitorunitInfoDtoList( public List<BaseMonitorunitInfoDto> selectBaseMonitorunitInfoDtoList(
BaseMonitorunitInfo baseMonitorunitInfo) { BaseMonitorunitInfo baseMonitorunitInfo) {
if(baseMonitorunitInfo.getRoleId() != null){
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoDtoListByRoleId(baseMonitorunitInfo);
}
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
} }

@ -91,6 +91,9 @@ public class SysRoleServiceImpl implements ISysRoleService
{ {
List<SysRole> userRoles = roleMapper.selectRolesByUserId(userId); List<SysRole> userRoles = roleMapper.selectRolesByUserId(userId);
List<SysRole> roles = selectRoleAll(); List<SysRole> roles = selectRoleAll();
if (roles.size() == 0){
return userRoles;
}
for (SysRole role : roles) for (SysRole role : roles)
{ {
for (SysRole userRole : userRoles) for (SysRole userRole : userRoles)

@ -17,6 +17,7 @@
<result property="updateBy" column="Update_By" /> <result property="updateBy" column="Update_By" />
<result property="updateTime" column="Update_Time" /> <result property="updateTime" column="Update_Time" />
<result property="parentName" column="parent_name" /> <result property="parentName" column="parent_name" />
<result property="roleId" column="role_id" />
<result property="monitorunitStatus" column="Monitorunit_Status" /> <result property="monitorunitStatus" column="Monitorunit_Status" />
<result property="monitorunitImage" column="monitorunit_Image" /> <result property="monitorunitImage" column="monitorunit_Image" />
</resultMap> </resultMap>
@ -77,6 +78,28 @@
order by t1.objId order by t1.objId
</select> </select>
<select id="selectBaseMonitorunitInfoDtoListByRoleId" parameterType="BaseMonitorunitInfo" resultMap="BaseMonitorunitInfoDtoResult">
select t2.objid, t2.monitorunit_id, t2.monitorunit_name,t2.monitorunit_Status, t2.parent_id, t4.MonitorUnit_Name as parent_name,
t2.monitorunit_type,t3.MonitorUnitType_Name, t2.substation_id,t5.Substation_Name,t2.Monitorunit_Image,
t2.enable_flag,t2.Create_Time
from sys_role_monitorinfo t1
left join base_monitorunit_info t2 on t1.monitorUnit_Id = t2.MonitorUnit_Id
left join base_monitorunit_type t3 on t2.MonitorUnit_Type = t3.MonitorUnitType_Id
left join base_monitorunit_info t4 on t2.Parent_Id = t4.MonitorUnit_Id
left join base_substation_info t5 on t2.Substation_Id = t5.Substation_Id
<where>
<if test="roleId != null"> and t1.role_id = #{roleId}</if>
<if test="monitorunitId != null and monitorunitId != ''"> and t2.MonitorUnit_Id like concat('%', #{monitorunitId}, '%')</if>
<if test="monitorunitName != null and monitorunitName != ''"> and t2.MonitorUnit_Name like concat('%', #{monitorunitName}, '%')</if>
<if test="parentId != null and parentId != ''"> and t2.Parent_Id = #{parentId}</if>
<if test="monitorunitType != null and monitorunitType != ''"> and t2.MonitorUnit_Type = #{monitorunitType}</if>
<if test="substationId != null and substationId != ''"> and t2.Substation_Id = #{substationId}</if>
<if test="enableFlag != null and enableFlag != ''"> and t2.Enable_Flag = #{enableFlag}</if>
<if test="monitorunitStatus != null and monitorunitStatus != '' "> and t2.Monitorunit_Status = #{monitorunitStatus}</if>
</where>
order by t2.objId
</select>
<select id="selectBaseMonitorunitInfoByObjId" parameterType="Long" resultMap="BaseMonitorunitInfoResult"> <select id="selectBaseMonitorunitInfoByObjId" parameterType="Long" resultMap="BaseMonitorunitInfoResult">
select t.ObjId, t.MonitorUnit_Id, t.MonitorUnit_Name,t.monitorunit_status, t.Monitorunit_Image,t.Parent_Id, t.MonitorUnit_Type, t.Substation_Id, t.Enable_Flag, t.Create_By, t.Create_Time, t.Update_By, t.Update_Time, p.MonitorUnit_Name as parent_name select t.ObjId, t.MonitorUnit_Id, t.MonitorUnit_Name,t.monitorunit_status, t.Monitorunit_Image,t.Parent_Id, t.MonitorUnit_Type, t.Substation_Id, t.Enable_Flag, t.Create_By, t.Create_Time, t.Update_By, t.Update_Time, p.MonitorUnit_Name as parent_name
from base_monitorunit_info t from base_monitorunit_info t

Loading…
Cancel
Save