基于云平台系统功能调整

This commit is contained in:
xy
2026-01-07 19:21:21 +08:00
parent 09e2f329b7
commit 02578546f2
16 changed files with 288 additions and 44 deletions

View File

@@ -166,7 +166,6 @@ public class LineWarningServiceImpl extends MppServiceImpl<LineWarningMapper, Li
Map<String, DictData> targetMap = dataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity()));
//获取监测点和部门表关系
List<DeptLine> deptLines = deptLineFeignClient.getAllData().getData();
// Map<String, List<DeptLine>> deptLineMap = deptLines.stream().collect(Collectors.groupingBy(DeptLine::getLineId));
Map<String, DeptLine> deptLineMap = deptLines.stream().collect(Collectors.toMap(DeptLine::getLineId, Function.identity()));
//获取监测点按时间统计越限天数

View File

@@ -72,6 +72,7 @@
sys_dict_type sys_dict_type
WHERE sys_dict_data.type_id = sys_dict_type.id
AND sys_dict_type.code = #{dictTypeCode}
and sys_dict_type.state = 1
and sys_dict_data.state = 1
order by sort
</select>

View File

@@ -37,7 +37,7 @@ public class PqDashboardPageServiceImpl extends ServiceImpl<PqDashboardPageMappe
@Override
public Boolean addDashboard(PqDashboardPageParam pqDashboardPageParam) {
PqDashboardPage pqDashboardPage = new PqDashboardPage();
// checkName(pqDashboardPageParam,false);
checkName(pqDashboardPageParam,false);
BeanUtils.copyProperties(pqDashboardPageParam,pqDashboardPage);
//根据前端传递状态赋值
@@ -50,7 +50,7 @@ public class PqDashboardPageServiceImpl extends ServiceImpl<PqDashboardPageMappe
@Override
public Boolean updateDashboard(PqDashboardPageParam.UpdatePqDashboardPageParam updatePqDashboardPageParam) {
PqDashboardPage pqDashboardPage = new PqDashboardPage();
// checkName(updatePqDashboardPageParam,true);
checkName(updatePqDashboardPageParam,true);
BeanUtils.copyProperties(updatePqDashboardPageParam,pqDashboardPage);
this.updateById(pqDashboardPage);
@@ -122,7 +122,8 @@ public class PqDashboardPageServiceImpl extends ServiceImpl<PqDashboardPageMappe
private void checkName(PqDashboardPageParam pqDashboardPageParam, boolean isExcludeSelf) {
LambdaQueryWrapper<PqDashboardPage> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper
.eq(PqDashboardPage::getPageName, pqDashboardPageParam.getPageName());
.eq(PqDashboardPage::getPageName, pqDashboardPageParam.getPageName())
.eq(PqDashboardPage::getUserId, RequestUtil.getUserIndex());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (pqDashboardPageParam instanceof PqDashboardPageParam.UpdatePqDashboardPageParam) {

View File

@@ -52,6 +52,9 @@ public class ComponentDTO implements Serializable {
@ApiModelProperty("时间标识")
private String timeKey;
@ApiModelProperty("组件类型")
private String componentType;
@ApiModelProperty("子级")
List<ComponentDTO> children;

View File

@@ -24,7 +24,6 @@ import java.util.List;
public class ComponentParam {
@ApiModelProperty("资源id")
// @NotBlank(message = UserValidMessage.FUNCTION_ID_NOT_BLANK)
private String functionId;
@ApiModelProperty("节点")
@@ -37,7 +36,6 @@ public class ComponentParam {
private String name;
@ApiModelProperty("功能数组")
// @NotEmpty(message = UserValidMessage.FUNCTION_GROUP_NOT_BLANK)
private List<Integer> functionGroup;
@ApiModelProperty("排序")
@@ -65,6 +63,8 @@ public class ComponentParam {
@NotBlank(message = "系统类型不为空")
private String systemType;
@ApiModelProperty("组件类型")
private String componentType;
/**
* 组件更新操作实体

View File

@@ -0,0 +1,24 @@
package com.njcn.user.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @author xy
*/
@Data
public class RoleSystemParam implements Serializable {
@ApiModelProperty("角色id")
@NotBlank(message = "角色id不能为空")
private String roleId;
@ApiModelProperty("系统id")
@NotNull(message = "系统id不能为空")
private List<String> systemIds;
}

View File

@@ -75,6 +75,11 @@ public class Component extends BaseEntity {
*/
private String systemType;
/**
* 组件类型
*/
private String componentType;
private String icon;
private String image;

View File

@@ -0,0 +1,37 @@
package com.njcn.user.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author xy
* @since 2026-01-05
*/
@Data
@TableName("sys_role_system")
@Accessors(chain = true)
public class SysRoleSystem implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 角色id
*/
@MppMultiId
private String roleId;
/**
* 系统id
*/
private String systemId;
}

View File

@@ -43,6 +43,9 @@ public class ComponentVO implements Serializable {
@ApiModelProperty("系统类型")
private String systemType;
@ApiModelProperty("组件类型")
private String componentType;
@ApiModelProperty("图标标识")
private String icon;

View File

@@ -0,0 +1,74 @@
package com.njcn.user.controller;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.user.pojo.param.RoleSystemParam;
import com.njcn.user.pojo.po.SysRoleSystem;
import com.njcn.user.service.ISysRoleSystemService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
/**
* <p>
* 前端控制器
* </p>
*
* @author xy
* @since 2026-01-05
*/
@RestController
@RequestMapping("/sysRoleSystem")
@Validated
@Slf4j
@Api(tags = "角色与系统管理")
@AllArgsConstructor
public class SysRoleSystemController extends BaseController {
private final ISysRoleSystemService sysRoleSystemService;
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getSystemByRoleId")
@ApiOperation("根据角色id获取系统信息")
@ApiImplicitParam(name = "id", value = "角色id", required = true)
public HttpResult<RoleSystemParam> getSystemByRoleId(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getSystemByRoleId");
SysRoleSystem sysRoleSystem = sysRoleSystemService.selectByMultiId(
new SysRoleSystem().setRoleId(id)
);
RoleSystemParam result = new RoleSystemParam();
if (ObjectUtil.isNotNull(sysRoleSystem)) {
result.setRoleId(sysRoleSystem.getRoleId());
result.setSystemIds(Arrays.asList(sysRoleSystem.getSystemId().split(",")));
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增角色与系统关系")
@ApiImplicitParam(name = "param", value = "新增数据", required = true)
public HttpResult<Boolean> add(@RequestBody @Validated RoleSystemParam param) {
String methodDescribe = getMethodDescribe("add");
SysRoleSystem sysRoleSystem = new SysRoleSystem()
.setRoleId(param.getRoleId())
.setSystemId(String.join(",",param.getSystemIds()));
boolean result = sysRoleSystemService.saveOrUpdateByMultiId(sysRoleSystem);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -0,0 +1,16 @@
package com.njcn.user.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.user.pojo.po.SysRoleSystem;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xy
* @since 2026-01-05
*/
public interface SysRoleSystemMapper extends MppBaseMapper<SysRoleSystem> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.user.service;
import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.user.pojo.po.SysRoleSystem;
/**
* <p>
* 服务类
* </p>
*
* @author xy
* @since 2026-01-05
*/
public interface ISysRoleSystemService extends IMppService<SysRoleSystem> {
}

View File

@@ -54,15 +54,12 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
checkComponentParam(componentParam, false);
Component component = new Component();
BeanUtil.copyProperties(componentParam, component);
// String functionGroup = componentParam.getFunctionGroup().stream().map(String::valueOf).collect(Collectors.joining(","));
// component.setFunctionGroup(functionGroup);
component.setState(ComponentState.ENABLE);
if (Objects.equals(componentParam.getPid(), FunctionState.FATHER_PID)) {
component.setPids(FunctionState.FATHER_PID);
} else {
Component fatherComponent = this.lambdaQuery().eq(Component::getId, componentParam.getPid()).one();
String pidS = fatherComponent.getPids();
component.setPids(pidS + "," + componentParam.getPid());
component.setPid("1");
component.setPids("0,1");
}
return this.save(component);
}
@@ -80,11 +77,49 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
checkComponentParam(componentParam, true);
Component component = new Component();
BeanUtil.copyProperties(componentParam, component);
// String functionGroup = componentParam.getFunctionGroup().stream().map(String::valueOf).collect(Collectors.joining(","));
// component.setFunctionGroup(functionGroup);
if (Objects.equals(componentParam.getPid(), FunctionState.FATHER_PID)) {
component.setPids(FunctionState.FATHER_PID);
} else {
component.setPid("1");
component.setPids("0,1");
}
return this.updateById(component);
}
// @Override
// public List<ComponentVO> getComponentTree() {
// List<ComponentVO> list = new ArrayList<>();
// List<ComponentVO> result = new ArrayList<>();
// List<ComponentDTO> componentList = componentMapper.getAllComponent();
// if (!CollectionUtils.isEmpty(componentList)) {
// componentList.forEach(item -> {
// ComponentVO componentVO = new ComponentVO();
// BeanUtil.copyProperties(item, componentVO);
// componentVO.setTimeKeys(StrUtil.split(item.getTimeKey(), ","));
// list.add(componentVO);
// });
// Map<String, List<ComponentVO>> map = list.stream().filter(m -> !Objects.isNull(m.getSystemType())).collect(Collectors.groupingBy(ComponentVO::getSystemType));
// map.forEach((k, v) -> {
// DictData dictData = dicDataFeignClient.getDicDataById(k).getData();
// if (Objects.isNull(dictData)) {
// throw new BusinessException(SystemResponseEnum.SYSTEM_TYPE_EMPTY);
// }
// ComponentVO componentVO = new ComponentVO();
// componentVO.setId(dictData.getId());
// componentVO.setName(dictData.getName());
// componentVO.setSort(dictData.getSort());
// componentVO.setChildren(
// v.stream()
// .filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
// .peek(funS -> funS.setChildren(getChildCategoryList(funS, v))).sorted(Comparator.comparing(ComponentVO::getSort))
// .collect(Collectors.toList()));
// result.add(componentVO);
// });
// result.sort(Comparator.comparing(ComponentVO::getSort));
// }
// return result;
// }
@Override
public List<ComponentVO> getComponentTree() {
List<ComponentVO> list = new ArrayList<>();
@@ -95,24 +130,35 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
ComponentVO componentVO = new ComponentVO();
BeanUtil.copyProperties(item, componentVO);
componentVO.setTimeKeys(StrUtil.split(item.getTimeKey(), ","));
// componentVO.setFunctionGroup(Arrays.stream(item.getFunctionGroup().split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList()));
list.add(componentVO);
});
Map<String, List<ComponentVO>> map = list.stream().filter(m -> !Objects.isNull(m.getSystemType())).collect(Collectors.groupingBy(ComponentVO::getSystemType));
map.forEach((k, v) -> {
DictData dictData = dicDataFeignClient.getDicDataById(k).getData();
if (Objects.isNull(dictData)) {
throw new BusinessException(SystemResponseEnum.SYSTEM_TYPE_EMPTY);
}
//二层集合
List<ComponentVO> second = list.stream().filter(item -> Objects.equals(item.getPid(), "0")).collect(Collectors.toList());
//三层集合
List<ComponentVO> third = list.stream().filter(item -> Objects.equals(item.getPid(), "1")).collect(Collectors.toList());
Set<String> uniqueValues = list.stream()
.flatMap(obj -> Arrays.stream(obj.getSystemType().split(",")))
.map(String::trim)
.collect(Collectors.toSet());
//根据字典code获取当前所有系统
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode("System_Type").getData();
dictDataList.forEach(dic->{
//第一层
ComponentVO componentVO = new ComponentVO();
componentVO.setId(dictData.getId());
componentVO.setName(dictData.getName());
componentVO.setSort(dictData.getSort());
componentVO.setChildren(
v.stream()
.filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
.peek(funS -> funS.setChildren(getChildCategoryList(funS, v))).sorted(Comparator.comparing(ComponentVO::getSort))
.collect(Collectors.toList()));
componentVO.setId(dic.getId());
componentVO.setName(dic.getName());
componentVO.setSort(dic.getSort());
//第二层
if (CollectionUtil.isNotEmpty(second)) {
List<ComponentVO> l2 = second.stream().filter(item2 -> item2.getSystemType().contains(dic.getId())).sorted(Comparator.comparing(ComponentVO::getSort)).collect(Collectors.toList());
componentVO.setChildren(l2);
//第三层
componentVO.getChildren().forEach(item3->{
List<ComponentVO> l3 = third.stream().filter(item4 -> item4.getComponentType().contains(item3.getId())).sorted(Comparator.comparing(ComponentVO::getSort)).collect(Collectors.toList());
item3.setChildren(l3);
});
}
result.add(componentVO);
});
result.sort(Comparator.comparing(ComponentVO::getSort));
@@ -167,13 +213,11 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
@Override
public List<Component> getFatherComponent(String systemType) {
List<Component> list = new ArrayList<>();
Component component = new Component();
component.setId("0");
component.setName("");
list.add(component);
list.addAll(this.lambdaQuery().eq(Component::getSystemType, systemType).eq(Component::getPid, ComponentState.FATHER_PID).eq(Component::getState, ComponentState.ENABLE).list());
return list;
return new ArrayList<>(this.lambdaQuery()
.eq(Component::getSystemType, systemType)
.eq(Component::getPid, ComponentState.FATHER_PID)
.eq(Component::getState, ComponentState.ENABLE)
.list());
}
/**

View File

@@ -1,12 +1,12 @@
package com.njcn.user.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.user.enums.UserResponseEnum;
@@ -127,11 +127,10 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
@Override
public List<Role> selectRoleDetail(Integer id) {
List<Integer> role = new ArrayList<>();
role.add(RoleType.USER);
role.add(RoleType.APP);
if (Objects.equals(id, RoleType.SUPER_ADMINISTRATOR)) {
role.add(RoleType.ADMINISTRATOR);
} else {
role.add(RoleType.USER);
role.add(RoleType.APP);
}
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("sys_role.state", DataStateEnum.DELETED.getCode());

View File

@@ -0,0 +1,20 @@
package com.njcn.user.service.impl;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.user.mapper.SysRoleSystemMapper;
import com.njcn.user.pojo.po.SysRoleSystem;
import com.njcn.user.service.ISysRoleSystemService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xy
* @since 2026-01-05
*/
@Service
public class SysRoleSystemServiceImpl extends MppServiceImpl<SysRoleSystemMapper, SysRoleSystem> implements ISysRoleSystemService {
}

View File

@@ -286,13 +286,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
if (Objects.equals(UserType.SUPER_ADMINISTRATOR, type)) {
types.addAll(Arrays.asList(UserType.ADMINISTRATOR, UserType.USER, UserType.APP));
}
//业务管理员,展示管理员和web用户
//业务管理员展示web用户
else if (Objects.equals(UserType.ADMINISTRATOR, type) && !roleCodeList.contains("operation_manager")) {
types.addAll(Arrays.asList(UserType.ADMINISTRATOR, UserType.USER));
types.addAll(Arrays.asList(UserType.USER));
}
//运维管理员,展示管理员和App用户
//运维管理员,展示web用户、App用户
else if (Objects.equals(UserType.ADMINISTRATOR, type) && roleCodeList.contains("operation_manager")) {
types.addAll(Arrays.asList(UserType.ADMINISTRATOR, UserType.USER, UserType.APP));
types.addAll(Arrays.asList(UserType.USER, UserType.APP));
}
if (ObjectUtil.isNotNull(queryParam)) {
//查询参数不为空,进行条件填充
@@ -482,7 +482,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
Role roleByCode = roleService.getRoleByCode(AppRoleEnum.MARKET_USER.getCode());
List<UserRole> userRoles = userRoleMapper.selectUserRole(Stream.of(roleByCode.getId()).collect(Collectors.toList()));
List<String> collect = userRoles.stream().map(UserRole::getUserId).collect(Collectors.toList());
return this.listByIds(collect);
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ne(User::getState, UserState.DELETE).in(User::getId, collect);
return this.list(queryWrapper);
}
@Override