change - 智慧场景数据权限

main
wenjy 3 years ago
parent 3474a2ce0a
commit 25a8da5e1d

@ -3,6 +3,9 @@ package com.ruoyi.web.controller.iot;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.dto.BaseAlarmModuleDto;
import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto;
@ -41,6 +44,9 @@ public class WisdomScenarioContorller extends BaseController {
@Autowired private IRecordAlarmService recordAlarmService;
@Autowired
private ISysRoleService iSysRoleService;
/**
* :
*
@ -53,8 +59,26 @@ public class WisdomScenarioContorller extends BaseController {
@ResponseBody
public String quantityStatistics(String monitorUnitType) {
List<BaseMonitorunitInfo> baseMonitorunitInfos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
List<BaseMonitorunitInfo> baseMonitorunitInfos = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
if(!ShiroUtils.getLoginName().equals("admin")){
for (SysRole sysRole : sysRoles) {
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfos.addAll(baseMonitorunitInfos1);
}
}else {
List<BaseMonitorunitInfo> baseMonitorunitInfos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
baseMonitorunitInfos.addAll(baseMonitorunitInfos1);
}
List<BaseMonitorunitInfo> collect =
baseMonitorunitInfos.stream()
.filter(
@ -65,10 +89,26 @@ public class WisdomScenarioContorller extends BaseController {
.collect(Collectors.toList());
int sensorAmount = 0;
for (BaseMonitorunitInfo x : collect) {
List<BaseSensorInfoDto> baseSensorInfoDtos =
baseSensorInfoService.selectBaseSensorInfoList(
new BaseSensorInfo(null, null, null, x.getMonitorunitId()));
sensorAmount = sensorAmount + baseSensorInfoDtos.size();
List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
if(ShiroUtils.getLoginName().equals("admin")){
BaseSensorInfo baseSensorInfo = new BaseSensorInfo();
baseSensorInfo.setMonitorunitId(x.getMonitorunitId());
List<BaseSensorInfoDto> baseSensorInfoDtos1 =
baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
sensorAmount = sensorAmount + baseSensorInfoDtos.size();
}else {
for (SysRole sysRole : sysRoles) {
BaseSensorInfo baseSensorInfo = new BaseSensorInfo();
baseSensorInfo.setMonitorunitId(x.getMonitorunitId());
baseSensorInfo.setRoleId(sysRole.getRoleId());
List<BaseSensorInfoDto> baseSensorInfoDtos1 =
baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
}
sensorAmount = sensorAmount + baseSensorInfoDtos.size();
}
}
int finalSensorAmount = sensorAmount;
@ -93,8 +133,27 @@ public class WisdomScenarioContorller extends BaseController {
@GetMapping("/getMonitorUnitModule")
@ResponseBody
public String getMonitorUnitModule(String monitorUnitType) {
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
if(!ShiroUtils.getLoginName().equals("admin")){
for (SysRole sysRole : sysRoles) {
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoDtos.addAll(baseMonitorunitInfos1);
}
}else {
List<BaseMonitorunitInfoDto> baseMonitorunitInfos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
baseMonitorunitInfoDtos.addAll(baseMonitorunitInfos1);
}
/*List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());*/
List<BaseMonitorunitInfoDto> collect =
baseMonitorunitInfoDtos.stream()
.filter(
@ -122,9 +181,26 @@ public class WisdomScenarioContorller extends BaseController {
@GetMapping("/getAlarmModule")
@ResponseBody
public String getAlarmModule(String monitorUnitId) {
List<BaseAlarmModuleDto> baseAlarmModuleDtos = new ArrayList();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
if(!ShiroUtils.getLoginName().equals("admin")){
for (SysRole sysRole : sysRoles) {
BaseAlarmModule baseAlarmModule = new BaseAlarmModule();
baseAlarmModule.setRoleId(sysRole.getRoleId());
baseAlarmModule.setMonitorunitId(monitorUnitId);
List<BaseAlarmModuleDto> baseAlarmModuleDtos1 = baseAlarmModuleService.selectAlarmModuleAmountList(baseAlarmModule);
baseAlarmModuleDtos.addAll(baseAlarmModuleDtos1);
}
}else {
List<BaseAlarmModuleDto> baseAlarmModuleDtos1 = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
baseAlarmModuleDtos.addAll(baseAlarmModuleDtos1);
}
List<BaseAlarmModuleDto> baseAlarmModuleDtos =
baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
//List<BaseAlarmModuleDto> baseAlarmModuleDtos =baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
if (baseAlarmModuleDtos.size() < 6) {
List<BaseAlarmModuleDto> info = new ArrayList<>();
@ -161,11 +237,32 @@ public class WisdomScenarioContorller extends BaseController {
public String getAlarmInfo(String monitorUnitId) {
if (!monitorUnitId.isEmpty()) {
List<RecordAlarmDto> recordAlarmDtos = recordAlarmService.selectAlarmInfoList(monitorUnitId);
String s = JSONArray.toJSONString(recordAlarmDtos);
if(ShiroUtils.getLoginName().equals("admin")){
List<RecordAlarmDto> recordAlarmDtos = recordAlarmService.selectAlarmInfoList(monitorUnitId);
String s = JSONArray.toJSONString(recordAlarmDtos);
return s;
}else{
List<RecordAlarmDto> recordAlarmDtos = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
for (SysRole sysRole : sysRoles) {
RecordAlarm recordAlarm = new RecordAlarm();
recordAlarm.setRoleId(sysRole.getRoleId());
recordAlarm.setMonitorUnitTypeId(monitorUnitId);
List<RecordAlarmDto> recordAlarmDtos1 = recordAlarmService.selectAlarmInfoListByRoleId(recordAlarm);
recordAlarmDtos.addAll(recordAlarmDtos1);
}
String s = JSONArray.toJSONString(recordAlarmDtos);
return s;
}
return s;
}
return null;

@ -72,6 +72,8 @@ public class BaseAlarmModule extends BaseEntity
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedTime;
private Long roleId;
public Long getObjId() {
return objId;
}
@ -185,6 +187,14 @@ public class BaseAlarmModule extends BaseEntity
this.alarmCategoryName = alarmCategoryName;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -57,6 +57,8 @@ public class RecordAlarm extends BaseEntity
private Long roleId;
private String monitorUnitTypeId;
public void setSensorId(String sensorId)
{
this.sensorId = sensorId;
@ -168,6 +170,14 @@ public class RecordAlarm extends BaseEntity
this.roleId = roleId;
}
public String getMonitorUnitTypeId() {
return monitorUnitTypeId;
}
public void setMonitorUnitTypeId(String monitorUnitTypeId) {
this.monitorUnitTypeId = monitorUnitTypeId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -68,6 +68,7 @@ public interface BaseAlarmModuleMapper
* @return java.util.List<com.ruoyi.system.domain.dto.BaseAlarmModuleDto>
*/
public List<BaseAlarmModuleDto> selectAlarmModuleAmountList(BaseAlarmModule baseAlarmModule);
public List<BaseAlarmModuleDto> selectAlarmModuleAmountListByRoleId(BaseAlarmModule baseAlarmModule);
/**
*

@ -71,6 +71,8 @@ public interface RecordAlarmMapper
*/
public List<RecordAlarmDto> selectAlarmInfoList(String monitorUnitTypeId);
public List<RecordAlarmDto> selectAlarmInfoListByRoleId(RecordAlarm recordAlarm);
/**
* ,
* @author WenJY

@ -69,6 +69,8 @@ public interface IRecordAlarmService
*/
public List<RecordAlarmDto> selectAlarmInfoList(String monitorUnitTypeId);
public List<RecordAlarmDto> selectAlarmInfoListByRoleId(RecordAlarm recordAlarm);
/**
*
* @author WenJY

@ -103,6 +103,11 @@ public class BaseAlarmModuleServiceImpl implements IBaseAlarmModuleService
*/
@Override
public List<BaseAlarmModuleDto> selectAlarmModuleAmountList(BaseAlarmModule baseAlarmModule) {
if(baseAlarmModule.getRoleId() != null && baseAlarmModule.getRoleId() > 1){
return baseAlarmModuleMapper.selectAlarmModuleAmountListByRoleId(baseAlarmModule);
}
return baseAlarmModuleMapper.selectAlarmModuleAmountList(baseAlarmModule);
}

@ -111,6 +111,11 @@ public class RecordAlarmServiceImpl implements IRecordAlarmService
return recordAlarmMapper.selectAlarmInfoList(monitorUnitTypeId);
}
@Override
public List<RecordAlarmDto> selectAlarmInfoListByRoleId(RecordAlarm recordAlarm) {
return recordAlarmMapper.selectAlarmInfoListByRoleId(recordAlarm);
}
/**
* ,
* @author WenJY

@ -157,6 +157,26 @@
order by t1.Order_Flag
</select>
<select id="selectAlarmModuleAmountListByRoleId" parameterType="BaseAlarmModule" resultMap="BaseAlarmModuleDtoResult">
select t1.AlarmModule_Text,t1.Order_Flag,count(t4.Alarm_Value) as alarmModuleAmount
from base_alarm_module t1
left join base_monitorunit_info t2 on t2.MonitorUnit_Type = t1.MonitorUnit_Id
left join base_sensor_info t3 on t2.MonitorUnit_Id = t3.MonitorUnit_Id
left join (
select t3.*,t1.role_id
from sys_role_monitorinfo t1
left join base_sensor_info t2 on t1.monitorUnit_Id = t2.MonitorUnit_Id
left join record_alarm t3 on t2.Sensor_Id = t3.Sensor_Id
where t3.Sensor_Id is not null
) t4 on t3.Sensor_Id = t4.Sensor_Id and t1.AlarmType_Id = t4.AlarmType_Id
<where>
<if test="monitorunitId != null and monitorunitId != ''">and t1.MonitorUnit_Id = #{monitorunitId}</if>
<if test="roleId != null ">and t4.role_id = #{roleId}</if>
</where>
group by t1.AlarmModule_Text,t1.Order_Flag
order by t1.Order_Flag
</select>
<select id="selectAlarmCategoryAmountList" parameterType="BaseAlarmModule" resultMap="BaseAlarmModuleDtoResult">
select a.AlarmModule_Text,sum(a.alarmModuleAmount) as alarmModuleAmount
from (select t5.AlarmCategory_Name as AlarmModule_Text,count(t4.Alarm_Value) as alarmModuleAmount

@ -167,6 +167,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and t4.Collect_Time is not null
</select>
<select id="selectAlarmInfoListByRoleId" parameterType="RecordAlarm" resultMap="RecordAlarmDtoResult">
select t1.AlarmModule_Id,
t1.AlarmModule_Text,
t2.MonitorUnit_Name,
t3.Sensor_Location,
t3.Sensor_Name,
t4.Min_Value,
t4.Max_Value,
t4.Alarm_Uid,
t4.Alarm_Value,
t4.Collect_Time,
t4.Dispose_Flag
from base_alarm_module t1
left join base_monitorunit_info t2 on t2.MonitorUnit_Type = t1.MonitorUnit_Id
left join base_sensor_info t3 on t2.MonitorUnit_Id = t3.MonitorUnit_Id
left join (
select t3.*,t1.role_id
from sys_role_monitorinfo t1
left join base_sensor_info t2 on t1.monitorUnit_Id = t2.MonitorUnit_Id
left join record_alarm t3 on t2.Sensor_Id = t3.Sensor_Id
where t3.Sensor_Id is not null
) t4 on t3.Sensor_Id = t4.Sensor_Id and t1.AlarmType_Id = t4.AlarmType_Id
<where>
t4.Collect_Time between DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 30 DAY), '%Y-%m-%d 00:00:00') and DATE_FORMAT(now(), '%Y-%m-%d 23:59:59')
and t4.Collect_Time is not null
<if test="monitorUnitTypeId != null and monitorUnitTypeId != '' ">and t1.MonitorUnit_Id = #{monitorUnitTypeId}</if>
<if test="roleId != null">and t4.role_id = #{roleId}</if>
</where>
</select>
<select id="selectAlarmTrendList" parameterType="String" resultMap="RecordAlarmDtoResult">
select substring(Collect_Time,6,5) as Collect_Time,count(*) as Alarm_Value
from record_alarm

Loading…
Cancel
Save