change - 首页监控单元数量统计修改

main
wenjy 3 years ago
parent e12f665a83
commit 5262d2ad6f

@ -70,12 +70,18 @@ public class IndexController {
SysUser sysUser = ShiroUtils.getSysUser(); SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
for (SysRole sysRole : sysRoles) { if(!ShiroUtils.getLoginName().equals("admin")){
// for (SysRole sysRole : sysRoles) {
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); //
baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
}
}else{
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos = List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
} }
@ -139,51 +145,67 @@ public class IndexController {
List<List<String>> data = new ArrayList<>(); List<List<String>> data = new ArrayList<>();
List<String> header = List<String> header =
new ArrayList<String>() { new ArrayList<String>() {
{ {
this.add("名称"); this.add("名称");
this.add("监控数量"); this.add("监控数量");
this.add("告警数量"); this.add("告警数量");
} }
}; };
List<BaseMonitorunitType> baseMonitorunitTypes = List<BaseMonitorunitType> baseMonitorunitTypes =
baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtoList = new ArrayList<BaseMonitorunitInfoDto>(); List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtoList = new ArrayList<BaseMonitorunitInfoDto>();
SysUser sysUser = ShiroUtils.getSysUser(); SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
for (SysRole sysRole : sysRoles) {
// if(!ShiroUtils.getLoginName().equals("admin")){
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); for (SysRole sysRole : sysRoles) {
baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); //
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
}
}else {
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos = List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
} }
baseMonitorunitTypes.forEach(
x -> { for (BaseMonitorunitType baseMonitorunitType : baseMonitorunitTypes) {
List<BaseMonitorunitInfoDto> collect = List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtoList1 =
baseMonitorunitInfoDtoList.stream() baseMonitorunitInfoDtoList.stream()
.filter( .filter(
y -> y ->!y.getParentId().isEmpty()&& y.getMonitorunitType().equals(baseMonitorunitType.getMonitorunittypeId()))
!y.getParentId().isEmpty() .collect(Collectors.toList());
&& y.getMonitorunitType().equals(x.getMonitorunittypeId())) if(baseMonitorunitInfoDtoList1.size() > 0){
.collect(Collectors.toList()); /*List<BaseMonitorunitInfoDto> collect2 =
List<BaseMonitorunitInfoDto> collect2 = baseMonitorunitInfoDtoList1.stream().filter(z -> z.getMonitorunitStatus().equals(0L)).collect(Collectors.toList());*/
collect.stream()
.filter(z -> z.getMonitorunitStatus().equals(0)) //List<Long> longList = baseMonitorunitInfoDtoList1.stream().filter(z -> z.getMonitorunitStatus().equals(0L)).map(BaseMonitorunitInfoDto::getMonitorunitStatus).collect(Collectors.toList());
.collect(Collectors.toList()); data.add(
data.add( new ArrayList<String>() {
new ArrayList<String>() { {
{ this.add(baseMonitorunitType.getMonitorunittypeName());
this.add(x.getMonitorunittypeName()); this.add(baseMonitorunitInfoDtoList1.size() + "");
this.add(collect.size() + ""); this.add(0 + "");
this.add(collect2.size() + ""); }
} });
}); }else{
}); data.add(
new ArrayList<String>() {
{
this.add(baseMonitorunitType.getMonitorunittypeName());
this.add(0 + "");
this.add(0 + "");
}
});
}
}
return JSONArray.toJSONString(new ScrollTableDto(header, data)); return JSONArray.toJSONString(new ScrollTableDto(header, data));
} catch (Exception ex) { } catch (Exception ex) {

Loading…
Cancel
Save