服务器配置管理接口增加相关注解

邮箱配置管理接口增加相关注解
数据库配置管理接口增加相关注解
报警规则管理接口增加相关注解
报警日志管理接口增加相关注解
报警联系人组管理接口增加相关注解
系统启动类增加controller层,报警联系人组声明接口使用feignClient调用
台站运行管理核设施经纬度信息历史数据错误,经纬度交换字段推送
This commit is contained in:
qiaoqinzheng 2023-06-15 14:02:04 +08:00
parent f8c4685b45
commit 6daca4ca17
24 changed files with 203 additions and 202 deletions

View File

@ -17,6 +17,11 @@
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
<!-- feign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.controller;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.AlarmContactGroup;
@ -15,26 +16,31 @@ public class AlarmContactGroupController {
private IAlarmContactGroupService alarmContactGroupService;
@GetMapping("findPage")
@ApiOperation(value = "分页查询报警联系人组信息", notes = "分页查询报警联系人组信息")
public Result findPage(QueryRequest queryRequest, AlarmContactGroup alarmContactGroup){
return alarmContactGroupService.findPage(queryRequest, alarmContactGroup);
}
@GetMapping("findInfo")
@ApiOperation(value = "查询报警联系人组信息详情", notes = "查询报警联系人组信息详情")
public Result findPage(String id){
return alarmContactGroupService.findInfo(id);
}
@PostMapping("create")
@ApiOperation(value = "新增报警人联系人组", notes = "新增报警联系人组")
public Result findPage(@RequestBody AlarmContactGroup alarmContactGroup){
return alarmContactGroupService.create(alarmContactGroup);
}
@PutMapping("update")
@ApiOperation(value = "修改报警人联系人组", notes = "修改报警联系人组")
public Result update(@RequestBody AlarmContactGroup alarmContactGroup){
return alarmContactGroupService.update(alarmContactGroup);
}
@DeleteMapping("deleteById")
@ApiOperation(value = "删除报警人联系人组", notes = "删除报警联系人组")
public Result deleteById(String id){
return alarmContactGroupService.deleteById(id);
}

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.controller;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.AlarmLog;
@ -15,26 +16,31 @@ public class AlarmLogController {
private IAlarmLogService alarmLogService;
@GetMapping("findPage")
@ApiOperation(value = "分页查询报警日志信息", notes = "分页查询报警日志信息")
public Result findPage(QueryRequest queryRequest, AlarmLog alarmLog){
return alarmLogService.findPage(queryRequest, alarmLog);
}
@GetMapping("findInfo")
@ApiOperation(value = "查询报警日志信息详情", notes = "查询报警日志信息详情")
public Result findPage(String id){
return alarmLogService.findInfo(id);
}
@PostMapping("create")
@ApiOperation(value = "新增报警日志", notes = "新增报警日志")
public Result findPage(@RequestBody AlarmLog alarmLog){
return alarmLogService.create(alarmLog);
}
@PutMapping("update")
@ApiOperation(value = "修改报警日志", notes = "修改报警日志")
public Result update(@RequestBody AlarmLog alarmLog){
return alarmLogService.update(alarmLog);
}
@DeleteMapping("deleteById")
@ApiOperation(value = "删除报警日志", notes = "删除报警日志")
public Result deleteById(String id){
return alarmLogService.deleteById(id);
}

View File

@ -1,11 +1,13 @@
package org.jeecg.modules.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.AlarmRule;
import org.jeecg.modules.service.IAlarmRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
@RestController
@ -17,26 +19,31 @@ public class AlarmRuleController {
private IAlarmRuleService alarmRuleService;
@GetMapping("findPage")
@ApiOperation(value = "分页查询报警规则信息", notes = "分页查询报警规则信息")
public Result findPage(QueryRequest queryRequest, AlarmRule alarmRule){
return alarmRuleService.findPage(queryRequest, alarmRule);
}
@GetMapping("findInfo")
@ApiOperation(value = "查看规则信息详情", notes = "查看规则信息详情")
public Result findPage(String id){
return alarmRuleService.findInfo(id);
}
@PostMapping("create")
@ApiOperation(value = "新增规则信息", notes = "新增规则信息")
public Result findPage(@RequestBody AlarmRule alarmRule){
return alarmRuleService.create(alarmRule);
}
@PutMapping("update")
@ApiOperation(value = "修改规则信息", notes = "修改规则信息")
public Result update(@RequestBody AlarmRule alarmRule){
return alarmRuleService.update(alarmRule);
}
@DeleteMapping("deleteById")
@ApiOperation(value = "删除规则信息", notes = "删除规则信息")
public Result deleteById(String id){
return alarmRuleService.deleteById(id);
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.SysDatabase;
@ -9,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Date;
@RestController
@ -20,31 +22,37 @@ public class SysDatabaseController {
private ISysDatabaseService sysDatabaseService;
@GetMapping("findPage")
@ApiOperation(value = "分页查询数据库配置信息", notes = "分页查询数据库配置信息")
public Result findPage(QueryRequest queryRequest, SysDatabase sysDatabase){
return sysDatabaseService.findPage(queryRequest, sysDatabase);
}
@GetMapping("findInfo")
@ApiOperation(value = "查询数据库配置信息详情", notes = "查询数据库配置信息详情")
public Result findInfo(String id){
return sysDatabaseService.findInfo(id);
}
@PostMapping("create")
@ApiOperation(value = "新增数据库配置信息", notes = "新增数据库配置信息")
public Result create(@RequestBody SysDatabase sysDatabase){
return sysDatabaseService.create(sysDatabase);
}
@PutMapping("update")
@ApiOperation(value = "修改数据库配置信息", notes = "修改数据库配置信息")
public Result update(@RequestBody SysDatabase sysDatabase){
return sysDatabaseService.update(sysDatabase);
}
@DeleteMapping("deleteById")
@ApiOperation(value = "删除数据库配置信息", notes = "删除数据库配置信息")
public Result deleteById(String id){
return sysDatabaseService.deleteById(id);
}
@GetMapping("findAlarmHistory")
@ApiOperation(value = "查询数据库历史报警信息", notes = "查询数据库历史报警信息")
public Result findAlarmHistory(String databaseId,
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
return sysDatabaseService.findAlarmHistory(databaseId, startTime, endTime);

View File

@ -51,6 +51,7 @@ public class SysEmailController {
}
@GetMapping("findAlarmHistory")
@ApiOperation(value = "查询邮箱历史报警信息", notes = "查询邮箱历史报警信息")
public Result findAlarmHistory(String emailId,
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
return sysEmailService.findAlarmHistory(emailId, startTime, endTime);

View File

@ -51,6 +51,7 @@ public class SysServerController {
}
@GetMapping("findAlarmHistory")
@ApiOperation(value = "查询服务器历史报警信息", notes = "查询服务器历史报警信息")
public Result findAlarmHistory(String serverId,
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,@DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
return sysServerService.findAlarmHistory(serverId, startTime, endTime);

View File

@ -44,6 +44,10 @@ public class AlarmContactGroup implements Serializable {
@TableField(exist = false)
List<String> userIds;
@TableField(exist = false)
List<SysUser> users;
@TableField(exist = false)
Integer personNumber;
}

View File

@ -1,27 +0,0 @@
package org.jeecg.modules.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class AlarmContactGroupVo implements Serializable {
private String id;
private String name;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
List<SysUser> users;
Integer personNumber;
}

View File

@ -1,52 +0,0 @@
package org.jeecg.modules.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
* 用户角色表
* </p>
*
* @Author scott
* @since 2018-12-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysUserRole implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 用户id
*/
private String userId;
/**
* 角色id
*/
private String roleId;
/**租户ID*/
private Integer tenantId;
public SysUserRole() {
}
public SysUserRole(String userId, String roleId) {
this.userId = userId;
this.roleId = roleId;
}
}

View File

@ -1,7 +0,0 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.AlarmContactGroupVo;
public interface AlarmContactGroupVoMapper extends BaseMapper<AlarmContactGroupVo> {
}

View File

@ -1,7 +0,0 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.SysRole;
public interface SysRoleMapper extends BaseMapper<SysRole> {
}

View File

@ -1,7 +0,0 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.SysUser;
public interface SysUserMapper extends BaseMapper<SysUser> {
}

View File

@ -1,7 +0,0 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.SysUserRole;
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
}

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.service;
import org.jeecg.modules.entity.SysUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Map;
@Component
@FeignClient(value = "jeecg-system")
public interface IAlarmSysUserService {
@RequestMapping("/alarmSysUser/findUserMap")
Map<String, SysUser> findUserMap();
}

View File

@ -1,13 +0,0 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.entity.SysUser;
import java.util.List;
import java.util.Map;
public interface ISysUserService extends IService<SysUser> {
Map<String ,SysUser> findUserList();
}

View File

@ -11,13 +11,11 @@ import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.entity.AlarmContactGroup;
import org.jeecg.modules.entity.AlarmContactGroupMember;
import org.jeecg.modules.entity.AlarmContactGroupVo;
import org.jeecg.modules.entity.SysUser;
import org.jeecg.modules.mapper.AlarmContactGroupMapper;
import org.jeecg.modules.mapper.AlarmContactGroupMemberMapper;
import org.jeecg.modules.mapper.AlarmContactGroupVoMapper;
import org.jeecg.modules.service.IAlarmContactGroupService;
import org.jeecg.modules.service.ISysUserService;
import org.jeecg.modules.service.IAlarmSysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -28,24 +26,22 @@ import java.util.stream.Collectors;
@Service("alarmContactGroupService")
public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupMapper, AlarmContactGroup> implements IAlarmContactGroupService {
@Autowired
private AlarmContactGroupVoMapper alarmContactGroupVoMapper;
@Autowired
private AlarmContactGroupMemberMapper alarmContactGroupMemberMapper;
@Autowired
private ISysUserService sysUserService;
private IAlarmSysUserService alarmSysUserService;
@Override
public Result findPage(QueryRequest queryRequest, AlarmContactGroup alarmContactGroup) {
Result result = new Result();
//获取用户信息
Map<String ,SysUser> userList = sysUserService.findUserList();
Page<AlarmContactGroupVo> page = new Page<>();
LambdaQueryWrapper<AlarmContactGroupVo> queryWrapper = new LambdaQueryWrapper<>();
Page<AlarmContactGroupVo> alarmContactGroupVoPage = alarmContactGroupVoMapper.selectPage(page, queryWrapper);
Map<String ,SysUser> userList = alarmSysUserService.findUserMap();
Page<AlarmContactGroup> page = new Page<>();
LambdaQueryWrapper<AlarmContactGroup> queryWrapper = new LambdaQueryWrapper<>();
Page<AlarmContactGroup> alarmContactGroupPage = this.baseMapper.selectPage(page, queryWrapper);
LambdaQueryWrapper<AlarmContactGroupMember> contactGroupMemberQueryWrapper = new LambdaQueryWrapper<>();
List<AlarmContactGroupMember> alarmContactGroupMembers = alarmContactGroupMemberMapper.selectList(contactGroupMemberQueryWrapper);
alarmContactGroupVoPage.getRecords().forEach(item->{
alarmContactGroupPage.getRecords().forEach(item->{
List<SysUser> sysUsers = new LinkedList<>();
//联系人组对应联系人信息不为空
if (CollectionUtils.isNotEmpty(alarmContactGroupMembers)){
@ -66,7 +62,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
}
});
result.setSuccess(true);
result.setResult(alarmContactGroupVoPage);
result.setResult(alarmContactGroupPage);
return result;
}

View File

@ -28,6 +28,8 @@ public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule
Result result = new Result();
Page<AlarmRule> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
LambdaQueryWrapper<AlarmRule> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Objects.nonNull(alarmRule.getEnabled()), AlarmRule::getEnabled, alarmRule.getEnabled());
queryWrapper.eq(StringUtils.isNotBlank(alarmRule.getSourceId()), AlarmRule::getSourceId, alarmRule.getSourceId());
Page<AlarmRule> alarmRulePage = this.baseMapper.selectPage(page, queryWrapper);
result.setSuccess(true);
result.setResult(alarmRulePage);

View File

@ -1,61 +0,0 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.entity.SysRole;
import org.jeecg.modules.entity.SysUser;
import org.jeecg.modules.entity.SysUserRole;
import org.jeecg.modules.mapper.SysRoleMapper;
import org.jeecg.modules.mapper.SysUserMapper;
import org.jeecg.modules.mapper.SysUserRoleMapper;
import org.jeecg.modules.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("sysUserService")
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
@Autowired
private SysUserRoleMapper sysUserRoleMapper;
@Autowired
private SysRoleMapper sysRoleMapper;
@Override
public Map<String ,SysUser> findUserList() {
Map<String ,SysUser> map = new HashMap<>();
LambdaQueryWrapper<SysUser> userQueryWrapper = new LambdaQueryWrapper<>();
List<SysUser> sysUsers = this.baseMapper.selectList(userQueryWrapper);
LambdaQueryWrapper<SysUserRole> userRoleQueryWrapper = new LambdaQueryWrapper<>();
List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectList(userRoleQueryWrapper);
LambdaQueryWrapper<SysRole> roleQueryWrapper = new LambdaQueryWrapper<>();
List<SysRole> sysRoles = sysRoleMapper.selectList(roleQueryWrapper);
List<SysRole> roles = new LinkedList<>();
//遍历所有用户信息
if (CollectionUtils.isNotEmpty(sysUsers)){
for (SysUser sysUser:sysUsers) {
if (CollectionUtils.isNotEmpty(sysUserRoles)){
//获取各用户匹配的权限集合
List<SysUserRole> userRoles = sysUserRoles.stream().filter(item -> item.getUserId().equals(sysUser.getId())).collect(Collectors.toList());
List<String> roleIds = userRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(sysRoles)){
for (SysRole role:sysRoles) {
if (roleIds.contains(role.getId())){
roles.add(role);
}
}
}
sysUser.setRoles(roles);
}
map.put(sysUser.getId(), sysUser);
}
}
return map;
}
}

View File

@ -52,4 +52,10 @@ public class StationOperationController {
return result;
}
@GetMapping("getDataReceivingStatus")
@ApiOperation(value = "查询台站监测数据信息", notes = "查询台站监测数据信息")
public void getDataReceivingStatus(List<String> stationIds){
stationOperationService.getDataReceivingStatus(stationIds);
}
}

View File

@ -38,4 +38,12 @@ public interface IStationOperationService extends IService<StationOperation> {
* @return
*/
Result getHitEquList(PointVo pointVo);
/**
* 查询台站监测数据
* @param stationIds
* @return
*/
Result getDataReceivingStatus(List<String> stationIds);
}

View File

@ -10,6 +10,7 @@ import com.spatial4j.core.shape.Rectangle;
import io.swagger.models.auth.In;
import org.jeecg.common.PointUtil;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.entity.Point;
import org.jeecg.modules.entity.PointVo;
@ -22,6 +23,9 @@ import org.jeecg.modules.service.IStationOperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
@ -66,8 +70,8 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
stationOperation.setStationName(nuclearfacility.getFacilityName());
stationOperation.setStationType("Nuclear Facility");
stationOperation.setAltitude("--");
stationOperation.setLon(PointUtil.calculate(nuclearfacility.getLongitude()));
stationOperation.setLat(PointUtil.calculate(nuclearfacility.getLatitude()));
stationOperation.setLon(PointUtil.calculate(nuclearfacility.getLatitude()));
stationOperation.setLat(PointUtil.calculate(nuclearfacility.getLongitude()));
stationOperation.setStatus(nuclearfacility.getStatus());
result.add(stationOperation);
}
@ -95,8 +99,8 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
HashMap<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) redisUtil.get("nuclearFacilityMap");
GardsNuclearfacility nuclearfacility = nuclearFacilityMap.get(stationId);
if (Objects.nonNull(nuclearfacility)){
nuclearfacility.setLongitude(PointUtil.calculate(nuclearfacility.getLongitude()));
nuclearfacility.setLatitude(PointUtil.calculate(nuclearfacility.getLatitude()));
nuclearfacility.setLongitude(PointUtil.calculate(nuclearfacility.getLatitude()));
nuclearfacility.setLatitude(PointUtil.calculate(nuclearfacility.getLongitude()));
result.setResult(nuclearfacility);
result.setSuccess(true);
}else {
@ -177,13 +181,13 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
point.setNuclearFacilityName(facilityInfoValue.getFacilityName());
if (StringUtils.isNotBlank(facilityInfoValue.getLongitude())){
String pointValue = PointUtil.calculate(facilityInfoValue.getLongitude());
facilityInfoValue.setLongitude(pointValue);
point.setLon(pointValue);
facilityInfoValue.setLatitude(pointValue);
point.setLat(pointValue);
}
if (StringUtils.isNotBlank(facilityInfoValue.getLatitude())){
String pointValue = PointUtil.calculate(facilityInfoValue.getLatitude());
facilityInfoValue.setLatitude(pointValue);
point.setLat(pointValue);
facilityInfoValue.setLongitude(pointValue);
point.setLon(pointValue);
}
nuclearPoints.add(point);
}
@ -239,6 +243,26 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
return result;
}
@Override
public Result getDataReceivingStatus(List<String> stationIds) {
if (CollectionUtils.isNotEmpty(stationIds)){
//获取当前日期时间
LocalDate endDate = LocalDate.now();
//将当前日期换算成
// endDate.minusDays();
//根据台站id
}
return null;
}
/**
* 获取外接正方形的最大最小经纬度
*

View File

@ -15,4 +15,4 @@ spring:
config:
import:
- optional:nacos:jeecg.yaml
- optional:nacos:jeecg-station-operation-@profile.name@.yaml
- optional:nacos:jeecg-@profile.name@.yaml

View File

@ -0,0 +1,91 @@
package org.jeecg.modules.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.entity.SysRole;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.entity.SysUserRole;
import org.jeecg.modules.system.mapper.SysDictItemMapper;
import org.jeecg.modules.system.mapper.SysRoleMapper;
import org.jeecg.modules.system.mapper.SysUserMapper;
import org.jeecg.modules.system.mapper.SysUserRoleMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("alarmSysUser")
public class AlarmSysUserController {
@Resource
private SysUserMapper sysUserMapper;
@Resource
private SysUserRoleMapper sysUserRoleMapper;
@Resource
private SysRoleMapper sysRoleMapper;
@Resource
private SysDictItemMapper sysDictItemMapper;
@GetMapping("findUserMap")
public Map<String, SysUser> findUserMap(){
Map<String ,SysUser> map = new HashMap<>();
LambdaQueryWrapper<SysUser> userQueryWrapper = new LambdaQueryWrapper<>();
List<SysUser> sysUsers = sysUserMapper.selectList(userQueryWrapper);
LambdaQueryWrapper<SysUserRole> userRoleQueryWrapper = new LambdaQueryWrapper<>();
List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectList(userRoleQueryWrapper);
LambdaQueryWrapper<SysRole> roleQueryWrapper = new LambdaQueryWrapper<>();
List<SysRole> sysRoles = sysRoleMapper.selectList(roleQueryWrapper);
List<SysRole> roles = new LinkedList<>();
//遍历所有用户信息
if (CollectionUtils.isNotEmpty(sysUsers)){
for (SysUser sysUser:sysUsers) {
if (CollectionUtils.isNotEmpty(sysUserRoles)){
//获取各用户匹配的权限集合
List<SysUserRole> userRoles = sysUserRoles.stream().filter(item -> item.getUserId().equals(sysUser.getId())).collect(Collectors.toList());
List<String> roleIds = userRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(sysRoles)){
for (SysRole role:sysRoles) {
if (roleIds.contains(role.getId())){
roles.add(role);
}
}
}
sysUser.setRoles(roles);
}
map.put(sysUser.getId(), sysUser);
}
}
return map;
}
@RequestMapping("findCacheTime")
public void findCacheTime(){
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
List<SysDictItem> sysDictItems = sysDictItemMapper.selectList(queryWrapper);
//获取缓存时间对应的值
Map<String, String> cacheTime = sysDictItems.stream().filter(item -> item.getItemText().equals("Cache time"))
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
//获取实际分度值
Map<String, String> scaleInterval = sysDictItems.stream().filter(item -> item.getItemText().equals("Scale interval"))
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
//获取时间线长度
Map<String, String> timelineLength = sysDictItems.stream().filter(item -> item.getItemText().equals("Timeline length"))
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
//获取更新间隔时间
Map<String, String> updateIntervalTime = sysDictItems.stream().filter(item -> item.getItemText().equals("Update interval time"))
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
}
}