change - 首页添加角色数据权限

main
wenjy 3 years ago
parent 45de52146f
commit 9647eb4729

@ -149,13 +149,23 @@ public class IndexController {
List<BaseMonitorunitType> baseMonitorunitTypes =
baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtoList = new ArrayList<BaseMonitorunitInfoDto>();
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(
x -> {
List<BaseMonitorunitInfoDto> collect =
baseMonitorunitInfoDtos.stream()
baseMonitorunitInfoDtoList.stream()
.filter(
y ->
!y.getParentId().isEmpty()
@ -202,8 +212,22 @@ public class IndexController {
@ResponseBody
public String getSensorStateCharts() {
try {
List<BaseSensorInfoDto> baseSensorInfoDtos =
baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo());
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
for (SysRole sysRole : sysRoles) {
BaseSensorInfo baseSensorInfo = new BaseSensorInfo();
baseSensorInfo.setEnableFlag(0L);
baseSensorInfo.setRoleId(sysRole.getRoleId());
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
}
/*List<BaseSensorInfoDto> baseSensorInfoDtos =
baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo());*/
List<String> yAxis =
new ArrayList<String>() {
{
@ -216,7 +240,7 @@ public class IndexController {
List<Integer> data =
new ArrayList<Integer>() {
{
this.add(
/*this.add(
baseSensorInfoDtos.stream()
.filter(x -> x.getSensorStatus() == 0)
.collect(Collectors.toList())
@ -230,7 +254,10 @@ public class IndexController {
baseSensorInfoDtos.stream()
.filter(x -> x.getSensorStatus() == 2)
.collect(Collectors.toList())
.size()); // 告警
.size()); // 告警*/
this.add(0);
this.add(baseSensorInfoDtos.size());
this.add(0);
}
};
@ -254,6 +281,7 @@ public class IndexController {
@ResponseBody
public String getSensorStateInfo() {
try {
List<List<String>> data = new ArrayList<>();
List<String> header =
@ -266,24 +294,49 @@ public class IndexController {
};
List<BaseSensorType> baseSensorTypeList =
baseSensorTypeService.selectBaseSensorTypeList(new BaseSensorType());
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
baseSensorTypeList.forEach(
x -> {
List<BaseSensorInfoDto> baseSensorInfoDtos =
baseSensorInfoService.selectBaseSensorInfoList(
new BaseSensorInfo(x.getSensortypeId(), 0L));
List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
for (SysRole sysRole : sysRoles) {
//
BaseSensorInfo baseSensorInfo = new BaseSensorInfo();
baseSensorInfo.setEnableFlag(0L);
baseSensorInfo.setRoleId(sysRole.getRoleId());
baseSensorInfo.setSensorType(x.getSensortypeId());
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
}
data.add(
new ArrayList<String>() {
{
this.add(x.getSensortypeName());
this.add(baseSensorInfoDtos.size() + "");
this.add(
baseSensorInfoDtos.stream()
.filter(z -> z.getSensorStatus() == 1)
.collect(Collectors.toList())
.size()
+ "");
}
});
new ArrayList<String>() {
{
this.add(x.getSensortypeName());
if(baseSensorInfoDtos != null){
this.add(baseSensorInfoDtos.size() + "");
if(baseSensorInfoDtos.size() > 0) {
/*this.add(
baseSensorInfoDtos.stream()
.filter(z -> z.getSensorStatus() == 1)
.collect(Collectors.toList())
.size()
+ "");*/
this.add(0+"");
}else{
this.add(0+"");
}
}else{
this.add(0+"");
this.add(0+"");
}
}
});
});
return JSONArray.toJSONString(new ScrollTableDto(header, data));
} catch (Exception ex) {
@ -311,16 +364,33 @@ public class IndexController {
@GetMapping("/quantityStatistics")
@ResponseBody
public String quantityStatistics() {
List<BaseSensorInfoDto> baseSensorInfoDtos =
baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo("", 0L));
List<BaseMonitorunitInfo> baseMonitorunitInfos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtoList = new ArrayList<BaseMonitorunitInfoDto>();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
for (SysRole sysRole : sysRoles) {
//
BaseSensorInfo baseSensorInfo = new BaseSensorInfo();
baseSensorInfo.setEnableFlag(0L);
baseSensorInfo.setRoleId(sysRole.getRoleId());
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
}
List<Integer> result =
new ArrayList<Integer>() {
{
this.add(baseSensorInfoDtos.size());
this.add(
baseMonitorunitInfos.stream()
baseMonitorunitInfoDtoList.stream()
.filter(x -> !x.getParentId().isEmpty() && x.getEnableFlag() == 0L)
.collect(Collectors.toList())
.size());
@ -340,7 +410,16 @@ public class IndexController {
@ResponseBody
public String getAlarmAmount() {
List<String> info = new ArrayList<>();
List<RecordAlarm> recordAlarms = recordAlarmService.selectRecordAlarmList(new RecordAlarm());
List<RecordAlarm> recordAlarms = 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());
List<RecordAlarm> recordAlarms1 = recordAlarmService.selectRecordAlarmList(recordAlarm);
recordAlarms.addAll(recordAlarms1);
}
if (recordAlarms.size() > 0) {
int size =
@ -409,7 +488,21 @@ public class IndexController {
List<String> dayByMonth = getSevenDate();
List<RecordAlarmDto> recordAlarmDtos = recordAlarmService.selectAlarmTrendList("");
List<RecordAlarmDto> recordAlarmDtos = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
if(ShiroUtils.getLoginName().equals("admin")){
List<RecordAlarmDto> recordAlarmDtos1 = recordAlarmService.selectAlarmTrendList("");
recordAlarmDtos.addAll(recordAlarmDtos1);
}else{
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
for (SysRole sysRole : sysRoles) {
RecordAlarm recordAlarm = new RecordAlarm();
recordAlarm.setRoleId(sysRole.getRoleId());
List<RecordAlarmDto> recordAlarmDtos1 = recordAlarmService.selectAlarmTrendListByRoleId(sysRole.getRoleId());
recordAlarmDtos.addAll(recordAlarmDtos1);
}
}
dayByMonth.forEach(
x -> {

@ -77,6 +77,8 @@ public class BaseSensorInfo extends BaseEntity
@Excel(name = "是否启用")
private Long enableFlag;
private Long roleId;
public void setObjId(Long objId)
{
this.objId = objId;
@ -177,6 +179,14 @@ public class BaseSensorInfo extends BaseEntity
return enableFlag;
}
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)

@ -55,6 +55,8 @@ public class RecordAlarm extends BaseEntity
private String endCollectTime;
private Long roleId;
public void setSensorId(String sensorId)
{
this.sensorId = sensorId;
@ -158,6 +160,14 @@ public class RecordAlarm extends BaseEntity
this.endCollectTime = endCollectTime;
}
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)

@ -30,6 +30,15 @@ public interface BaseSensorInfoMapper
*/
public List<BaseSensorInfoDto> selectBaseSensorInfoList(BaseSensorInfo baseSensorInfo);
/**
*
* @author WenJY
* @date 2022-05-15 12:49
* @param baseSensorInfo
* @return java.util.List<com.ruoyi.system.domain.dto.BaseSensorInfoDto>
*/
public List<BaseSensorInfoDto> selectBaseSensorInfoListByRoleId(BaseSensorInfo baseSensorInfo);
/**
*
*

@ -28,6 +28,8 @@ public interface RecordAlarmMapper
*/
public List<RecordAlarm> selectRecordAlarmList(RecordAlarm recordAlarm);
public List<RecordAlarm> selectRecordAlarmListByRoleId(RecordAlarm recordAlarm);
/**
*
*
@ -77,4 +79,6 @@ public interface RecordAlarmMapper
* @return java.util.List<com.ruoyi.system.domain.dto.RecordAlarmDto>
*/
public List<RecordAlarmDto> selectAlarmTrendList(String monitorUnitTypeId);
public List<RecordAlarmDto> selectAlarmTrendListByRoleId(Long roleId);
}

@ -78,4 +78,6 @@ public interface IRecordAlarmService
*/
public List<RecordAlarmDto> selectAlarmTrendList(String monitorUnitTypeId);
public List<RecordAlarmDto> selectAlarmTrendListByRoleId(Long roleId);
}

@ -51,7 +51,16 @@ public class BaseSensorInfoServiceImpl implements IBaseSensorInfoService
@Override
public List<BaseSensorInfoDto> selectBaseSensorInfoList(BaseSensorInfo baseSensorInfo)
{
return baseSensorInfoMapper.selectBaseSensorInfoList(baseSensorInfo);
try{
if(baseSensorInfo.getRoleId() != null && baseSensorInfo.getRoleId() > 1){
List<BaseSensorInfoDto> baseSensorInfoDtos = baseSensorInfoMapper.selectBaseSensorInfoListByRoleId(baseSensorInfo);
return baseSensorInfoDtos;
}
return baseSensorInfoMapper.selectBaseSensorInfoList(baseSensorInfo);
}catch (Exception ex) {
System.out.println(ex.getMessage());
return null;
}
}
/**

@ -43,6 +43,11 @@ public class RecordAlarmServiceImpl implements IRecordAlarmService
@Override
public List<RecordAlarm> selectRecordAlarmList(RecordAlarm recordAlarm)
{
if(recordAlarm.getRoleId() != null && recordAlarm.getRoleId() > 1){
return recordAlarmMapper.selectRecordAlarmListByRoleId(recordAlarm);
}
return recordAlarmMapper.selectRecordAlarmList(recordAlarm);
}
@ -118,4 +123,9 @@ public class RecordAlarmServiceImpl implements IRecordAlarmService
return recordAlarmMapper.selectAlarmTrendList(monitorUnitTypeId);
}
@Override
public List<RecordAlarmDto> selectAlarmTrendListByRoleId(Long roleId) {
return recordAlarmMapper.selectAlarmTrendListByRoleId(roleId);
}
}

@ -20,6 +20,7 @@
<result property="createTime" column="Create_Time"/>
<result property="updateBy" column="Update_By"/>
<result property="updateTime" column="Update_Time"/>
<result property="roleId" column="role_id"/>
</resultMap>
<resultMap type="BaseSensorInfoDto" id="BaseSensorInfoDtoResult">
@ -103,6 +104,44 @@
</where>
</select>
<select id="selectBaseSensorInfoListByRoleId" parameterType="BaseSensorInfo" resultMap="BaseSensorInfoDtoResult">
select t2.ObjId,
t2.EdgeId,
t2.Sensor_Id,
t2.Sensor_Name,
t2.Sensor_Type,
t2.Sensor_Status,
t2.MonitorUnit_Id,
t3.MonitorUnit_Name,
t2.Sensor_Location,
t2.Sensor_Address,
t2.Order_Num,
t2.Enable_Flag,
t2.Create_By,
t2.Create_Time,
t2.Update_By,
t2.Update_Time
from sys_role_monitorinfo t1
left join base_sensor_info t2 on t1.monitorUnit_Id = t2.MonitorUnit_Id
left join base_monitorunit_info t3 on t2.MonitorUnit_Id = t3.MonitorUnit_Id
<where>
<if test="roleId != null ">and t1.role_id = #{roleId}</if>
<if test="EdgeId != null and EdgeId != ''">and t2.EdgeId = #{EdgeId}</if>
<if test="sensorId != null and sensorId != ''">and t2.Sensor_Id = #{sensorId}</if>
<if test="sensorName != null and sensorName != ''">and t2.Sensor_Name like concat('%', #{sensorName},
'%')
</if>
<if test="sensorType != null and sensorType != ''">and t2.Sensor_Type = #{sensorType}</if>
<if test="sensorStatus != null ">and t2.Sensor_Status = #{sensorStatus}</if>
<if test="monitorunitId != null and monitorunitId != ''">and t2.MonitorUnit_Id = #{monitorunitId}</if>
<if test="sensorLocation != null and sensorLocation != ''">and t2.Sensor_Location = #{sensorLocation}</if>
<if test="sensorAddress != null and sensorAddress != ''">and t2.Sensor_Address = #{sensorAddress}</if>
<if test="orderNum != null ">and t2.Order_Num = #{orderNum}</if>
<if test="enableFlag != null ">and t2.Enable_Flag = #{enableFlag}</if>
and t2.Sensor_Id is not null
</where>
</select>
<select id="selectBaseSensorInfoByObjId" parameterType="Long" resultMap="BaseSensorInfoDtoResult">
select t1.ObjId,
t1.EdgeId,

@ -53,6 +53,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != '' ">and Collect_Time between #{beginCollectTime} and #{endCollectTime}</if>
</where>
</select>
<select id="selectRecordAlarmListByRoleId" parameterType="RecordAlarm" resultMap="RecordAlarmResult">
select t3.Sensor_Id,
t3.AlarmType_Id,
t3.Min_Value,
t3.Alarm_Value,
t3.Alarm_Uid,
t3.Max_Value,
t3.Dispose_Flag,
t3.Collect_Time,
t3.Dispose_Mode,
t3.Alarm_Reason
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>
<if test="roleId != null"> and t1.role_id = #{roleId}</if>
<if test="sensorId != null and sensorId != ''"> and t3.Sensor_Id = #{sensorId}</if>
<if test="disposeFlag != null"> and t3.Dispose_Flag = #{disposeFlag}</if>
<if test="alarmtypeId != null and alarmtypeId != ''"> and t3.AlarmType_Id = #{alarmtypeId}</if>
<if test="minValue != null "> and t3.Min_Value = #{minValue}</if>
<if test="alarmValue != null "> and t3.Alarm_Value = #{alarmValue}</if>
<if test="maxValue != null "> and t3.Max_Value = #{maxValue}</if>
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != '' ">and t3.Collect_Time between #{beginCollectTime} and #{endCollectTime}</if>
and t3.Sensor_Id is not null
</where>
</select>
<select id="selectRecordAlarmBySensorId" parameterType="String" resultMap="RecordAlarmDtoResult">
select t1.AlarmModule_Id,
@ -147,4 +174,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by substring(Collect_Time,6,5)
</select>
<select id="selectAlarmTrendListByRoleId" parameterType="Long" resultMap="RecordAlarmDtoResult">
select substring(t3.Collect_Time,6,5) as Collect_Time,count(t3.Alarm_Uid) as Alarm_Value
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 t1.role_id = #{roleId} and t3.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')
group by substring(t3.Collect_Time,6,5)
</select>
</mapper>
Loading…
Cancel
Save